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

Gurobi- Free Variable

進行中

コメント

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.
  • Ronald van der Velden
    • Gurobi Staff

    Could you describe a bit more how you want to use that variable - is it continuous or integer and how do you want to use the variable? The challenge is that computers have limited precision so the question becomes "how close to zero is considered zero". See also this article for more detail.

    0
  • Muhammad Arslan Shahid
    • Gurobi-versary
    • Conversationalist
    • First Question

    A continuous variable.

    I want to use a free variable (e.g. x) in a constraint that ensures that "x" should not equal zero and takes any value other than zero that is feasible.

    0
  • Ronald van der Velden
    • Gurobi Staff

    As you can see in the article, the problem with your constraint is that it's not properly defined when something is "close enough to zero". If 0.0 is not allowed, would 0.001 be allowed, or 0.0001 ?

    If you have a properly defined threshold, you may look at indicator constraints.

    • Give your variable lowerbound -GRB.INFINITY and upperbound +GRB.INFINITY
    • Define a binary variable that is 1 when your continuous variable is positive , 0 when negative
    • Add two indicator constraints linking both variables: When the binary is 1, your continuous variable must be at least equal to the threshold. When it's 0, the continuous variable must not be greater than -threshold.

    Hope this helps!

    Kind regards,
    Ronald

    0

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