@@ -225,46 +225,52 @@ Return a JuMP model read from `filename` in the format `format`.
225225
226226See [`MOI.FileFormats.FileFormat`](@ref) for a list of supported formats.
227227
228- ## Compression
229-
230- If the filename ends in `.gz`, the file will be uncompressed using GZip.
231-
232- If the filename ends in `.bz2`, the file will be uncompressed using BZip2.
233-
234228## Keyword arguments
235229
236230Other `kwargs` are passed to the `Model` constructor of the chosen format.
237231
238232For details, see the docstring each file format's `Model` constructor. For
239233example, [`MOI.FileFormats.MPS.Model`](@ref).
240234
235+ ## Nonlinear models
236+
237+ To maintain backwards compatibility, nonlinear models in `.mof.json` and `.nl`
238+ files are parsed into a [`MOI.NLPBlock`](@ref). To parse as [`MOI.ScalarNonlinearFunction`](@ref),
239+ pass the keyword `use_nlp_block = false`.
240+
241+ ## Compression
242+
243+ If the filename ends in `.gz`, the file will be uncompressed using GZip.
244+
245+ If the filename ends in `.bz2`, the file will be uncompressed using BZip2.
246+
241247## Example
242248
243249```jldoctest
244250julia> model = Model();
245251
246252julia> @variable(model, x >= 0);
247253
248- julia> @objective(model, Min, 2 * x + 1 );
254+ julia> @objective(model, Min, log(x) );
249255
250- julia> filename = joinpath(mktempdir(), "model.mps ");
256+ julia> filename = joinpath(mktempdir(), "model.mof.json ");
251257
252- julia> write_to_file(model, filename; generic_names = true )
258+ julia> write_to_file(model, filename)
253259
254- julia> new_model = read_from_file(filename)
260+ julia> new_model = read_from_file(filename; use_nlp_block = false )
255261A JuMP Model
256262├ solver: none
257263├ objective_sense: MIN_SENSE
258- │ └ objective_function_type: AffExpr
264+ │ └ objective_function_type: NonlinearExpr
259265├ num_variables: 1
260266├ num_constraints: 1
261267│ └ VariableRef in MOI.GreaterThan{Float64}: 1
262268└ Names registered in the model: none
263269
264270julia> print(new_model)
265- Min 2 C1 + 1
271+ Min log(x)
266272Subject to
267- C1 ≥ 0
273+ x ≥ 0
268274```
269275"""
270276function read_from_file (
@@ -298,33 +304,44 @@ Other `kwargs` are passed to the `Model` constructor of the chosen format.
298304For details, see the docstring each file format's `Model` constructor. For
299305example, [`MOI.FileFormats.MPS.Model`](@ref).
300306
307+ ## Nonlinear models
308+
309+ To maintain backwards compatibility, nonlinear models in `.mof.json` and `.nl`
310+ files are parsed into a [`MOI.NLPBlock`](@ref). To parse as [`MOI.ScalarNonlinearFunction`](@ref),
311+ pass the keyword `use_nlp_block = false`.
312+
301313## Example
302314
303315```jldoctest
304316julia> model = Model();
305317
306318julia> @variable(model, x >= 0);
307319
308- julia> @objective(model, Min, 2 * x + 1 );
320+ julia> @objective(model, Min, log(x) );
309321
310322julia> io = IOBuffer();
311323
312- julia> write(io, model; format = MOI.FileFormats.FORMAT_MPS );
324+ julia> write(io, model; format = MOI.FileFormats.FORMAT_MOF );
313325
314326julia> seekstart(io);
315327
316- julia> new_model = read(io, Model; format = MOI.FileFormats.FORMAT_MPS)
328+ julia> new_model = read(
329+ io,
330+ Model;
331+ format = MOI.FileFormats.FORMAT_MOF,
332+ use_nlp_block = false,
333+ )
317334A JuMP Model
318335├ solver: none
319336├ objective_sense: MIN_SENSE
320- │ └ objective_function_type: AffExpr
337+ │ └ objective_function_type: NonlinearExpr
321338├ num_variables: 1
322339├ num_constraints: 1
323340│ └ VariableRef in MOI.GreaterThan{Float64}: 1
324341└ Names registered in the model: none
325342
326343julia> print(new_model)
327- Min 2 x + 1
344+ Min log(x)
328345Subject to
329346 x ≥ 0
330347```
0 commit comments