Data structure for sparse coefficient matrices
AnsweredI am new to Gurobi and I am trying to understand which data structure to use for coefficients. I want to model a large sparse coefficient matrix A as seen below. I am wondering if it should be done using a tuplelist, a tupledict or some other structure? In the statement below, A is the coefficient matrix and z is a decision variable.
-
Official comment
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 why not try our AI Gurobot?. -
Welcome to Gurobi!
Which API are you going to use? (From your mention of tuplelist and tupledict, I am going to assume Python.)
As of version 8.1.1, Gurobi does not support matrix-based modeling in Python. So right now the recommendation is to model your constraints using the addConstr method (or in bulk using addConstrs). You can have a look at the code examples here.
With Gurobi 9 (scheduled for later this fall), you will be able to do matrix-oriented modeling, using NumPy or SciPy matrices.
1
Post is closed for comments.
Comments
2 comments