Skip to main content

Convert a LP in a form of matrix

Answered

Comments

3 comments

  • Jaromił Najman
    • Gurobi Staff

    From the coefficient statistics you can see

    Coefficient statistics:
      Matrix range     [1e+00, 1e+02]
      Objective range  [1e+00, 2e+01]
      Bounds range     [1e+00, 5e+03]
      RHS range        [1e+00, 9e+01]

    vs

    Coefficient statistics:
      Matrix range     [1e+00, 1e+02]
      Objective range  [1e+00, 2e+01]
      Bounds range     [0e+00, 0e+00]
      RHS range        [1e+00, 9e+01]

    It looks like you need to set variable bounds.

    Best regards, 
    Jaromił

     

    0
  • Sen Xue
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks a lot. beside, I found that not only the variable bounds is not set, but some row of matrix A and b must be reset according to the corresponding constr sense, the code is

    for i in range(len(m.getConstrs())):
      if m.getConstrs()[i].sense == '>':
            A[i,:]=A[i,:]*(-1)
            rhs[i]=rhs[i]*(-1)

    I thought that gurobi can automatically give the corresponding matrix Ax<=b, but it is not. By the way, it seems that for constr sense of '=', that part of matrix Ax<=b given by gurobi is correct.

    0
  • Jaromił Najman
    • Gurobi Staff

    You can make it better by using the addMConstr method. To use it, you have to also extract constraint senses as you did with RHS.

    0

Please sign in to leave a comment.