Skip to content

[Bug] Init #457

@jbcaillau

Description

@jbcaillau

@PierreMartinon test below with v0.15.2 and OC v1.0.3

julia> using OptimalControl

julia> using NLPModelsIpopt

julia> o = @def begin
               t  [0, 1], time
               x  R², state
               u  R, control
               x(0) == [0, 1]
               x(1) == [0, -1]
               (t) == [x₂(t), u(t)]
               0  x₁(t)  0.1
               -10  u(t)  10
               (u(t)^2)  min
           end
    t  [0, 1], time
    x  R², state
    u  R, control
    x(0) == [0, 1]
    x(1) == [0, -1]
    (t) == [x₂(t), u(t)]
    0  x₁(t)  0.1
    -10  u(t)  10
    (u(t) ^ 2)  min

The optimal control problem is of the form:

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

    subject to

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

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

    where x(t)  R² and u(t)  R.

Declarations (* required):

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


julia> s = solve(o; max_iter=0, init=(state=[1, 2], control=30));
This is Ipopt version 3.14.17, running with linear solver MUMPS 5.8.0.

Number of nonzeros in equality constraint Jacobian...:     3005
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:      251

Total number of variables............................:     1004
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      502
                     variables with only upper bounds:        0
Total number of equality constraints.................:      755
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  1.0000000e-01 3.00e+00 5.91e-12   0.0 0.00e+00    -  0.00e+00 0.00e+00   0

Number of Iterations....: 0

                                   (scaled)                 (unscaled)
Objective...............:   1.0000000000000001e-01    1.0000000000000001e-01
Dual infeasibility......:   5.9103832938944834e-12    5.9103832938944834e-12
Constraint violation....:   3.0000000000000000e+00    3.0000000000000000e+00
Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   1.9900000198999997e+01    1.9900000198999997e+01
Overall NLP error.......:   1.9900000198999997e+01    1.9900000198999997e+01


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

EXIT: Maximum Number of Iterations Exceeded.

julia> state(s)(0)
2-element Vector{Float64}:
 0.0990000098
 2.0

julia> control(s)(0)
9.900000099

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