メインコンテンツへスキップ

for loop for optimisation model

回答済み

コメント

4件のコメント

  • Simon Bowly
    • Gurobi Staff Gurobi Staff

    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,
    Simon

    0
  • Zahra Namazian
    • Gurobi-versary
    • First Comment
    • First Question

    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
  • Simon Bowly
    • Gurobi Staff Gurobi Staff

    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
  • Zahra Namazian
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Simon,

    Thank you so much for your reply.

    It works for my problem. 

    Kind regards,

    Zahra

    0

サインインしてコメントを残してください。