This is how I use addVar
to add variable into the model:
my_set[j, t] = self.m.addVar(vtype=GRB.INTEGER, lb=min_value, ub=max_value, name='test')
And this can only constraint the value as an integer falling between min_value and max_value, but actually I'd like to constraint the possible value in certain set of integers. How can I make it?
I don't know if it is directly possible (this is not possible in standard ILP, so maybe as an extension of gurobi), but you can add some constraints to your program. Assuming the variable you want to constrained is y and the set of variable is D y = {v 1 , v 2 , ..., v |D y | } , you could add the following x i variables and constraints:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.