Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant variables in algorithms #845

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Algorithms/A20/A20.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ numtype(::A20{N}) where {N} = N
function rsetrep(::A20{N}) where {N}
VT = Vector{N}
MT = Matrix{N}
return RT = ReachSet{N,Zonotope{N,VT,MT}}
return ReachSet{N,Zonotope{N,VT,MT}}
end

include("post.jl")
Expand Down
8 changes: 4 additions & 4 deletions src/Algorithms/ASB07/ASB07.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ end
step_size(alg::ASB07) = alg.δ
numtype(::ASB07{N}) where {N} = N

function rsetrep(alg::ASB07{N,AM,RM,Val{false}}) where {N,AM,RM}
return RT = ReachSet{N,Zonotope{N,Vector{N},Matrix{N}}}
function rsetrep(::ASB07{N,AM,RM,Val{false}}) where {N,AM,RM}
return ReachSet{N,Zonotope{N,Vector{N},Matrix{N}}}
end

function rsetrep(alg::ASB07{N,AM,RM,S,R,Val{n},Val{p}}) where {N,AM,RM,S,R,n,p}
function rsetrep(::ASB07{N,AM,RM,S,R,Val{n},Val{p}}) where {N,AM,RM,S,R,n,p}
VT = SVector{n,N}
MT = SMatrix{n,p,N,n * p}
ZT = Zonotope{N,VT,MT}
return RT = ReachSet{N,ZT}
return ReachSet{N,ZT}
end

include("post.jl")
Expand Down
4 changes: 2 additions & 2 deletions src/Algorithms/ASB07/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function reach_homog_ASB07!(F::Vector{ReachSet{N,Zonotope{N,VN,MN}}},
NSTEPS::Integer,
δ::N,
max_order::Integer,
X::Universe,
::Universe,
recursive::Val{true},
reduction_method::AbstractReductionMethod,
Δt0::TN) where {N,TN,VN,MN}
Expand Down Expand Up @@ -42,7 +42,7 @@ function reach_homog_ASB07!(F::Vector{ReachSet{N,Zonotope{N,VN,MN}}},
NSTEPS::Integer,
δ::N,
max_order::Integer,
X::Universe,
::Universe,
recursive::Val{false},
reduction_method::AbstractReductionMethod,
Δt0::TN) where {N,TN,VN,MN}
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/ASB07/reach_inhomog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function reach_inhomog_ASB07!(F::Vector{ReachSet{N,Zonotope{N,VN,MN}}},
NSTEPS::Integer,
δ::N,
max_order::Integer,
X::Universe,
::Universe,
U::Zonotope,
recursive::Val{true},
reduction_method::AbstractReductionMethod,
Expand Down
4 changes: 2 additions & 2 deletions src/Algorithms/BFFPSV18/BFFPSV18.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ function BFFPSV18(; δ::N,
lazy_initial_set, lazy_input, sparse, view)
end

_concretize_setrep(setrep::Type{Interval}, N) = Interval{N}
_concretize_setrep(setrep::Type{Hyperrectangle}, N) = Hyperrectangle{N,Vector{N},Vector{N}}
_concretize_setrep(::Type{Interval}, N) = Interval{N}
_concretize_setrep(::Type{Hyperrectangle}, N) = Hyperrectangle{N,Vector{N},Vector{N}}

# blocks of size 1
function _parse_opts_1D(vars, dim::Integer, partition)
Expand Down
6 changes: 3 additions & 3 deletions src/Algorithms/BFFPSV18/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Matrix operations: Dense
# Invariant: No
function reach_homog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::AbstractMatrix{NM}, NSTEPS, δ,
X::Universe, ST::Type{<:Interval{N}}, vars, block_indices,
::Universe, ST::Type{<:Interval{N}}, vars, block_indices,
row_blocks, column_blocks, Δt0,
viewval::Val{true}) where {NM,N}

