メインコンテンツへスキップ

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

回答済み

コメント

4件のコメント

  • 正式なコメント
    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.
  • 伟星 郭
    • 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

    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

投稿コメントは受け付けていません。