Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOI throws error with EAGO.jl #167

Closed
jonasmac16 opened this issue Sep 22, 2021 · 0 comments · Fixed by #218
Closed

MOI throws error with EAGO.jl #167

jonasmac16 opened this issue Sep 22, 2021 · 0 comments · Fixed by #218

Comments

@jonasmac16
Copy link
Contributor

I have tried using EAGO.jl with GalacticOptim.jl but it seems to run into a couple of errors.
The MWE:

using GalacticOptim
using EAGO
rosenbrock(x,p) =  (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p  = [1.0,100.0]
l1 = rosenbrock(x0, p)
f = OptimizationFunction(rosenbrock, GalacticOptim.AutoForwardDiff())
prob = GalacticOptim.OptimizationProblem(f, x0, p, lb = [-1.0,-1.0], ub = [1.5,1.5])

sol = solve(prob, EAGO.Optimizer());

The first error I get is the following:

ERROR: MathOptInterface.UnsupportedAttribute{MathOptInterface.VariablePrimalStart}: Attribute MathOptInterface.VariablePrimalStart() is not supported by the model.
Stacktrace:
 [1] throw_set_error_fallback(model::Optimizer, attr::MathOptInterface.VariablePrimalStart, index::MathOptInterface.VariableIndex, value::Float64; error_if_supported::MathOptInterface.SetAttributeNotAllowed{MathOptInterface.VariablePrimalStart})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/attributes.jl:438
 [2] throw_set_error_fallback(model::Optimizer, attr::MathOptInterface.VariablePrimalStart, index::MathOptInterface.VariableIndex, value::Float64)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/attributes.jl:435
 [3] set(::Optimizer, ::MathOptInterface.VariablePrimalStart, ::MathOptInterface.VariableIndex, ::Float64)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/attributes.jl:410
 [4] __solve(prob::OptimizationProblem{true, OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, opt::Optimizer; maxiters::Nothing, maxtime::Nothing, abstol::Nothing, reltol::Nothing, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GalacticOptim ~/.julia/dev/GalacticOptim/src/solve/moi.jl:156
 [5] __solve
   @ ~/.julia/dev/GalacticOptim/src/solve/moi.jl:135 [inlined]
 [6] #solve#476
   @ ~/.julia/packages/SciMLBase/n3U0M/src/solve.jl:3 [inlined]
 [7] solve(::OptimizationProblem{true, OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::Optimizer)
   @ SciMLBase ~/.julia/packages/SciMLBase/n3U0M/src/solve.jl:3
 [8] top-level scope
   @ REPL[12]:1

It seems like it doesn't like the fact that an initial values being set. The MOI interface might need some additional checks such as if the chosen optimiser allows for initial values.

So if I comment out that section which sets the initial values https://github.com/SciML/GalacticOptim.jl/blob/2b657d2a2e1ce80547c54b4cbb4f468d2ee56bad/src/solve/moi.jl#L155-L157

A new error emerges:

ERROR: MethodError: no method matching add_nonlinear_evaluator!(::Optimizer, ::GalacticOptim.MOIOptimizationProblem{Float64, OptimizationFunction{true, GalacticOptim.AutoForwardDiff, typeof(rosenbrock), GalacticOptim.var"#105#121"{GalacticOptim.var"#103#119"{Vector{Float64}, GalacticOptim.var"#102#118"{OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}}, Int64}, GalacticOptim.var"#102#118"{OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}}}, GalacticOptim.var"#109#125"{GalacticOptim.var"#107#123"{Vector{Float64}, GalacticOptim.var"#102#118"{OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}}, Int64}, GalacticOptim.var"#102#118"{OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}}}, GalacticOptim.var"#111#127", Nothing, Nothing, Nothing}, Vector{Float64}, Vector{Float64}})
Closest candidates are:
  add_nonlinear_evaluator!(::Optimizer) at /home/jonas/.julia/packages/EAGO/5sz05/src/eago_optimizer/parse.jl:291
  add_nonlinear_evaluator!(::Optimizer, ::Nothing) at /home/jonas/.julia/packages/EAGO/5sz05/src/eago_optimizer/parse.jl:297
  add_nonlinear_evaluator!(::Optimizer, ::EAGO.EmptyNLPEvaluator) at /home/jonas/.julia/packages/EAGO/5sz05/src/eago_optimizer/parse.jl:298
  ...
Stacktrace:
 [1] add_nonlinear_evaluator!(m::Optimizer)
   @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/parse.jl:293
 [2] initial_parse!(m::Optimizer)
   @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/parse.jl:405
 [3] optimize!(m::Optimizer)
   @ EAGO ~/.julia/packages/EAGO/5sz05/src/eago_optimizer/optimize/optimize.jl:28
 [4] __solve(prob::OptimizationProblem{true, OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, opt::Optimizer; maxiters::Nothing, maxtime::Nothing, abstol::Nothing, reltol::Nothing, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GalacticOptim ~/.julia/dev/GalacticOptim/src/solve/moi.jl:168
 [5] __solve
   @ ~/.julia/dev/GalacticOptim/src/solve/moi.jl:135 [inlined]
 [6] #solve#476
   @ ~/.julia/packages/SciMLBase/n3U0M/src/solve.jl:3 [inlined]
 [7] solve(::OptimizationProblem{true, OptimizationFunction{true, GalacticOptim.AutoForwardDiff{nothing}, typeof(rosenbrock), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::Optimizer)
   @ SciMLBase ~/.julia/packages/SciMLBase/n3U0M/src/solve.jl:3
 [8] top-level scope
   @ REPL[13]:1

This probably relates to following lines and associated functions but I don't fully understand the MOI syntax.

https://github.com/SciML/GalacticOptim.jl/blob/2b657d2a2e1ce80547c54b4cbb4f468d2ee56bad/src/solve/moi.jl#L159-L166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant