JLD

Index

Warning

In the examples in the documentation below, the methods are not prefixed by the module name even if they are private.

julia> using CTModels
julia> x = 1
julia> private_fun(x) # throw an error

must be replaced by

julia> using CTModels
julia> x = 1
julia> CTModels.private_fun(x)

However, if the method is reexported by another package, then, there is no need of prefixing.

julia> module OptimalControl
           import CTModels: private_fun
           export private_fun
       end
julia> using OptimalControl
julia> x = 1
julia> private_fun(x)

Documentation

CTModels.export_ocp_solutionMethod
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 .jld2 extension is automatically appended.

Example

julia> using JLD2
julia> export_ocp_solution(JLD2Tag(), sol; filename="mysolution")
# → creates "mysolution.jld2"
CTModels.import_ocp_solutionMethod
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 .jld2 extension is automatically appended.

Returns

  • CTModels.Solution: The loaded solution object.

Example

julia> using JLD2
julia> sol = import_ocp_solution(JLD2Tag(), model; filename="mysolution")