Skip to content

[Bug] Sol getters for exa + ipopt #475

@jbcaillau

Description

@jbcaillau

@jbcaillau

julia> o = @def begin
           t  [0, 1], time
           x = (q, v)  R², state
           u  R, control
           x(0) == [1, -2]
           x(1) == [0, 0]
           (q)(t) == v(t)
           (v)(t) == u(t)
           0.5( u(t)^2 )  min
       end
Abstract defintion:

    t  [0, 1], time
    x = ((q, v)  R², state)
    u  R, control
    x(0) == [1, -2]
    x(1) == [0, 0]
    ((q))(t) == v(t)
    ((v))(t) == u(t)
    0.5 * (u(t) ^ 2)  min

The (autonomous) optimal control problem is of the form:

    minimize  J(x, u) =f⁰(x(t), u(t)) dt, over [0, 1]

    subject to

        (t) = f(x(t), u(t)), t in [0, 1] a.e.,

        ϕ₋  ϕ(x(0), x(1))  ϕ₊, 

    where x(t) = (q(t), v(t))  R² and u(t)  R.

Declarations (* required):

╭──────────┬────────┬────────┬──────────┬─────────────┬───────────┬────────────╮
│ variable │ times* │ state* │ control* │ constraints │ dynamics* │ objective* │
├──────────┼────────┼────────┼──────────┼─────────────┼───────────┼────────────┤
│    X     │   V    │   V    │    V     │      V      │     V     │     V      │
╰──────────┴────────┴────────┴──────────┴─────────────┴───────────┴────────────╯


julia> s = solve(o, :exa)
▫ This is OptimalControl version v1.1.1 running with: direct, exa, ipopt.

▫ The optimal control problem is solved with CTDirect version v0.16.2.

   ┌─ The NLP is modelled with ExaModels and solved with NLPModelsIpopt.
   │
   ├─ Number of time steps: 250
   └─ Discretisation scheme: trapeze

▫ This is Ipopt version 3.14.17, running with linear solver MUMPS 5.8.0.

Number of nonzeros in equality constraint Jacobian...:     2004
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:     1751

Total number of variables............................:      753
                     variables with only lower bounds:        0
                variables with lower and upper bounds:        0
                     variables with only upper bounds:        0
Total number of equality constraints.................:      504
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  5.0000000e-03 2.10e+00 4.31e-14   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  2.0000000e+00 2.15e-16 4.44e-16 -11.0 2.10e+00    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 1

                                   (scaled)                 (unscaled)
Objective...............:   2.0000000000000013e+00    2.0000000000000013e+00
Dual infeasibility......:   4.4408920985006262e-16    4.4408920985006262e-16
Constraint violation....:   2.1510571102112408e-16    2.1510571102112408e-16
Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   0.0000000000000000e+00    0.0000000000000000e+00
Overall NLP error.......:   4.4408920985006262e-16    4.4408920985006262e-16


Number of objective function evaluations             = 2
Number of objective gradient evaluations             = 2
Number of equality constraint evaluations            = 2
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 2
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 1
Total seconds in IPOPT                               = 0.004

EXIT: Optimal Solution Found.
ERROR: BoundsError: attempt to access 0-element Vector{Float64} at index [1:502]
Stacktrace:
  [1] throw_boundserror(A::Vector{Float64}, I::Tuple{UnitRange{Int64}})
    @ Base ./essentials.jl:14
  [2] checkbounds
    @ ./abstractarray.jl:699 [inlined]
  [3] view
    @ ./subarray.jl:214 [inlined]
  [4] multipliers_L(result::SolverCore.GenericExecutionStats{Float64, Vector{…}, Vector{…}, Any}, x::ExaModels.Variable{Tuple{…}, Int64})
    @ ExaModels ~/.julia/packages/ExaModels/HeWwY/src/nlp.jl:907
  [5] (::var"#507#531"{var"#507#508#532"{}})(sol::SolverCore.GenericExecutionStats{Float64, Vector{…}, Vector{…}, Any}; val::Symbol)
    @ Main ~/.julia/packages/CTParser/kc1TO/src/onepass.jl:1133
  [6] parse_DOCP_solution_primal(docp::CTDirect.DOCP{…}, solution::Vector{…}; mult_LB::Vector{…}, mult_UB::Vector{…}, nlp_model::CTDirect.ExaBackend, docp_solution::SolverCore.GenericExecutionStats{…})
    @ CTDirect ~/.julia/packages/CTDirect/9mdGM/src/solution.jl:208
  [7] parse_DOCP_solution_primal
    @ ~/.julia/packages/CTDirect/9mdGM/src/solution.jl:180 [inlined]
  [8] build_OCP_solution(docp::CTDirect.DOCP{…}, docp_solution::SolverCore.GenericExecutionStats{…}; nlp_model::CTDirect.ExaBackend)
    @ CTDirect ~/.julia/packages/CTDirect/9mdGM/src/solution.jl:26
  [9] solve(ocp::Model{…}, description::Symbol; display::Bool, grid_size::Int64, disc_method::Symbol, time_grid::Nothing, init::Nothing, adnlp_backend::Symbol, exa_backend::Nothing, lagrange_to_mayer::Bool, kwargs::@Kwargs{})
    @ CTDirect ~/.julia/packages/CTDirect/9mdGM/src/solve.jl:180
 [10] solve(ocp::Model{…}, description::Symbol; display::Bool, kwargs::@Kwargs{})
    @ OptimalControl ~/.julia/packages/OptimalControl/t2lBD/src/solve.jl:135
 [11] solve(ocp::Model{…}, description::Symbol)
    @ OptimalControl ~/.julia/packages/OptimalControl/t2lBD/src/solve.jl:117
 [12] top-level scope
    @ REPL[38]:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions