Movatterモバイル変換


[0]ホーム

URL:


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

Concepts

Features

Reference

Gurobi
Back to top

Nonlinear Expression Helper Functions#

This section covers functions in thegurobipy.nlfunc module. Eachfunction can be called with any modeling object and returns anNLExpr orMNLExpr representing the resultingnonlinear expression. The resulting expression can be used to addnonlinear constraints to the model. For example:

importgurobipyasgpfromgurobipyimportGRB,nlfuncwithgp.Env()asenv,gp.Model(env=env)asmodel:x=model.addVar(lb=-GRB.INFINITY,name="x")y=model.addVar(lb=-GRB.INFINITY,name="y")z=model.addVar(lb=-GRB.INFINITY,name="z")# Create a constraint specifying z = sin(x + y)model.addConstr(z==nlfunc.sin(x+y))
gurobipy.nlfunc.sqrt(expr)#

Return an expression representing the square root of the argument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

Also note the additional information on how Gurobi handles thesquare root function internally.

gurobipy.nlfunc.sin(expr)#

Return an expression representing the sine of the argument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

gurobipy.nlfunc.cos(expr)#

Return an expression representing the cosine of the argument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

gurobipy.nlfunc.tan(expr)#

Return an expression representing the tangent function of theargument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

gurobipy.nlfunc.exp(expr)#

Return an expression representing the exponential function of theargument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

gurobipy.nlfunc.log(expr)#

Return an expression representing the natural logarithm of theargument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

Also note the additional information on how Gurobi handles thelogarithm functions internally.

gurobipy.nlfunc.log2(expr)#

Return an expression representing the base 2 logarithm of theargument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

Also note the additional information on how Gurobi handles thelogarithm functions internally.

gurobipy.nlfunc.log10(expr)#

Return an expression representing the base 10 logarithm of theargument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

Also note the additional information on how Gurobi handles thelogarithm functions internally.

gurobipy.nlfunc.logistic(expr)#

Return an expression representing the logistic function of theargument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

gurobipy.nlfunc.tanh(expr)#

Return an expression representing the hyperbolic tangent function of theargument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

gurobipy.nlfunc.signpow(expr,a)#

Return an expression representing the signed power function of theargument.

Parameters:
  • expr – A modeling object or numeric value

  • a – A numeric value greater than or equal to 1

Returns:

If the first argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

gurobipy.nlfunc.square(expr)#

Return an expression representing the square of the argument.

Parameters:

expr – A modeling object or numeric value

Returns:

If the argument is a term-based modeling object or numericvalue, returns anNLExpr. If the argument is amatrix-friendly modeling object, returns anMNLExpr.

Help and Feedback

On this page

[8]ページ先頭

©2009-2025 Movatter.jp