Skip to content

comparaison test between JuMP and OptimalControl Models #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
734fdc7
comp
Nico77310 Jun 17, 2025
9643762
comparison
Nico77310 Jun 26, 2025
ac397be
comparisonv2
Nico77310 Jun 26, 2025
5ffa2ff
up
ocots Jun 26, 2025
545c11a
list_of_problems_final
Nico77310 Jun 27, 2025
6e90683
init
Nico77310 Jun 30, 2025
2caf579
available_problems
antoinepichon03 Jun 30, 2025
cf80b8c
objectives
Nico77310 Jun 30, 2025
96b960b
Merge branch '78-dev-comparison-tests' of https://github.com/control-…
Nico77310 Jun 30, 2025
6e8c5e3
all_tests
Nico77310 Jul 1, 2025
d9810de
small refactoring
ocots Jul 2, 2025
3429581
available_problems dans OptimalControlProbleme.jl et exporté
antoinepichon03 Jul 4, 2025
e11596f
Merge branch '78-dev-comparison-tests-olivier' into 78-dev-comparison…
Nico77310 Jul 4, 2025
5ba5fe7
fixed_init
Nico77310 Jul 9, 2025
81b585e
moonlander, shuttle, truck
PierreMartinon Jul 11, 2025
c42938e
fixed cart
PierreMartinon Jul 17, 2025
e46404f
update direct transcription call
PierreMartinon Jul 17, 2025
3b25090
objective test only
PierreMartinon Jul 17, 2025
7adad2d
vanderpol
PierreMartinon Jul 17, 2025
16a9874
ok except vehicle and truck
PierreMartinon Jul 18, 2025
3c025b8
truck ok
PierreMartinon Jul 18, 2025
7b34e25
test_jump ok
PierreMartinon Jul 18, 2025
6a1022b
test OC ok
PierreMartinon Jul 18, 2025
d886522
test quick ok except electric_vehicle
PierreMartinon Jul 18, 2025
7424828
relative_comparison
Nico77310 Jul 18, 2025
e8fc84b
todo: fix shuttle error (test_comparison:89, * with nh vector)
PierreMartinon Jul 18, 2025
648a430
sync problems from problems_update
PierreMartinon Jul 18, 2025
e5e84ef
remove obsolete option const_violation_tol; use objective(sol)
PierreMartinon Jul 18, 2025
416e92d
update available problems
Nico77310 Jul 29, 2025
e0bf084
english
Nico77310 Jul 29, 2025
dc3a646
removed_costate_comparison
Nico77310 Aug 1, 2025
ff9e463
fixed_costate_figures
Nico77310 Aug 1, 2025
442b8f8
up compat
ocots Aug 7, 2025
4034039
beam, bioreactor: nh=500, trapeze
ocots Aug 8, 2025
37345b1
cart_pendulum
ocots Aug 8, 2025
0a4e108
metadata update
ocots Aug 8, 2025
b95dcbc
chain
ocots Aug 8, 2025
1cc5d98
dielectrophoretic_particle
ocots Aug 8, 2025
0c791d4
dielectrophoretic_particle
ocots Aug 8, 2025
e4f9636
double_oscillator
ocots Aug 8, 2025
f191521
ducted_fan
ocots Aug 8, 2025
ff358b8
fix
ocots Aug 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ OptimalControlModels = "OptimalControl"

[compat]
CTBase = "0.16"
JuMP = "1.25"
OptimalControl = "1.0"
JuMP = "1.28"
OptimalControl = "1.1"
julia = "1.10"
8 changes: 4 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[compat]
Documenter = "1.10"
Ipopt = "1.9"
JuMP = "1.25"
Documenter = "1.14"
Ipopt = "1.10"
JuMP = "1.28"
Markdown = "1.11"
NLPModelsIpopt = "0.10"
OptimalControl = "1.0"
OptimalControl = "1.1"
TOML = "1.0"
285 changes: 259 additions & 26 deletions docs/src/list_of_problems.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,249 @@ OptimalControlProblems.metadata[:chain]

The table below summarizes the names and status of the each problem:

