Skip to main content

Lindo style table of dual values and allowable increases

Answered

Comments

2 comments

  • Official comment
    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?.
  • Eli Towle
    Gurobi Staff Gurobi Staff

    There isn't a built-in way to generate such a table. You have to query the sensitivity information (like you do) and build the table yourself. I would guess you want to use something like this:

    # Var/Constr attributes to print
    var_attrs = ('VarName', 'X', 'SAObjLow', 'SAObjUp')
    con_attrs = ('ConstrName', 'Pi', 'SARHSLow', 'SARHSUp')

    # Print formatted tables
    head_fmt = '\n{:12s}' + '{:>15s}' * 3
    row_fmt = '{:12s}' + '{:>15.6f}' * 3
    print(head_fmt.format(*var_attrs))
    for v in m.getVars():
        print(row_fmt.format(*map(lambda x: v.getAttr(x), var_attrs)))
    print(head_fmt.format(*con_attrs))
    for c in m.getConstrs():
        print(row_fmt.format(*map(lambda x: c.getAttr(x), con_attrs)))

    For the \( \texttt{afiro.mps} \) model that comes with your Gurobi installation, we see the following output:

    VarName                   X       SAObjLow        SAObjUp
    X01               80.000000           -inf       0.344771
    X02               25.500000      -8.421494      -0.055229
    X03               54.500000      -0.628571       8.021494
    X04               84.800000           -inf       0.325256
    . . . .
    . . . .
    . . . .
    X36              339.942857      -2.083588       0.000000
    X37              383.942857      -1.603588       0.000000
    X38                0.000000       0.000000            inf
    X39                0.000000       0.000000            inf

    ConstrName               Pi       SARHSLow        SARHSUp
    R09               -0.628571     -25.500000      86.500000
    R10               -0.000000     -84.800000      10.200000
    X05               -0.344771      54.500000      89.622642
    X21               -0.228571     -25.500000      86.500000
      . . . .
    . . . .
    . . . .
    X48               -0.942857    -475.920000      24.080000
    X49                0.000000    -378.460357            inf
    X50                0.000000     299.800000            inf
    X51                0.000000      19.307143            inf

     

    0

Post is closed for comments.