Private API
This page lists non-exported (internal) symbols of CTModels.
From CTModels
AbstractOptimalControlProblem
CTModels.AbstractOptimalControlProblem — Type
Type alias for AbstractModel.
Provides compatibility with CTSolvers naming conventions.
AbstractOptimalControlSolution
CTModels.AbstractOptimalControlSolution — Type
Type alias for AbstractSolution.
Provides compatibility with CTSolvers naming conventions.
AbstractTag
CTModels.AbstractTag — Type
abstract type AbstractTagAbstract type for export/import functions, used to choose between JSON or JLD extensions.
ConstraintsDictType
CTModels.ConstraintsDictType — Type
Type alias for a dictionary of constraints. This is used to store constraints before building the model.
julia> const TimesDisc = Union{Times, StepRangeLen}See also: ConstraintsModel, PreModel and Model.
Dimension
CTModels.Dimension — Type
Type alias for a dimension. This is used to define the dimension of the state space, the costate space, the control space, etc.
julia> const Dimension = IntegerJLD2Tag
CTModels.JLD2Tag — Type
struct JLD2Tag <: CTModels.AbstractTagJLD tag for export/import functions.
JSON3Tag
CTModels.JSON3Tag — Type
struct JSON3Tag <: CTModels.AbstractTagJSON tag for export/import functions.
Time
CTModels.Time — Type
Times
CTModels.Times — Type
TimesDisc
CTModels.TimesDisc — Type
ctNumber
CTModels.ctNumber — Type
Type alias for a real number.
julia> const ctNumber = RealctVector
CTModels.ctVector — Type
Type alias for a vector of real numbers.
julia> const ctVector = AbstractVector{<:ctNumber}See also: ctNumber.
export_ocp_solution
CTModels.export_ocp_solution — Function
export_ocp_solution(sol; format=:JLD, filename="solution")Export an optimal control solution to a file.
Arguments
sol::AbstractSolution: The solution to export.
Keyword Arguments
format::Symbol=:JLD: Export format, either:JLDor:JSON.filename::String="solution": Base filename (extension added automatically).
Notes
Requires loading the appropriate package (JLD2 or JSON3) before use.
See also: import_ocp_solution
export_ocp_solution(
::CTModels.JSON3Tag,
sol::CTModels.Solution;
filename
)
Export an optimal control solution to a .json file using the JSON3 format.
This function serializes a CTModels.Solution into a structured JSON dictionary, including all primal and dual information, which can be read by external tools.
Arguments
::CTModels.JSON3Tag: A tag used to dispatch the export method for JSON3.sol::CTModels.Solution: The solution to be saved.
Keyword Arguments
filename::String = "solution": Base filename. The.jsonextension is automatically appended.
Notes
The exported JSON includes the time grid, state, control, costate, objective, solver info, and all constraint duals (if available).
Example
julia> using JSON3
julia> export_ocp_solution(JSON3Tag(), sol; filename="mysolution")
# → creates "mysolution.json"export_ocp_solution(
::CTModels.JLD2Tag,
sol::CTModels.Solution;
filename
)
Export an optimal control solution to a .jld2 file using the JLD2 format.
This function serializes and saves a CTModels.Solution object to disk, allowing it to be reloaded later.
Arguments
::CTModels.JLD2Tag: A tag used to dispatch the export method for JLD2.sol::CTModels.Solution: The optimal control solution to be saved.
Keyword Arguments
filename::String = "solution": Base name of the file. The.jld2extension is automatically appended.
Example
julia> using JLD2
julia> export_ocp_solution(JLD2Tag(), sol; filename="mysolution")
# → creates "mysolution.jld2"import_ocp_solution
CTModels.import_ocp_solution — Function
import_ocp_solution(ocp; format=:JLD, filename="solution")Import an optimal control solution from a file.
Arguments
ocp::AbstractModel: The model associated with the solution.
Keyword Arguments
format::Symbol=:JLD: Import format, either:JLDor:JSON.filename::String="solution": Base filename (extension added automatically).
Returns
Solution: The imported solution.
Notes
Requires loading the appropriate package (JLD2 or JSON3) before use.
See also: export_ocp_solution
import_ocp_solution(
::CTModels.JSON3Tag,
ocp::CTModels.Model;
filename
)
Import an optimal control solution from a .json file exported with export_ocp_solution.
This function reads the JSON contents and reconstructs a CTModels.Solution object, including the discretized primal and dual trajectories.
Arguments
::CTModels.JSON3Tag: A tag used to dispatch the import method for JSON3.ocp::CTModels.Model: The model associated with the optimal control problem. Used to rebuild the full solution.
Keyword Arguments
filename::String = "solution": Base filename. The.jsonextension is automatically appended.
Returns
CTModels.Solution: A reconstructed solution instance.
Notes
Handles both vector and matrix encodings of signals. If dual fields are missing or null, the corresponding attributes are set to nothing.
Example
julia> using JSON3
julia> sol = import_ocp_solution(JSON3Tag(), model; filename="mysolution")import_ocp_solution(
::CTModels.JLD2Tag,
ocp::CTModels.Model;
filename
)
Import an optimal control solution from a .jld2 file.
This function loads a previously saved CTModels.Solution from disk.
Arguments
::CTModels.JLD2Tag: A tag used to dispatch the import method for JLD2.ocp::CTModels.Model: The associated model (used for dispatch consistency; not used internally).
Keyword Arguments
filename::String = "solution": Base name of the file. The.jld2extension is automatically appended.
Returns
CTModels.Solution: The loaded solution object.
Example
julia> using JLD2
julia> sol = import_ocp_solution(JLD2Tag(), model; filename="mysolution")