Basic array attribute question
AnsweredI am new to Gurobi, and trying to understand the get/set attr API. It's clear from the documentation which attributes are for ints/doubles/strings/char, but it's not clear which are used in an array and which aren't. For example, X is used to get/set an array of doubles. Can someone point me to some documentation on this topic? Some list of which are used where? I am using the C API, though I would imagine this question applies more generally to all APIs.
-
Can someone point me to some documentation on this topic? Some list of which are used where?
You can access attribute array via the GRBgetXXXattrarray and GRBgetXXXattrarray functions.
- GRBgetintattrarray
- GRBsetintattrarray
- GRBgetdblattrarray
- GRBsetdblattrarray
- GRBgetcharattrarray
- GRBsetcharattrarray
if you are interested only in some specifically indexed variables, then you could use the corresponding \(\texttt{list}\) functions, see C documentation of Attribute Management.
Best regards,
Jaromił0 -
I understand that. I'm not asking about which functions I can use. I saw those in the API.
What I'm asking is which ATTRIBUTES refer to arrays and which don't. Clearly, there are some that do (such as X, which I mentioned, as well as LB and UB and others). Other attributes are not arrays (I presume NumConstrs is not an array). I don't know which are which. Which are arrays?
0 -
Thank you for clarifying.
From the Attributes documentation
The following tables list the full set of Gurobi attributes. The attributes have been grouped by type: model attributes take scalar values, while variable, linear constraint, SOS constraint, quadratic constraint, and general constraint attributes contain one entry per variable or constraint in the model. The APIs provide methods to query attribute values for individual constraints or variables, or to query their values for arrays of constraints or variables (refer to our Attribute Examples section for examples). Array queries are generally more efficient.
In addition Solution Quality, Multi-Objective, Multi-Scenario, and Batch attributes are all scalar values.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
3 comments