Movatterモバイル変換


[0]ホーム

URL:


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

Concepts

Features

Reference

Gurobi
Back to top

General Constraint Helper Functions#

Gurobi general constraint helper functions - used in conjunction withoverloaded operators andModel.addConstr orModel.addConstrs to buildgeneralconstraints.

abs_(argvar)#

Used to set a decision variable equal to the absolute value of anotherdecision variable.

Parameters:

argvar – (Var) The variable whose absolute value will be taken.

Example:
m.addConstr(y==gp.abs_(x))
Returns:

Returns aGenExpr object.

and_(*args)#

Used to set a binary decision variable equal to the logical AND of alist of other binary decision variables.

Parameters:

args – (Var, or list or iterable of Var) The variables over whichthe AND concatenation will be taken.

Example:
m.addConstr(z==gp.and_(x,y))m.addConstr(z==gp.and_([x,y]))
Returns:

Returns aGenExpr object.

Deprecated since version 12.0:Passing atupledict as thevars argument is deprecated.To take the AND concatenation over all variables in a tupledicttd,passtd.values().

max_(*args,constant=None)#

Used to set a decision variable equal to the maximum of a list ofdecision variables and, if desired, a constant.

Parameters:
  • args – (Var, or list or iterable of Var) The variables over whichthe MAX will be taken.

  • constant – (float, optional) The constant value to include amongthe arguments of the MAX operation.

Example:
m.addConstr(z==gp.max_(x,y,constant=3))m.addConstr(z==gp.max_([x,y],constant=3))
Returns:

Returns aGenExpr object.

Deprecated since version 12.0:Passing atupledict as thevars argument is deprecated.To take the MAX over all variables in a tupledicttd, passtd.values().

min_(*args,constant=None)#

Used to set a decision variable equal to the minimum of a list ofdecision variables and, if desired, a constant.

Parameters:
  • args – (Var, or list or iterable of Var) The variables over whichthe MIN will be taken.

  • constant – (float, optional) The constant value to include amongthe arguments of the MIN operation.

Example:
m.addConstr(z==gp.min_(x,y,constant=3))m.addConstr(z==gp.min_([x,y],constant=3))
Returns:

Returns aGenExpr object.

Deprecated since version 12.0:Passing atupledict as thevars argument is deprecated.To take the MIN over all variables in a tupledicttd, passtd.values().

or_(*args)#

Used to set a binary decision variable equal to the logical OR of a listof other binary decision variables.

Parameters:

args – (Var, or list or iterable of Var) The variables over whichthe OR concatenation will be taken.

Example:
m.addConstr(z==gp.or_(x,y))m.addConstr(z==gp.or_([x,y]))
Returns:

Returns aGenExpr object.

Deprecated since version 12.0:Passing atupledict as thevars argument is deprecated.To take the OR concatenation over all variables in a tupledicttd,passtd.values().

norm(vars,which)#

Used to set a decision variable equal to the norm of other decisionvariables.

Parameters:
  • vars – (list or iterable of Var, or 1-dim MVar) The variables over whichthe NORM will be taken. Note that this may not contain duplicates.

  • which – (float) Which norm to use. Options are 0, 1, 2, and anyvalue greater than or equal to GRB.INFINITY.

Example:
x=m.addVars(3)nx=m.addVar()m.addConstr(nx==gp.norm(x,1.0))
Returns:

Returns aGenExpr object.

Deprecated since version 12.0:Passing atupledict as thevars argument is deprecated.To take the NORM over all variables in a tupledicttd, passtd.values().

Help and Feedback

On this page

[8]ページ先頭

©2009-2025 Movatter.jp