Nonlinear API

More information can be found in the Nonlinear Modeling section of the manual.

JuMP.@NLconstraintMacro
@NLconstraint(m::Model, expr)

Add a constraint described by the nonlinear expression expr. See also @constraint. For example:

@NLconstraint(model, sin(x) <= 1)
@NLconstraint(model, [i = 1:3], sin(i * x) <= 1 / i)
source
JuMP.@NLconstraintsMacro
@NLconstraints(model, args...)

Adds multiple nonlinear constraints to model at once, in the same fashion as the @NLconstraint macro.

The model must be the first argument, and multiple variables can be added on multiple lines wrapped in a begin ... end block.

Examples

@NLconstraints(model, begin
    t >= sqrt(x^2 + y^2)
    [i = 1:2], z[i] <= log(a[i])
end)
source
JuMP.@NLexpressionMacro
@NLexpression(args...)

Efficiently build a nonlinear expression which can then be inserted in other nonlinear constraints and the objective. See also [@expression]. For example:

@NLexpression(model, my_expr, sin(x)^2 + cos(x^2))
@NLconstraint(model, my_expr + y >= 5)
@NLobjective(model, Min, my_expr)

Indexing over sets and anonymous expressions are also supported:

@NLexpression(m, my_expr_1[i=1:3], sin(i * x))
my_expr_2 = @NLexpression(m, log(1 + sum(exp(x[i])) for i in 1:2))
source
JuMP.@NLexpressionsMacro
@NLexpressions(model, args...)

Adds multiple nonlinear expressions to model at once, in the same fashion as the @NLexpression macro.

The model must be the first argument, and multiple variables can be added on multiple lines wrapped in a begin ... end block.

Examples

@NLexpressions(model, begin
    my_expr, sqrt(x^2 + y^2)
    my_expr_1[i = 1:2], log(a[i]) - z[i]
end)
source
JuMP.@NLobjectiveMacro
@NLobjective(model, sense, expression)

Add a nonlinear objective to model with optimization sense sense. sense must be Max or Min.

Example

@NLobjective(model, Max, 2x + 1 + sin(x))
source
JuMP.@NLparameterMacro
@NLparameter(model, param == value)

Create and return a nonlinear parameter param attached to the model model with initial value set to value. Nonlinear parameters may be used only in nonlinear expressions.

Example

model = Model()
@NLparameter(model, x == 10)
value(x)

# output
10.0
@NLparameter(model, param_collection[...] == value_expr)

Create and return a collection of nonlinear parameters param_collection attached to the model model with initial value set to value_expr (may depend on index sets). Uses the same syntax for specifying index sets as @variable.

Example

model = Model()
@NLparameter(model, y[i = 1:10] == 2 * i)
value(y[9])

# output
18.0
source
JuMP.valueMethod
value(p::NonlinearParameter)

Return the current value stored in the nonlinear parameter p.

Example

model = Model()
@NLparameter(model, p == 10)
value(p)

# output
10.0
source
JuMP.set_valueMethod
set_value(p::NonlinearParameter, v::Number)

Store the value v in the nonlinear parameter p.

Example

model = Model()
@NLparameter(model, p == 0)
set_value(p, 5)
value(p)

# output
5.0
source