I coded my model in gurobipy and I want to get the matrix of constraints and vector of cost. Is there any way to access those?
Cannot comment on the answer of @david-nehme due to insufficient reputation, feel free to add this to his answer and delete mine.
Since Gurobi 9.0 you can query the coefficient matrix via .getA()
as a <class 'scipy.sparse.csr.csr_matrix'>
.
import matplotlib.pyplot as plt
import gurobipy as grb
m = grb.read("miplib/instances/miplib2010/aflow40b.mps.gz")
A = m.getA()
plt.spy(A) # different options, e.g. markersize=0.5
plt.show()
Also check out matrix plots using betterspy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With