Condition within a condition in constraint

Awaiting user input

Comments

3 comments

  • Jaromił Najman

    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
    Comment actions Permalink
  • Syed Saad Ali

    Hi Jaromil,

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

    0
    Comment actions Permalink
  • Jaromił Najman

    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
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk