Skip to main content

How to get the total coeff matrix of MILP model

Answered

Comments

4 comments

  • Official comment
    Erik Halseth
    • Gurobi Staff Gurobi Staff

    Hi Shiyuan,

    We appreciate your reply.

    Based on your answers, we would recommend this Python Gurobi function to extract constraint coefficients as a Scipy matrix in CSR format.

    With respect to the RHS and objective coefficients, you could use:

    rhs = m.getAttr("RHS",m.getConstrs())
    obj = m.getAttr("Obj",m.getVars())

    You may need to modify the data structures for rhs and obj, but that depends on how you structure them as input to your NN.

    Warm thanks,

    Erik H.

     

  • Erik Halseth
    • Gurobi Staff Gurobi Staff

    Hi Shiyuan,

    We appreciate your question.

    To get started, we do have some questions:

    1. In the context of your research, what software programming language are you currently using to interact with the Gurobi API?

    2. When you say the "total coeff matrix", do you mean the coefficients of only the constraints? Or constraint coefficients, right-hand side coefficients, and objective coefficients?

    3) Are you looking to execute an optimization process with Gurobi, and then send this "total coeff matrix" into the neural network as training input? Or as neural weights?

    Warm thanks,

    Erik H.

    0
  • Qu Shiyuan
    • Gurobi-versary
    • First Comment
    • First Question

    Thx for your reply~

    1. I use python as my programming language.

    2. I would better have the constraints coefficients, RHS and objective coefficients. 

    3. In short, it can be understood that I try to gain a matrix of all of the coeff above and use them as input of NN. 

    0
  • Qu Shiyuan
    • Gurobi-versary
    • First Comment
    • First Question

    I sincerely appreciate your genuine help and prompt response. The method you provided has significantly improved my work efficiency, and my questions have been thoroughly resolved.

    0

Please sign in to leave a comment.