From 3abf3e2f7a9268f33d76991174f7de8a7b5a592c Mon Sep 17 00:00:00 2001 From: mforets Date: Wed, 27 Feb 2019 15:03:50 -0300 Subject: [PATCH 1/3] add special case for overapproximate of linear map --- src/Approximations/overapproximate.jl | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Approximations/overapproximate.jl b/src/Approximations/overapproximate.jl index a64904bf05..6350145bb9 100644 --- a/src/Approximations/overapproximate.jl +++ b/src/Approximations/overapproximate.jl @@ -115,6 +115,37 @@ function overapproximate(S::CartesianProductArray{N, <:AbstractHyperrectangle{N} return convert(Hyperrectangle, S) end +""" + overapproximate(lm::LinearMap{N, <:AbstractHyperrectangle{N}}, + ::Type{Hyperrectangle}) where {N} + +Return a tight overapproximation of the linear map of a hyperrectangular set +using a hyperrectangle. + +### Input + +- `S` -- linear map of a hyperrectangular set +- `Hyperrectangle` -- type for dispatch + +### Output + +A hyperrectangle. + +### Algorithm + +If `c` and `r` denote the center and vector radius of a hyperrectangle `H`, +a tight hyperrectangular overapproximation of `M * H` is obtained by transforming +`c ↦ M*c` and `r ↦ abs.(⋅) * c`, where `abs.(⋅)` denotes the element-wise absolute +value operator. +""" +function overapproximate(lm::LinearMap{N, <:AbstractHyperrectangle{N}}, + ::Type{Hyperrectangle}) where {N<:Real} + M, X = lm.M, lm.X + center_MX = M * center(X) + radius_MX = abs.(M) * radius_hyperrectangle(X) + return Hyperrectangle(center_MX, radius_MX) +end + """ overapproximate(S::LazySet)::Union{Hyperrectangle, EmptySet} @@ -413,3 +444,4 @@ function overapproximate(cap::Intersection{N, ) where {N<:Real} return overapproximate(swap(cap), dir; kwargs...) end + From 89c4fa44fd28e283d35b5846adec125425fa7afe Mon Sep 17 00:00:00 2001 From: mforets Date: Wed, 27 Feb 2019 15:16:45 -0300 Subject: [PATCH 2/3] add unit test --- test/unit_overapproximate.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/unit_overapproximate.jl b/test/unit_overapproximate.jl index 7c5486be98..28c73ecf66 100644 --- a/test/unit_overapproximate.jl +++ b/test/unit_overapproximate.jl @@ -43,6 +43,12 @@ for N in [Float64, Rational{Int}, Float32] Zoa = overapproximate(Z, Hyperrectangle) # faster o.a. Zba = box_approximation(Z) # default o.a. implementation that uses supp function @test Zoa.center ≈ Zba.center && Zoa.radius ≈ Zba.radius + + # overapproximation of the lazy linear map of a hyperrectangular set + H = Hyperrectangle(N[0, 0], N[1/2, 1]) + M = Diagonal(N[2, 2]) + OA = overapproximate(M*H, Hyperrectangle) + @test OA isa Hyperrectangle && OA.center == N[0, 0] && OA.radius == N[1, 2] end # tests that do not work with Rational{Int} From 42f7f9f07e66f0f465c89fc4076275ed6bdc77f5 Mon Sep 17 00:00:00 2001 From: Marcelo Forets Date: Wed, 27 Feb 2019 15:17:40 -0300 Subject: [PATCH 3/3] Update src/Approximations/overapproximate.jl --- src/Approximations/overapproximate.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Approximations/overapproximate.jl b/src/Approximations/overapproximate.jl index 6350145bb9..3df97a7c4c 100644 --- a/src/Approximations/overapproximate.jl +++ b/src/Approximations/overapproximate.jl @@ -135,7 +135,7 @@ A hyperrectangle. If `c` and `r` denote the center and vector radius of a hyperrectangle `H`, a tight hyperrectangular overapproximation of `M * H` is obtained by transforming -`c ↦ M*c` and `r ↦ abs.(⋅) * c`, where `abs.(⋅)` denotes the element-wise absolute +`c ↦ M*c` and `r ↦ abs.(M) * c`, where `abs.(⋅)` denotes the element-wise absolute value operator. """ function overapproximate(lm::LinearMap{N, <:AbstractHyperrectangle{N}},