Skip to main content

Can I add conditional statements in Gurobi - Python?

Answered

Comments

2 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.
  • Jaromił Najman
    • Gurobi Staff

    Hi Eduardo,

    I don't know whether there is a way to condense everything into one line and still keep it readable.

    I would propose a 2 liner

    m.addConstr(i_pit[p,i,1] == Ipi0[p][i] + other terms)
    m.addConstrs(i_pit[p,i,t] == i_pit[p,i,t-1] + same other terms for t in range(T) if t != 1)

    Best regards, 
    Jaromił

    0

Post is closed for comments.