Solution
CTModels.Components.state Function
Return the state model (on a CTModels.Models.Model) or the state trajectory function (on a CTModels.Solutions.Solution).
See also: CTModels.Models.state_dimension, CTModels.Models.state_components.
CTModels.Components.control Function
Return the control model (on a CTModels.Models.Model) or the control trajectory function (on a CTModels.Solutions.Solution).
See also: CTModels.Models.control_dimension, CTModels.Models.control_components.
CTModels.Components.costate Function
Return the costate trajectory function from a CTModels.Solutions.Solution.
See also: CTModels.Components.state, CTModels.Solutions.dual.
CTModels.Components.variable Function
Return the variable model (on a CTModels.Models.Model) or the variable value (on a CTModels.Solutions.Solution).
See also: CTModels.Models.variable_dimension, CTModels.Models.variable_components.
CTModels.Components.time_grid Function
Return the time grid for a component from a CTModels.Solutions.Solution.
See also: CTModels.Solutions.build_solution.
CTModels.Components.objective Function
Return the objective model (on a CTModels.Models.Model) or the objective value (on a CTModels.Solutions.Solution).
CTModels.Solutions.status Function
status(sol::CTModels.Solutions.Solution) -> AnyReturn the status criterion (a Symbol).
status(r::AbstractIntegrationResult) -> AnyReturn the termination status of the integration result, as a Symbol.
This generic is owned by CTModels.Solutions; CTSolvers.Integrators contributes the methods for AbstractIntegrationResult subtypes so that a single status works uniformly on OCP solutions and on integration results.
Arguments
r::AbstractIntegrationResult: The integration result.
Throws
CTBase.Exceptions.NotImplemented: If not implemented by the concrete type.
See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.successful.
status(
sol::CTFlows.Trajectories.VectorFieldTrajectory
) -> AnyReturn the termination status of the solution by delegating to the integration result.
Arguments
sol::VectorFieldTrajectory: The vector field solution.
Returns
- The termination status (a
Symbol) from the integration result.
See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.status.
status(
sol::CTFlows.Trajectories.HamiltonianVectorFieldTrajectory
) -> AnyReturn the termination status of the solution by delegating to the integration result.
Arguments
sol::HamiltonianVectorFieldTrajectory: The Hamiltonian vector field solution.
Returns
- The termination status (a
Symbol) from the integration result.
See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.status.
status(sol::CTFlows.Trajectories.StateFlowTrajectory) -> AnyReturn the termination status of a StateFlowTrajectory, delegating to the underlying state trajectory.
status(
r::CTSolversSciMLIntegrator.SciMLIntegrationResult
) -> AnyReturn the termination status of the SciML ODE solution, as a Symbol derived from its retcode (e.g. :Success, :MaxIters).
CTModels.Solutions.message Function
message(sol::CTModels.Solutions.Solution) -> AnyReturn the message associated to the status criterion.
CTModels.Solutions.successful Function
successful(sol::CTModels.Solutions.Solution) -> BoolReturn the successful status.
successful(r::AbstractIntegrationResult) -> AnyReturn whether the integration terminated successfully.
This generic is owned by CTModels.Solutions; CTSolvers.Integrators contributes the methods for AbstractIntegrationResult subtypes so that a single successful works uniformly on OCP solutions and on integration results.
Arguments
r::AbstractIntegrationResult: The integration result.
Throws
CTBase.Exceptions.NotImplemented: If not implemented by the concrete type.
See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.status.
successful(
sol::CTFlows.Trajectories.VectorFieldTrajectory
) -> AnyReturn whether the solution terminated successfully by delegating to the integration result.
Arguments
sol::VectorFieldTrajectory: The vector field solution.
Returns
- Whether the integration succeeded.
See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.successful.
successful(
sol::CTFlows.Trajectories.HamiltonianVectorFieldTrajectory
) -> AnyReturn whether the solution terminated successfully by delegating to the integration result.
Arguments
sol::HamiltonianVectorFieldTrajectory: The Hamiltonian vector field solution.
Returns
- Whether the integration succeeded.
See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.successful.
successful(
sol::CTFlows.Trajectories.StateFlowTrajectory
) -> AnyReturn whether a StateFlowTrajectory terminated successfully, delegating to the underlying state trajectory.
successful(
r::CTSolversSciMLIntegrator.SciMLIntegrationResult
) -> AnyReturn whether the SciML ODE solution terminated successfully, per SciMLBase.successful_retcode.
CTModels.Solutions.iterations Function
iterations(sol::CTModels.Solutions.Solution) -> AnyReturn the number of iterations (if solved by an iterative method).
CTModels.Solutions.constraints_violation Function
constraints_violation(
sol::CTModels.Solutions.Solution
) -> AnyReturn the constraints violation.
CTModels.Solutions.infos Function
infos(sol::CTModels.Solutions.Solution) -> Dict{Symbol, Any}Return a dictionary of additional infos depending on the solver or nothing.
CTModels.Solutions.model Function
model(
sol::CTModels.Solutions.Solution{<:CTModels.Solutions.AbstractTimeGridModel, <:CTModels.Components.AbstractTimesModel, <:CTModels.Components.AbstractStateModel, <:CTModels.Components.AbstractControlModel, <:CTModels.Components.AbstractVariableModel, M<:CTModels.Models.AbstractModel}
) -> CTModels.Models.AbstractModelReturn the model of the optimal control problem.
CTModels.Solutions.is_empty Function
is_empty(
model::CTModels.Solutions.EmptyTimeGridModel
) -> BoolReturn true if the time grid model is empty.
Arguments
model::EmptyTimeGridModel: An empty time grid model
Returns
Bool: Alwaystruefor empty time grid models
Example
julia> etg = CTModels.EmptyTimeGridModel()
julia> CTModels.is_empty(etg)
trueis_empty(
model::CTModels.Solutions.AbstractTimeGridModel
) -> BoolReturn false for non-empty time grid models.
Arguments
model::AbstractTimeGridModel: Any non-empty time grid model
Returns
Bool: Alwaysfalsefor non-empty time grid models
Example
julia> T = LinRange(0, 1, 101)
julia> utg = CTModels.UnifiedTimeGridModel(T)
julia> CTModels.is_empty(utg)
falseCTModels.Solutions.is_empty_time_grid Function
is_empty_time_grid(sol::CTModels.Solutions.Solution) -> BoolCheck if the time grid is empty from the solution.
CTModels.Solutions.dual Function
dual(
sol::CTModels.Solutions.Solution,
model::CTModels.Models.Model,
label::Symbol
) -> AnyReturn the dual variable associated with a constraint identified by its label.
Searches through all constraint types (path, boundary, state, control, and variable constraints) defined in the model and returns the corresponding dual value from the solution.
Arguments
sol::Solution: Solution object containing dual variables.model::Model: Model containing constraint definitions.label::Symbol: Symbol corresponding to a constraint label.
Returns
A function of time t for time-dependent constraints, or a scalar/vector for time-invariant duals. If the label is not found, throws an IncorrectArgument exception.
Notes
For path/boundary constraints, duals are indexed per declaration (one column per row of the stacked nonlinear constraint vector).
For box constraints (state/control/variable), the dual matrices/vectors stored in the
Solutionare indexed by primal component (i.e.state_dimension(model)columns for state, etc.), following the CTDirect convention. For a label targeting component indicesrg, this function returnsduals_lb[:, rg] - duals_ub[:, rg](or the time-independent analogue for variables). Components never constrained carry a zero multiplier.If several labels target the same component,
dual(sol, model, :label)returns the (same) per-component multiplier for each: CTModels does not track which declaration "owns" the multiplier, because the solver only sees the effective (intersected) bound.
CTModels.Solutions.path_constraints_dual Function
path_constraints_dual(
model::CTModels.Solutions.DualModel{PC_Dual<:Union{Nothing, Function}}
) -> Union{Nothing, Function}Return the dual function associated with the nonlinear path constraints.
Arguments
model::DualModel: A model including dual variables for path constraints.
Returns
PC_Dual: A function mapping timetto the vector of dual values, ornothingif not set.
See also: CTModels.Solutions.boundary_constraints_dual, CTModels.Solutions.state_constraints_lb_dual.
path_constraints_dual(_::CTModels.Solutions.EmptyDualModel)Return nothing for an empty dual model: the path constraints dual is absent.
path_constraints_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, Function}Return the dual of the path constraints.
CTModels.Solutions.boundary_constraints_dual Function
boundary_constraints_dual(
model::CTModels.Solutions.DualModel{<:Union{Nothing, Function}, BC_Dual<:Union{Nothing, AbstractVector{<:Real}}}
) -> Union{Nothing, AbstractVector{<:Real}}Return the dual vector associated with the boundary constraints.
Arguments
model::DualModel: A model including dual variables for boundary constraints.
Returns
BC_Dual: A vector of dual values, ornothingif not set.
See also: CTModels.Solutions.path_constraints_dual, CTModels.Solutions.state_constraints_lb_dual.
boundary_constraints_dual(
_::CTModels.Solutions.EmptyDualModel
)Return nothing for an empty dual model: the boundary constraints dual is absent.
boundary_constraints_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, AbstractVector{<:Real}}Return the dual of the boundary constraints.
CTModels.Solutions.state_constraints_lb_dual Function
state_constraints_lb_dual(
model::CTModels.Solutions.DualModel{<:Union{Nothing, Function}, <:Union{Nothing, AbstractVector{<:Real}}, SC_LB_Dual<:Union{Nothing, Function}}
) -> Union{Nothing, Function}Return the dual function associated with the lower bounds of state constraints.
Arguments
model::DualModel: A model including dual variables for state lower bounds.
Returns
SC_LB_Dual: A function mapping timetto a vector of dual values, ornothingif not set.
See also: CTModels.Solutions.state_constraints_ub_dual, CTModels.Solutions.control_constraints_lb_dual.
state_constraints_lb_dual(
_::CTModels.Solutions.EmptyDualModel
)Return nothing for an empty dual model: the state lower-bound dual is absent.
state_constraints_lb_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, Function}Return the lower bound dual of the state constraints.
CTModels.Solutions.state_constraints_ub_dual Function
state_constraints_ub_dual(
model::CTModels.Solutions.DualModel{<:Union{Nothing, Function}, <:Union{Nothing, AbstractVector{<:Real}}, <:Union{Nothing, Function}, SC_UB_Dual<:Union{Nothing, Function}}
) -> Union{Nothing, Function}Return the dual function associated with the upper bounds of state constraints.
Arguments
model::DualModel: A model including dual variables for state upper bounds.
Returns
SC_UB_Dual: A function mapping timetto a vector of dual values, ornothingif not set.
See also: CTModels.Solutions.state_constraints_lb_dual, CTModels.Solutions.control_constraints_ub_dual.
state_constraints_ub_dual(
_::CTModels.Solutions.EmptyDualModel
)Return nothing for an empty dual model: the state upper-bound dual is absent.
state_constraints_ub_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, Function}Return the upper bound dual of the state constraints.
CTModels.Solutions.control_constraints_lb_dual Function
control_constraints_lb_dual(
model::CTModels.Solutions.DualModel{<:Union{Nothing, Function}, <:Union{Nothing, AbstractVector{<:Real}}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, CC_LB_Dual<:Union{Nothing, Function}}
) -> Union{Nothing, Function}Return the dual function associated with the lower bounds of control constraints.
Arguments
model::DualModel: A model including dual variables for control lower bounds.
Returns
CC_LB_Dual: A function mapping timetto a vector of dual values, ornothingif not set.
See also: CTModels.Solutions.control_constraints_ub_dual, CTModels.Solutions.state_constraints_lb_dual.
control_constraints_lb_dual(
_::CTModels.Solutions.EmptyDualModel
)Return nothing for an empty dual model: the control lower-bound dual is absent.
control_constraints_lb_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, Function}Return the lower bound dual of the control constraints.
CTModels.Solutions.control_constraints_ub_dual Function
control_constraints_ub_dual(
model::CTModels.Solutions.DualModel{<:Union{Nothing, Function}, <:Union{Nothing, AbstractVector{<:Real}}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, CC_UB_Dual<:Union{Nothing, Function}}
) -> Union{Nothing, Function}Return the dual function associated with the upper bounds of control constraints.
Arguments
model::DualModel: A model including dual variables for control upper bounds.
Returns
CC_UB_Dual: A function mapping timetto a vector of dual values, ornothingif not set.
See also: CTModels.Solutions.control_constraints_lb_dual, CTModels.Solutions.state_constraints_ub_dual.
control_constraints_ub_dual(
_::CTModels.Solutions.EmptyDualModel
)Return nothing for an empty dual model: the control upper-bound dual is absent.
control_constraints_ub_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, Function}Return the upper bound dual of the control constraints.
CTModels.Solutions.variable_constraints_lb_dual Function
variable_constraints_lb_dual(
model::CTModels.Solutions.DualModel{<:Union{Nothing, Function}, <:Union{Nothing, AbstractVector{<:Real}}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, VC_LB_Dual<:Union{Nothing, AbstractVector{<:Real}}}
) -> Union{Nothing, AbstractVector{<:Real}}Return the dual vector associated with the lower bounds of variable constraints.
Arguments
model::DualModel: A model including dual variables for variable lower bounds.
Returns
VC_LB_Dual: A vector of dual values, ornothingif not set.
See also: CTModels.Solutions.variable_constraints_ub_dual, CTModels.Solutions.state_constraints_lb_dual.
variable_constraints_lb_dual(
_::CTModels.Solutions.EmptyDualModel
)Return nothing for an empty dual model: the variable lower-bound dual is absent.
variable_constraints_lb_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, AbstractVector{<:Real}}Return the lower bound dual of the variable constraints.
CTModels.Solutions.variable_constraints_ub_dual Function
variable_constraints_ub_dual(
model::CTModels.Solutions.DualModel{<:Union{Nothing, Function}, <:Union{Nothing, AbstractVector{<:Real}}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, <:Union{Nothing, Function}, <:Union{Nothing, AbstractVector{<:Real}}, VC_UB_Dual<:Union{Nothing, AbstractVector{<:Real}}}
) -> Union{Nothing, AbstractVector{<:Real}}Return the dual vector associated with the upper bounds of variable constraints.
Arguments
model::DualModel: A model including dual variables for variable upper bounds.
Returns
VC_UB_Dual: A vector of dual values, ornothingif not set.
See also: CTModels.Solutions.variable_constraints_lb_dual, CTModels.Solutions.state_constraints_ub_dual.
variable_constraints_ub_dual(
_::CTModels.Solutions.EmptyDualModel
)Return nothing for an empty dual model: the variable upper-bound dual is absent.
variable_constraints_ub_dual(
sol::CTModels.Solutions.Solution
) -> Union{Nothing, AbstractVector{<:Real}}Return the upper bound dual of the variable constraints.
CTModels.Solutions.dim_dual_state_constraints_box Function
dim_dual_state_constraints_box(
sol::CTModels.Solutions.Solution
) -> Int64Return the dimension of the box constraints duals on state.
Arguments
sol::Solution: The optimal control solution.
Returns
Dimension: The state box constraints duals dimension.
See also: CTModels.Solutions.state_constraints_lb_dual, CTModels.Solutions.dim_dual_control_constraints_box.
CTModels.Solutions.dim_dual_control_constraints_box Function
dim_dual_control_constraints_box(
sol::CTModels.Solutions.Solution
) -> Int64Return the dimension of the box constraints duals on control.
Arguments
sol::Solution: The optimal control solution.
Returns
Dimension: The control box constraints duals dimension.
See also: CTModels.Solutions.control_constraints_lb_dual, CTModels.Solutions.dim_dual_state_constraints_box.
CTModels.Solutions.dim_dual_variable_constraints_box Function
dim_dual_variable_constraints_box(
sol::CTModels.Solutions.Solution
) -> Int64Return the dimension of the variable box constraints duals.
Arguments
sol::Solution: The optimal control solution.
Returns
Dimension: The variable box constraints duals dimension.
See also: CTModels.Solutions.variable_constraints_lb_dual, CTModels.Solutions.variable_constraints_ub_dual.