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

Add NoBloating approximation model #209

Merged
merged 2 commits into from
May 30, 2020
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
45 changes: 43 additions & 2 deletions src/Continuous/discretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ function Backward(; exp::Symbol=:base, setops::Symbol=:lazy, sih::Symbol=:concre
Backward(Val(exp), Val(setops), Val(sih))
end

struct Discrete <: AbstractApproximationModel
#
# no bloating or "discrete time" approximation model ref Eqs. (14) in [[BFFPSV18]]
struct NoBloating{EM, SO} <: AbstractApproximationModel
exp::EM
setops::SO
end

# convenience constructor using symbols
function NoBloating(; exp::Symbol=:base, setops::Symbol=:lazy)
NoBloating(Val(exp), Val(setops))
end

struct CorrectionHull{EM} <: AbstractApproximationModel
Expand Down Expand Up @@ -178,3 +185,37 @@ function discretize(ivp::IVP{<:CLCS, <:LazySet}, δ, alg::CorrectionHull)
ivp_discr = ConstrainedLinearDiscreteSystem(Φ, X)
return InitialValueProblem(ivp_discr, Ω0)
end

# ============================================================
# NoBloating Approximation
# ============================================================

# homogeneous case
function discretize(ivp::IVP{<:CLCS, <:LazySet}, δ, alg::NoBloating)
A = state_matrix(ivp)
X0 = initial_state(ivp)

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

Ω0 = copy(X0)
X = stateset(ivp)
Sdiscr = ConstrainedLinearDiscreteSystem(Φ, X)
return InitialValueProblem(Sdiscr, Ω0)
end

# inhomogeneous case
function discretize(ivp::IVP{<:CLCCS, <:LazySet}, δ, alg::NoBloating)
A = state_matrix(ivp)
X0 = initial_state(ivp)

Φ = _exp(A, δ, alg.exp)
M = Φ₁(A, δ, alg.exp)
U = next_set(inputset(ivp), 1) # inputset(ivp)
Ud = M * U # TODO assert alg.setops / alg.inputsetops are lazy
In = IdentityMultiple(one(eltype(A)), size(A, 1))

Ω0 = copy(X0)
X = stateset(ivp)
Sdiscr = ConstrainedLinearControlDiscreteSystem(Φ, In, X, Ud)
return InitialValueProblem(Sdiscr, Ω0)
end
1 change: 1 addition & 0 deletions src/Initialization/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export
Backward,
Discrete,
CorrectionHull,
NoBloating,

# Flowpipes
flowpipe,
Expand Down
19 changes: 15 additions & 4 deletions test/algorithms/GLGM06.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
@testset "GLGM06 algorithm" begin

# one-dimensional
prob, tspan = exponential_1d()
sol = solve(prob, tspan=tspan, GLGM06(δ=0.01))
prob, _ = exponential_1d()
sol = solve(prob, T=5.0, GLGM06(δ=0.01))
@test isa(sol.alg, GLGM06)
@test setrep(sol) <: Zonotope
@test setrep(sol) == Zonotope{Float64,Array{Float64,1},Array{Float64,2}}
@test dim(sol) == 1

# higher-dimensional homogeneous
prob, tspan = linear5D_homog()
sol = solve(prob, tspan=tspan, GLGM06(δ=0.01))
prob, _ = linear5D_homog()
sol = solve(prob, T=5.0, GLGM06(δ=0.01))
@test dim(sol) == 5

# static option TODO
Expand All @@ -21,4 +21,15 @@
# TODO higher-dimensional with input
#prob, tspan = linear5D()
#sol = solve(prob, tspan=tspan, GLGM06(δ=0.01))

# use approx model for "discrete-time" reachability
sol = solve(prob, T=5.0, GLGM06(δ=0.01, approx_model=NoBloating()))

# higher-dimensional inhomogeneous
prob, _ = linear5D_homog()
sol = solve(prob, T=5.0, GLGM06(δ=0.01))
@test dim(sol) == 5

# use approx model for "discrete-time" reachability
sol = solve(prob, T=5.0, GLGM06(δ=0.01, approx_model=NoBloating()))
end