Try our new documentation site (beta).
Model.setAttr()
setAttr ( attrname, objects, newvalues )
Change the value of an attribute.
Call this method with two arguments
(i.e., setAttr(attrname, newvalue)
) to set a model attribute.
Call it with three arguments (i.e.,
setAttr(attrname, objects, newvalues)
) to set attribute values
for a list or dict of model objects (Var
objects, Constr
objects, etc.). To set the same value for all objects in the second
argument, you can pass a scalar value in the third argument. If the
second argument is a list, the third argument should be a list of the
same length. If the second argument is a dict, the third argument
should be dict with a value for every key from the second.
The full list of available attributes can be found in the Attributes section.
Raises an AttributeError
if the specified attribute doesn't
exist or can't be set.
Raises a GurobiError
if there is a problem with the
Model
object.
Note that, due to our lazy update approach, the change won't actually take effect until you update the model (using Model.update), optimize the model (using Model.optimize), or write the model to disk (using Model.write).
Arguments:
attrname: Name of attribute to set.
objs: List of model objects (Var or Constr or ...)
newvalue: Desired new value(s) for attribute.
Example usage:
model.setAttr("objCon", 0) model.setAttr(GRB.Attr.ObjCon, 0) model.setAttr("LB", model.getVars(), [0]*model.numVars) model.setAttr("RHS", model.getConstrs(), [1.0]*model.numConstrs) model.setAttr("vType", model.getVars(), GRB.CONTINUOUS) model.objcon = 0