Get a problem
julia
using OptimalControl, JuMP, OptimalControlProblemsChoose the problems
julia
problems(OptimalControlBackend())22-element Vector{Symbol}:
:balanced_field
:beam
:bioreactor
:brachistochrone
:bryson_denham
:cart_pendulum
:chain
:dielectrophoretic_particle
:double_oscillator
:ducted_fan
⋮
:jackson
:moonlander
:mountain_car
:robbins
:robot
:rocket
:space_shuttle
:steering
:vanderpolproblems(backend) lists the problems valid in that modeling, and problems(backend1, backend2) those valid in both. The keyword status (:valid, :draft or :all) selects by status. Every list is computed from the files of the package, so it is always up to date.
Build a problem
A problem is a function of the modeling backend. Each modeling returns the most abstract object it can represent, and takes at retrieval only what it needs to build it:
| Modeling | Returns | Keywords |
|---|---|---|
| OptimalControl, scalarized OptimalControl | a Problem: the continuous problem and its initial guess | parameters, init |
| JuMP | a JuMP.Model, already discretized | grid_size, scheme, ordering, parameters, init, and the arguments of JuMP.Model |
julia
pb = chain(OptimalControlBackend())Problem chain (OptimalControl modeling, valid)
state dimension: 3
control dimension: 1
variable dimension: 0julia
nlp = chain(JuMPBackend(); grid_size=50)
num_variables(nlp)204Change the parameters
The default parameters are in the metadata; parameters replaces some of them, the others keep their default value.
julia
parameters_data(:beam)(t0 = 0, tf = 1, x₁_l = 0, x₁_u = 0.1, x₁_t0 = 0, x₂_t0 = 1, x₁_tf = 0, x₂_tf = -1)julia
pb = beam(OptimalControlBackend(); parameters=(x₁_u=0.2,))
metadata(pb)[:parameters](t0 = 0, tf = 1, x₁_l = 0, x₁_u = 0.2, x₁_t0 = 0, x₂_t0 = 1, x₁_tf = 0, x₂_tf = -1)The problem page of each problem lists its parameters.
Read the metadata
| Function | Returns |
|---|---|
problem_metadata(:p) | every metadata field, without building the problem |
metadata(pb) | the metadata of a built Problem, with the parameters it was built with |
grid_size_data(:p, backend) | the default number of steps in the modeling of backend |
parameters_data(:p) | the default parameters |
OptimalControlProblems.initial_guess_data(:p) | the shared initial guess (see Initial guess) |
OptimalControlProblems.reference_objective(:p, backend; grid_size, scheme) | the reference objective of the discretized problem in the modeling of backend, or nothing |
OptimalControlProblems.reference_solution_data(:p) | the analytic solution of the continuous problem, when known |
OptimalControlProblems.features(:p) | dimensions, kind of cost, free times, constraints |
OptimalControlProblems.status(:p) | the status in each modeling |
julia
OptimalControlProblems.features(:chain)(state_dimension = 3, control_dimension = 1, variable_dimension = 0, cost = :mayer, initial_time = :fixed, final_time = :fixed, constraints = (state_box = 0, control_box = 0, variable_box = 0, path = 0, boundary = 5))