Movatterモバイル変換


[0]ホーム

URL:


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

Concepts

Features

Reference

Gurobi
Back to top

Overloaded Operators#

The Gurobi C++ interface overloads several arithmetic and comparisonoperators. Overloaded arithmetic operators (+,-,*,/) are used tocreate linear and quadratic expressions. Overloaded comparison operators(<=,>=,and==) are used to build linear and quadratic constraints.

Note that the results of overloaded comparison operators are generallynever stored in user variables. They are immediately passed toGRBModel::addConstr orGRBModel::addQConstr.

GRBTempConstroperator==(GRBQuadExprlhsExpr,GRBQuadExprrhsExpr)#

Create an equality constraint

Parameters:
  • lhsExpr – Left-hand side of equality constraint.

  • rhsExpr – Right-hand side of equality constraint.

Returns:

A constraint of typeGRBTempConstr. The result istypically immediately passed toGRBModel::addConstr.

GRBTempConstroperator<=(GRBQuadExprlhsExpr,GRBQuadExprrhsExpr)#

Create an inequality constraint

Parameters:
  • lhsExpr – Left-hand side of inequality constraint.

  • rhsExpr – Right-hand side of inequality constraint.

Returns:

A constraint of typeGRBTempConstr. The result istypically immediately passed toGRBModel::addConstr orGRBModel::addQConstr.

GRBTempConstroperator>=(GRBQuadExprlhsExpr,GRBQuadExprrhsExpr)#

Create an inequality constraint

Parameters:
  • lhsExpr – Left-hand side of inequality constraint.

  • rhsExpr – Right-hand side of inequality constraint.

Returns:

A constraint of typeGRBTempConstr. The result istypically immediately passed toGRBModel::addConstr orGRBModel::addQConstr.

GRBLinExproperator+(constGRBLinExpr&expr1,constGRBLinExpr&expr2)#

Overloaded operator on expression objects.

Add a pair of expressions.

Parameters:
  • expr1 – First expression to be added.

  • expr2 – Second expression to be added.

Returns:

Sum expression.

GRBLinExproperator+(constGRBLinExpr&expr)#

Overloaded operator on expression objects.

Allow plus sign to be used before an expression.

Parameters:

expr – Expression.

Returns:

Result expression.

GRBLinExproperator+(GRBVarx,GRBVary)#

Overloaded operator on expression objects.

Add a pair of variables.

Parameters:
  • x – First variable to be added.

  • y – Second variable to be added.

Returns:

Sum expression.

GRBQuadExproperator+(constGRBQuadExpr&expr1,constGRBQuadExpr&expr2)#

Overloaded operator on expression objects.

Add a pair of expressions.

Parameters:
  • expr1 – First expression to be added.

  • expr2 – Second expression to be added.

Returns:

Sum expression.

GRBQuadExproperator+(constGRBQuadExpr&expr)#

Overloaded operator on expression objects.

Allow plus sign to be used before an expression.

Parameters:

expr – Expression.

Returns:

Result expression.

GRBLinExproperator-(constGRBLinExpr&expr1,constGRBLinExpr&expr2)#

Overloaded operator on expression objects.

Subtract one expression from another.

Parameters:
  • expr1 – Start expression.

  • expr2 – Expression to be subtracted.

Returns:

Difference expression.

GRBLinExproperator-(constGRBLinExpr&expr)#

Overloaded operator on expression objects.

Negate an expression.

Parameters:

expr – Expression.

Returns:

Negation of expression.

GRBQuadExproperator-(constGRBQuadExpr&expr1,constGRBQuadExpr&expr2)#

Overloaded operator on expression objects.

Subtract one expression from another.

Parameters:
  • expr1 – Start expression.

  • expr2 – Expression to be subtracted.

Returns:

Difference expression.

GRBQuadExproperator-(constGRBQuadExpr&expr)#

Overloaded operator on expression objects.

Negate an expression.

Parameters:

expr – Expression.

Returns:

Negation of expression.

GRBLinExproperator*(GRBVarx,doublea)#

Overloaded operator on expression objects.

Multiply a variable and a constant.

Parameters:
  • x – Variable.

  • a – Constant multiplier.

Returns:

Expression that represents the result of multiplying thevariable by a constant.

GRBLinExproperator*(doublea,GRBVarx)#

Overloaded operator on expression objects.

Multiply a variable and a constant.

Parameters:
  • a – Constant multiplier.

  • x – Variable.

Returns:

Expression that represents the result of multiplying thevariable by a constant.

GRBLinExproperator*(constGRBLinExpr&expr,doublea)#

Overloaded operator on expression objects.

Multiply an expression and a constant.

Parameters:
  • expr – Expression.

  • a – Constant multiplier.

Returns:

Expression that represents the result of multiplying theexpression by a constant.

GRBLinExproperator*(doublea,constGRBLinExpr&expr)#

Overloaded operator on expression objects.

Multiply an expression and a constant.

Parameters:
  • a – Constant multiplier.

  • expr – Expression.

Returns:

Expression that represents the result of multiplying theexpression by a constant.

GRBQuadExproperator*(constGRBQuadExpr&expr,doublea)#

Overloaded operator on expression objects.

Multiply an expression and a constant.

Parameters:
  • expr – Expression.

  • a – Constant multiplier.

Returns:

Expression that represents the result of multiplying theexpression by a constant.

GRBQuadExproperator*(doublea,constGRBQuadExpr&expr)#

Overloaded operator on expression objects.

Multiply an expression and a constant.

Parameters:
  • a – Constant multiplier.

  • expr – Expression.

Returns:

Expression that represents the result of multiplying theexpression by a constant.

GRBQuadExproperator*(GRBVarx,GRBVary)#

Overloaded operator on expression objects.

Multiply a pair of variables.

Parameters:
  • x – First variable.

  • y – Second variable.

Returns:

Expression that represents the result of multiplying theargument variables.

GRBQuadExproperator*(GRBVarvar,constGRBLinExpr&expr)#

Overloaded operator on expression objects.

Multiply an expression and a variable.

Parameters:
  • var – Variable.

  • expr – Expression.

Returns:

Expression that represents the result of multiplying theexpression by a variable.

GRBQuadExproperator*(constGRBLinExpr&expr,GRBVarvar)#

Overloaded operator on expression objects.

Multiply an expression and a variable.

Parameters:
  • var – Variable.

  • expr – Expression.

Returns:

Expression that represents the result of multiplying theexpression by a variable.

GRBQuadExproperator*(constGRBLinExpr&expr1,constGRBLinExpr&expr2)#

Overloaded operator on expression objects.

Multiply a pair of expressions.

Parameters:
  • expr1 – First expression.

  • expr2 – Second expression.

Returns:

Expression that represents the result of multiplying theargument expressions.

GRBLinExproperator/(GRBVarx,doublea)#

Overloaded operator to divide a variable or expression by a constant.

Parameters:
  • x – Variable.

  • a – Constant divisor.

Returns:

Expression that represents the result of dividing the variableby a constant.

GRBLinExproperator/(constGRBLinExpr&expr,doublea)#

Overloaded operator to divide a variable or expression by a constant.

Parameters:
  • expr – Expression.

  • a – Constant divisor.

Returns:

Expression that represents the result of dividing the expressionby a constant.

GRBLinExproperator/(constGRBQuadExpr&expr,doublea)#

Overloaded operator to divide a variable or expression by a constant.

Parameters:
  • expr – Expression.

  • a – Constant divisor.

Returns:

Expression that represents the result of dividing the expressionby a constant.

Help and Feedback

On this page

[8]ページ先頭

©2009-2025 Movatter.jp