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

How to round up a variable to it’s nearest tenth in gurobi?

回答済み

コメント

2件のコメント

  • 正式なコメント
    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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Matthias Miltenberger
    • Gurobi Staff

    Say you want to round up variable \(x\) to its next tenth. You could add a new variable \(y\) that represents a tenth of \(x\) and is used everywhere where you need \(x\). \(x\) needs to be integer and to enforce rounding up, you can add 5 to its value:

    \[\begin{aligned}
    10x &\geq y + 5\\
    &\dots \\
    x &\text{ integer}
    \end{aligned}\]

    Then, \(10x\) will represent the rounded value of \(y\).

    I hope that helps.

    Cheers,
    Matthias

    0

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