OptimalControl API

Index

Available methods

using OptimalControl
available_methods()
(:direct, :adnlp, :ipopt)

Documentation

OptimalControl.OptimalControlModule
source
OptimalControl.solveMethod
solve(
    ocp::OptimalControlModel,
    description::Symbol...;
    display,
    init,
    kwargs...
) -> Union{Nothing, OptimalControlSolution}

Solve the the optimal control problem ocp by the method given by the (optional) description.

The (optional) description

You can pass a partial description. If you give a partial description, then, if several complete descriptions contains the partial one, then, the method with the highest priority is chosen. The higher in the list, the higher is the priority.

Keyword arguments:

  • display: print or not information during the resolution
  • init: an initial condition for the solver
Warning

There is only one available method for the moment: a direct method which transforms the optimal control problem into a nonlinear programming problem (NLP) solved by Ipopt, thanks to the package ADNLPModels. The direct method comes from the CTDirect package.

Tip
  • To see the list of available methods, simply call available_methods().
  • You can pass any other option by a pair keyword=value according to the chosen method.

Examples

julia> sol = solve(ocp)
julia> sol = solve(ocp, :direct)
julia> sol = solve(ocp, :direct, :ipopt)
julia> sol = solve(ocp, :direct, :ipopt, display=false)
julia> sol = solve(ocp, :direct, :ipopt, display=false, init=sol)
julia> sol = solve(ocp, init=(state=[-0.5, 0.2],))
julia> sol = solve(ocp, init=(state=[-0.5, 0.2], control=0.5))
julia> sol = solve(ocp, init=(state=[-0.5, 0.2], control=0.5, variable=[1, 2]))
julia> sol = solve(ocp, init=(state=[-0.5, 0.2], control=t->6-12*t))
julia> sol = solve(ocp, init=(state=t->[-1+t, t*(t-1)], control=0.5))
julia> sol = solve(ocp, init=(state=t->[-1+t, t*(t-1)], control=t->6-12*t))
source