Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark mode
Gurobi Optimizer Reference Manual
Light LogoDark Logo

Concepts

Features

Reference

Gurobi
Back to top

gurobipy.GenConstr#

classGenConstr#

Gurobi general constraint object. General constraints are alwaysassociated with a particular model. You add a general constraint to amodel either by using one of theModel.addGenConstr* methods, or byusingModel.addConstr orModel.addConstrs plus ageneral constraint helper function).

General constraint objects have a number of attributes, which can bequeried with theGenConstr.getAttr method.

The full list of attributescan be found in theAttributes section of thisdocument. Examples of how to query and set attributes can also be foundinthis section.

getAttr(attrname)#

Query the value of a general constraint attribute.

Raises anAttributeError if the requested attribute doesn’t exist orcan’t be queried. Raises aGurobiError if there is a problem withtheGenConstr object (e.g., it was removed from the model).

Parameters:

attrname – The attribute being queried.

Returns:

The current value of the requested attribute.

Example:
print(genconstr.getAttr(GRB.Attr.GenConstrType))print(genconstr.getAttr("GenConstrType"))
setAttr(attrname,newvalue)#

Set the value of a general constraint attribute. Note that, due to our lazy update approach,the change won’t actually take effect until you update the model (usingModel.update), optimize the model (usingModel.optimize), or write the model to disk (usingModel.write).

Raises anAttributeError if the specified attribute doesn’t exist orcan’t be set. Raises aGurobiError if there is a problem with theGenConstr object (e.g., it was removed from the model).

Parameters:
  • attrname – The attribute being modified.

  • newvalue – The desired new value of the attribute.

Help and Feedback

On this page

[8]ページ先頭

©2009-2025 Movatter.jp