for loop for optimisation model
回答済みHi,
I have an optimization model in a "for loop"using Python/Jupyter Notebook and Gurobi. For each iteration, I need to record the decision variables and use them as an input of the next "for loop" to optimise the model for new ranges. I was wondering if you would advise me how I can record the decision variables in each loop.
Thanks,
-
正式なコメント
This post is more than three 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 Zahra,
Could you elaborate on what you are trying to achieve here? Are you trying to solve separate models in each iteration of the loop and extract the solution values to use in a separate model, or do you need the variables themselves in order to build constraints in another iteration?
Best regards,
Simon0 -
Hi Simon,
Thank you so much for your reply.
I deal with both condition you explained. I wondered if you could please explain how I can solve the above mentioned problems.
Thanks and regards,
Zahra
0 -
Hi Zahra,
You can store solution values and/or variables in a Python dictionary in order to access them in later iterations. It may help to familiarise yourself with the following article covering the basics of python dictionaries: https://www.pythontutorial.net/python-basics/python-dictionary/
0 -
Hi Simon,
Thank you so much for your reply.
It works for my problem.
Kind regards,
Zahra
0
投稿コメントは受け付けていません。
コメント
5件のコメント