Decision variable type (floating point)
I am using Gurobi to solve my linear problem. my decision variable is a matrix where each element is between 0 and 1. I used continous variable type (i.e., var_type='C). But I wonder why the floating point values cannot bew selected, although in my toy example, the optimum values for each element of matrix x should be floating point type.

Hi,
Sorry, I don't understand your question.
Gurobi can only handle vector type of variables. If you have a variable matrix (like in semidefinite programming) you have to find a way to write this as Ax <=b where x is a vector.
Best regards,
Sonja
1 
Hi Sonja and all,
Thank you for your comment. But as far as I understand though, the sample example about "The Traveling Salesman Problem" , Gurobi can support 2dimensional according to the line 9 in the following codes. My problem is that after running my code, all the decision variable will be equal to its lower bound initialized value (i.e., lb) and in the result it shows: "Solved in 0 iterations and 0.00 seconds"
I think the solver has not tried as it shows 0 iteration. So, I am not sure what is the problem. Appreciate to guide me.
from tspdata import TSPData
2 from sys import argv
3 from mip.model import *
4 from mip.constants import *
5 inst = TSPData(argv[1])
6 n = inst.n
7 d = inst.d
8 model = Model()
9 x = [ [ model.add_var(var_type=BINARY) for j in range(n) ] for i in range(n) ]
10 y = [ model.add_var() for i in range(n) ]
11 model += xsum( d[i][j]*x[i][j] for j in range(n) for i in range(n) )
12 for i in range(n):
13 model += xsum( x[j][i] for j in range(n) if j != i ) == 1
14 for i in range(n):
15 model += xsum( x[i][j] for j in range(n) if j != i ) == 1
16 for i in range(1, n):
17 for j in [x for x in range(1, n) if x!=i]:
18 model += y[i]  (n+1)*x[i][j] >= y[j] n
19 model.optimize(max_seconds=30)
20 arcs = [(i,j) for i in range(n) for j in range(n) if x[i][j].x >= 0.99]
21 print('optimal route : {}'.format(arcs))0
Please sign in to leave a comment.
Comments
2 comments