Skip to content

[Bug] Plot issue #214

Description

@jbcaillau

@ocots not critical but strange: first run of the code below produces an error, re-plotting afterwards (plot(s) again) does not. any clue?

Image

using OptimalControl
using NLPModelsIpopt
using MadNLPMumps
using BenchmarkTools
using Plots

function ocp3(x0; tf=10)

    α₁ = 13/18
    α₂ = 11/18
    α₃ = 13/18

    β₁ = 5/4
    β₂ = 10/7
    β₃ = 5/3

    o = @def begin
        t  [0, tf], time
        x  R³, state
        u  R, control
        x(0) == x0
        (x₁)(t) == x₂(t)
        (x₂)(t) == x₃(t)
        (x₃)(t) == u(t) 
        ( u(t)^2 + α₁ * abs(x₁(t))^β₁ + α₂ * abs(x₂(t))^β₂ + α₃ * abs(x₃(t))^β₃ )  min
    end 

    return o

end

N = 250
tol = 1e-8
x0 = [10, 1, 1]
print("\nModelling:")
o = ocp3(x0)
@btime ocp3($x0);
print("\nSolving with Ipopt:")
s = solve(o, :exa; grid_size=N, tol=tol, print_level=0);
@btime solve($o, :exa; grid_size=$N, tol=$tol, print_level=0);
print("\nSolving with MadNLP:")
s = solve(o, :exa, :madnlp; grid_size=N, tol=tol, print_level=MadNLP.ERROR)
@btime solve($o, :exa, :madnlp; grid_size=$N, tol=$tol, print_level=MadNLP.ERROR);
plot(s)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions