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

Gurobi solution created new variables with prefix name of MPS_Rg. What does this mean?

回答済み

コメント

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?.
  • Lance Clifner
    • Gurobi-versary
    • First Comment
    • First Question

    So, I believe I have figured this out.

    It appears that MPSRg*blort* is a dummy variable created by Gurobi for the constraint row named *blort*.  It appears to add this variable in order to make the constraint row be treated as an "E" (Equals) constraint row, and then sets the value of the dummy variable so that the constraint is TRUE.

    Curiously, my constraint row of R-R11_Q0 was defined as an "L" constraint.  I had set both a Max and a Min for this constraint row, and Gurobi used the dummy variable to make the constraint always equal to the Max value.

    When I removed the Min constraint, Gurobi stopped creating the dummy variable and allowed the constraint value to float around anywhere between 0 and the Max.

    Unless I am missing something, it seems like the Gurobi solution should be the same whether I set a constraint row to have a Min of 0 and a Max of some positive value or I set that constraint row to have only a Max.  That is, not to throw in the unexpected dummy variable in one case and not the other.  My preference is not to have the dummy variable (I don't like it when things magically appear with no explanation--these dummy variables do not appear to be mentioned anywhere in the Gurobi documentation.)

    At some point, I am sure I will need to use an upper and (non-zero) lower bound on a constraint row and will have to look at this dummy variable issue again.

    I'd be happy to hear from anyone who can shed further light on this issue.  Thanks.

    0
  • Eli Towle
    • Gurobi Staff Gurobi Staff

    It sounds like you are adding a "range constraint" to your model, which requires that the value of an expression lies within the specified range. Gurobi creates a new variable when modeling such constraints (e.g., see the documentation for GRBaddrangeconstr() in C or Model.addRange() in Python).

    If you want to avoid the new variable, you can manually add two separate constraints for the lower and upper bounds. As an example in Python, instead of adding a range constraint with

    m.addConstr(x + y == [0, 5], name="range0")

    you can write

    m.addConstr(x + y >= 0, name="expr_lb")
    m.addConstr(x + y <= 5, name="expr_ub")
    1
  • Lance Clifner
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks for the pointers to the documentation, I understand what is happening and why the new variable was added, and how to make it operate the way that I want it to work!

    0

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