# LazySets: overapproximate sum of two HPolyhedron in 3D (or n-D)

**URL:** <https://discourse.julialang.org/t/lazysets-overapproximate-sum-of-two-hpolyhedron-in-3d-or-n-d/24396>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 20, 2019, 11:04am UTC](https://discourse.julialang.org/t/lazysets-overapproximate-sum-of-two-hpolyhedron-in-3d-or-n-d/24396 "2019-05-20T11:04:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uwechsler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwechsler/32/5223_2.png) [@uwechsler](https://discourse.julialang.org/u/uwechsler)\
**Post date:** [May 20, 2019, 11:04am UTC](https://discourse.julialang.org/t/lazysets-overapproximate-sum-of-two-hpolyhedron-in-3d-or-n-d/24396/1 "2019-05-20T11:04:51Z")

</div>

I am using the package [LazySets](https://github.com/JuliaReach/LazySets.jl) to compute the Minkowsky sum of two HPolyhedron and then extract the resulting constraints to feed them into my JuMP model.  
For the 2D case, I can approximate the exact Polyhedron with overapproximate, like this:

```julia
n = 2
A = [Matrix{Float64}(I, n,n); -Matrix{Float64}(I, n,n)]
b = 0.1*ones(size(A,1))
hPoly = HPolyhedron(A, b)
minkowSum = hPoly ⊕ hPoly 
overapproximate(minkowSum , 1e-3)

```

However, for higher dimensional Polyhedron (e.g. n=3) overapproximate throws an error. Is there a way to approximate the HPolyhedron resulting from the Minkowsky addition for n=3 with LazySets or [Polyhedra](https://github.com/JuliaPolyhedra/Polyhedra.jl)?

---

<div class="post-metadata">

**Author:** ![uwechsler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwechsler/32/5223_2.png) [@uwechsler](https://discourse.julialang.org/u/uwechsler)\
**Post date:** [July 5, 2019, 1:19pm UTC](https://discourse.julialang.org/t/lazysets-overapproximate-sum-of-two-hpolyhedron-in-3d-or-n-d/24396/2 "2019-07-05T13:19:42Z")

</div>

For anybody having similar issues, here is a short update:

Overapproximating an `AbstractPolytope` with n\ge4 is not implemented yet. For any updates on that topic, consider:  
[https://github.com/JuliaReach/LazySets.jl/issues/969](https://github.com/JuliaReach/LazySets.jl/issues/969)

If you want to overapproximate an `AbstractPolytope` with n=3, the following code can be used

```julia
using LazySets
using Polyhedra
P = rand(HPolytope, dim=n)
A = rand(n,n)
minkowSum= A*P + P
dirs = SphericalDirections(10, 10)
oa = overapproximate(minkowSum, dirs)

```

The link below refers to the GitHub issue, where additional references can be found.  
[https://github.com/JuliaReach/LazySets.jl/issues/1476](https://github.com/JuliaReach/LazySets.jl/issues/1476)
