Skip to content

Commit 060ac84

Browse files
authoredDec 12, 2024
Merge pull request #316 from control-toolbox/integer
Integer
2 parents 0b8a8e7 + 307e262 commit 060ac84

7 files changed

+37
-37
lines changed
 

‎ext/plot.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ $(TYPEDEF)
1111
A leaf of a plot tree.
1212
"""
1313
struct PlotLeaf <: AbstractPlotTreeElement
14-
value::Tuple{Symbol, Integer}
15-
PlotLeaf(value::Tuple{Symbol, Integer}) = new(value)
14+
value::Tuple{Symbol, Int}
15+
PlotLeaf(value::Tuple{Symbol, Int}) = new(value)
1616
end
1717

1818
"""
@@ -41,7 +41,7 @@ function __plot_time!(
4141
p::Union{Plots.Plot, Plots.Subplot},
4242
sol::OptimalControlSolution,
4343
s::Symbol,
44-
i::Integer,
44+
i::Int,
4545
time::Symbol;
4646
t_label,
4747
label::String,
@@ -103,7 +103,7 @@ Plot the i-th component of a vectorial function of time `f(t) ∈ Rᵈ` where `f
103103
function __plot_time(
104104
sol::OptimalControlSolution,
105105
s::Symbol,
106-
i::Integer,
106+
i::Int,
107107
time::Symbol;
108108
t_label,
109109
label::String,
@@ -187,7 +187,7 @@ $(TYPEDSIGNATURES)
187187
188188
Plot a leaf.
189189
"""
190-
function __plot_tree(leaf::PlotLeaf, depth::Integer; kwargs...)
190+
function __plot_tree(leaf::PlotLeaf, depth::Int; kwargs...)
191191
return Plots.plot()
192192
end
193193

@@ -196,7 +196,7 @@ $(TYPEDSIGNATURES)
196196
197197
Plot a node.
198198
"""
199-
function __plot_tree(node::PlotNode, depth::Integer = 0; kwargs...)
199+
function __plot_tree(node::PlotNode, depth::Int = 0; kwargs...)
200200
#
201201
subplots = ()
202202
#
@@ -612,8 +612,8 @@ corresponding respectively to the argument `xx` and the argument `yy`.
612612
"""
613613
@recipe function f(
614614
sol::OptimalControlSolution,
615-
xx::Union{Symbol, Tuple{Symbol, Integer}},
616-
yy::Union{Symbol, Tuple{Symbol, Integer}},
615+
xx::Union{Symbol, Tuple{Symbol, Int}},
616+
yy::Union{Symbol, Tuple{Symbol, Int}},
617617
time::Symbol = :default,
618618
)
619619

@@ -629,8 +629,8 @@ end
629629

630630
function recipe_label(
631631
sol::OptimalControlSolution,
632-
xx::Union{Symbol, Tuple{Symbol, Integer}},
633-
yy::Union{Symbol, Tuple{Symbol, Integer}},
632+
xx::Union{Symbol, Tuple{Symbol, Int}},
633+
yy::Union{Symbol, Tuple{Symbol, Int}},
634634
)
635635

636636
#
@@ -661,7 +661,7 @@ Get the data for plotting.
661661
"""
662662
function __get_data_plot(
663663
sol::OptimalControlSolution,
664-
xx::Union{Symbol, Tuple{Symbol, Integer}};
664+
xx::Union{Symbol, Tuple{Symbol, Int}};
665665
time::Symbol = :default,
666666
)
667667
T = time_grid(sol)

‎src/CTBase.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ Type alias for a dimension. This is used to define the dimension of the state sp
174174
the costate space, the control space, etc.
175175
176176
```@example
177-
julia> const Dimension = Integer
177+
julia> const Dimension = Int
178178
```
179179
"""
180-
const Dimension = Integer
180+
const Dimension = Int
181181

182182
#
183183
"""

‎src/onepass.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $(TYPEDEF)
2525
x::Union{Symbol, Nothing} = nothing
2626
u::Union{Symbol, Nothing} = nothing
2727
aliases::OrderedDict{Symbol, Union{Real, Symbol, Expr}} = __init_aliases()
28-
lnum::Integer = 0
28+
lnum::Int = 0
2929
line::String = ""
3030
t_dep::Bool = false
3131
end
@@ -199,7 +199,7 @@ p_variable!(p, ocp, v, q; components_names = nothing, log = false) = begin
199199
v isa Symbol || return __throw("forbidden variable name: $v", p.lnum, p.line)
200200
p.v = v
201201
vv = QuoteNode(v)
202-
qq = q isa Integer ? q : 9
202+
qq = q isa Int ? q : 9
203203
for i 1:qq
204204
p.aliases[Symbol(v, ctindices(i))] = :($v[$i])
205205
end # make: v₁, v₂... if the variable is named v
@@ -283,7 +283,7 @@ p_state!(p, ocp, x, n; components_names = nothing, log = false) = begin
283283
x isa Symbol || return __throw("forbidden state name: $x", p.lnum, p.line)
284284
p.x = x
285285
xx = QuoteNode(x)
286-
nn = n isa Integer ? n : 9
286+
nn = n isa Int ? n : 9
287287
for i 1:nn
288288
p.aliases[Symbol(x, ctindices(i))] = :($x[$i])
289289
end # Make x₁, x₂... if the state is named x
@@ -314,7 +314,7 @@ p_control!(p, ocp, u, m; components_names = nothing, log = false) = begin
314314
u isa Symbol || return __throw("forbidden control name: $u", p.lnum, p.line)
315315
p.u = u
316316
uu = QuoteNode(u)
317-
mm = m isa Integer ? m : 9
317+
mm = m isa Int ? m : 9
318318
for i 1:mm
319319
p.aliases[Symbol(u, ctindices(i))] = :($u[$i])
320320
end # make: u₁, u₂... if the control is named u
@@ -341,7 +341,7 @@ end
341341
p_constraint!(p, ocp, e1, e2, e3, label = gensym(); log = false) = begin
342342
c_type = constraint_type(e2, p.t, p.t0, p.tf, p.x, p.u, p.v)
343343
log && println("constraint ($c_type): $e1$e2$e3, ($label)")
344-
label isa Integer && (label = Symbol(:eq, label))
344+
label isa Int && (label = Symbol(:eq, label))
345345
label isa Symbol || return __throw("forbidden label: $label", p.lnum, p.line)
346346
llabel = QuoteNode(label)
347347
code = @match c_type begin

‎src/optimal_control_model-setters.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ function time!(
343343
ocp::OptimalControlModel{<:TimeDependence, VT};
344344
t0::Union{Time, Nothing} = nothing,
345345
tf::Union{Time, Nothing} = nothing,
346-
ind0::Union{Integer, Nothing} = nothing,
347-
indf::Union{Integer, Nothing} = nothing,
346+
ind0::Union{Int, Nothing} = nothing,
347+
indf::Union{Int, Nothing} = nothing,
348348
name::Union{String, Symbol} = __time_name(),
349349
) where {VT}
350350

@@ -417,24 +417,24 @@ function time!(
417417
ocp.initial_time = t0
418418
ocp.final_time = tf
419419
ocp.time_name = name
420-
ocp.initial_time_name = t0 isa Integer ? string(t0) : string(round(t0, digits = 2))
421-
ocp.final_time_name = tf isa Integer ? string(tf) : string(round(tf, digits = 2))
420+
ocp.initial_time_name = t0 isa Int ? string(t0) : string(round(t0, digits = 2))
421+
ocp.final_time_name = tf isa Int ? string(tf) : string(round(tf, digits = 2))
422422
end
423-
(::Nothing, ::Integer, ::Time, ::Nothing) => begin # (ind0, tf)
423+
(::Nothing, ::Int, ::Time, ::Nothing) => begin # (ind0, tf)
424424
ocp.initial_time = Index(ind0)
425425
ocp.final_time = tf
426426
ocp.time_name = name
427427
ocp.initial_time_name = variable_components_names(ocp)[ind0]
428-
ocp.final_time_name = tf isa Integer ? string(tf) : string(round(tf, digits = 2))
428+
ocp.final_time_name = tf isa Int ? string(tf) : string(round(tf, digits = 2))
429429
end
430-
(::Time, ::Nothing, ::Nothing, ::Integer) => begin # (t0, indf)
430+
(::Time, ::Nothing, ::Nothing, ::Int) => begin # (t0, indf)
431431
ocp.initial_time = t0
432432
ocp.final_time = Index(indf)
433433
ocp.time_name = name
434-
ocp.initial_time_name = t0 isa Integer ? string(t0) : string(round(t0, digits = 2))
434+
ocp.initial_time_name = t0 isa Int ? string(t0) : string(round(t0, digits = 2))
435435
ocp.final_time_name = variable_components_names(ocp)[indf]
436436
end
437-
(::Nothing, ::Integer, ::Nothing, ::Integer) => begin # (ind0, indf)
437+
(::Nothing, ::Int, ::Nothing, ::Int) => begin # (ind0, indf)
438438
ocp.initial_time = Index(ind0)
439439
ocp.final_time = Index(indf)
440440
ocp.time_name = name
@@ -521,7 +521,7 @@ julia> constraint!(ocp, :mixed; f = (t, x, u, v) -> x[1]*v[2]-u, lb=0, ub=1)
521521
function constraint!(
522522
ocp::OptimalControlModel{T, V},
523523
type::Symbol;
524-
rg::Union{OrdinalRange{<:Integer}, Index, Integer, Nothing} = nothing,
524+
rg::Union{OrdinalRange{<:Int}, Index, Int, Nothing} = nothing,
525525
f::Union{Function, Nothing} = nothing,
526526
lb::Union{ctVector, Nothing} = nothing,
527527
ub::Union{ctVector, Nothing} = nothing,

‎src/optimal_control_solution-setters.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function __OptimalControlSolution(
1616
costate::Union{Nothing, Function} = nothing,
1717
time_grid::Union{Nothing, TimesDisc} = nothing,
1818
variable::Union{Nothing, Variable} = nothing,
19-
iterations::Union{Nothing, Integer} = nothing,
19+
iterations::Union{Nothing, Int} = nothing,
2020
stopping::Union{Nothing, Symbol} = nothing,
2121
message::Union{Nothing, String} = nothing,
2222
success::Union{Nothing, Bool} = nothing,
@@ -103,7 +103,7 @@ function OptimalControlSolution(
103103
variable::Union{Nothing, Variable} = nothing,
104104
costate::Union{Nothing, Function} = nothing,
105105
time_grid::Union{Nothing, TimesDisc} = nothing,
106-
iterations::Union{Nothing, Integer} = nothing,
106+
iterations::Union{Nothing, Int} = nothing,
107107
stopping::Union{Nothing, Symbol} = nothing,
108108
message::Union{Nothing, String} = nothing,
109109
success::Union{Nothing, Bool} = nothing,
@@ -170,7 +170,7 @@ function OptimalControlSolution(
170170
variable::Variable,
171171
costate::Union{Nothing, Function} = nothing,
172172
time_grid::Union{Nothing, TimesDisc} = nothing,
173-
iterations::Union{Nothing, Integer} = nothing,
173+
iterations::Union{Nothing, Int} = nothing,
174174
stopping::Union{Nothing, Symbol} = nothing,
175175
message::Union{Nothing, String} = nothing,
176176
success::Union{Nothing, Bool} = nothing,

‎src/utils.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $(TYPEDSIGNATURES)
33
44
Return `i` ∈ [0, 9] as a subscript.
55
"""
6-
function ctindice(i::Integer)::Char
6+
function ctindice(i::Int)::Char
77
if i < 0 || i > 9
88
throw(IncorrectArgument("the indice must be between 0 and 9"))
99
end
@@ -15,7 +15,7 @@ $(TYPEDSIGNATURES)
1515
1616
Return `i` > 0 as a subscript.
1717
"""
18-
function ctindices(i::Integer)::String
18+
function ctindices(i::Int)::String
1919
if i < 0
2020
throw(IncorrectArgument("the indice must be positive"))
2121
end
@@ -31,7 +31,7 @@ $(TYPEDSIGNATURES)
3131
3232
Return `i` ∈ [0, 9] as an upperscript.
3333
"""
34-
function ctupperscript(i::Integer)::Char
34+
function ctupperscript(i::Int)::Char
3535
if i < 0 || i > 9
3636
throw(IncorrectArgument("the upperscript must be between 0 and 9"))
3737
end
@@ -57,7 +57,7 @@ $(TYPEDSIGNATURES)
5757
5858
Return `i` > 0 as an upperscript.
5959
"""
60-
function ctupperscripts(i::Integer)::String
60+
function ctupperscripts(i::Int)::String
6161
if i < 0
6262
throw(IncorrectArgument("the upperscript must be positive"))
6363
end
@@ -165,7 +165,7 @@ $(TYPEDSIGNATURES)
165165
166166
Transforms `x` to a Vector{<:Vector{<:ctNumber}}.
167167
"""
168-
function vec2vec(x::Vector{<:ctNumber}, n::Integer)::Vector{<:Vector{<:ctNumber}}
168+
function vec2vec(x::Vector{<:ctNumber}, n::Int)::Vector{<:Vector{<:ctNumber}}
169169
y = [x[1:n]]
170170
for i = (n + 1):n:(length(x) - n + 1)
171171
y = vcat(y, [x[i:(i + n - 1)]])
@@ -203,7 +203,7 @@ Transforms `x` to a Vector{<:Vector{<:ctNumber}}.
203203
"""
204204
function matrix2vec(
205205
x::Matrix{<:ctNumber},
206-
dim::Integer = __matrix_dimension_stock(),
206+
dim::Int = __matrix_dimension_stock(),
207207
)::Vector{<:Vector{<:ctNumber}}
208208
m, n = size(x)
209209
y = nothing

‎test/solution_test.jld2

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)