Skip to main content

Retrieve constraints matrix from Gurobi or MOI or JuMP in Julia

Answered

Comments

4 comments

  • Official comment
    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.
  • Simon Bowly
    • Gurobi Staff

    Hi Hongyu,

    When you say print the matrix, do you mean you want to extract all coefficients of all constraints into a dense or sparse array? Or are you just aiming to traverse all constraints and variables and print each coefficient?

    Best regards,
    Simon

    0
  • Hongyu Zhang
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Simon, 

    Thanks for your reply.

    I mean to extract all coefficients of all constraints into a dense or sparse array. 

    Kind regards,

     

    Hongyu.

    0
  • Simon Bowly
    • Gurobi Staff

    Hi Hongyu,

    There doesn't seem to be a method in JuMP to directly access the constraint matrix anymore, due to the different types of constraints it can handle. There is some discussion about this in the discourse forum and the section of the documentation on accessing constraints.

    You could use this to extract each coefficient and build a matrix for selected constraints. I suggest reading the discourse post above in its entirety though. I think the comments from the developers there (that in general there should be no need to extract the constraint matrix for a model you have already formulated algebraically) are quite accurate.

    Best regards,
    Simon

    0

Post is closed for comments.