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,
-
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
サインインしてコメントを残してください。
コメント
4件のコメント