Skip to content

Commit 59083a9

Browse files
authored
[docs] add more examples to nlp.md (#3068)
1 parent b2502d0 commit 59083a9

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/src/manual/nlp.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ julia> @NLobjective(model, Min, exp(x[1]) - sqrt(x[2]))
3333

3434
Use [`@NLconstraint`](@ref) to add a nonlinear constraint.
3535

36-
```jldoctest; setup=:(model = Model(); @variable(model, x[1:2]))
36+
```jldoctest nonlinear_constraint; setup=:(model = Model(); @variable(model, x[1:2]))
3737
julia> @NLconstraint(model, exp(x[1]) <= 1)
3838
exp(x[1]) - 1.0 ≤ 0
3939
@@ -52,6 +52,11 @@ julia> @NLconstraint(model, con[i = 1:2], prod(x[j] for j = 1:i) == i)
5252
You can only create nonlinear constraints with `<=`, `>=`, and `==`.
5353
More general `Nonlinear`-in-`Set` constraints are not supported.
5454

55+
Delete a nonlinear constraint using [`delete`](@ref):
56+
```jldoctest nonlinear_constraint
57+
julia> delete(model, con[1])
58+
```
59+
5560
## Create a nonlinear expression
5661

5762
Use [`@NLexpression`](@ref) to create nonlinear expression objects. The syntax
@@ -90,6 +95,17 @@ julia> @NLexpression(model, nested[i = 1:2], sin(my_expr[i]))
9095
subexpression[7]: sin(subexpression[5])
9196
```
9297

98+
Use [`value`](@ref) to query the value of a nonlinear expression:
99+
```jldoctest nl_expression
100+
julia> set_start_value(x[1], 1.0)
101+
102+
julia> value(start_value, nested[1])
103+
0.7456241416655579
104+
105+
julia> sin(sin(1.0))
106+
0.7456241416655579
107+
```
108+
93109
## Create a nonlinear parameter
94110

95111
For nonlinear models only, JuMP offers a syntax for explicit "parameter" objects,

0 commit comments

Comments
 (0)