@@ -49,14 +49,26 @@ function of `model`.
4949
5050To remove the objective, pass `nothing`.
5151
52- ## Examples
53-
54- ```julia
55- model = Model()
56- x = MOI.VariableIndex(1)
57- set_objective(model, :(\$ x^2 + 1))
58- set_objective(model, x)
59- set_objective(model, nothing)
52+ ## Example
53+
54+ ```jldoctest
55+ julia> import MathOptInterface as MOI
56+
57+ julia> model = MOI.Nonlinear.Model()
58+ A Nonlinear.Model with:
59+ 0 objectives
60+ 0 parameters
61+ 0 expressions
62+ 0 constraints
63+
64+ julia> x = MOI.VariableIndex(1)
65+ MOI.VariableIndex(1)
66+
67+ julia> MOI.Nonlinear.set_objective(model, :(\$ x^2 + 1))
68+
69+ julia> MOI.Nonlinear.set_objective(model, x)
70+
71+ julia> MOI.Nonlinear.set_objective(model, nothing)
6072```
6173"""
6274function set_objective (model:: Model , obj)
@@ -77,13 +89,19 @@ Parse `expr` into a [`Expression`](@ref) and add to `model`. Returns an
7789
7890`expr` must be a type that is supported by [`parse_expression`](@ref).
7991
80- ## Examples
92+ ## Example
8193
82- ```julia
83- model = Model()
84- x = MOI.VariableIndex(1)
85- ex = add_expression(model, :(\$ x^2 + 1))
86- set_objective(model, :(sqrt(\$ ex)))
94+ ```jldoctest
95+ julia> import MathOptInterface as MOI
96+
97+ julia> model = MOI.Nonlinear.Model();
98+
99+ julia> x = MOI.VariableIndex(1);
100+
101+ julia> ex = MOI.Nonlinear.add_expression(model, :(\$ x^2 + 1))
102+ MathOptInterface.Nonlinear.ExpressionIndex(1)
103+
104+ julia> MOI.Nonlinear.set_objective(model, :(sqrt(\$ ex)))
87105```
88106"""
89107function add_expression (model:: Model , expr)
@@ -111,12 +129,17 @@ Parse `func` and `set` into a [`Constraint`](@ref) and add to `model`. Returns a
111129[`ConstraintIndex`](@ref) that can be used to delete the constraint or query
112130solution information.
113131
114- ## Examples
132+ ## Example
133+
134+ ```jldoctest
135+ julia> import MathOptInterface as MOI
136+
137+ julia> model = MOI.Nonlinear.Model();
115138
116- ``` julia
117- model = Model()
118- x = MOI.VariableIndex(1 )
119- c = add_constraint(model, :( \$ x^2), MOI.LessThan(1.0) )
139+ julia> x = MOI.VariableIndex(1);
140+
141+ julia> c = MOI.Nonlinear.add_constraint(model, :( \$ x^2), MOI.LessThan(1.0) )
142+ MathOptInterface.Nonlinear.ConstraintIndex(1 )
120143```
121144"""
122145function add_constraint (
@@ -141,13 +164,39 @@ end
141164
142165Delete the constraint index `c` from `model`.
143166
144- ## Examples
167+ ## Example
168+
169+ ```jldoctest
170+ julia> import MathOptInterface as MOI
171+
172+ julia> model = MOI.Nonlinear.Model()
173+ A Nonlinear.Model with:
174+ 0 objectives
175+ 0 parameters
176+ 0 expressions
177+ 0 constraints
178+
179+ julia> x = MOI.VariableIndex(1)
180+ MOI.VariableIndex(1)
181+
182+ julia> c = MOI.Nonlinear.add_constraint(model, :(\$ x^2), MOI.LessThan(1.0))
183+ MathOptInterface.Nonlinear.ConstraintIndex(1)
184+
185+ julia> model
186+ A Nonlinear.Model with:
187+ 0 objectives
188+ 0 parameters
189+ 0 expressions
190+ 1 constraint
145191
146- ```julia
147- model = Model()
148- x = MOI.VariableIndex(1)
149- c = add_constraint(model, :(\$ x^2), MOI.LessThan(1.0))
150- delete(model, c)
192+ julia> MOI.Nonlinear.delete(model, c)
193+
194+ julia> model
195+ A Nonlinear.Model with:
196+ 0 objectives
197+ 0 parameters
198+ 0 expressions
199+ 0 constraints
151200```
152201"""
153202function delete (model:: Model , c:: ConstraintIndex )
@@ -170,13 +219,26 @@ Add a new parameter to `model` with the default value `value`. Returns a
170219[`ParameterIndex`](@ref) that can be interpolated into other input expressions
171220and used to modify the value of the parameter.
172221
173- ## Examples
222+ ## Example
223+
224+ ```jldoctest
225+ julia> import MathOptInterface as MOI
226+
227+ julia> model = MOI.Nonlinear.Model()
228+ A Nonlinear.Model with:
229+ 0 objectives
230+ 0 parameters
231+ 0 expressions
232+ 0 constraints
233+
234+ julia> x = MOI.VariableIndex(1)
235+ MOI.VariableIndex(1)
236+
237+ julia> p = MOI.Nonlinear.add_parameter(model, 1.2)
238+ MathOptInterface.Nonlinear.ParameterIndex(1)
174239
175- ```julia
176- model = Model()
177- x = MOI.VariableIndex(1)
178- p = add_parameter(model, 1.2)
179- c = add_constraint(model, :(\$ x^2 - \$ p), MOI.LessThan(0.0))
240+ julia> c = MOI.Nonlinear.add_constraint(model, :(\$ x^2 - \$ p), MOI.LessThan(0.0))
241+ MathOptInterface.Nonlinear.ConstraintIndex(1)
180242```
181243"""
182244function add_parameter (model:: Model , value:: Float64 )
0 commit comments