Skip to content

Commit

Permalink
make helper function a dict
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Mar 4, 2019
1 parent cfbbbfd commit 8983b0c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 38 deletions.
6 changes: 2 additions & 4 deletions src/ReachSets/ContinuousPost/BFFPSV18/check_property.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ function check_property(S::IVP{<:AbstractDiscreteSystem},
n = statedim(S)
blocks = options[:blocks]
partition = convert_partition(options[:partition])
dir = interpret_template_direction_symbol(
options[:template_directions_init])
dir = template_direction_symbols[options[:template_directions_init]]
block_sizes = compute_block_sizes(partition)
N = ceil(Int, options[:T] / options[])
ε_init = options[:ε_init]
Expand Down Expand Up @@ -90,8 +89,7 @@ function check_property(S::IVP{<:AbstractDiscreteSystem},
push!(args, U)

# raw overapproximation function
dir = interpret_template_direction_symbol(
options[:template_directions_iter])
dir = template_direction_symbols[options[:template_directions_iter]]
if dir != nothing
overapproximate_fun =
(i, x) -> overapproximate(x, dir(length(partition[i])))
Expand Down
6 changes: 2 additions & 4 deletions src/ReachSets/ContinuousPost/BFFPSV18/reach.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ function reach(S::Union{IVP{<:LDS{NUM}, <:LazySet{NUM}},
n = statedim(S)
blocks = options[:blocks]
partition = convert_partition(options[:partition])
dir = interpret_template_direction_symbol(
options[:template_directions_init])
dir = template_direction_symbols[options[:template_directions_init]]
block_sizes = compute_block_sizes(partition)
N = ceil(Int, options[:T] / options[])
ε_init = options[:ε_init]
Expand Down Expand Up @@ -115,8 +114,7 @@ function reach(S::Union{IVP{<:LDS{NUM}, <:LazySet{NUM}},
push!(args, U)

# overapproximation function for states
dir = interpret_template_direction_symbol(
options[:template_directions_iter])
dir = template_direction_symbols[options[:template_directions_iter]]
if dir != nothing
overapproximate_fun = (i, x) -> overapproximate(x, dir(length(partition[i])))
elseif options[:block_types_iter] != nothing
Expand Down
2 changes: 1 addition & 1 deletion src/ReachSets/DiscretePost/DiscretePost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ end
function get_overapproximation_option(𝒫::DiscretePost, n::Int)
oa = 𝒫.options[:overapproximation]
if oa isa Symbol
dirs = Utils.interpret_template_direction_symbol(oa)
dirs = Utils.template_direction_symbols[oa]
return dirs(n)
elseif oa <: LazySets.LazySet
return oa
Expand Down
35 changes: 6 additions & 29 deletions src/Utils/Utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export @filename_to_png,
@relpath

# internal conversion
export interpret_template_direction_symbol,
export template_direction_symbols,
matrix_conversion,
matrix_conversion_lazy_explicit

Expand Down Expand Up @@ -407,34 +407,11 @@ function convert_partition(partition::AbstractVector{<:AbstractVector{Int}})::Un
return partition_out
end

"""
interpret_template_direction_symbol(symbol::Symbol)
Return a template direction type for a given symbol.
### Input
- `symbol` -- symbol
### Output
The template direction type if it is known, or `nothing` otherwise.
"""
function interpret_template_direction_symbol(symbol::Symbol)
if symbol == :box
dir = Approximations.BoxDirections
elseif symbol == :oct
dir = Approximations.OctDirections
elseif symbol == :boxdiag
dir = Approximations.BoxDiagDirections
else
if symbol != :nothing
warn("ignoring unknown template direction $symbol")
end
dir = nothing
end
return dir
end
template_direction_symbols = Dict(
:box => Approximations.BoxDirections,
:oct => Approximations.OctDirections,
:boxdiag => Approximations.BoxDiagDirections
)

"""
compute_block_sizes(partition::Union{Vector{Int}, Vector{UnitRange{Int}}}
Expand Down

0 comments on commit 8983b0c

Please sign in to comment.