Skip to main content

for loop for optimisation model

Answered

Comments

5 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Simon Bowly
    • 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

    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

Post is closed for comments.