Relationship between OptimalControl.jl and ControlSystems.jl

At JuliaCon 2024 I learned about the package OptimalControl.jl and related.

To install them, you need to add a custom registry:

pkg> registry add https://github.com/control-toolbox/ct-registry.git
pkg> add OptimalControl

What is the relationship to ControlSystems.jl ?

Do they solve different problems, or is there an overlap?

For example, both can be used to solve an LQR problem:

What are the advantages and disadvantages of these two packages?

1 Like

One is a tool for classical linear feedback control, whereas the other is a tool for numerical trajectory optimization. There is very little overlap and no relation.

1 Like

So LQR has a very different meaning in the context of linear feedback control and in the context of trajectory optimization?

No, but lqr in Controlsystems.jl solvers a very particular version of an lqr problem, in trajectory optimization you can specify the flavor of your cost and time horizon etc, but get a trajectory as result rather than a feedback gain.

3 Likes

Indeed, the LQ in LQR suggests that a Linear dynamical system, and Quadratic cost function are considered (the R stands for regulation). In this regard, the label just specifies the class of a problem, not the way to solve it.

One way we can solve the LQR problem is to formulate and solve a related optimization problem (a quadratic program) in which the control trajectory is the outcome. This gives an open-loop control, which is not particularly useful in practice. There are, however, techniques how to introduce feedback into such scheme, for example the receding horizon control (aka model predictive control). Advantage of this approach is that constraints on the control and state variables can be easily added (true, strictly speaking in presence of constraints the system is no longer linear, but we like to call it linear anyway – constrained linear system).

In the special case when there are no constraints, there is an alternative – and a very elegant and efficient – way to solve the problem. An associated Riccati equation (differential one in the finite final time case, algebraic one in the infinite final time case) can be formulated and solved, which then gives the coefficients for a proportional state feedback controller. An extremely powerful and useful result. It can be that some in the control systems community automatically associate the LQR problem with the Riccati equation based way of solving it.

2 Likes

Dear @ufechner7, dear all, seizing the opportunity of OptimalControl.jl latest release to provide some more details:

As pointed by @baggepinnen the package is indeed devoted to trajectory (= solution to ODEs) optimisation, either by direct methods (transcription into nonlinear programs) or indirect methods (multiple shooting on Hamiltonian flows). There are already very nice tools, in particular for direct solving, in other languages (such as Casadi, GPOPS…) or in Julia (InfiniteOpt.jl…) We try to propose a user friendly unified approach for both direct and indirect approaches, including the differential geometric tools needed to do so (check, e.g., Goddard tuto). We build upon cutting edge modeller-solver pairs such as ADNLPModels.jl / ExaModels.jl with Ipopt / MadNLP.jl (the latter now allowing to solve control problems on GPU) for the direct part, on OrdinaryDiffEq.jl and AD tools (ForwardDiff.jl + DI) for the indirect one (+ ongoing discussions with @rveltz to leverage BifurcationKit.jl for continuation). The DSL leverages the very nice package MLStyle.jl by @thautwarm.

Optimal control of ODEs is all about dynamical systems, optimisation… and use cases: there are several tutorials and applications in the package documentation, and we welcome issues and PRs :slightly_smiling_face:. More to come, with ongoing benchmarks on OptimalControlProblems.jl.

2 Likes