Skip to content

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
julia
status(sol::CTModels.Solutions.Solution) -> Any

Return the status criterion (a Symbol).

julia
status(r::AbstractIntegrationResult) -> Any

Return 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

See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.successful.

julia
status(
    sol::CTFlows.Trajectories.VectorFieldTrajectory
) -> Any

Return 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.

julia
status(
    sol::CTFlows.Trajectories.HamiltonianVectorFieldTrajectory
) -> Any

Return 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.

julia
status(sol::CTFlows.Trajectories.StateFlowTrajectory) -> Any

Return the termination status of a StateFlowTrajectory, delegating to the underlying state trajectory.

julia
status(
    r::CTSolversSciMLIntegrator.SciMLIntegrationResult
) -> Any

Return the termination status of the SciML ODE solution, as a Symbol derived from its retcode (e.g. :Success, :MaxIters).

CTModels.Solutions.message Function
julia
message(sol::CTModels.Solutions.Solution) -> Any

Return the message associated to the status criterion.

CTModels.Solutions.successful Function
julia
successful(sol::CTModels.Solutions.Solution) -> Bool

Return the successful status.

julia
successful(r::AbstractIntegrationResult) -> Any

Return 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

See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.status.

julia
successful(
    sol::CTFlows.Trajectories.VectorFieldTrajectory
) -> Any

Return 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.

julia
successful(
    sol::CTFlows.Trajectories.HamiltonianVectorFieldTrajectory
) -> Any

Return 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.

julia
successful(
    sol::CTFlows.Trajectories.StateFlowTrajectory
) -> Any

Return whether a StateFlowTrajectory terminated successfully, delegating to the underlying state trajectory.

julia
successful(
    r::CTSolversSciMLIntegrator.SciMLIntegrationResult
) -> Any

Return whether the SciML ODE solution terminated successfully, per SciMLBase.successful_retcode.

CTModels.Solutions.iterations Function
julia
iterations(sol::CTModels.Solutions.Solution) -> Any

Return the number of iterations (if solved by an iterative method).

CTModels.Solutions.constraints_violation Function
julia
constraints_violation(
    sol::CTModels.Solutions.Solution
) -> Any

Return the constraints violation.

CTModels.Solutions.infos Function
julia
infos(sol::CTModels.Solutions.Solution) -> Dict{Symbol, Any}

Return a dictionary of additional infos depending on the solver or nothing.

CTModels.Solutions.model Function
julia
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.AbstractModel

Return the model of the optimal control problem.

CTModels.Solutions.is_empty Function
julia
is_empty(
    model::CTModels.Solutions.EmptyTimeGridModel
) -> Bool

Return true if the time grid model is empty.

Arguments

  • model::EmptyTimeGridModel: An empty time grid model

Returns

  • Bool: Always true for empty time grid models

Example

julia
julia> etg = CTModels.EmptyTimeGridModel()
julia> CTModels.is_empty(etg)
true
julia
is_empty(
    model::CTModels.Solutions.AbstractTimeGridModel
) -> Bool

Return false for non-empty time grid models.

Arguments

  • model::AbstractTimeGridModel: Any non-empty time grid model

Returns

  • Bool: Always false for non-empty time grid models

Example

julia
julia> T = LinRange(0, 1, 101)
julia> utg = CTModels.UnifiedTimeGridModel(T)
julia> CTModels.is_empty(utg)
false
CTModels.Solutions.is_empty_time_grid Function
julia
is_empty_time_grid(sol::CTModels.Solutions.Solution) -> Bool

Check if the time grid is empty from the solution.

CTModels.Solutions.dual Function
julia
dual(
    sol::CTModels.Solutions.Solution,
    model::CTModels.Models.Model,
    label::Symbol
) -> Any

Return 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 Solution are indexed by primal component (i.e. state_dimension(model) columns for state, etc.), following the CTDirect convention. For a label targeting component indices rg, this function returns duals_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
julia
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 time t to the vector of dual values, or nothing if not set.

See also: CTModels.Solutions.boundary_constraints_dual, CTModels.Solutions.state_constraints_lb_dual.

julia
path_constraints_dual(_::CTModels.Solutions.EmptyDualModel)

Return nothing for an empty dual model: the path constraints dual is absent.

julia
path_constraints_dual(
    sol::CTModels.Solutions.Solution
) -> Union{Nothing, Function}

Return the dual of the path constraints.

CTModels.Solutions.boundary_constraints_dual Function
julia
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, or nothing if not set.

See also: CTModels.Solutions.path_constraints_dual, CTModels.Solutions.state_constraints_lb_dual.

julia
boundary_constraints_dual(
    _::CTModels.Solutions.EmptyDualModel
)

Return nothing for an empty dual model: the boundary constraints dual is absent.

julia
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
julia
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 time t to a vector of dual values, or nothing if not set.

See also: CTModels.Solutions.state_constraints_ub_dual, CTModels.Solutions.control_constraints_lb_dual.

julia
state_constraints_lb_dual(
    _::CTModels.Solutions.EmptyDualModel
)

Return nothing for an empty dual model: the state lower-bound dual is absent.

julia
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
julia
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 time t to a vector of dual values, or nothing if not set.

See also: CTModels.Solutions.state_constraints_lb_dual, CTModels.Solutions.control_constraints_ub_dual.

julia
state_constraints_ub_dual(
    _::CTModels.Solutions.EmptyDualModel
)

Return nothing for an empty dual model: the state upper-bound dual is absent.

julia
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
julia
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 time t to a vector of dual values, or nothing if not set.

See also: CTModels.Solutions.control_constraints_ub_dual, CTModels.Solutions.state_constraints_lb_dual.

julia
control_constraints_lb_dual(
    _::CTModels.Solutions.EmptyDualModel
)

Return nothing for an empty dual model: the control lower-bound dual is absent.

julia
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
julia
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 time t to a vector of dual values, or nothing if not set.

See also: CTModels.Solutions.control_constraints_lb_dual, CTModels.Solutions.state_constraints_ub_dual.

julia
control_constraints_ub_dual(
    _::CTModels.Solutions.EmptyDualModel
)

Return nothing for an empty dual model: the control upper-bound dual is absent.

julia
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
julia
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, or nothing if not set.

See also: CTModels.Solutions.variable_constraints_ub_dual, CTModels.Solutions.state_constraints_lb_dual.

julia
variable_constraints_lb_dual(
    _::CTModels.Solutions.EmptyDualModel
)

Return nothing for an empty dual model: the variable lower-bound dual is absent.

julia
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
julia
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, or nothing if not set.

See also: CTModels.Solutions.variable_constraints_lb_dual, CTModels.Solutions.state_constraints_ub_dual.

julia
variable_constraints_ub_dual(
    _::CTModels.Solutions.EmptyDualModel
)

Return nothing for an empty dual model: the variable upper-bound dual is absent.

julia
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
julia
dim_dual_state_constraints_box(
    sol::CTModels.Solutions.Solution
) -> Int64

Return 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
julia
dim_dual_control_constraints_box(
    sol::CTModels.Solutions.Solution
) -> Int64

Return 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
julia
dim_dual_variable_constraints_box(
    sol::CTModels.Solutions.Solution
) -> Int64

Return 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.