Get constraints in matrix format from gurobipy
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? From the python API, there's no single function to get the matrix coefficients from a Gurobi model, but it's not to hard to write one yourself. It is convenient to have lists of your variables and constraints. If you have a gurobi model in variable m dvars = m.getVars() constrs = m.getConstrs() will give you the list of variables and constraints. You can then use m.getAttr to retrieve attributes related to the variables. To obtain the objective function coefficients,