Expand Down Expand Up @@ -45,7 +45,7 @@ end
# Matrix operations: Dense
# Invariant: No
function reach_homog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::MT, NSTEPS, δ::N,
X::Universe, ST, vars, block_indices,
::Universe, ST, vars, block_indices,
row_blocks::AbstractVector{<:RBLKi},
column_blocks::AbstractVector{<:CBLKj},
Δt0,
Expand Down Expand Up @@ -87,7 +87,7 @@ end
# Matrix operations: Sparse
# Invariant: No
function reach_homog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::MT, NSTEPS, δ::N,
X::Universe, ST, vars, block_indices,
::Universe, ST, vars, block_indices,
row_blocks::AbstractVector{<:RBLKi},
column_blocks::AbstractVector{<:CBLKj},
Δt0,
Expand Down
8 changes: 4 additions & 4 deletions src/Algorithms/BFFPSV18/reach_inhomog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Matrix operations: Dense
# Invariant: No
function reach_inhomog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::MT, NSTEPS, δ,
X::Universe, U, ST::Type{<:Interval{N}}, vars, block_indices,
::Universe, U, ST::Type{<:Interval{N}}, vars, block_indices,
row_blocks::AbstractVector{<:RBLKi},
column_blocks::AbstractVector{<:CBLKj},
Δt0,
Expand Down Expand Up @@ -60,7 +60,7 @@ end
# Matrix operations: Dense
# Invariant: No
function reach_inhomog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::MT, NSTEPS, δ,
X::Universe, U, ST, vars, block_indices,
::Universe, U, ST, vars, block_indices,
row_blocks::AbstractVector{<:RBLKi},
column_blocks::AbstractVector{<:CBLKj},
Δt0,
Expand Down Expand Up @@ -114,7 +114,7 @@ end
# Matrix operations: Sparse
# Invariant: No
function reach_inhomog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::MT, NSTEPS, δ::N,
X::Universe, U, ST, vars, block_indices,
::Universe, U, ST, vars, block_indices,
row_blocks::AbstractVector{<:RBLKi},
column_blocks::AbstractVector{<:CBLKj},
Δt0,
Expand Down Expand Up @@ -168,7 +168,7 @@ function reach_inhomog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::MT, NST
end

