SkillAgentSearch skills...

OptimalControl.jl

Model and solve optimal control problems in Julia, both on CPU and GPU.

Install / Use

/learn @control-toolbox/OptimalControl.jl

README

OptimalControl.jl

<!-- For instructions on how to customize this README.template.md and use the centralized workflow, please see the user guide: https://github.com/orgs/control-toolbox/discussions/67 -->

The OptimalControl.jl package is part of the control-toolbox ecosystem.

| Category | Badge | |-----------------------|-----------| | Documentation | Stable Docs Dev Docs | | CI / Build | Build Status | | Test Coverage | Coverage | | Package Evaluation | PkgEval Dependencies | | Release / Version | Release | | Citation | DOI | | License | License | | Code Style / Quality | Code Style: Blue Aqua.jl | | Downloads | Monthly Total |

About control-toolbox

The control-toolbox ecosystem brings together <a href="https://julialang.org" style="display:inline-flex; align-items:center;"> <img src="https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia.ico" width="16em" style="margin-right:0.3em;"> Julia </a> packages for mathematical control and its applications.

  • The root package, OptimalControl.jl, provides tools to model and solve optimal control problems defined by ordinary differential equations. It supports both direct and indirect methods, and can run on CPU or GPU.
<p align="right"> <a href="http://control-toolbox.org/OptimalControl.jl"> <img src="https://img.shields.io/badge/Documentation-OptimalControl.jl-blue" alt="Documentation OptimalControl.jl"> </a> </p>
  • Complementing it, OptimalControlProblems.jl offers a curated collection of benchmark optimal control problems formulated with ODEs in Julia. Each problem is available both in the OptimalControl DSL and in JuMP, with discretised versions ready to be solved using the solver of your choice. This makes the package particularly useful for benchmarking and comparing different solution strategies.
<p align="right"> <a href="http://control-toolbox.org/OptimalControlProblems.jl"> <img src="https://img.shields.io/badge/Documentation-OptimalControlProblems.jl-blue" alt="Documentation OptimalControlProblems.jl"> </a> </p>

Installation

To install OptimalControl please <a href="https://docs.julialang.org/en/v1/manual/getting-started/">open Julia's interactive session (known as REPL)</a> and press <kbd>]</kbd> key in the REPL to use the package mode, then add the package:

julia> ]
pkg> add OptimalControl

[!TIP] If you are new to Julia, please follow this guidelines.

[!NOTE] The package requires Julia version 1.10 or later.

Basic usage

Let us model and solve a simple optimal control problem, then plot the solution:

using OptimalControl
using NLPModelsIpopt
using Plots

ocp = @def begin
    t ∈ [0, 1], time
    x ∈ R², state
    u ∈ R, control
    x(0) == [-1, 0]
    x(1) == [0, 0]
    ẋ(t) == [x₂(t), u(t)]
    0.5∫( u(t)^2 ) → min
end

sol = solve(ocp)

plot(sol)

For more details about this problem, please check the basic example presented in the documentation.

Citing us

If you use OptimalControl.jl in your work, please cite us:

Caillau, J.-B., Cots, O., Gergaud, J., Martinon, P., & Sed, S. OptimalControl.jl: a Julia package to model and solve optimal control problems with ODE's [Computer software]. https://doi.org/10.5281/zenodo.13336563

or in BibTeX format:

@software{OptimalControl_jl,
author = {Caillau, Jean-Baptiste and Cots, Olivier and Gergaud, Joseph and Martinon, Pierre and Sed, Sophia},
doi = {10.5281/zenodo.16753152},
license = {["MIT"]},
title = {{OptimalControl.jl: a Julia package to model and solve optimal control problems with ODE's}},
url = {https://control-toolbox.org/OptimalControl.jl}
}

Contributing

If you think you found a bug or if you have a feature request / suggestion, feel free to open an issue.
Before opening a pull request, please start an issue or a discussion on the topic.

Contributions are welcomed, check out how to contribute to a Github project. If it is your first contribution, you can also check this first contribution tutorial. You can find first good issues (if any 🙂) here. You may find other packages to contribute to at the control-toolbox organization.

If you want to ask a question, feel free to start a discussion here. This forum is for general discussion about this repository and the control-toolbox organization.

[!NOTE] If you want to add an application or a package to the control-toolbox ecosystem, please follow this set up tutorial.

Related Skills

View on GitHub
GitHub Stars126
CategoryDevelopment
Updated4d ago
Forks8

Languages

Julia

Security Score

100/100

Audited on Mar 24, 2026

No findings