diff --git a/ext/plot.jl b/ext/plot.jl index 4474b72..e292261 100644 --- a/ext/plot.jl +++ b/ext/plot.jl @@ -11,8 +11,8 @@ $(TYPEDEF) A leaf of a plot tree. """ struct PlotLeaf <: AbstractPlotTreeElement - value::Tuple{Symbol, Integer} - PlotLeaf(value::Tuple{Symbol, Integer}) = new(value) + value::Tuple{Symbol, Int} + PlotLeaf(value::Tuple{Symbol, Int}) = new(value) end """ @@ -41,7 +41,7 @@ function __plot_time!( p::Union{Plots.Plot, Plots.Subplot}, sol::OptimalControlSolution, s::Symbol, - i::Integer, + i::Int, time::Symbol; t_label, label::String, @@ -103,7 +103,7 @@ Plot the i-th component of a vectorial function of time `f(t) ∈ Rᵈ` where `f function __plot_time( sol::OptimalControlSolution, s::Symbol, - i::Integer, + i::Int, time::Symbol; t_label, label::String, @@ -187,7 +187,7 @@ $(TYPEDSIGNATURES) Plot a leaf. """ -function __plot_tree(leaf::PlotLeaf, depth::Integer; kwargs...) +function __plot_tree(leaf::PlotLeaf, depth::Int; kwargs...) return Plots.plot() end @@ -196,7 +196,7 @@ $(TYPEDSIGNATURES) Plot a node. """ -function __plot_tree(node::PlotNode, depth::Integer = 0; kwargs...) +function __plot_tree(node::PlotNode, depth::Int = 0; kwargs...) # subplots = () # @@ -612,8 +612,8 @@ corresponding respectively to the argument `xx` and the argument `yy`. """ @recipe function f( sol::OptimalControlSolution, - xx::Union{Symbol, Tuple{Symbol, Integer}}, - yy::Union{Symbol, Tuple{Symbol, Integer}}, + xx::Union{Symbol, Tuple{Symbol, Int}}, + yy::Union{Symbol, Tuple{Symbol, Int}}, time::Symbol = :default, ) @@ -629,8 +629,8 @@ end function recipe_label( sol::OptimalControlSolution, - xx::Union{Symbol, Tuple{Symbol, Integer}}, - yy::Union{Symbol, Tuple{Symbol, Integer}}, + xx::Union{Symbol, Tuple{Symbol, Int}}, + yy::Union{Symbol, Tuple{Symbol, Int}}, ) # @@ -661,7 +661,7 @@ Get the data for plotting. """ function __get_data_plot( sol::OptimalControlSolution, - xx::Union{Symbol, Tuple{Symbol, Integer}}; + xx::Union{Symbol, Tuple{Symbol, Int}}; time::Symbol = :default, ) T = time_grid(sol) diff --git a/src/CTBase.jl b/src/CTBase.jl index d9270be..59f7d8e 100644 --- a/src/CTBase.jl +++ b/src/CTBase.jl @@ -174,10 +174,10 @@ Type alias for a dimension. This is used to define the dimension of the state sp the costate space, the control space, etc. ```@example -julia> const Dimension = Integer +julia> const Dimension = Int ``` """ -const Dimension = Integer +const Dimension = Int # """ diff --git a/src/onepass.jl b/src/onepass.jl index 4c2b86d..e533df9 100644 --- a/src/onepass.jl +++ b/src/onepass.jl @@ -25,7 +25,7 @@ $(TYPEDEF) x::Union{Symbol, Nothing} = nothing u::Union{Symbol, Nothing} = nothing aliases::OrderedDict{Symbol, Union{Real, Symbol, Expr}} = __init_aliases() - lnum::Integer = 0 + lnum::Int = 0 line::String = "" t_dep::Bool = false end @@ -199,7 +199,7 @@ p_variable!(p, ocp, v, q; components_names = nothing, log = false) = begin v isa Symbol || return __throw("forbidden variable name: $v", p.lnum, p.line) p.v = v vv = QuoteNode(v) - qq = q isa Integer ? q : 9 + qq = q isa Int ? q : 9 for i ∈ 1:qq p.aliases[Symbol(v, ctindices(i))] = :($v[$i]) 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 x isa Symbol || return __throw("forbidden state name: $x", p.lnum, p.line) p.x = x xx = QuoteNode(x) - nn = n isa Integer ? n : 9 + nn = n isa Int ? n : 9 for i ∈ 1:nn p.aliases[Symbol(x, ctindices(i))] = :($x[$i]) 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 u isa Symbol || return __throw("forbidden control name: $u", p.lnum, p.line) p.u = u uu = QuoteNode(u) - mm = m isa Integer ? m : 9 + mm = m isa Int ? m : 9 for i ∈ 1:mm p.aliases[Symbol(u, ctindices(i))] = :($u[$i]) end # make: u₁, u₂... if the control is named u @@ -341,7 +341,7 @@ end p_constraint!(p, ocp, e1, e2, e3, label = gensym(); log = false) = begin c_type = constraint_type(e2, p.t, p.t0, p.tf, p.x, p.u, p.v) log && println("constraint ($c_type): $e1 ≤ $e2 ≤ $e3, ($label)") - label isa Integer && (label = Symbol(:eq, label)) + label isa Int && (label = Symbol(:eq, label)) label isa Symbol || return __throw("forbidden label: $label", p.lnum, p.line) llabel = QuoteNode(label) code = @match c_type begin diff --git a/src/optimal_control_model-setters.jl b/src/optimal_control_model-setters.jl index c21c96d..e7b8c5c 100644 --- a/src/optimal_control_model-setters.jl +++ b/src/optimal_control_model-setters.jl @@ -343,8 +343,8 @@ function time!( ocp::OptimalControlModel{<:TimeDependence, VT}; t0::Union{Time, Nothing} = nothing, tf::Union{Time, Nothing} = nothing, - ind0::Union{Integer, Nothing} = nothing, - indf::Union{Integer, Nothing} = nothing, + ind0::Union{Int, Nothing} = nothing, + indf::Union{Int, Nothing} = nothing, name::Union{String, Symbol} = __time_name(), ) where {VT} @@ -417,24 +417,24 @@ function time!( ocp.initial_time = t0 ocp.final_time = tf ocp.time_name = name - ocp.initial_time_name = t0 isa Integer ? string(t0) : string(round(t0, digits = 2)) - ocp.final_time_name = tf isa Integer ? string(tf) : string(round(tf, digits = 2)) + ocp.initial_time_name = t0 isa Int ? string(t0) : string(round(t0, digits = 2)) + ocp.final_time_name = tf isa Int ? string(tf) : string(round(tf, digits = 2)) end - (::Nothing, ::Integer, ::Time, ::Nothing) => begin # (ind0, tf) + (::Nothing, ::Int, ::Time, ::Nothing) => begin # (ind0, tf) ocp.initial_time = Index(ind0) ocp.final_time = tf ocp.time_name = name ocp.initial_time_name = variable_components_names(ocp)[ind0] - ocp.final_time_name = tf isa Integer ? string(tf) : string(round(tf, digits = 2)) + ocp.final_time_name = tf isa Int ? string(tf) : string(round(tf, digits = 2)) end - (::Time, ::Nothing, ::Nothing, ::Integer) => begin # (t0, indf) + (::Time, ::Nothing, ::Nothing, ::Int) => begin # (t0, indf) ocp.initial_time = t0 ocp.final_time = Index(indf) ocp.time_name = name - ocp.initial_time_name = t0 isa Integer ? string(t0) : string(round(t0, digits = 2)) + ocp.initial_time_name = t0 isa Int ? string(t0) : string(round(t0, digits = 2)) ocp.final_time_name = variable_components_names(ocp)[indf] end - (::Nothing, ::Integer, ::Nothing, ::Integer) => begin # (ind0, indf) + (::Nothing, ::Int, ::Nothing, ::Int) => begin # (ind0, indf) ocp.initial_time = Index(ind0) ocp.final_time = Index(indf) 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) function constraint!( ocp::OptimalControlModel{T, V}, type::Symbol; - rg::Union{OrdinalRange{<:Integer}, Index, Integer, Nothing} = nothing, + rg::Union{OrdinalRange{<:Int}, Index, Int, Nothing} = nothing, f::Union{Function, Nothing} = nothing, lb::Union{ctVector, Nothing} = nothing, ub::Union{ctVector, Nothing} = nothing, diff --git a/src/optimal_control_solution-setters.jl b/src/optimal_control_solution-setters.jl index 7cd6f6c..90d3800 100644 --- a/src/optimal_control_solution-setters.jl +++ b/src/optimal_control_solution-setters.jl @@ -16,7 +16,7 @@ function __OptimalControlSolution( costate::Union{Nothing, Function} = nothing, time_grid::Union{Nothing, TimesDisc} = nothing, variable::Union{Nothing, Variable} = nothing, - iterations::Union{Nothing, Integer} = nothing, + iterations::Union{Nothing, Int} = nothing, stopping::Union{Nothing, Symbol} = nothing, message::Union{Nothing, String} = nothing, success::Union{Nothing, Bool} = nothing, @@ -103,7 +103,7 @@ function OptimalControlSolution( variable::Union{Nothing, Variable} = nothing, costate::Union{Nothing, Function} = nothing, time_grid::Union{Nothing, TimesDisc} = nothing, - iterations::Union{Nothing, Integer} = nothing, + iterations::Union{Nothing, Int} = nothing, stopping::Union{Nothing, Symbol} = nothing, message::Union{Nothing, String} = nothing, success::Union{Nothing, Bool} = nothing, @@ -170,7 +170,7 @@ function OptimalControlSolution( variable::Variable, costate::Union{Nothing, Function} = nothing, time_grid::Union{Nothing, TimesDisc} = nothing, - iterations::Union{Nothing, Integer} = nothing, + iterations::Union{Nothing, Int} = nothing, stopping::Union{Nothing, Symbol} = nothing, message::Union{Nothing, String} = nothing, success::Union{Nothing, Bool} = nothing, diff --git a/src/utils.jl b/src/utils.jl index 009d038..d4bfb0e 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -3,7 +3,7 @@ $(TYPEDSIGNATURES) Return `i` ∈ [0, 9] as a subscript. """ -function ctindice(i::Integer)::Char +function ctindice(i::Int)::Char if i < 0 || i > 9 throw(IncorrectArgument("the indice must be between 0 and 9")) end @@ -15,7 +15,7 @@ $(TYPEDSIGNATURES) Return `i` > 0 as a subscript. """ -function ctindices(i::Integer)::String +function ctindices(i::Int)::String if i < 0 throw(IncorrectArgument("the indice must be positive")) end @@ -31,7 +31,7 @@ $(TYPEDSIGNATURES) Return `i` ∈ [0, 9] as an upperscript. """ -function ctupperscript(i::Integer)::Char +function ctupperscript(i::Int)::Char if i < 0 || i > 9 throw(IncorrectArgument("the upperscript must be between 0 and 9")) end @@ -57,7 +57,7 @@ $(TYPEDSIGNATURES) Return `i` > 0 as an upperscript. """ -function ctupperscripts(i::Integer)::String +function ctupperscripts(i::Int)::String if i < 0 throw(IncorrectArgument("the upperscript must be positive")) end @@ -165,7 +165,7 @@ $(TYPEDSIGNATURES) Transforms `x` to a Vector{<:Vector{<:ctNumber}}. """ -function vec2vec(x::Vector{<:ctNumber}, n::Integer)::Vector{<:Vector{<:ctNumber}} +function vec2vec(x::Vector{<:ctNumber}, n::Int)::Vector{<:Vector{<:ctNumber}} y = [x[1:n]] for i = (n + 1):n:(length(x) - n + 1) y = vcat(y, [x[i:(i + n - 1)]]) @@ -203,7 +203,7 @@ Transforms `x` to a Vector{<:Vector{<:ctNumber}}. """ function matrix2vec( x::Matrix{<:ctNumber}, - dim::Integer = __matrix_dimension_stock(), + dim::Int = __matrix_dimension_stock(), )::Vector{<:Vector{<:ctNumber}} m, n = size(x) y = nothing diff --git a/test/solution_test.jld2 b/test/solution_test.jld2 index 0c2791d..f613d1f 100644 Binary files a/test/solution_test.jld2 and b/test/solution_test.jld2 differ