function reach_inhomog_BFFPSV18!(F, Xhat0::CartesianProductArray{N}, Φ::MT, NSTEPS, δ::N,
X::Universe, U, ST, vars, block_indices,
::Universe, U, ST, vars, block_indices,
row_blocks::AbstractVector{<:RBLKi},
column_blocks::AbstractVector{<:CBLKj},
Δt0,
Expand Down
6 changes: 3 additions & 3 deletions src/Algorithms/BOX/BOX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ numtype(::BOX{N}) where {N} = N

function setrep(::BOX{N,AM,Val{false},D,R}) where {N,AM,D,R}
VT = Vector{N}
return ST = Hyperrectangle{N,VT,VT}
return Hyperrectangle{N,VT,VT}
end

function rsetrep(::BOX{N,AM,Val{true},Val{n},R}) where {N,AM,n,R}
VT = SVector{n,N}
return ST = Hyperrectangle{N,VT,VT}
return Hyperrectangle{N,VT,VT}
end

function rsetrep(alg::BOX{N}) where {N}
ST = setrep(alg)
return RT = ReachSet{N,ST}
return ReachSet{N,ST}
end

include("post.jl")
Expand Down
4 changes: 2 additions & 2 deletions src/Algorithms/BOX/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function reach_homog_BOX!(F::Vector{ReachSet{N,Hyperrectangle{N,VNC,VNR}}},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::N,
X::Universe,
::Universe,
recursive::Val{false},
Δt0::TN) where {N,TN,VNC,VNR}

Expand Down Expand Up @@ -55,7 +55,7 @@ function reach_homog_BOX!(F::Vector{ReachSet{N,Hyperrectangle{N,VNC,VNR}}},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
X::Universe,
::Universe,
recursive::Val{true},
Δt0::TN) where {N,TN,VNC,VNR}

Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/BOX/reach_inhomog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function reach_inhomog_BOX!(F::Vector{ReachSet{N,Hyperrectangle{N,VNC,VNR}}},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::N,
X::Universe,
::Universe,
U::Hyperrectangle,
recursive::Val{false},
Δt0::TN) where {N,TN,VNC,VNR}
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/CARLIN/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end

# TODO check if it can be removed
function _project(sol, vars)
return πsol_1n = Flowpipe([ReachSet(set(project(R, vars)), tspan(R)) for R in sol])
return Flowpipe([ReachSet(set(project(R, vars)), tspan(R)) for R in sol])
end

struct CanonicalQuadraticForm{T,MT<:AbstractMatrix{T}} <: AbstractContinuousSystem
Expand Down
14 changes: 7 additions & 7 deletions src/Algorithms/GLGM06/GLGM06.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,27 @@ end
step_size(alg::GLGM06) = alg.δ
numtype(::GLGM06{N}) where {N} = N

@inline function setrep(alg::GLGM06{N,AM,Val{false}}) where {N,AM}
return ST = Zonotope{N,Vector{N},Matrix{N}}
@inline function setrep(::GLGM06{N,AM,Val{false}}) where {N,AM}
return Zonotope{N,Vector{N},Matrix{N}}
end

@inline function rsetrep(alg::GLGM06{N,AM,Val{false}}) where {N,AM}
ST = setrep(alg)
return RT = ReachSet{N,ST}
return ReachSet{N,ST}
end

@inline function setrep(alg::GLGM06{N,AM,Val{true},Val{n},Val{p}}) where {N,AM,n,p}
@inline function setrep(::GLGM06{N,AM,Val{true},Val{n},Val{p}}) where {N,AM,n,p}
VT = SVector{n,N}
MT = SMatrix{n,p,N,n * p}
return ZT = Zonotope{N,VT,MT}
return Zonotope{N,VT,MT}
end

@inline function rsetrep(alg::GLGM06{N,AM,Val{true},Val{n},Val{p}}) where {N,AM,n,p}
ZT = setrep(alg)
return RT = ReachSet{N,ZT}
return ReachSet{N,ZT}
end

@inline function rsetrep(alg::GLGM06{N,AM,Val{true},Missing,Missing}) where {N,AM}
@inline function rsetrep(::GLGM06{N,AM,Val{true},Missing,Missing}) where {N,AM}
throw(ArgumentError("the reach-set representation for a statically sized zonotope " *
"that the system's dimension argument has been defined; add `dim=...`" *
"to the algorithm constructor"))
Expand Down
4 changes: 2 additions & 2 deletions src/Algorithms/GLGM06/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function reach_homog_GLGM06!(F::Vector{ReachSet{N,Zonotope{N,VN,MN}}},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
X::Universe,
::Universe,
preallocate::Val{false},
Δt0::TimeInterval,
disjointness_method::AbstractDisjointnessMethod) where {N,VN,MN}
Expand All @@ -35,7 +35,7 @@ function reach_homog_GLGM06!(F::Vector{ReachSet{N,Zonotope{N,Vector{N},Matrix{N}
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
X::Universe,
::Universe,
preallocate::Val{true},
Δt0::TimeInterval,
disjointness_method::AbstractDisjointnessMethod) where {N}
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/GLGM06/reach_inhomog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function reach_inhomog_GLGM06!(F::Vector{ReachSet{N,Zonotope{N,VN,MN}}},
NSTEPS::Integer,
δ::Float64,
max_order::Integer,
X::Universe,
::Universe,
U::LazySet,
reduction_method::AbstractReductionMethod,
Δt0::TimeInterval,
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/INT/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function reach_homog_INT!(F::Vector{ReachSet{N,Interval{N}}},
Φ::N,
NSTEPS::Integer,
δ::Float64,
X::Universe,
::Universe,
Δt0::TimeInterval) where {N}
# initial reach set
Δt = (zero(N) .. δ) + Δt0
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/INT/reach_inhomog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function reach_inhomog_INT!(F::Vector{ReachSet{N,Interval{N}}},
Φ::N,
NSTEPS::Integer,
δ::Float64,
X::Universe,
::Universe,
U::Interval,
Δt0::TimeInterval) where {N}

Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/LGG09/LGG09.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ step_size(alg::LGG09) = alg.δ
numtype(::LGG09{N}) where {N} = N
setrep(alg::LGG09) = setrep(alg.template)

function rsetrep(alg::LGG09{N,AM,VN,TN}) where {N,AM,VN,TN}
function rsetrep(::LGG09{N,AM,VN,TN}) where {N,AM,VN,TN}
SN = SubArray{N,1,Matrix{N},Tuple{Base.Slice{Base.OneTo{Int}},Int},true}
return TemplateReachSet{N,VN,TN,SN}
end
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/LGG09/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function reach_homog_LGG09!(F::Vector{RT},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::N,
X::Universe, # no invariant
::Universe, # no invariant
Δt0::TimeInterval,
cache,
threaded) where {N,VN,TN,SN,RT<:TemplateReachSet{N,VN,TN,SN}}
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/LGG09/reach_inhomog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function reach_inhomog_LGG09!(F::Vector{RT},
Φ::AbstractMatrix{N},
NSTEPS::Integer,
δ::N,
X::Universe,
::Universe,
U::LazySet,
Δt0::TimeInterval,
cache,
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/ORBIT/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ end
# Φ^2*Ω0 + Φ*V + V
# ....
# Φ^(NSTEPS)*Ω0 + Φ^(NSTEPS-1)*V + ... + Φ*V + V
function _orbit!(F, Φ::AbstractMatrix{N}, Ω0, V, NSTEPS, δ, X::Universe, Δt0) where {N}
function _orbit!(F, Φ::AbstractMatrix{N}, Ω0, V, NSTEPS, δ, ::Universe, Δt0) where {N}
# preallocate output sequence
n = size(Φ, 1)
VT = vector_type(typeof(Φ))
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/TMJets/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function _initialize(X0::LazySet, orderQ, orderT)
return _initialize(box_approximation(X0), orderQ, orderT)
end

# taylor model representations
# Taylor model representations
function _initialize(X0::TaylorModelReachSet, orderQ, orderT)
return set(X0)
end
Expand Down
10 changes: 5 additions & 5 deletions src/Algorithms/VREP/VREP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ end
step_size(alg::VREP) = alg.δ
numtype(::VREP{N}) where {N} = N

function setrep(alg::VREP{N,AM,Val{false},Missing}) where {N,AM}
function setrep(::VREP{N,AM,Val{false},Missing}) where {N,AM}
return VPolytope{N,Vector{N}}
end

function setrep(alg::VREP{N,AM,Val{false},D}) where {N,AM,D}
function setrep(::VREP{N,AM,Val{false},D}) where {N,AM,D}
return VPolygon{N,Vector{N}}
end

function setrep(alg::VREP{N,AM,Val{true},Missing}) where {N,AM}
return error("the set representation of this algorithm requires the dimension to be specified, but it is $(alg.dim)")
end

function setrep(alg::VREP{N,AM,Val{true},Val{2}}) where {N,AM}
function setrep(::VREP{N,AM,Val{true},Val{2}}) where {N,AM}
return VPolygon{N,SVector{2,N}}
end

function setrep(alg::VREP{N,AM,Val{true},Val{n}}) where {N,AM,n}
function setrep(::VREP{N,AM,Val{true},Val{n}}) where {N,AM,n}
return VPolytope{N,SVector{n,N}}
end

function rsetrep(alg::VREP{N}) where {N}
ST = setrep(alg)
return RT = ReachSet{N,ST}
return ReachSet{N,ST}
end

include("post.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/VREP/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function reach_homog_VREP!(F::Vector{ReachSet{N,VP}},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
X::Universe,
::Universe,
Δt0::TimeInterval) where {N,VN,VP<:VPOLY{N,VN}}

# initial reach set
Expand Down