Skip to main content

How to represent an if function controlled by three variables?

Answered

Comments

4 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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.
  • Yuhan Liu
    • Gurobi-versary
    • First Comment
    • First Question

    Sorry, I need to make some additional modifications.c9 should be modified to c1,and c10 should be modified to c2.

    I have made the following constraints regarding M1:

    for d in range(365):
        for h in range(25):
            if h == 0:
                m.addConstr((Q1_t[d,0] == 1))
                m.addConstr((M1_t[d,0] == 1))
              m.addConstr((Q2_t[d,0] == 1))
            else:
                m.addConstr((Q1_t[d,h] == gp.quicksum(p1_t[d,j] for j in range(0,h))))
                m.addConstr((M1_t[d,h] == 0.2*Q1_t[d,h]))
                m.addConstr((Q2_t[d,h] == gp.quicksum(p2_t[d,j] for j in range(0,h))))
    0
  • Jaromił Najman
    • Gurobi Staff

    We discuss how to model conditional constraints in the Knowledge Base article How do I model conditional statements in Gurobi? It looks like your formulation already follows the modeling discussed in the Knowledge Base article, but it might have too many uses of \(\epsilon\).

    It is hard to follow your code, because the variable names in your code do not match the parameters and variables in your hand-written formula.

    In order to investigate the source of infeasibility, please refer to How do I determine why my model is infeasible?

    Best regards, 
    Jaromił

    0
  • Yuhan Liu
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you for your reply.It has helped me a lot

    0

Post is closed for comments.