How to make a deep copy of a linear expression using gurobipy
AnsweredI need to make changes to my objective function, solve the model and reset the objective function to be the original one. Since my objective function is a LinExp, I was wondering how to make a deep copy of that.
0
-
The best way to make a copy of your objective is to generate an additional one during construction. For example
[...]
origobj = gp.LinExpr([1,2,-1],[x,y,z])
modobj = gp.LinExpr([1,2,-1],[x,y,z])
model.setObjective(modobj)
# do something with current objective
# after finishing, set the objective to origobj
model.setObjective(origobj)Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment