Skip to content

Optimal control interface - #374

Merged
29 commits merged into
masterfrom
qqy/optimal_control
Jan 23, 2026
Merged

Optimal control interface#374
29 commits merged into
masterfrom
qqy/optimal_control

Conversation

@ErikQQY

@ErikQQY ErikQQY commented Sep 15, 2025

Copy link
Copy Markdown
Member

Close: #336

The current implementation concatenates the inequality/equality(the upper part) and the loss function([loss_bc; loss_collocation] as the lower part) as the constraints in OptimizationProblem. The Jacobian is handled by concatenating the Jacobian of inequality constraints(the upper square matrix) and the Jacobian of the loss function ([jac_loss_bc; jac_loss_collocation] as the lower rectangular matrix), resulting in a (N*M + length(bc_resid_prototype) + length(f_prototype)*(N-1)) x (N*M) Jacobian. Then the Jacobian is, upper part: banded matrix; lower part: almost banded matrix.

There are some weird issues with formulating the state variables and control variables, which may prevent the solver from finding an optimal solution. I’ll see what’s going wrong here.

Some TODOs:

  • Better ucons and lcons handling. More friendly information on choosing ucons and lcons should be provided to users.
  • Better cost function definition. The cost function definition should allow for using the interpolations, e.g. cost(sol, p) = sol(pi)[2]-1.0. Maybe we can also allow integral expressions.

@ErikQQY
ErikQQY marked this pull request as draft September 15, 2025 16:14
@github-actions

github-actions Bot commented Sep 15, 2025

Copy link
Copy Markdown
Contributor

Benchmark Results

Click to check benchmark results
master 3f83b22... master / 3f83b22...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.278 ± 0.02 s 0.313 ± 0.022 s 0.889 ± 0.088
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 9.57 ± 1.7 ms 9.85 ± 1.5 ms 0.971 ± 0.23
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 2.44 ± 0.081 ms 2.52 ± 0.12 ms 0.97 ± 0.057
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 7.2 ± 1.8 ms 7.39 ± 1.9 ms 0.975 ± 0.35
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 1.32 ± 0.36 ms 1.34 ± 0.27 ms 0.982 ± 0.33
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 1.77 ± 0.98 ms 1.79 ± 0.98 ms 0.989 ± 0.77
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 2.94 ± 0.97 ms 3.02 ± 1 ms 0.973 ± 0.46
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.0699 ± 0.017 s 0.0727 ± 0.017 s 0.962 ± 0.33
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.0944 ± 0.017 s 0.0881 ± 0.029 s 1.07 ± 0.41
Simple Pendulum/IIP/Shooting(Tsit5()) 0.243 ± 0.075 ms 0.244 ± 0.069 ms 0.996 ± 0.42
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 0.457 ± 0.0084 s 0.514 ± 0.0069 s 0.888 ± 0.02
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 12.3 ± 7.1 ms 13.1 ± 8.6 ms 0.939 ± 0.82
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 2.83 ± 0.33 ms 2.94 ± 0.44 ms 0.964 ± 0.18
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 8.43 ± 1.2 ms 8.5 ± 1.4 ms 0.992 ± 0.21
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 1.52 ± 0.23 ms 1.52 ± 0.25 ms 0.999 ± 0.22
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 3.11 ± 3.4 ms 3.13 ± 3.2 ms 0.992 ± 1.5
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 5.3 ± 6 ms 5.47 ± 7.5 ms 0.968 ± 1.7
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.123 ± 0.023 s 0.134 ± 0.038 s 0.922 ± 0.31
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.154 ± 0.069 s 0.166 ± 0.093 s 0.926 ± 0.66
Simple Pendulum/OOP/Shooting(Tsit5()) 0.537 ± 0.5 ms 0.538 ± 0.32 ms 0.999 ± 1.1
time_to_load 4.6 ± 0.037 s 4.71 ± 0.034 s 0.976 ± 0.011
### Benchmark Plots A plot of the benchmark results has been uploaded as an artifact to the workflow run for this PR. Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

@ErikQQY
ErikQQY marked this pull request as ready for review November 17, 2025 06:45
@ChrisRackauckas ChrisRackauckas closed this pull request by merging all changes into master in 9547569 Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Onto Dynamic Optimization: Allow for solving via OptimizationProblem and allow inequality constraints

2 participants