Private API
This page lists non-exported (internal) symbols of CTDirect.
From CTDirect
AbstractDiscretizer
CTDirect.AbstractDiscretizer — Type
abstract type AbstractDiscretizer <: CTSolvers.Strategies.AbstractStrategyAbstract type for optimal control problem discretization strategies.
This type defines the interface for converting continuous optimal control problems into discrete optimization problems suitable for numerical solvers. Subtypes must implement the callable interface to perform the actual discretization.
Interface Requirements
Subtypes must implement:
(discretizer::AbstractDiscretizer)(ocp::AbstractModel): Perform discretization
Example
julia> using CTDirect
julia> MyDiscretizer <: AbstractDiscretizer end
julia> # Implement the required interface
julia> (d::MyDiscretizer)(ocp) = discretize_collocation(ocp)See also: Collocation, discretize
Discretization
CTDirect.Discretization — Type
abstract type DiscretizationAbstract type representing a discretization strategy for an optimal control problem.
Concrete subtypes of Discretization define specific schemes for transforming a continuous-time problem into a discrete-time representation suitable for numerical solution.
Example
julia> struct MyDiscretization <: Discretization end
MyDiscretization__discretizer
CTDirect.__discretizer — Function
__discretizer() -> CTDirect.Collocation
Returns the default discretizer instance used by the convenience method.
This function provides the default collocation discretizer that is used when no specific discretizer is provided to the discretize function.
Returns
AbstractDiscretizer: The default collocation discretizer instance
Notes
- This function is internal and primarily used for providing default values
- The default is currently
Collocation()but may change in future versions
See also: discretize, Collocation
discretize
CTDirect.discretize — Function
discretize(
ocp::CTModels.OCP.AbstractModel,
discretizer::CTDirect.AbstractDiscretizer
) -> CTSolvers.DOCP.DiscretizedModel{TO, TAMB, TEMB, TASB, TESB} where {TO<:CTModels.OCP.AbstractModel, TAMB<:(CTSolvers.Optimization.ADNLPModelBuilder{T} where T<:(CTDirect.var"#build_adnlp_model#build_adnlp_model##0"{CTDirect.var"#build_adnlp_model#5#9"{docp}} where docp)), TEMB<:(CTSolvers.Optimization.ExaModelBuilder{T} where T<:(CTDirect.var"#build_exa_model#build_exa_model##0"{CTDirect.var"#build_exa_model#8#14"{CTDirect.Collocation, var"#s179", T}} where {var"#s179"<:CTModels.OCP.AbstractModel, T})), TASB<:(CTSolvers.Optimization.ADNLPSolutionBuilder{T} where T<:CTDirect.var"#build_adnlp_solution#build_adnlp_solution##0"), TESB<:(CTSolvers.Optimization.ExaSolutionBuilder{T} where T<:CTDirect.var"#build_exa_solution#build_exa_solution##0")}
Discretize an optimal control problem using the specified discretizer.
This function applies a discretization strategy to convert a continuous optimal control problem into a form suitable for numerical optimization.
Arguments
ocp::AbstractModel: The optimal control problem to discretizediscretizer::AbstractDiscretizer: The discretization strategy to apply
Returns
- The discretized problem (type depends on the specific discretizer)
Example
julia> using CTDirect
julia> ocp = create_ocp() # Create your OCP
julia> discretized = discretize(ocp, Collocation())See also: AbstractDiscretizer, Collocation
discretize(
ocp::CTModels.OCP.AbstractModel;
discretizer
) -> CTSolvers.DOCP.DiscretizedModel{TO, TAMB, TEMB, TASB, TESB} where {TO<:CTModels.OCP.AbstractModel, TAMB<:(CTSolvers.Optimization.ADNLPModelBuilder{T} where T<:(CTDirect.var"#build_adnlp_model#build_adnlp_model##0"{CTDirect.var"#build_adnlp_model#5#9"{docp}} where docp)), TEMB<:(CTSolvers.Optimization.ExaModelBuilder{T} where T<:(CTDirect.var"#build_exa_model#build_exa_model##0"{CTDirect.var"#build_exa_model#8#14"{CTDirect.Collocation, var"#s179", T}} where {var"#s179"<:CTModels.OCP.AbstractModel, T})), TASB<:(CTSolvers.Optimization.ADNLPSolutionBuilder{T} where T<:CTDirect.var"#build_adnlp_solution#build_adnlp_solution##0"), TESB<:(CTSolvers.Optimization.ExaSolutionBuilder{T} where T<:CTDirect.var"#build_exa_solution#build_exa_solution##0")}
Discretize an optimal control problem using the default discretizer.
This is a convenience method that uses the default collocation discretizer when no specific discretizer is provided.
Arguments
ocp::AbstractModel: The optimal control problem to discretizediscretizer::AbstractDiscretizer: The discretization strategy (default: Collocation())
Returns
- The discretized problem using the specified or default discretizer
Example
julia> using CTDirect
julia> ocp = create_ocp() # Create your OCP
julia> discretized = discretize(ocp) # Uses default Collocation
julia> discretized_custom = discretize(ocp, MyCustomDiscretizer())Notes
- The default discretizer is
Collocation() - For custom discretization, provide a specific discretizer instance
See also: AbstractDiscretizer, Collocation