Skip to content

Commit

Permalink
Merge branch 'master' into schillic/algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
mforets committed Aug 27, 2024
2 parents 2d7071b + f792a25 commit 9971f48
Show file tree
Hide file tree
Showing 27 changed files with 163 additions and 177 deletions.
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ReachabilityAnalysis"
uuid = "1e97bd63-91d1-579d-8e8d-501d2b57c93f"
version = "0.26.0"
version = "0.26.1"

[deps]
CarlemanLinearization = "4803f6b2-022a-4c1b-a771-522a3413ec86"
Expand All @@ -25,18 +25,18 @@ TaylorModels = "314ce334-5f6e-57ae-acf6-00b6e903104a"
TaylorSeries = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"

[compat]
CarlemanLinearization = "0.3"
CarlemanLinearization = "0.3 - 0.4"
CommonSolve = "0.2"
ExprTools = "0.1"
HybridSystems = "0.4"
IntervalArithmetic = "0.16 - 0.20, =0.20.9" # new versions require updates and are incompatible with dependencies
IntervalMatrices = "0.6 - 0.10"
LazySets = "2.12"
LazySets = "2.14"
LinearAlgebra = "<0.0.1, 1.6"
MathematicalSystems = "0.11 - 0.13"
Parameters = "0.10 - 0.12"
Random = "<0.0.1, 1.6"
ReachabilityBase = "0.1, 0.2"
ReachabilityBase = "0.1 - 0.3"
RecipesBase = "0.6 - 0.8, 1"
Reexport = "0.2, 1"
Requires = "0.5, 1"
Expand Down
4 changes: 2 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ ExponentialUtilities = "1"
IntervalArithmetic = "=0.20.9" # new versions require updates and are incompatible with dependencies
JLD2 = "0.4"
LaTeXStrings = "1"
LazySets = "2"
LazySets = "2.14"
Literate = "2"
MathematicalSystems = "0.11 - 0.13"
OrdinaryDiffEq = "6"
Plots = "1"
ReachabilityBase = "0.2.3"
ReachabilityBase = "0.2.3 - 0.3"
Symbolics = "5"
2 changes: 1 addition & 1 deletion src/Algorithms/A20/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function post(alg::A20{N}, ivp::IVP{<:AbstractContinuousSystem}, tspan;
ivp_norm = _normalize(ivp)

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp_norm = homogenize(ivp_norm)
end

Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/BFFPSV18/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function post(alg::BFFPSV18{N,ST}, ivp::IVP{<:AbstractContinuousSystem}, tspan;
ivp_norm = _normalize(ivp)

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp_norm = homogenize(ivp_norm)
end

Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/BOX/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function post(alg::BOX{N}, ivp::IVP{<:AbstractContinuousSystem}, tspan;
ivp_norm = _normalize(ivp)

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp_norm = homogenize(ivp_norm)
end

Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/CARLIN/reach.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ end
function _compute_resets(resets::Vector{Float64}, T)
# assumes initial time is 0
aux = vcat(0.0, resets, T)
return [interval(aux[i], aux[i + 1]) for i in 1:(length(aux) - 1)]
return [IA.interval(aux[i], aux[i + 1]) for i in 1:(length(aux) - 1)]
end

function reach_CARLIN_resets(X0, F1, F2, resets; alg, N, T, Δt, bloat, compress)
Expand Down
5 changes: 2 additions & 3 deletions src/Algorithms/GLGM06/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function post(alg::GLGM06{N}, ivp::IVP{<:AbstractContinuousSystem}, tspan;
ivp_norm = _normalize(ivp)

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp_norm = homogenize(ivp_norm)
end

Expand Down Expand Up @@ -58,8 +58,7 @@ function post(alg::GLGM06{N}, ivp::IVP{<:AbstractContinuousSystem}, tspan;
end
=#

reach_homog_GLGM06!(F, Ω0, Φ, NSTEPS, δ, max_order, X, preallocate, Δt0,
disjointness_method)
reach_homog_GLGM06!(F, Ω0, Φ, NSTEPS, δ, X, preallocate, Δt0, disjointness_method)
else
# TODO: implement preallocate option for this scenario
U = inputset(ivp_discr)
Expand Down
8 changes: 0 additions & 8 deletions src/Algorithms/GLGM06/reach_homog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
# X is the universal set => it is ignored
# in this case order reduction only has to be applied to the
# initial set because the loop does not create new generators
# it is assumed that order(Ω0) <= max_order
function reach_homog_GLGM06!(F::Vector{ReachSet{N,Zonotope{N,VN,MN}}},
Ω0::Zonotope{N,VN,MN},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
max_order::Integer,
::Universe,
preallocate::Val{false},
Δt0::TimeInterval,
Expand All @@ -37,7 +35,6 @@ function reach_homog_GLGM06!(F::Vector{ReachSet{N,Zonotope{N,Vector{N},Matrix{N}
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
max_order::Integer,
::Universe,
preallocate::Val{true},
Δt0::TimeInterval,
Expand Down Expand Up @@ -81,7 +78,6 @@ function reach_homog_GLGM06!(F::Vector{ReachSet{N,Zonotope{N,VN,MN}}},
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
max_order::Integer,
X::LazySet,
preallocate::Val{false},
Δt0::TimeInterval,
Expand Down Expand Up @@ -110,7 +106,6 @@ function reach_homog_GLGM06!(F::Vector{ReachSet{N,Zonotope{N,Vector{N},Matrix{N}
Φ::AbstractMatrix,
NSTEPS::Integer,
δ::Float64,
max_order::Integer,
X::LazySet,
preallocate::Val{true},
Δt0::TimeInterval,
Expand Down Expand Up @@ -153,13 +148,11 @@ end

#= O L D
# homogeneous case using StaticArrays
# it is assumed that the order of Ω0 is at most max_order
function reach_homog_GLGM06!(F::Vector{ReachSet{N, Zonotope{N, VN, MN}}},
Ω0::Zonotope{N, VN, MN},
Φ::SMatrix,
NSTEPS::Integer,
δ::Float64,
max_order::Integer,
X::Universe) where {N, VN<:SVector, MN<:SMatrix}
# initial reach set
Expand Down Expand Up @@ -198,7 +191,6 @@ function reach_homog_GLGM06!(F::Vector{ReachSet{N, Zonotope{N, VN, MN}}},
Φ::SMatrix,
NSTEPS::Integer,
δ::Float64,
max_order::Integer,
X::Universe) where {N, VN<:SVector, MN<:SMatrix}
# initial reach set
Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/INT/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function post(alg::INT{N}, ivp::IVP{<:AbstractContinuousSystem}, tspan;
ivp_norm = _normalize(ivp)

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp_norm = homogenize(ivp_norm)
end

Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/LGG09/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function post(alg::LGG09{N,AM,VN,TN}, ivp::IVP{<:AbstractContinuousSystem}, tspa
ivp_norm = _normalize(ivp)

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp_norm = homogenize(ivp_norm)
end

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 @@ -34,7 +34,7 @@ function _post!(U::Union{Nothing,AbstractSingleton}, alg::ORBIT, F, ivp,
@unpack δ, approx_model = alg

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp = homogenize(ivp)
end

Expand Down
2 changes: 1 addition & 1 deletion src/Algorithms/VREP/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function post(alg::VREP{N}, ivp::IVP{<:AbstractContinuousSystem}, tspan;
ivp_norm = _normalize(ivp)

# homogenize the initial-value problem
if haskey(kwargs, :homogenize) && kwargs[:homogenize] == true
if get(kwargs, :homogenize, false)
ivp_norm = homogenize(ivp_norm)
end

Expand Down
4 changes: 2 additions & 2 deletions src/Continuous/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function solve(ivp::IVP{AT,VT}, args...;
X0 = initial_state(ivp)
S = system(ivp)

threading = haskey(kwargs, :threading) ? kwargs[:threading] : (Threads.nthreads() > 1)
threading = get(kwargs, :threading, Threads.nthreads() > 1)

F = _solve_distributed(cpost, S, X0, tspan, Val(threading); kwargs...)
return ReachSolution(MixedFlowpipe(F), cpost)
Expand Down Expand Up @@ -347,7 +347,7 @@ function _default_cpost(S::AbstractContinuousSystem, X0, ishybrid, tspan; kwargs
if statedim(S) == 1 && !is_second_order(S)
opC = INT(; δ=δ)
else
static = haskey(kwargs, :static) ? kwargs[:static] : false
static = get(kwargs, :static, false)
if ishybrid || !(X0 isa AbstractZonotope)
opC = GLGM06(; δ=δ, static=static, approx_model=Forward())
else
Expand Down
11 changes: 6 additions & 5 deletions src/Discretization/CorrectionHullModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
module CorrectionHullModule

using ..DiscretizationModule
using ..Exponentiation: _exp, _alias, IntervalExpAlg, interval_matrix
using ..Exponentiation: _exp, _alias, IntervalExpAlg
using ..Overapproximate: _convert_or_overapproximate, _overapproximate
using IntervalMatrices: IntervalMatrix, correction_hull, input_correction, _exp_remainder
using IntervalMatrices: AbstractIntervalMatrix, IntervalMatrix, correction_hull,
input_correction, _exp_remainder
using MathematicalSystems
using LazySets
using LazySets: LinearMap
Expand Down Expand Up @@ -85,7 +86,7 @@ function discretize(ivp::IVP{<:CLCS,<:LazySet}, δ, alg::CorrectionHull)
end

function _discretize_chull(A, Φ::IntervalMatrix, X0, δ, alg, P=nothing)
X0z = _convert_or_overapproximate(X0, Zonotope)
X0z = _convert_or_overapproximate(Zonotope, X0)
Y = _overapproximate* X0z, Zonotope)
if !isnothing(P)
Y = minkowski_sum(Y, P)
Expand All @@ -106,7 +107,7 @@ function _correction_hull_without_E(A, δ, p)
end

function _discretize_chull(A, Φ::AbstractMatrix, X0, δ, alg)
X0z = _convert_or_overapproximate(X0, Zonotope)
X0z = _convert_or_overapproximate(Zonotope, X0)
Y = linear_map(Φ, X0z)

H = overapproximate(CH(X0z, Y), Zonotope)
Expand Down Expand Up @@ -137,7 +138,7 @@ function discretize(ivp::IVP{<:CLCCS,<:LazySet}, δ, alg::CorrectionHull)

Φ = _exp(A, δ, alg.exp)

A_interval = interval_matrix(A)
A_interval = A isa AbstractIntervalMatrix ? A : IntervalMatrix(A)

origin_not_contained_in_U = zeros(dim(U)) Uz

Expand Down
8 changes: 2 additions & 6 deletions src/Discretization/DiscretizationModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ next_set(inputs::AbstractInput, state::Int64) = collect(nextinput(inputs, state)

abstract type AbstractApproximationModel end

function _default_approximation_model(ivp::IVP{<:AbstractContinuousSystem})
function _default_approximation_model(::IVP{<:AbstractContinuousSystem})
return Forward()
end

Expand All @@ -39,17 +39,13 @@ isinterval(A::IntervalMatrix{N,IT}) where {N,IT<:IA.Interval{N}} = true
isinterval(A::AbstractMatrix{IT}) where {IT<:IA.Interval} = true

# options for a-posteriori transformation of a discretized set
# valid options are:
# AbstractDirections, Val{:lazy}, Val{:concrete}, Val{:vrep}, Val{:zono}, Val{:zonotope}
# _alias(setops) = setops # no-op

_alias(setops::AbstractDirections) = setops
_alias(setops::Val{:lazy}) = setops
_alias(setops::Val{:concrete}) = setops
_alias(setops::Val{:vrep}) = setops
_alias(setops::Val{:box}) = setops
_alias(setops::Val{:zono}) = setops
_alias(setops::Val{:zonotope}) = Val(:zono)
_alias(::Val{:zonotope}) = Val(:zono)

"""
discretize(ivp::IVP, δ, alg::AbstractApproximationModel)
Expand Down
Loading

0 comments on commit 9971f48

Please sign in to comment.