Skip to content

box_approximation over interection(<unbounded set>, ::AbstractPolytope) throws assertion error #3844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Zinoex opened this issue May 15, 2025 · 3 comments · May be fixed by #3845
Open

box_approximation over interection(<unbounded set>, ::AbstractPolytope) throws assertion error #3844

Zinoex opened this issue May 15, 2025 · 3 comments · May be fixed by #3845
Assignees
Labels
bug 🐛 Something isn't working

Comments

@Zinoex
Copy link
Contributor

Zinoex commented May 15, 2025

If computing say box_approximation((Hyperrectangle(;low=[19.5], high=[20.5]) × Universe(1)) ∩ Hyperrectangle(;low=[19.5, 19.0], high=[20.5, 22.0])) (not the most interesting example, I know, but I ran into it with this where I have no control over the LHS of the intersection) then LazySets throws the assertion error: "AssertionError: the first set in the intersection must be bounded". The box approximation over this intersection is however well-defined. The order does not matter due to swap in ρ for Intersections.

The same thing happens for the following example:

box_approximation(Hyperrectangle(;
        low=[-12.0, -12.0, -0.5, -2.5, -0.35, -0.5, -0.05],
        high=[12.0, 12.0, 0.5, 2.5, 0.35, 0.5, 0.05],
    ) ∩ HalfSpace([0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0], 0.1))
@schillic
Copy link
Member

The order does not matter due to swap in ρ for Intersections.

Unfortunately, the code orders the arguments to have the general set first and the AbstractPolyhedron second. This does not work here. ρ for Intersections is really ugly and would need a revision.

That said, I believe for box_approximation, there should be a workaround: the keyword argument algorithm="simple" could be passed to ρ because the simple "min" heuristics should be sufficient here. I may be wrong, but for now I sent a potential patch in #3845.

@schillic schillic added the bug 🐛 Something isn't working label May 16, 2025
@Zinoex
Copy link
Contributor Author

Zinoex commented May 16, 2025

Out of ignorance and curiosity, can I ask why algorithm="simple" does not work in the general case?

@schillic
Copy link
Member

schillic commented May 16, 2025

It does work, but it can give arbitrarily bad approximations. After thinking about it, it probably does also in this case, so I do not think anymore that the current proposal in #3845 is a good solution.

Instead, I will probably change my proposal to defining box_approximation for Intersections and checking whether the arguments satisfy ispolyhedral, and if so, letting it create a Polyhedron.
EDIT: Done.

Below is an example showing that box_approximation is already not precise even for Intersections of bounded sets. (But here it uses another approximation algorithm based on line search.)

julia> X = Ball1(zeros(2), 1.);

julia> Y = Ball1([0.5,0], 1.);

julia> box_approximation(X  Y)
Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}([0.12499999871910017, 0.0], [0.8750000012809, 0.7500000025617999])

Image

@schillic schillic self-assigned this May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants