Closed SebKrantz closed 1 week ago
What version of Ipopt.jl are you using. You need at least Ipopt v1.6.0
Thanks @odow, indeed, my version of Ipopt was outdated, but even after updating I get
ERROR: AssertionError: node.type == MOI.Nonlinear.NODE_VALUE
Stacktrace:
[1] _to_expr(data::MathOptInterface.Nonlinear.Model, expr::MathOptInterface.Nonlinear.Expression, variable_order::Dict{Int64, Int64}, subexpressions::Vector{Any})
@ MathOptSymbolicAD ~/.julia/packages/MathOptSymbolicAD/A5rTJ/src/nonlinear_oracle.jl:521
[2] (::MathOptSymbolicAD.var"#16#18"{MathOptInterface.Nonlinear.Model, Vector{Any}, Dict{Int64, Int64}})(c::MathOptInterface.Nonlinear.Constraint)
@ MathOptSymbolicAD ~/.julia/packages/MathOptSymbolicAD/A5rTJ/src/nonlinear_oracle.jl:549
[3] iterate
@ ./generator.jl:47 [inlined]
[4] collect_to!
@ ./array.jl:845 [inlined]
[5] collect_to_with_first!
@ ./array.jl:823 [inlined]
[6] collect(itr::Base.Generator{Base.ValueIterator{OrderedCollections.OrderedDict{MathOptInterface.Nonlinear.ConstraintIndex, MathOptInterface.Nonlinear.Constraint}}, MathOptSymbolicAD.var"#16#18"{MathOptInterface.Nonlinear.Model, Vector{Any}, Dict{Int64, Int64}}})
@ Base ./array.jl:797
[7] map
@ ./abstractarray.jl:2961 [inlined]
[8] MathOptInterface.Nonlinear.Evaluator(model::MathOptInterface.Nonlinear.Model, backend::MathOptSymbolicAD.DefaultBackend, ordered_variables::Vector{MathOptInterface.VariableIndex})
@ MathOptSymbolicAD ~/.julia/packages/MathOptSymbolicAD/A5rTJ/src/nonlinear_oracle.jl:548
[9] _setup_model(model::Ipopt.Optimizer)
@ Ipopt ~/.julia/packages/Ipopt/YDBAD/src/MOI_wrapper.jl:789
[10] optimize!(model::Ipopt.Optimizer)
@ Ipopt ~/.julia/packages/Ipopt/YDBAD/src/MOI_wrapper.jl:900
[11] optimize!
@ ~/.julia/packages/MathOptInterface/mz9FK/src/Bridges/bridge_optimizer.jl:380 [inlined]
[12] optimize!
@ ~/.julia/packages/MathOptInterface/mz9FK/src/MathOptInterface.jl:85 [inlined]
[13] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Ipopt.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/mz9FK/src/Utilities/cachingoptimizer.jl:316
[14] optimize!(model::JuMP.Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ JuMP ~/.julia/packages/JuMP/as6Ji/src/optimizer_interface.jl:457
[15] optimize!(model::JuMP.Model)
@ JuMP ~/.julia/packages/JuMP/as6Ji/src/optimizer_interface.jl:409
[16] optimal_network(param::Dict{Any, Any}, graph::Dict{Symbol, Any}; I0::Nothing, Il::Nothing, Iu::Nothing, verbose::Bool, return_model::Int64)
@ OptimalTransportNetworks ~/Documents/Julia/OptimalTransportNetworks.jl/src/main/optimal_network.jl:156
[17] top-level scope
@ ./timing.jl:262 [inlined]
[18] top-level scope
@ ~/Documents/Julia/OptimalTransportNetworks.jl/examples/example01.jl:0
For both the fixed and mobile model. I thus presume this has to do with some part of the model specification. Perhaps the parameters?
The issue is that we don't support logical or comparison operators:
I'm not sure why I didn't add this. Perhaps Symbolics.jl didn't support differentiating them when I first wrote this.
Hi @odow, is there any chance this support could be added in the near future?
I have no immediate plans, but I would happily review a PR. Having a minimal reproducible example would be helpful.
Hi @odow,
I've tried this backend with my optimal transport network models at https://github.com/SebKrantz/OptimalTransportNetworks.jl/tree/main/src/models, and it seems to work for none of them. For example, using Example 1 which calls this model:
Yields:
This does not seem to be dependent on how the parameters are passed to the optimizer, for example I can
Which yields the same. I note that this works with Matlab's symbolic differentiation engine ADiGator, so I guess the problem lies in certain parts of the model specification not supported by the symbolic backend rather than the model not being symbolically differentiable?