From b1a0369316558016bde218068bfde63b18d4641d Mon Sep 17 00:00:00 2001 From: mforets Date: Wed, 29 Aug 2018 19:08:02 -0300 Subject: [PATCH 1/4] rename intersect -> intersection for the concrete operation --- src/HPolytope.jl | 16 ++++++++-------- src/VPolytope.jl | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/HPolytope.jl b/src/HPolytope.jl index 355d8e522f..72efdd8538 100644 --- a/src/HPolytope.jl +++ b/src/HPolytope.jl @@ -213,7 +213,7 @@ import Polyhedra:polyhedron, SimpleHRepresentation, SimpleHRepresentation, hcartesianproduct, points -export intersect, convex_hull, cartesian_product, vertices_list +export intersection, convex_hull, cartesian_product, vertices_list # HPolytope from an HRep function HPolytope(P::HRep{N, T}, backend=CDDLib.CDDLibrary()) where {N, T} @@ -246,9 +246,9 @@ function polyhedron(P::HPolytope{N}, backend=CDDLib.CDDLibrary()) where {N} end """ - intersect(P1::HPolytope{N}, P2::HPolytope{N}; - [backend]=CDDLib.CDDLibrary(), - [prunefunc]=removehredundancy!)::HPolytope{N} where {N<:Real} + intersection(P1::HPolytope{N}, P2::HPolytope{N}; + [backend]=CDDLib.CDDLibrary(), + [prunefunc]=removehredundancy!)::HPolytope{N} where {N<:Real} Compute the intersection of two polytopes in H-representation. @@ -266,13 +266,13 @@ Compute the intersection of two polytopes in H-representation. The `HPolytope` obtained by the intersection of `P1` and `P2`. """ -function intersect(P1::HPolytope{N}, P2::HPolytope{N}; - backend=CDDLib.CDDLibrary(), - prunefunc=removehredundancy!)::HPolytope{N} where {N<:Real} +function intersection(P1::HPolytope{N}, P2::HPolytope{N}; + backend=CDDLib.CDDLibrary(), + prunefunc=removehredundancy!)::HPolytope{N} where {N<:Real} P1 = polyhedron(P1, backend) P2 = polyhedron(P2, backend) - Pint = intersect(P1, P2) + Pint = Polyhedra.intersect(P1, P2) prunefunc(Pint) return HPolytope(Pint) end diff --git a/src/VPolytope.jl b/src/VPolytope.jl index 5d86606669..f8b51d5680 100644 --- a/src/VPolytope.jl +++ b/src/VPolytope.jl @@ -129,7 +129,7 @@ import Polyhedra:polyhedron, SimpleHRepresentation, SimpleVRepresentation, convexhull, hcartesianproduct -export intersect, convex_hull, cartesian_product, vertices_list +export intersection, convex_hull, cartesian_product, vertices_list # VPolytope from a VRep function VPolytope(P::VRep{N, T}, backend=CDDLib.CDDLibrary()) where {N, T} @@ -162,9 +162,9 @@ function polyhedron(P::VPolytope{N}, backend=CDDLib.CDDLibrary()) where {N} end """ - intersect(P1::VPolytope{N}, P2::VPolytope{N}; - [backend]=CDDLib.CDDLibrary(), - [prunefunc]=removehredundancy!)::VPolytope{N} where {N<:Real} + intersection(P1::VPolytope{N}, P2::VPolytope{N}; + [backend]=CDDLib.CDDLibrary(), + [prunefunc]=removehredundancy!)::VPolytope{N} where {N<:Real} Compute the intersection of two polytopes in V-representation. @@ -182,13 +182,13 @@ Compute the intersection of two polytopes in V-representation. The `VPolytope` obtained by the intersection of `P1` and `P2`. """ -function intersect(P1::VPolytope{N}, P2::VPolytope{N}; - backend=CDDLib.CDDLibrary(), - prunefunc=removehredundancy!)::VPolytope{N} where {N<:Real} +function intersection(P1::VPolytope{N}, P2::VPolytope{N}; + backend=CDDLib.CDDLibrary(), + prunefunc=removehredundancy!)::VPolytope{N} where {N<:Real} P1 = polyhedron(P1, backend) P2 = polyhedron(P2, backend) - Pint = intersect(P1, P2) + Pint = Polyhedra.intersect(P1, P2) prunefunc(Pint) return VPolytope(Pint) end From 252d80fd2e047e0054ffef053f8ea5ad255234ea Mon Sep 17 00:00:00 2001 From: mforets Date: Wed, 29 Aug 2018 19:08:13 -0300 Subject: [PATCH 2/4] update tests --- test/unit_Polytope.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit_Polytope.jl b/test/unit_Polytope.jl index fc58961a72..d86bb42a88 100644 --- a/test/unit_Polytope.jl +++ b/test/unit_Polytope.jl @@ -105,7 +105,7 @@ if test_suite_polyhedra A = [N(0) N(-1); N(-1) N(0); N(1) N(1)] b = N[-0.25, -0.25, -0] p2 = HPolytope(A, b) - cap = intersect(p1, p2) + cap = intersection(p1, p2) # currently broken, see #565 # convex hull @@ -135,7 +135,7 @@ if test_suite_polyhedra # intersection p1 = VPolytope(vertices_list(BallInf(N[0, 0], N(1)))) p2 = VPolytope(vertices_list(BallInf(N[2, 2], N(1)))) - cap = intersect(p1, p2) + cap = intersection(p1, p2) @test vertices_list(cap) == [N[1, 1]] # convex hull From 919ab96f3fc283f6fd9cdfa9d4d5f0885691dc1c Mon Sep 17 00:00:00 2001 From: mforets Date: Wed, 29 Aug 2018 19:08:22 -0300 Subject: [PATCH 3/4] update docs --- docs/src/lib/representations.md | 2 ++ docs/src/man/concrete_polyhedra.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/lib/representations.md b/docs/src/lib/representations.md index 5033268141..057a240671 100644 --- a/docs/src/lib/representations.md +++ b/docs/src/lib/representations.md @@ -349,6 +349,7 @@ dim(::HPolytope) addconstraint!(::HPolytope{Real}, ::LinearConstraint{Real}) constraints_list(::HPolytope) tosimplehrep(::HPolytope) +intersection(::HPolytope, ::HPolytope) ``` Inherited from [`LazySet`](@ref): * [`norm`](@ref norm(::LazySet, ::Real)) @@ -366,6 +367,7 @@ VPolytope dim(::VPolytope) σ(::AbstractVector{Real}, ::VPolytope{Real}) vertices_list(::VPolytope) +intersection(::VPolytope, ::VPolytope) ``` Inherited from [`LazySet`](@ref): * [`norm`](@ref norm(::LazySet, ::Real)) diff --git a/docs/src/man/concrete_polyhedra.md b/docs/src/man/concrete_polyhedra.md index cc6446433c..4897bf334b 100644 --- a/docs/src/man/concrete_polyhedra.md +++ b/docs/src/man/concrete_polyhedra.md @@ -108,7 +108,7 @@ polyoverapprox(x) = HPolytope(overapproximate(x, 1e-3).constraints) Epoly = polyoverapprox(E) Bpoly = polyoverapprox(B) -X = intersect(Epoly, Bpoly) +X = intersecttion(Epoly, Bpoly) plot(E, 1e-3, aspectratio=1, alpha=0.4) plot!(B, 1e-3, alpha=0.4) From 9ba47d65b2ed12bea472a4b38041e91d062fb524 Mon Sep 17 00:00:00 2001 From: mforets Date: Thu, 30 Aug 2018 09:16:17 -0300 Subject: [PATCH 4/4] revise docs --- docs/src/lib/representations.md | 2 -- docs/src/man/concrete_polyhedra.md | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/src/lib/representations.md b/docs/src/lib/representations.md index 057a240671..5033268141 100644 --- a/docs/src/lib/representations.md +++ b/docs/src/lib/representations.md @@ -349,7 +349,6 @@ dim(::HPolytope) addconstraint!(::HPolytope{Real}, ::LinearConstraint{Real}) constraints_list(::HPolytope) tosimplehrep(::HPolytope) -intersection(::HPolytope, ::HPolytope) ``` Inherited from [`LazySet`](@ref): * [`norm`](@ref norm(::LazySet, ::Real)) @@ -367,7 +366,6 @@ VPolytope dim(::VPolytope) σ(::AbstractVector{Real}, ::VPolytope{Real}) vertices_list(::VPolytope) -intersection(::VPolytope, ::VPolytope) ``` Inherited from [`LazySet`](@ref): * [`norm`](@ref norm(::LazySet, ::Real)) diff --git a/docs/src/man/concrete_polyhedra.md b/docs/src/man/concrete_polyhedra.md index 4897bf334b..53cc890a85 100644 --- a/docs/src/man/concrete_polyhedra.md +++ b/docs/src/man/concrete_polyhedra.md @@ -96,8 +96,8 @@ product. The dual representation as a list of vertices can be obtained with the `vertices_list` function. -For example, the intersection of two polytopes is performed with the `intersect` -method. +For example, the concrete intersection of two polytopes is performed with the +`intersection` method. ```@example concrete_polyhedra E = Ellipsoid(ones(2), diagm([2.0, 0.5])) @@ -108,7 +108,7 @@ polyoverapprox(x) = HPolytope(overapproximate(x, 1e-3).constraints) Epoly = polyoverapprox(E) Bpoly = polyoverapprox(B) -X = intersecttion(Epoly, Bpoly) +X = intersection(Epoly, Bpoly) plot(E, 1e-3, aspectratio=1, alpha=0.4) plot!(B, 1e-3, alpha=0.4)