How to relax integrality for some variables?
AnsweredI'd like to implement some relax-fix heuristics with my model in python.
I know we can fix values with variables lb and ub attributes.
But how could I relax x[i,j] from {0,1} to a continuous variable programmatically?
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi,
You can change the type of a variable by modifying the VType variable attribute. For example:
import gurobipy as gp
m = gp.Model()
# Create binary variable
x = m.addVar(vtype=gp.GRB.BINARY)
m.update()
print("x's original type is: {}".format(x.VType))
# Change to continuous
x.VType = gp.GRB.CONTINUOUS
m.update()
print("x's new type is: {}".format(x.VType))gives us:
x's original type is: B
x's new type is: CThanks,
Eli
0
Post is closed for comments.
Comments
2 comments