Closed odow closed 1 month ago
julia> import MathOptInterface as MOI
julia> begin
src = MOI.Utilities.Model{Float64}()
x = MOI.add_variable(src)
MOI.set(src, MOI.ObjectiveSense(), MOI.MIN_SENSE)
MOI.set(src, MOI.ObjectiveFunction{MOI.VariableIndex}(), x)
dest = MOI.FileFormats.NL.Model()
MOI.copy_to(dest, src)
MOI.write_to_file(dest, "/tmp/nl.nl")
input = MOI.FileFormats.NL.Model(; use_nlp_block = false)
MOI.read_from_file(input, "/tmp/nl.nl")
model = MOI.Utilities.Model{Float64}()
MOI.copy_to(model, input)
print(model)
end
Minimize ScalarNonlinearFunction:
+(+(*(1.0, v[1])), +(0.0))
Subject to:
x-ref https://discourse.julialang.org/t/nlp-attribute-scalarnonlinearfunction-is-not-supported-by-the-model/110444/20?u=odow
The issue is that our reader converts everything to nonlinear, and doesn't attempt to lower back to linear if there are no nonlinear terms.