Skip to main content

"If" in object function

Awaiting user input

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 why not try our AI Gurobot?.
  • Matthias Miltenberger
    • Gurobi Staff

    Hi Saeed,

    I am not entirely sure that this is what you are trying to model but to me, this appears to be a case for splitting the \(P_\text{grid}\) variables into a positive and a negative part:

    Pgrid_pos = m.addVars(n-1, name="P_grid_pos", obj=10)
    Pgrid_neg = m.addVars(n-1, name="P_grid_neg", obj=5)
    m.addConstrs(Pgrid[i] == Pgrid_pos[i] - Pgrid_neg[i] for i in range(n-1))

    Cheers,
    Matthias

    0

Post is closed for comments.