sensenli
sensenli

Reputation: 59

How to update a constant term of a constraint in Gurobi

I am facing a problem where I must call the Gurobi engine iteratively. Between runs, I have to update the constant term in some of the constraints. I check the manual book in which I find GRBModel::chgCoeff() could be used to change the coefficient of variables in the constraint but there is no function related to changing the constant term. Any idea to do that? Thank you!

Upvotes: 0

Views: 1463

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35795

I think that you have to set the RHS attribute of the Linear Constraint object. So, if constr is your constraint, something like

constr.Set(GRB.DoubleAttr.RHS, 329);

(this is C#, I guess you use C++, so the case of some of the letters may be different...).

Upvotes: 3

Related Questions