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,
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
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
Post is closed for comments.
Comments
3 comments