Solve

Index

Documentation

CTDirect.available_methodsMethod
available_methods() -> NTuple{6, Tuple{Symbol, Symbol}}

Return the list of available methods to solve the optimal control problem.

source
CTDirect.direct_transcriptionMethod
direct_transcription(
    ocp::CTModels.Model,
    description...;
    grid_size,
    disc_method,
    time_grid,
    init,
    lagrange_to_mayer,
    kwargs...
) -> CTDirect.DOCP{_A, CTModels.Model{TD, TimesModelType, StateModelType, ControlModelType, VariableModelType, DynamicsModelType, ObjectiveModelType, ConstraintsModelType, BuildExaModelType}} where {_A<:CTDirect.Discretization, TD<:CTModels.TimeDependence, TimesModelType<:CTModels.AbstractTimesModel, StateModelType<:CTModels.AbstractStateModel, ControlModelType<:CTModels.AbstractControlModel, VariableModelType<:CTModels.AbstractVariableModel, DynamicsModelType<:Function, ObjectiveModelType<:CTModels.AbstractObjectiveModel, ConstraintsModelType<:CTModels.AbstractConstraintsModel, BuildExaModelType<:Union{Nothing, Function}}

Discretize an optimal control problem into a nonlinear optimization problem.

Arguments

  • ocp: optimal control problem as defined in CTModels
  • [description]: set the NLP model ([:adnlp] or exa) and / or solver ([:ipopt], :madnlp or :knitro)

Keyword arguments (optional)

  • grid_size: number of time steps for the discretized problem ([250])
  • disc_method: discretization method ([:trapeze], :euler, :euler_implicit, :midpoint, gauss_legendre_2, gauss_legendre_3)
  • time_grid: explicit time grid (can be non uniform)
  • init: info for the starting guess (values as named tuple or existing solution)

Other kewwords arguments are passed down to the NLP modeler

source
CTDirect.display_methodMethod
display_method(
    ocp,
    description::Symbol...;
    grid_size,
    disc_method,
    time_grid,
    kwargs...
)

Display the details of the solving method (NLP modeller, solver, discretization...)

source
CTDirect.parse_descriptionMethod
parse_description(
    description
) -> Tuple{Union{CTDirect.IpoptBackend, CTDirect.KnitroBackend, CTDirect.MadNLPBackend}, Union{CTDirect.ADNLPBackend, CTDirect.ExaBackend}}

Parse problem description to retrieve NLP model and solver choice

  • NLP solver: ipopt, madnlp or knitro
  • NLP model: :adnlp or :exa
source
CTDirect.solveMethod
solve(
    ocp::CTModels.Model,
    description::Symbol...;
    display,
    grid_size,
    disc_method,
    time_grid,
    init,
    adnlp_backend,
    exa_backend,
    lagrange_to_mayer,
    kwargs...
) -> CTModels.Solution{TimeGridModelType, TimesModelType, StateModelType, ControlModelType, VariableModelType, CostateModelType, Float64, DualModelType, CTModels.SolverInfos{Dict{Symbol, Any}}, ModelType} where {TimeGridModelType<:CTModels.TimeGridModel, TimesModelType<:CTModels.TimesModel, StateModelType<:Union{CTModels.StateModelSolution{TS} where TS<:CTModels.var"#114#136", CTModels.StateModelSolution{TS} where TS<:CTModels.var"#115#137"}, ControlModelType<:Union{CTModels.ControlModelSolution{TS} where TS<:CTModels.var"#116#138", CTModels.ControlModelSolution{TS} where TS<:CTModels.var"#117#139"}, VariableModelType<:Union{CTModels.VariableModelSolution{Vector{Float64}}, CTModels.VariableModelSolution{Float64}}, CostateModelType<:Union{CTModels.var"#118#140", CTModels.var"#119#141"}, DualModelType<:(CTModels.DualModel{PC_Dual, Vector{Float64}, SC_LB_Dual, SC_UB_Dual, CC_LB_Dual, CC_UB_Dual, Vector{Float64}, Vector{Float64}} where {PC_Dual<:Union{CTModels.var"#121#143"{CTModels.var"#120#142"}, CTModels.var"#122#144"{CTModels.var"#120#142"}}, SC_LB_Dual<:Union{CTModels.var"#124#146"{CTModels.var"#123#145"}, CTModels.var"#125#147"{CTModels.var"#123#145"}}, SC_UB_Dual<:Union{CTModels.var"#127#149"{CTModels.var"#126#148"}, CTModels.var"#128#150"{CTModels.var"#126#148"}}, CC_LB_Dual<:Union{CTModels.var"#130#152"{CTModels.var"#129#151"}, CTModels.var"#131#153"{CTModels.var"#129#151"}}, CC_UB_Dual<:Union{CTModels.var"#133#155"{CTModels.var"#132#154"}, CTModels.var"#134#156"{CTModels.var"#132#154"}}}), ModelType<:CTModels.Model}

Solve an OCP with a direct method

Arguments

  • ocp: optimal control problem as defined in CTModels
  • [description]: set the NLP model ([:adnlp] or exa) and / or solver ([:ipopt], :madnlp or :knitro)

Keyword arguments (optional)

  • display: ([true], false) will disable output if set to false
  • grid_size: number of time steps for the discretized problem ([250])
  • disc_method: discretization method ([:trapeze], :midpoint, gauss_legendre_2)
  • time_grid: explicit time grid (can be non uniform)
  • init: info for the starting guess (values or existing solution)

Other keywords are passed down to the NLP modeler and solver.

Result: a continuous solution of the original OCP, with main features

  • objective(sol): value of the objective
  • state(sol), control(sol): functions for state and control variables (trajectory)
  • variable(sol): optimization variables if any (e.g. free final time)
  • successful(sol): boolean indicating successful convergence of the NLP solver
  • status(sol): symbol for the return code of the NLP solver
  • message(sol): string with specific info from the NLP solver, if any
  • constraints_violation(sol): primal feasibility at the solution
  • iterations(sol): number of iterations
source