I am using Gurobi 9.5.1 in Python 3.10. In the context of column generation I request the duals of the master problem and set them in the objective of the subproblem. This is done repeated times.
duals = master.getAttr(GRB.Attr.Pi, master.getConstrs())
subprob.setAttr("Obj", subprob.getVars(), duals)
Around 10% of the time spent is in performing these operations. The rest is basically the solving times of the master and subproblems combined.
Is there a way to reduce such overhead?
constrs = master.getConstrs()
(the number of these normally stays the same in the context of column generation) and variablesvars = master.getVars()
, once at the beginning, then updatevars
as appropriate after generating columns. Then just use these instead of callinggetConstrs
andgetVars
every time. This should be significantly faster. $\endgroup$