From 6eede35d645e9c6cadee698c44cbf1a993feff0c Mon Sep 17 00:00:00 2001 From: schillic Date: Mon, 11 Mar 2024 17:49:00 +0100 Subject: [PATCH 1/2] remove exponential sizehint --- src/LazyOperations/Rectification.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LazyOperations/Rectification.jl b/src/LazyOperations/Rectification.jl index 8ffab95b1e..37a49e5d26 100644 --- a/src/LazyOperations/Rectification.jl +++ b/src/LazyOperations/Rectification.jl @@ -522,7 +522,6 @@ function to_union_of_projections(R::Rectification{N}, m = length(mixed_dimensions) i = m projections = Vector{LinearMap{N}}() - sizehint!(projections, 2^m) while true # compute next projection polyhedron = construct_constraints(mixed_dimensions, From 9dcba9710818ae117bbeedf89f4a1a6906e83cc2 Mon Sep 17 00:00:00 2001 From: schillic Date: Mon, 11 Mar 2024 18:01:01 +0100 Subject: [PATCH 2/2] filter empty intersections in to_union_of_projections --- src/LazyOperations/Rectification.jl | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/LazyOperations/Rectification.jl b/src/LazyOperations/Rectification.jl index 37a49e5d26..26a92bb6c2 100644 --- a/src/LazyOperations/Rectification.jl +++ b/src/LazyOperations/Rectification.jl @@ -462,6 +462,8 @@ Compute an equivalent union of projections from a rectification. - `R` -- rectification - `concrete_intersection` -- (optional, default: `false`) option to compute all intersections concretely or lazily +- `filter_empty_sets` -- (optional, default: `true`) option to filter out + empty sets in the union ### Algorithm @@ -500,7 +502,8 @@ The result can be one of three cases depending on the wrapped set ``X``, namely * a `UnionSetArray` of `LinearMap`s (projections) otherwise. """ function to_union_of_projections(R::Rectification{N}, - concrete_intersection::Bool=false) where {N} + concrete_intersection::Bool=false; + filter_empty_sets::Bool=true) where {N} n = dim(R.X) negative_dimensions, mixed_dimensions, mixed_dimensions_enumeration = compute_negative_and_mixed_dimensions(R.X, @@ -527,13 +530,19 @@ function to_union_of_projections(R::Rectification{N}, polyhedron = construct_constraints(mixed_dimensions, mixed_dimensions_enumeration, n, N) - cap = concrete_intersection ? - intersection(R.X, polyhedron) : R.X ∩ polyhedron - projection = construct_projection(cap, - negative_dimensions, - mixed_dimensions, - mixed_dimensions_enumeration, n) - push!(projections, projection) + if !filter_empty_sets || !isdisjoint(R.X, polyhedron) + if concrete_intersection + cap = intersection(R.X, polyhedron) + else + cap = Intersection(R.X, polyhedron) + set_isempty!(cap, false) # intersection is known to not be empty + end + projection = construct_projection(cap, + negative_dimensions, + mixed_dimensions, + mixed_dimensions_enumeration, n) + push!(projections, projection) + end if mixed_dimensions_enumeration[i] @inbounds while i > 0 && mixed_dimensions_enumeration[i]