Try our new documentation site (beta).
Filter Content By
Version
Text Search
${sidebar_list_label} - Back
Filter by Language
Model.getAttr()
getAttr ( attrname, objs=None )
Query the value of an attribute. When called with a single argument, it returns the value of a model attribute. When called with two arguments, it returns the value of an attribute for either a list or a dictionary containing either variables or constraints. If called with a list, the result is a list. If called with a dictionary, the result is a dictionary that uses the same keys, but is populated with the requested attribute values. The full list of available attributes can be found in the Attributes section.
Arguments:
attrname: Name of the attribute.
objs (optional): List or dictionary containing either constraints or variables
Example usage:
print model.numintvars print model.getAttr("numIntVars") print model.getAttr(GRB.attr.numIntVars) print model.getAttr("X", m.getVars()) print model.getAttr("Pi", m.getConstrs())