| Problem | With JuMP | With OptimalControl |
| --- | --- | --- |
| beam | ✅ | ✅ |
| bioreactor | ✅ | ✅ |
| cart_pendulum | ❌ | ✅ |
| chain | ✅ | ✅ |
| dielectrophoretic_particle | ✅ | ✅ |
| double_oscillator | ✅ | ✅ |
| ducted_fan | ✅ | ✅ |
| electrical_vehicle | ✅ | ✅ |
| glider | ✅ | ❌ |
| insurance | ✅ | ✅ |
| jackson | ✅ | ✅ |
| moonlander | ✅ | ✅ |
| quadrotor | 🟠 | ✅ |
| robbins | ✅ | ✅ |
| robot | ✅ | ✅ |
| rocket | ✅ | ✅ |
| space_shuttle | ✅ | 🟠 |
| steering | ✅ | ✅ |
| truck_trailer | 🟠 | 🟠 |
| vanderpol | ✅ | ✅ |
<table>
<tr>
<th rowspan="2">Problem</th>
<th colspan="2">Convergence</th>
<th colspan="2">Objective Value</th>
<th colspan="3">Comparison</th>
<th rowspan="2">Available Problems</th>
</tr>
<tr>
<th>JuMP</th>
<th>OptimalControl</th>
<th>JuMP</th>
<th>OptimalControl</th>
<th>Init</th>
<th>Objective</th>
<th>||.||<sub>L<sup>2</sup></sub></th>
</tr>
<tr>
<td>beam</td>
<td>✅</td>
<td>✅</td>
<td>9.1213</td>
<td>8.8986</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>bioreactor</td>
<td>✅</td>
<td>✅</td>
<td>19.053</td>
<td>19.077</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>cart_pendulum</td>
<td>✅</td>
<td>✅</td>
<td>1.7439</td>
<td>1.7444</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>chain</td>
<td>✅</td>
<td>✅</td>
<td>5.0698</td>
<td>5.0698</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>dielectrophoretic_particle</td>
<td>✅</td>
<td>✅</td>
<td>7.8113</td>
<td>7.8113</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>double_oscillator</td>
<td>✅</td>
<td>✅</td>
<td>0.0009</td>
<td>0.0009</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>ducted_fan</td>
<td>✅</td>
<td>✅</td>
<td>1831.8</td>
<td>1832.9</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>electric_vehicle</td>
<td>✅</td>
<td>✅</td>
<td>4.0246e5</td>
<td>1.2287e6</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>glider</td>
<td>✅</td>
<td>✅</td>
<td>1254.6</td>
<td>1254.6</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>insurance</td>
<td>✅</td>
<td>✅</td>
<td>2.0879</td>
<td>2.0578</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>jackson</td>
<td>✅</td>
<td>✅</td>
<td>0.1920</td>
<td>0.1920</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>moonlander</td>
<td>🟠</td>
<td>✅</td>
<td>1.4148</td>
<td>0.9621</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>quadrotor</td>
<td>✅</td>
<td>✅</td>
<td>1.4928</td>
<td>1.4925</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>robbins</td>
<td>✅</td>
<td>✅</td>
<td>20.628</td>
<td>20.204</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>robot</td>
<td>✅</td>
<td>✅</td>
<td>9.1427</td>
<td>9.1427</td>
<td>🟠</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
</tr>
<tr>
<td>rocket</td>
<td>✅</td>
<td>✅</td>
<td>1.0128</td>
<td>1.0128</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>space_shuttle</td>
<td>✅</td>
<td>✅</td>
<td>0.5959</td>
<td>0.5959</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
<td>✅</td>
</tr>
<tr>
<td>steering</td>
<td>✅</td>
<td>✅</td>
<td>0.5546</td>
<td>0.5546</td>
<td>🟠</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
</tr>
<tr>
<td>truck_trailer</td>
<td>✅</td>
<td>✅</td>
<td>59.211</td>
<td>59.259</td>
<td>🟠</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
<tr>
<td>vanderpol</td>
<td>✅</td>
<td>✅</td>
<td>1.0480</td>
<td>1.0480</td>
<td>✅</td>
<td>✅</td>
<td>🟠</td>
<td>🟠</td>
</tr>
</table>

**Legend**

The problems are solved with Ipopt and the parameters:

- Convergence
```julia
tol = 1e-8
constr_viol_tol = 1e-6
Expand All @@ -60,8 +276,25 @@ linear_solver = "mumps"
max_wall_time = 500
sb = "yes"
```
- Comparison
```julia
ε_rel = 1e-1
ε_abs = 1e-8
p = 2
```
The symbols in the table means:

- ✅ locally solved
- 🟠 locally infeasible or maximum of iterations
- ❌ error during execution
- Convergence
- ✅ locally solved
- 🟠 locally infeasible or maximum of iterations
- ❌ error during execution

- Comparison
- ✅ relative comparison is less than ```ε_rel```
- 🟠 relative comparison is greater or equal than ```ε_rel```
- ❌ error during execution

- Available Problems
- ✅ current problem has no issue
- 🟠 current problem has at least one issue
- ❌ error during execution
15 changes: 9 additions & 6 deletions ext/JuMPModels/beam.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
The Beam Problem:
The problem is formulated as a JuMP model and can be found [here](https://github.com/control-toolbox/bocop/tree/main/bocop)
"""
function OptimalControlProblems.beam(::JuMPBackend; nh::Int=100)
# Parameters
function OptimalControlProblems.beam(::JuMPBackend; nh::Int=500)

# parameters
tf = 1
step = tf / nh

# Model
# model
model = JuMP.Model()

# variables and initial guess
@variables(
model,
begin
Expand All @@ -19,7 +21,7 @@ function OptimalControlProblems.beam(::JuMPBackend; nh::Int=100)
end
)

# Boundary constraints
# boundary constraints
@constraints(
model,
begin
Expand All @@ -30,7 +32,7 @@ function OptimalControlProblems.beam(::JuMPBackend; nh::Int=100)
end
)

# Dynamics
# dynamics
@constraints(
model,
begin
Expand All @@ -39,7 +41,8 @@ function OptimalControlProblems.beam(::JuMPBackend; nh::Int=100)
end
)

@objective(model, Min, sum(u[t]^2 for t in 0:nh))
# objective
@objective(model, Min, 0.5 * step * sum(u[t]^2 + u[t-1]^2 for t in 1:nh))

return model
end
Loading
Loading