44Lists all the imported modules and packages:
55
66$(IMPORTS)
7+
8+ List of all the exported names:
9+
10+ $(EXPORTS)
711"""
812module CTModels
913
@@ -16,33 +20,152 @@ using MLStyle
1620using Parameters # @with_kw: to have default values in struct
1721using MacroTools: striplines
1822using PrettyTables # To print a table
19- import RecipesBase: plot, plot!, RecipesBase
23+ using RecipesBase: plot, plot!, RecipesBase
2024
2125# aliases
26+
27+ """
28+ Type alias for a dimension. This is used to define the dimension of the state space,
29+ the costate space, the control space, etc.
30+
31+ ```@example
32+ julia> const Dimension = Integer
33+ ```
34+ """
2235const Dimension = Int
36+
37+ """
38+ Type alias for a real number.
39+
40+ ```@example
41+ julia> const ctNumber = Real
42+ ```
43+ """
2344const ctNumber = Real
45+
46+ """
47+ Type alias for a time.
48+
49+ ```@example
50+ julia> const Time = ctNumber
51+ ```
52+
53+ See also: [`ctNumber`](@ref), [`Times`](@ref), [`TimesDisc`](@ref).
54+ """
2455const Time = ctNumber
56+
57+ """
58+ Type alias for a vector of real numbers.
59+
60+ ```@example
61+ julia> const ctVector = AbstractVector{<:ctNumber}
62+ ```
63+
64+ See also: [`ctNumber`](@ref).
65+ """
2566const ctVector = AbstractVector{<: ctNumber }
67+
68+ """
69+ Type alias for a vector of times.
70+
71+ ```@example
72+ julia> const Times = AbstractVector{<:Time}
73+ ```
74+
75+ See also: [`Time`](@ref), [`TimesDisc`](@ref).
76+ """
77+ const Times = AbstractVector{<: Time }
78+
79+ """
80+ Type alias for a grid of times. This is used to define a discretization of time interval given to solvers.
81+
82+ ```@example
83+ julia> const TimesDisc = Union{Times, StepRangeLen}
84+ ```
85+
86+ See also: [`Time`](@ref), [`Times`](@ref).
87+ """
88+ const TimesDisc = Union{Times,StepRangeLen}
89+
90+ """
91+ Type alias for a dictionnary of constraints. This is used to store constraints before building the model.
92+
93+ ```@example
94+ julia> const TimesDisc = Union{Times, StepRangeLen}
95+ ```
96+
97+ See also: [`ConstraintsModel`](@ref), [`PreModel`](@ref) and [`Model`](@ref).
98+ """
2699const ConstraintsDictType = Dict{
27100 Symbol,Tuple{Symbol,Union{Function,OrdinalRange{<: Int }},ctVector,ctVector}
28101}
29- const Times = AbstractVector{<: Time }
30- const TimesDisc = Union{Times,StepRangeLen}
31102
32103#
33104include (" default.jl" )
34105
35106# export / import
107+ """
108+ $(TYPEDEF)
109+
110+ Abstract type for export/import functions, used to choose between JSON or JLD extensions.
111+ """
36112abstract type AbstractTag end
113+
114+ """
115+ $(TYPEDEF)
116+
117+ JLD tag for export/import functions.
118+ """
37119struct JLD2Tag <: AbstractTag end
120+
121+ """
122+ $(TYPEDEF)
123+
124+ JSON tag for export/import functions.
125+ """
38126struct JSON3Tag <: AbstractTag end
39127
40128# to be extended
129+ """
130+ $(TYPEDSIGNATURES)
131+
132+ Export a solution in JLD format.
133+ """
41134export_ocp_solution (:: JLD2Tag , args... ; kwargs... ) = throw (CTBase. ExtensionError (:JLD2 ))
135+
136+ """
137+ $(TYPEDSIGNATURES)
138+
139+ Import a solution from a JLD file.
140+ """
42141import_ocp_solution (:: JLD2Tag , args... ; kwargs... ) = throw (CTBase. ExtensionError (:JLD2 ))
142+
143+ """
144+ $(TYPEDSIGNATURES)
145+
146+ Export a solution in JSON format.
147+ """
43148export_ocp_solution (:: JSON3Tag , args... ; kwargs... ) = throw (CTBase. ExtensionError (:JSON3 ))
149+
150+ """
151+ $(TYPEDSIGNATURES)
152+
153+ Import a solution from a JLD file.
154+ """
44155import_ocp_solution (:: JSON3Tag , args... ; kwargs... ) = throw (CTBase. ExtensionError (:JSON3 ))
45156
157+ """
158+ $(TYPEDSIGNATURES)
159+
160+ Export a solution in JLD or JSON formats.
161+
162+ # Examples
163+
164+ ```julia-repl
165+ julia> CTModels.export_ocp_solution(sol; filename_prefix="solution", format=:JSON)
166+ julia> CTModels.export_ocp_solution(sol; filename_prefix="solution", format=:JLD)
167+ ```
168+ """
46169function export_ocp_solution (args... ; format= __format (), kwargs... )
47170 if format == :JLD
48171 return export_ocp_solution (JLD2Tag (), args... ; kwargs... )
@@ -57,6 +180,18 @@ function export_ocp_solution(args...; format=__format(), kwargs...)
57180 end
58181end
59182
183+ """
184+ $(TYPEDSIGNATURES)
185+
186+ Import a solution from a JLD or JSON file.
187+
188+ # Examples
189+
190+ ```julia-repl
191+ julia> sol = CTModels.import_ocp_solution(ocp; filename_prefix="solution", format=:JSON)
192+ julia> sol = CTModels.import_ocp_solution(ocp; filename_prefix="solution", format=:JLD)
193+ ```
194+ """
60195function import_ocp_solution (args... ; format= __format (), kwargs... )
61196 if format == :JLD
62197 return import_ocp_solution (JLD2Tag (), args... ; kwargs... )
@@ -76,9 +211,20 @@ include("utils.jl")
76211include (" types.jl" )
77212
78213# to be extended
214+ """
215+ $(TYPEDSIGNATURES)
216+
217+ Plot a solution.
218+ """
79219function RecipesBase. plot (sol:: AbstractSolution ; kwargs... )
80220 throw (CTBase. ExtensionError (:Plots ))
81221end
222+
223+ """
224+ $(TYPEDSIGNATURES)
225+
226+ Plot a solution on an existing plot.
227+ """
82228function RecipesBase. plot! (p:: RecipesBase.AbstractPlot , sol:: AbstractSolution ; kwargs... )
83229 throw (CTBase. ExtensionError (:Plots ))
84230end
0 commit comments