Skip to content

Commit f71dd02

Browse files
authored
Merge pull request #621 from JuliaReach/schillic/620
#620 - overapproximate in LazyDiscretePost for singular map
2 parents 659fa03 + ffd6a13 commit f71dd02

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/ReachSets/DiscretePost/LazyDiscretePost.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct LazyDiscretePost <: DiscretePost
2727
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:overapproximation], Hyperrectangle)
2828
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:lazy_R⋂I], false)
2929
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:lazy_R⋂G], true)
30-
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:lazy_A⌜R⋂G⌟], true)
30+
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:lazy_A⌜R⋂G⌟], "invertible")
3131
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:lazy_A⌜R⋂G⌟⋂I], true)
3232
check_aliases_and_add_default_value!(𝑂.dict, 𝑂copy.dict, [:combine_invariant_guard], 𝑂copy[:lazy_R⋂I])
3333

@@ -158,7 +158,9 @@ function post(𝒫::LazyDiscretePost,
158158

159159
# apply assignment
160160
A⌜R⋂G⌟ = apply_assignment(𝒫, constrained_map, R⋂G)
161-
if !𝒫.options[:lazy_A⌜R⋂G⌟]
161+
if 𝒫.options[:lazy_A⌜R⋂G⌟] == "always" ||
162+
(𝒫.options[:lazy_A⌜R⋂G⌟] == "invertible" &&
163+
!isinvertible(constrained_map))
162164
A⌜R⋂G⌟ = overapproximate(A⌜R⋂G⌟, oa)
163165
end
164166

src/Utils/Utils.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export template_direction_symbols,
3737
export normalize,
3838
distribute_initial_set
3939

40+
# others
41+
export isinvertible
42+
4043
# Extension of MathematicalSystems for use inside Reachability.jl
4144
include("systems.jl")
4245

@@ -378,4 +381,34 @@ function matrix_conversion(Δ, options; A_passed=nothing)
378381
return Δ
379382
end
380383

384+
"""
385+
isinvertible(map::AbstractMap)
386+
387+
Check if the matrix of an affine map is invertible.
388+
389+
### Input
390+
391+
- `map` -- an affine map
392+
393+
### Output
394+
395+
`true` if the matrix is invertible.
396+
Because we use a sufficient criterion, there can be false positives.
397+
"""
398+
function isinvertible(map::AbstractMap)
399+
throw(ArgumentError("isinvertible(::$(typeof(map))) is not implemented"))
400+
end
401+
function isinvertible(map::ConstrainedIdentityMap)
402+
return true
403+
end
404+
function isinvertible(map::ConstrainedLinearMap)
405+
return LazySets.isinvertible(map.A)
406+
end
407+
function isinvertible(map::ConstrainedAffineMap)
408+
return LazySets.isinvertible(map.A)
409+
end
410+
function isinvertible(map::ConstrainedResetMap)
411+
return false
412+
end
413+
381414
end # module

0 commit comments

Comments
 (0)