Skip to content

Commit 807268a

Browse files
authored
Merge pull request #905 from JuliaReach/schillic/903
#903 - Fix/add `setops` option for `Forward`/`FirstOrder`
2 parents f66bfa7 + 810693b commit 807268a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Discretization/FirstOrderModule.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
module FirstOrderModule
55

66
using ..DiscretizationModule
7-
using ..Exponentiation: _exp, BaseExp
7+
using ..Exponentiation: _exp, _alias, BaseExp
8+
using ..ApplySetops: _apply_setops
89
using LinearAlgebra
910
using MathematicalSystems
1011
using LazySets
@@ -36,18 +37,20 @@ The transformations are [LeGuernicG10](@cite):
3637
3738
where ``B_ε`` is the input ball of radius ``ε`` centered in the origin.
3839
"""
39-
struct FirstOrder{EM} <: AbstractApproximationModel
40+
struct FirstOrder{EM,SO} <: AbstractApproximationModel
4041
exp::EM
42+
setops::SO
4143
end
4244

4345
# convenience constructor
44-
function FirstOrder(; exp=BaseExp)
45-
return FirstOrder(exp)
46+
function FirstOrder(; exp=BaseExp, setops=:lazy)
47+
return FirstOrder(_alias(exp), _alias(setops))
4648
end
4749

4850
function Base.show(io::IO, alg::FirstOrder)
4951
print(io, "`FirstOrder` approximation model with:\n")
5052
print(io, " - exponentiation method: $(alg.exp)\n")
53+
print(io, " - set operations method: $(alg.setops)\n")
5154
return nothing
5255
end
5356

@@ -70,6 +73,7 @@ function discretize(ivp::IVP{<:CLCS,<:AbstractZonotope}, δ, alg::FirstOrder)
7073
= Φ * X0
7174
α = (exp(norm_A * δ) - 1 - norm_A * δ) * norm(X0, Inf)
7275
Ω0 = ConvexHull(X0, Xδ + BallInf(zeros(n), α))
76+
Ω0 = _apply_setops(Ω0, alg.setops)
7377

7478
# create result
7579
X = stateset(ivp)
@@ -97,10 +101,12 @@ function discretize(ivp::IVP{<:CLCCS,<:AbstractZonotope}, δ, alg::FirstOrder)
97101
norm_U_over_A = isapproxzero(norm_A) ? 0 : norm(U, Inf) / norm_A
98102
α = factor * (norm(X0, Inf) + norm_U_over_A)
99103
Ω0 = ConvexHull(X0, Xδ + δ * U + BallInf(zeros(n), α))
104+
Ω0 = _apply_setops(Ω0, alg.setops)
100105

101106
# discretize inputs
102107
β = factor * norm_U_over_A
103108
V = δ * U + BallInf(zeros(n), β)
109+
V = _apply_setops(V, alg.setops)
104110

105111
# create result
106112
B = IdentityMultiple(one(eltype(A)), size(A, 1))

src/Discretization/ForwardModule.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ function discretize(ivp::IVP{<:CLCS,<:LazySet}, δ, alg::Forward)
8787
Φcache = sum(A) == abs(sum(A)) ? Φ : nothing
8888
P2A_abs = Φ₂(A_abs, δ, alg.exp, alg.inv, Φcache)
8989
E₊ = sih(P2A_abs * sih((A * A) * X0, alg.sih), alg.sih)
90+
9091
Ω0 = ConvexHull(X0, Φ * X0 E₊)
9192
Ω0 = _apply_setops(Ω0, alg)
93+
9294
X = stateset(ivp)
9395
Sdis = ConstrainedLinearDiscreteSystem(Φ, X)
9496
return InitialValueProblem(Sdis, Ω0)
@@ -115,6 +117,7 @@ function discretize(ivp::IVP{<:CLCS,Interval{N}}, δ, ::Forward) where {N}
115117
E⁺ =- one(N) - aδ) * convert(Interval, symmetric_interval_hull(X0)).dat
116118

117119
Ω0 = Interval(hull(X0.dat, Φ * X0.dat + E⁺))
120+
118121
X = stateset(ivp)
119122
# the system constructor creates a matrix
120123
Sdis = ConstrainedLinearDiscreteSystem(Φ, X)
@@ -143,6 +146,7 @@ function discretize(ivp::IVP{<:CLCCS,<:LazySet}, δ, alg::Forward)
143146

144147
# discretize inputs
145148
V = δ * U Eψ0
149+
V = _apply_setops(V, alg.setops)
146150

147151
Ω0 = ConvexHull(X0, Φ * X0 V E⁺)
148152
Ω0 = _apply_setops(Ω0, alg.setops)

0 commit comments

Comments
 (0)