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

Condition within a condition in constraint

ユーザーの入力を待っています。

コメント

4件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff Gurobi Staff
    This post is more than three 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 why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    If \(b,d\) are constants, you could determine whether \(d\leq b\) a priori and then implement your condition as

    d = 5
    b = 4
    a = min(b,d)
    q = m.addVar(vtype=GRB.BINARY,name="q")
    y = m.addVar(vtype=GRB.CONTINUOUS,name="y")
    m.addConstr(y == q * a)

    Best regards,
    Jaromił

    0
  • Syed Saad Ali
    • Gurobi-versary
    • Conversationalist
    • First Question

    Hi Jaromil,

    these $b$ and $d$ aren't known a priori and are in the form of a list.

    0
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    Hi Syed,

    In this case, could you elaborate more on the nature of the \(b\) and \(d\) terms? If they are both constant parameters, then both values should be available when the model is constructed. Otherwise they depend on the values of some other optimization variables making \(b\) and \(d\) optimization variables as well. How does the fact that \(b,d\) are lists take effect here? Do you actually want to introduce multiple constraints of the above form or do you want to check whether all values in \(d\) are \(\leq\) than \(b\)?

    Best regards,
    Jaromił

     

    0

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