Skip to main content

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

Answered

Comments

1 comment

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

Please sign in to leave a comment.