Private API
This page lists non-exported (internal) symbols of CTModels.
From CTModels
@ensure
CTModels.@ensure — Macro
@ensure condition exceptionThrows the provided exception if condition is false.
Usage
julia> @ensure x > 0 CTBase.IncorrectArgument("x must be positive")Arguments
condition: A Boolean expression to test.exception: An instance of an exception to throw ifconditionis false.
Throws
- The provided
exceptionif the condition is not satisfied.
__constraint_label
CTModels.__constraint_label — Function
__constraint_label() -> Symbol
Used to set the default value of the label of a constraint. A unique value is given to each constraint using the gensym function and prefixing by :unnamed.
__constraints
CTModels.__constraints — Function
__constraints()
Used to set the default value for the constraints.
__control_components
CTModels.__control_components — Function
__control_components(
m::Int64,
name::String
) -> Vector{String}
Used to set the default value of the names of the controls. The default value is ["u"] for a one dimensional control, and ["u₁", "u₂", ...] for a multi dimensional control.
__control_name
CTModels.__control_name — Function
__control_name() -> String
Used to set the default value of the names of the control. The default value is "u".
__criterion_type
CTModels.__criterion_type — Function
__criterion_type() -> Symbol
Used to set the default value of the type of criterion. Either :min or :max. The default value is :min. The other possible criterion type is :max.
__filename_export_import
CTModels.__filename_export_import — Function
__filename_export_import() -> String
Return the default filename (without extension) for exporting and importing solutions.
The default value is "solution".
__format
CTModels.__format — Function
__format() -> Symbol
Used to set the default value of the format of the file to be used for export and import.
__matrix_dimension_storage
CTModels.__matrix_dimension_storage — Function
__matrix_dimension_storage() -> Int64
Used to set the default value of the storage of elements in a matrix. The default value is 1.
__state_components
CTModels.__state_components — Function
__state_components(n::Int64, name::String) -> Vector{String}
Used to set the default value of the names of the states. The default value is ["x"] for a one dimensional state, and ["x₁", "x₂", ...] for a multi dimensional state.
__state_name
CTModels.__state_name — Function
__state_name() -> String
Used to set the default value of the name of the state. The default value is "x".
__time_name
CTModels.__time_name — Function
__time_name() -> String
Used to set the default value of the name of the time. The default value is t.
__variable_components
CTModels.__variable_components — Function
__variable_components(
q::Int64,
name::String
) -> Vector{String}
Used to set the default value of the names of the variables. The default value is ["v"] for a one dimensional variable, and ["v₁", "v₂", ...] for a multi dimensional variable.
__variable_name
CTModels.__variable_name — Function
__variable_name(q::Int64) -> String
Used to set the default value of the names of the variables. The default value is "v".
ctinterpolate
CTModels.ctinterpolate — Function
ctinterpolate(x, f) -> Any
Return a linear interpolation function for the data f defined at points x.
This function creates a one-dimensional linear interpolant using the Interpolations.jl package, with linear extrapolation beyond the bounds of x.
Arguments
x: A vector of points at which the valuesfare defined.f: A vector of values to interpolate.
Returns
A callable interpolation object that can be evaluated at new points.
Example
julia> x = 0:0.5:2
julia> f = [0.0, 1.0, 0.0, -1.0, 0.0]
julia> interp = ctinterpolate(x, f)
julia> interp(1.2)matrix2vec
CTModels.matrix2vec — Function
matrix2vec(A::Matrix{<:Real}) -> Vector{<:Vector{<:Real}}
matrix2vec(
A::Matrix{<:Real},
dim::Int64
) -> Vector{<:Vector{<:Real}}
Transform a matrix into a vector of vectors along the specified dimension.
Each row or column of the matrix A is extracted and stored as an individual vector, depending on dim.
Arguments
A: A matrix of elements of type<:ctNumber.dim: The dimension along which to split the matrix (1for rows,2for columns). Defaults to1.
Returns
A Vector of Vectors extracted from the rows or columns of A.
Note
This is useful when data needs to be represented as a sequence of state or control vectors in optimal control problems.
Example
julia> A = [1 2 3; 4 5 6]
julia> matrix2vec(A, 1) # splits into rows: [[1, 2, 3], [4, 5, 6]]
julia> matrix2vec(A, 2) # splits into columns: [[1, 4], [2, 5], [3, 6]]to_out_of_place
CTModels.to_out_of_place — Function
to_out_of_place(
f!,
n;
T
) -> Union{Nothing, CTModels.var"#f#8"{CTModels.var"#f#7#9"{Type{Float64}, _A, _B}} where {_A, _B}}
Convert an in-place function f! to an out-of-place function f.
The resulting function f returns a vector of type T and length n by first allocating memory and then calling f! to fill it.
Arguments
f!: An in-place function of the formf!(result, args...).n: The length of the output vector.T: The element type of the output vector (default isFloat64).
Returns
An out-of-place function f(args...; kwargs...) that returns the result as a vector or scalar, depending on n.
Example
julia> f!(r, x) = (r[1] = sin(x); r[2] = cos(x))
julia> f = to_out_of_place(f!, 2)
julia> f(π/4) # returns approximately [0.707, 0.707]