How to update a constant term of a constraint in Gurobi

与世无争的帅哥 提交于 2020-01-26 04:07:26

问题


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!


回答1:


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...).



来源:https://stackoverflow.com/questions/30355095/how-to-update-a-constant-term-of-a-constraint-in-gurobi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!