From 7f709688c2267aab12ef319a35da4533b78358cf Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 28 Sep 2023 09:46:35 +1300 Subject: [PATCH] DNMY: [FileFormats.MOF] change parse_as_nlpblock to false by default --- src/FileFormats/MOF/MOF.jl | 6 +++--- test/FileFormats/MOF/MOF.jl | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/FileFormats/MOF/MOF.jl b/src/FileFormats/MOF/MOF.jl index 250a43d4cf..3d4e2c0cdb 100644 --- a/src/FileFormats/MOF/MOF.jl +++ b/src/FileFormats/MOF/MOF.jl @@ -123,7 +123,7 @@ function get_options(m::Model) return get( m.model.ext, :MOF_OPTIONS, - Options(false, false, MOI.Nonlinear.SparseReverseMode(), true), + Options(false, false, MOI.Nonlinear.SparseReverseMode(), false), ) end @@ -140,7 +140,7 @@ Keyword arguments are: - `differentiation_backend::MOI.Nonlinear.AbstractAutomaticDifferentiation = MOI.Nonlinear.SparseReverseMode()`: automatic differentiation backend to use when reading models with nonlinear constraints and objectives. - - `parse_as_nlpblock::Bool=true`: if `true` parse `"ScalarNonlinearFunction"` + - `parse_as_nlpblock::Bool=false`: if `true` parse `"ScalarNonlinearFunction"` into an `MOI.NLPBlock`. If `false`, `"ScalarNonlinearFunction"` are parsed as `MOI.ScalarNonlinearFunction` functions. """ @@ -148,7 +148,7 @@ function Model(; print_compact::Bool = false, warn::Bool = false, differentiation_backend::MOI.Nonlinear.AbstractAutomaticDifferentiation = MOI.Nonlinear.SparseReverseMode(), - parse_as_nlpblock::Bool = true, + parse_as_nlpblock::Bool = false, ) model = MOI.Utilities.UniversalFallback(InnerModel{Float64}()) model.model.ext[:MOF_OPTIONS] = diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index 359146a756..0f76c5350b 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -119,7 +119,7 @@ function test_HS071() end function test_read_HS071() - model = MOF.Model() + model = MOF.Model(; parse_as_nlpblock = true) MOI.read_from_file(model, joinpath(@__DIR__, "nlp.mof.json")) @test MOI.get(model, MOI.ListOfConstraintTypesPresent()) == Tuple{Type,Type}[(MOI.VariableIndex, MOI.Interval{Float64})] @@ -283,7 +283,7 @@ function test_nonlinear_readingwriting() MOI.set(model, MOI.ConstraintName(), con, "con") MOI.write_to_file(model, TEST_MOF_FILE) # Read the model back in. - model2 = MOF.Model() + model2 = MOF.Model(; parse_as_nlpblock = true) MOI.read_from_file(model2, TEST_MOF_FILE) block = MOI.get(model2, MOI.NLPBlock()) MOI.initialize(block.evaluator, [:ExprGraph]) @@ -748,8 +748,7 @@ variables: x minobjective: ScalarNonlinearFunction(exp(x)) """, ["x"], - String[]; - parse_as_nlpblock = false, + String[], ) end @@ -760,8 +759,7 @@ variables: x c1: ScalarNonlinearFunction(exp(x)^2) <= 1.0 """, ["x"], - ["c1"]; - parse_as_nlpblock = false, + ["c1"], ) end @@ -1423,7 +1421,7 @@ function test_parse_nonlinear_objective_only() }""", ) seekstart(io) - model = MOF.Model() + model = MOF.Model(; parse_as_nlpblock = true) read!(io, model) block = MOI.get(model, MOI.NLPBlock()) @test block isa MOI.NLPBlockData