RoboticExplorationLab / TrajectoryOptimization.jl

A fast trajectory optimization library written in Julia
https://roboticexplorationlab.org
MIT License
330 stars 63 forks source link

Can't use AmplNLWriter as Jump backend #33

Open freemin7 opened 4 years ago

freemin7 commented 4 years ago

I am following this tutorial: Cartpole.ipybn but instead of using Ipopt i am trying to use a solver only accessible via AmplNLWriter. Instead of Block [17] i have

using AmplNLWriter
using MathOptInterface

const MOI = MathOptInterface

optimizer = AmplNLWriter.Optimizer("octeract-engine")

TrajectoryOptimization.build_MOI!(nlp, optimizer)
MOI.optimize!(optimizer)
MOI.get(optimizer, MOI.TerminationStatus())

I get the following stack trace:

MethodError: no method matching constraint_expr(::TrajOptNLP{4,1,Float64}, ::Int64)
Closest candidates are:
constraint_expr(!Matched::MathOptInterface.Test.FeasibilitySenseEvaluator, ::Int64) at /home/joto/.julia/packages/MathOptInterface/bygN7/src/Test/nlp.jl:204
  constraint_expr(!Matched::MathOptInterface.Test.HS071, ::Int64) at /home/joto/.julia/packages/MathOptInterface/bygN7/src/Test/nlp.jl:37
constr_expr(::AmplNLWriter.NLPEvaluator{TrajOptNLP{4,1,Float64}}, ::Int64) at MOI_wrapper.jl:163
(::AmplNLWriter.var"#85#86"{AmplNLWriter.AmplNLMathProgModel})(::Int64) at AmplNLWriter.jl:211
iterate at generator.jl:47 [inlined]
_collect(::UnitRange{Int64}, ::Base.Generator{UnitRange{Int64},AmplNLWriter.var"#85#86"{AmplNLWriter.AmplNLMathProgModel}}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at array.jl:678
collect_similar at array.jl:607 [inlined]
map at abstractarray.jl:2072 [inlined]
loadproblem!(::AmplNLWriter.AmplNLNonlinearModel, ::Int64, ::Int64, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Symbol, ::AmplNLWriter.NLPEvaluator{TrajOptNLP{4,1,Float64}}) at AmplNLWriter.jl:210
optimize!(::AmplNLWriter.Model{Float64}) at MOI_wrapper.jl:371
top-level scope at Cartpole.jl:62

The same problem persist if i try another solver: and replace octeract-engine with any other string. I open a twin issue at AmplNLWriter too. Until it is clear which package can fix this. https://github.com/jump-dev/AmplNLWriter.jl/issues/107

odow commented 4 years ago

This issue can be closed.

AMPLNLWriter needs to check if ExprGraph is in features_available, which it is not: https://github.com/RoboticExplorationLab/TrajectoryOptimization.jl/blob/20f726ebf168107305b36c7c551029e031ba24d3/src/nlp.jl#L777

@freemin7: you cannot use AMPLNLWriter with this problem, regardless of the solver. AMPLNLWriter requires the explicit expression graph to create an NL file. Use Ipopt or Knitro.