Skip to content

Commit

Permalink
better grid for test
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreMartinon committed Jun 13, 2024
1 parent a45066e commit 2ab2b06
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/test_objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ constraint!(ocp4, :initial, [0,0], :initial_constraint)
constraint!(ocp4, :final, [1,0], :final_constraint)
constraint!(ocp4, :control, -1, 1, :control_constraint)
constraint!(ocp4, :variable, [0.1, 0.1], [10, 10], :variable_constraint)
constraint!(ocp4, :variable, v -> v[2]-v[1], 1.0, Inf )
constraint!(ocp4, :variable, v -> v[2]-v[1], 0.1, Inf )
dynamics!(ocp4, (x, u, v) -> [x[2], u])
objective!(ocp4, :mayer, (x0, xf, v) -> v[1], :max)
sol4 = solve(ocp4, grid_size=100, print_level=0, tol=1e-12)
println("Target 8.0, found ", sol4.objective)

# with non uniform grid
sol5 = solve(ocp4, time_grid=[0,0.1,0.6,0.95,1], print_level=5, tol=1e-12)
sol5 = solve(ocp4, time_grid=[0,0.1,0.3,0.5,0.6,0.8,0.95,1], print_level=5)
plot(sol5, show=true)
println("Target 8.0, found ", sol5.objective)

0 comments on commit 2ab2b06

Please sign in to comment.