Skip to content

Commit

Permalink
Merge pull request #117 from JuliaReach/mforets/67
Browse files Browse the repository at this point in the history
rsetrep to retrieve reach set rep for an algorithm
  • Loading branch information
mforets authored Apr 16, 2020
2 parents 2dee985 + e856746 commit 8f3d6fd
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 12 deletions.
9 changes: 9 additions & 0 deletions src/Algorithms/ASB07/ASB07.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
δ::N
approx_model::AM=CorrectionHull(order=10, exp=:base)
max_order::Int=10
static::Bool=false
end

step_size(alg::ASB07) = alg.δ
numtype(::ASB07{N}) where {N} = N
function rsetrep(::ASB07{N}) where {N}
if static
error("not implemented")
else
RT = ReachSet{N, Zonotope{N, Vector{N}, Matrix{N}}}
end
return RT
end

include("post.jl")
include("reach.jl")
2 changes: 1 addition & 1 deletion src/Algorithms/ASB07/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function post(alg::ASB07, ivp::IVP{<:AbstractContinuousSystem}, tspan; kwargs...
Ω0 = _reduce_order(Ω0, max_order)

# reconvert the set of initial states and state matrix, if needed
static = haskey(kwargs, :static) ? kwargs[:static] : false
static = haskey(kwargs, :static) ? kwargs[:static] : alg.static
Ω0 = _reconvert(Ω0, Val(static))
Φ = _reconvert(Φ, Val(static))

Expand Down
4 changes: 4 additions & 0 deletions src/Algorithms/BFFPSV18/BFFPSV18.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ end
step_size(alg::BFFPSV18) = alg.δ
numtype(::BFFPSV18{N}) where {N} = N

function rsetrep(::BFFPSV18{N}) where {N}
error("not implemented")
end

#const _DEFAULT_APPROX_MODEL_BFFPSV18 =

include("post.jl")
Expand Down
9 changes: 9 additions & 0 deletions src/Algorithms/BOX/BOX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@ step ``k ∈ \\mathbb{N}``.
@with_kw struct BOX{N, AM} <: AbstractContinuousPost
δ::N
approx_model::AM=Forward(sih=:concrete, exp=:base, phi2=:base, setops=:lazy)
static::Bool=false
end

step_size(alg::BOX) = alg.δ
numtype(::BOX{N}) where {N} = N
function rsetrep(::BOX{N}) where {N}
if static
error("not implemented")
else
RT = ReachSet{N, Hyperrectangle{N, Vector{N}, Vector{N}}}
end
return RT
end

include("post.jl")
include("reach.jl")
2 changes: 1 addition & 1 deletion src/Algorithms/BOX/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function post(alg::BOX, ivp::IVP{<:AbstractContinuousSystem}, tspan; kwargs...)
Ω0 = overapproximate(Ω0, Hyperrectangle)

# reconvert the set of initial states and state matrix, if needed
static = haskey(kwargs, :static) ? kwargs[:static] : false
static = haskey(kwargs, :static) ? kwargs[:static] : alg.static
Ω0 = _reconvert(Ω0, Val(static))
Φ = _reconvert(Φ, Val(static))

Expand Down
19 changes: 17 additions & 2 deletions src/Algorithms/GLGM06/GLGM06.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,30 @@ See [xxx] and [yyy]
"""
@with_kw struct GLGM06{N, AM} <: AbstractContinuousPost
δ::N
# TODO: use set-operations option
# nota: la opcion set_operations="zonotope" es ignorada (?)
# TODO set_operations="zonotope" used or ignored
approx_model::AM=Forward(sih=:concrete, exp=:base, phi2=:base, setops=:lazy)
max_order::Int=10
static::Bool=false
end

step_size(alg::GLGM06) = alg.δ
numtype(::GLGM06{N}) where {N} = N

function rsetrep(alg::GLGM06{N}) where {N}
if !alg.static
RT = ReachSet{N, Zonotope{N, Vector{N}, Matrix{N}}}
else
error("not implemented")
# n : other parameter of GLGM06 / or just a field alg.dim
# p : order * dimension eg. alg.max_order * alg.dim
# VT = SVector{n, N}
# MT = SMatrix{n, p, N, n*p}
# ZT = Zonotope{N, VT, MT}
# RT = ReachSet{N, ZT}
end
return RT
end

include("post.jl")
include("reach.jl")
#include("check.jl")
2 changes: 1 addition & 1 deletion src/Algorithms/GLGM06/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function post(alg::GLGM06, ivp::IVP{<:AbstractContinuousSystem}, tspan; kwargs..
Ω0 = _reduce_order(Ω0, max_order)

# reconvert the set of initial states and state matrix, if needed
static = haskey(kwargs, :static) ? kwargs[:static] : false
static = haskey(kwargs, :static) ? kwargs[:static] : alg.static
Ω0 = _reconvert(Ω0, Val(static))
Φ = _reconvert(Φ, Val(static))

Expand Down
1 change: 1 addition & 0 deletions src/Algorithms/INT/INT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ end

step_size(alg::INT) = alg.δ
numtype(::INT{N}) where {N} = N
rsetrep(::INT{N}) where {N} = ReachSet{N, Interval{N, IA.Interval{N}}}

include("post.jl")
include("reach.jl")
10 changes: 10 additions & 0 deletions src/Algorithms/LGG09/LGG09.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ See [1] and [2].
δ::N
approx_model::AM=Forward(sih=:concrete, exp=:base, phi2=:base, setops=:lazy)
template::AD
static::Bool=false
end

step_size(alg::LGG09) = alg.δ
numtype(::LGG09{N}) where {N} = N
function rsetrep(alg::LGG09{N}) where {N}
if alg.static
error("not implemented")
else
error("not implemented")
#RT = TemplateReachSet{...}
end
return RT
end

include("reach.jl")
include("post.jl")
2 changes: 1 addition & 1 deletion src/Algorithms/LGG09/post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function post(alg::LGG09, ivp::IVP{<:AbstractContinuousSystem}, tspan; kwargs...
Ω0 = _reduce_order(Ω0, max_order)

# reconvert the set of initial states and state matrix, if needed
static = haskey(kwargs, :static) ? kwargs[:static] : false
static = haskey(kwargs, :static) ? kwargs[:static] : alg.static
Ω0 = _reconvert(Ω0, Val(static))
Φ = _reconvert(Φ, Val(static))

Expand Down
3 changes: 1 addition & 2 deletions src/Algorithms/TMJets/TMJets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ by Luis Benet and David Sanders in `TalorModels.jl`.
abs_tol::N=1e-15
orderT::Int=8
orderQ::Int=2
# setrep::ST=Zonotope{Float64, Vector{Float64}, Matrix{Float64}}
# add setrep as a type?
end

using TaylorModels: TaylorModelN
using TaylorModels: fp_rpa, remainder

numtype(::TMJets{N}) where {N} = N
rsetrep(::TMJets{N}) where {N} = TaylorModelReachSet{N}

include("post.jl")
include("reach.jl")
Expand Down
6 changes: 4 additions & 2 deletions src/Continuous/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end

function _solve_distributed(cpost, S, X0, tspan, threading::Val{true}; kwargs...)
nsets = length(X0)
FT = Flowipe{numtype(cpost), rsetrep(cpost)}
FT = Flowpipe{numtype(cpost), rsetrep(cpost)}
sol_tot = Vector{FT}(undef, nsets)

Threads.@threads for i in 1:length(X0)
Expand Down Expand Up @@ -217,6 +217,7 @@ function _get_cpost(ivp, args...; kwargs...)
got_opC = haskey(kwargs, :opC)
no_args = isempty(args) || args[1] === nothing

# continous post was specified
if got_alg
cpost = kwargs[:alg]
elseif got_algorithm
Expand Down Expand Up @@ -285,7 +286,8 @@ function _default_cpost(ivp::IVP{<:AbstractContinuousSystem}, tspan; kwargs...)
if statedim(ivp) == 1
opC = INT=δ)
else
opC = GLGM06=δ)
static = haskey(kwargs, :static) ? kwargs[:static] : false
opC = GLGM06=δ, static=static)
end
else
opC = TMJets()
Expand Down
4 changes: 3 additions & 1 deletion src/Initialization/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export
tend,
tspan,
vars_idx, # >> call this vars ?
sup_func, # TODO ?
sup_func, # TODO keep?
setrep,
rsetrep,

# Concrete operations
project,
Expand Down
3 changes: 3 additions & 0 deletions test/algorithms/TMJets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
X0s = split(X0, [2, 1]) # split along direction x
sols = solve(IVP(S, X0s), T=0.1, threading=false) # no threading
@test flowpipe(sols) isa MixedFlowpipe

sols = solve(IVP(S, X0s), T=0.1, threading=true) # with threading (default)
@test flowpipe(sols) isa MixedFlowpipe
end

@testset "TMJets algorithm: linear IVPs" begin
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Test, ReachabilityAnalysis, StaticArrays
using ReachabilityAnalysis: _isapprox
using ReachabilityAnalysis: _isapprox, setrep, rsetrep

# load test models
include("models/linear/exponential1D.jl")
Expand Down

0 comments on commit 8f3d6fd

Please sign in to comment.