VBasis/CBasis get and set
AnsweredI am a little confused that when getting the LP basis in python, you have to
self.model.getAttr("VBasis", self.model.getVars())
but for setting you have to do something like this:
for var in self.model.getVars():
var.setAttr("VBasis", vBasis[var.index])
Am I right or did I just not found the corresponding method?
Wouldn't it be good to have also a Wrapper like:
model.setAttr("VBasis",..)
Thanks a lot
Thomas
-
Hi Thomas,
The function Model.setAttr() already exists.
Cheers,
Marika-1 -
Hi Marika,
ah okay, I did not see the call with 3 arguments. So it should work like this
// solve
...
vBasis = self.model.getAttr("VBasis", self.model.getVars())
cBasis = self.model.getAttr("CBasis", self.model.getConstrs())
// do for example a problem specific RENS
...
// set lp solution
self.model.setAttr("VBasis", model.getVars(), vBasis)
self.model.setAttr("CBasis", model.getConstr(), cBasis)Thanks
Thomas
1 -
Hi, Thomas's second comment here is very useful. Could highly recommend that his code-snippet, or something like it, be included in discussions of lp warm start. A simple 'hello world style' example model doing this would also be useful. Multiple examples of warm start would be helpful.
Concrete 'how to' with examples that pop up when googling 'gurobi warm start'.
Understood this stuff is apparently totally obvious for gurobi employees.
It's not for every gurobi user, have learned that the hard way over the last few days.
Thanks
Noah
0 -
Thanks for the suggestion Noah! I have added this to my list of potential improvements for the Knowledge Base. -G
1
Please sign in to leave a comment.
Comments
4 comments