Skip to main content

If-Else condition for GUROBI C++ is not working

Answered

Comments

2 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.
  • Mario Ruthmair
    • Gurobi Staff

    Hi Mohammad,

    Your code snippet is a bit confusing for me, e.g., variable job_tardy is never used after creating it.
    Additionally, you are using GRBQuadExpr, does your model contain quadratic terms?
    I guess jmalloc[][][] are variables, right?

    But I would model it in a different way, without BigM and indicator constraints:
    The variable job_tardy has lower bound 0 so it cannot get negative.
    Then, you push up job_tardy by the difference of completion time and due date:

    job_comtime - duedate <= job_tardy

    In the minimization objective you sum up all job_tardy variables, so in any optimal solution the job_tardy values will correspond exactly to the tardiness of a job since it does not make sense to set it to a higher value due to minimization.

    Best regards,
    Mario

    0

Post is closed for comments.