Skip to main content

How to compare a expression with 0, Invalid data in vars array

Answered

Comments

3 comments

  • 伟星 郭
    Gurobi-versary
    First Comment
    First Question

    In another word, Max of value and if negative, return 0. 

    These are my two main constraints, y_t means the inventory level while z_t means the stock-out inventory level in time t.

    0
  • 伟星 郭
    Gurobi-versary
    First Comment
    First Question

    Oh,sorry, z_t shoule be like this,

    0
  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Hi,

    The issue here is that gp.max_() requires a list of variables (and an optional constant).
    You need to introduce additional helper variables that are set equal to the term in your max-function. Then you can use these variables in the max_() function.

    Alternatively, you do not necessarily need the max_() function here. You could just set a lower bound of 0 for the y- and z-variables, and add

    y_t >= y_{t-1} + sum ...

    to push y_t up if the right-hand side is positive (similar for z_t).
    Due to the minimization objective, the y_t and z_t variables should then always be equal to the max of 0 and the term in an optimal solution.

    Best regards,
    Mario

    0

Please sign in to leave a comment.