C++ API - Non-Member Functions#

Several Gurobi C++ interface functions aren’t member functions on a particular object.

GRBTempConstr operator==(GRBQuadExpr lhsExpr, GRBQuadExpr rhsExpr)#

Create an equality constraint

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

  • rhsExpr – Right-hand side of equality constraint.

Returns:

A constraint of type GRBTempConstr. The result is typically immediately passed to GRBModel::addConstr.

GRBTempConstr operator<=(GRBQuadExpr lhsExpr, GRBQuadExpr rhsExpr)#

Create an inequality constraint

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

  • rhsExpr – Right-hand side of inequality constraint.

Returns:

A constraint of type GRBTempConstr. The result is typically immediately passed to GRBModel::addConstr or GRBModel::addQConstr.

GRBTempConstr operator>=(GRBQuadExpr lhsExpr, GRBQuadExpr rhsExpr)#

Create an inequality constraint

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

  • rhsExpr – Right-hand side of inequality constraint.

Returns:

A constraint of type GRBTempConstr. The result is typically immediately passed to GRBModel::addConstr or GRBModel::addQConstr.

GRBLinExpr operator+(const GRBLinExpr &expr1, const GRBLinExpr &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.

GRBLinExpr operator+(const GRBLinExpr &expr)#

Overloaded operator on expression objects.

Allow plus sign to be used before an expression.

Parameters:

expr – Expression.

Returns:

Result expression.

GRBLinExpr operator+(GRBVar x, GRBVar y)#

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.

GRBQuadExpr operator+(const GRBQuadExpr &expr1, const GRBQuadExpr &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.

GRBQuadExpr operator+(const GRBQuadExpr &expr)#

Overloaded operator on expression objects.

Allow plus sign to be used before an expression.

Parameters:

expr – Expression.

Returns:

Result expression.

GRBLinExpr operator-(const GRBLinExpr &expr1, const GRBLinExpr &expr2)#

Overloaded operator on expression objects.

Subtract one expression from another.

Parameters:
  • expr1 – Start expression.

  • expr2 – Expression to be subtracted.

Returns:

Difference expression.

GRBLinExpr operator-(const GRBLinExpr &expr)#

Overloaded operator on expression objects.

Negate an expression.

Parameters:

expr – Expression.

Returns:

Negation of expression.

GRBQuadExpr operator-(const GRBQuadExpr &expr1, const GRBQuadExpr &expr2)#

Overloaded operator on expression objects.

Subtract one expression from another.

Parameters:
  • expr1 – Start expression.

  • expr2 – Expression to be subtracted.

Returns:

Difference expression.

GRBQuadExpr operator-(const GRBQuadExpr &expr)#

Overloaded operator on expression objects.

Negate an expression.

Parameters:

expr – Expression.

Returns:

Negation of expression.

GRBLinExpr operator*(GRBVar x, double a)#

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 the variable by a constant.

GRBLinExpr operator*(double a, GRBVar x)#

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 the variable by a constant.

GRBLinExpr operator*(const GRBLinExpr &expr, double a)#

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 the expression by a constant.

GRBLinExpr operator*(double a, const GRBLinExpr &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 the expression by a constant.

GRBQuadExpr operator*(const GRBQuadExpr &expr, double a)#

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 the expression by a constant.

GRBQuadExpr operator*(double a, const GRBQuadExpr &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 the expression by a constant.

GRBQuadExpr operator*(GRBVar x, GRBVar y)#

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 the argument variables.

GRBQuadExpr operator*(GRBVar var, const GRBLinExpr &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 the expression by a variable.

GRBQuadExpr operator*(const GRBLinExpr &expr, GRBVar var)#

Overloaded operator on expression objects.

Multiply an expression and a variable.

Parameters:
  • var – Variable.

  • expr – Expression.

Returns:

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

GRBQuadExpr operator*(const GRBLinExpr &expr1, const GRBLinExpr &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 the argument expressions.

GRBLinExpr operator/(GRBVar x, double a)#

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 variable by a constant.

GRBLinExpr operator/(const GRBLinExpr &expr, double a)#

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 expression by a constant.

GRBLinExpr operator/(const GRBQuadExpr &expr, double a)#

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 expression by a constant.

Attribute Enums#

These enums are used to get or set Gurobi attributes. The complete list of attributes can be found in the Attributes section.

enum GRB_CharAttr#

This enum is used to get or set char-valued attributes (through GRBModel::get or GRBModel::set). Please refer to the Attributes section to see a list of all attributes and their purpose.

enum GRB_DoubleAttr#

This enum is used to get or set double-valued attributes (through GRBModel::get or GRBModel::set). Please refer to the Attributes section to see a list of all attributes and their purpose.

enum GRB_IntAttr#

This enum is used to get or set int-valued attributes (through GRBModel::get or GRBModel::set). Please refer to the Attributes section to see a list of all attributes and their purpose.

enum GRB_StringAttr#

This enum is used to get or set string-valued attributes (through GRBModel::get or GRBModel::set). Please refer to the Attributes section to see a list of all attributes and their purpose.

Parameter Enums#

These enums are used to get or set Gurobi parameters. The complete of parameters can be found in the Parameters section.

enum GRB_DoubleParam#

This enum is used to get or set double-valued parameters (through GRBModel::get, GRBModel::set. GRBEnv::get, or GRBEnv::set). Please refer to the Parameters section to see a list of all parameters and their purpose.

enum GRB_IntParam#

This enum is used to get or set int-valued parameters (through GRBModel::get, GRBModel::set. GRBEnv::get, or GRBEnv::set). Please refer to the Parameters section to see a list of all parameters and their purpose.

enum GRB_StringParam#

This enum is used to get or set string-valued parameters (through GRBModel::get, GRBModel::set, GRBEnv::get, or GRBEnv::set). Please refer to the Parameters section to see a list of all parameters and their purpose.