How to retrieve a constraint matrix of (MI)LP in a sparse format in C++?
AnsweredSuppose, I am provided a large-scale (MI)LP problem, saved as GRBModel (C++ API), and I need to access the constraint matrix coefficients, taking into account the sparsity. In particular, any naive iterations of the form "::getCoeff(i, j)" are computationally prohibited for my setting. How do I retrieve it in a linear in the number of nonzero coefficients time?
No matter the format, CSC/CSR/triplet of lists are all ok.
-
Hi Kudria,
There is no dedicated C++ method to return the coefficient matrix in a compressed format. The APIs for C++, Java, and C# are object oriented and you would have to iterate over either Column or Constraint object and construct a CSR format on your own. However, in your case since you are using C++, you can use the C function GRBgetconstrs(), which will do the job for you.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment