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

Add Conditional Constraint

回答済み

コメント

4件のコメント

  • 正式なコメント
    Simranjit Kaur
    • 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?.
  • Ruoyun Chen
    • Gurobi-versary
    • First Comment
    • First Question

    The reason I'm asking this is because every time I try to implement x>5 it reports:

    '>' not supported between instances of 'Var' and 'float'

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi,

    Strict inequalities are not allowed in state-of-the-art optimization software due to compactness of the feasible set. The best thing you could model is an approximation of your statement which would be

    if \(x\geq 5+\epsilon_1\) then \(f(x)\geq g(x) + \epsilon_2\)

    for some small positive \(\epsilon_1,\epsilon_2\).

    You can achieve this by first modeling the relationship

    if \(x\geq 5+\epsilon_1 \Leftrightarrow \delta=1\)

    as described in this stackexchange post. This would be

    \[\begin{align}
    \epsilon_1&=10^{-6}\\
    x &\geq 5+\epsilon_1 - 10\cdot(1-\delta)\\
    x &\leq 5+\epsilon_1 + 10\cdot \delta\\
    \delta &\in \{0,1\}
    \end{align}\]
    You can then use an indicator constraint to model the relationship

    if \(\delta=1\) then \(g(y)+\epsilon_2-f(x) \leq 0\)

    Best regards,
    Jaromił

    0
  • Ruoyun Chen
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks a lot for your quick response Jaromił!

    0

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