Retrieve constraints matrix from Gurobi or MOI or JuMP in Julia
回答済みHello!
I want to retrieve an LP model in matrix form from Gurobi. I am using package JuMP in Julia. I can print all the constraints using MathOptInterface but not in matrix form. I have no idea how to print the problem matrix from Gurobi. Could anyone help with this? Thanks very much in advance!
Kind regards,
Hongyu.
-
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,
Simon0 -
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 -
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,
Simon0
サインインしてコメントを残してください。
コメント
3件のコメント