Retrieve an existing solution of decision variables and and assing it to another one
AnsweredI am working on an optimization problem with lagrange algorithm, I have two problems in the algorithm, so I would like to fix the solution obtained from the first problem let's say S1[s,t] to the second decision variable to make it fixed / as a parameter, I am using Gurobi python in this problem, I have tried S1[s,t].x to retrieve and assign the current solutions to the second decision variable S2[s,t], but it looks not working. Thank you in advance.
Best Regards,
-
Hi Abde,
To fix the variable \(\texttt{S2[s,t]}\) to the value of the variable \(\texttt{S1[s,t]}\) already optimized, you can use one of the approaches below:
- Via setting the lower and upper bounds
S2[s,t].LB = S1[s,t].X
S2[s,t].UB = S1[s,t].X- Via adding an additional constraint
model.addConstr(S2[s,t] == S1[s,t].X)
Best regards,Maliheh
1 -
Dear Ms. Maliheh,
Thank you so much for your kind reply, I really appreciate your help.
Best Regards,
0
Please sign in to leave a comment.
Comments
2 comments