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.

Raises an AttributeError if the requested attribute doesn't exist or can't be queried. Raises a GurobiError if there is a problem with the Model object.


attrname: Name of the attribute.

objs (optional): List or dictionary containing either constraints or variables

Example usage:

  print(model.getAttr("X", model.getVars()))
  print(model.getAttr("Pi", model.getConstrs()))