Skip to content
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

#3414 - fix _two_points_1d! & better vertices_list of 1D HPolytope #3415

Merged
merged 3 commits into from
Jan 5, 2024

Conversation

schillic
Copy link
Member

@schillic schillic commented Jan 3, 2024

Closes #3414.

Interestingly, Polyhedra's 1D backend is much better. This suggests to use a smarter algorithm for low/high/extrema of HPolytope/HPolyhedron in 1D. I still suggest that we merge this branch and add these algorithms in a separate issue.

julia> P = convert(HPolytope, Interval(1, 2))

julia> @time vertices_list(P)  # new behavior in this branch
  0.000328 seconds (691 allocations: 41.000 KiB)
2-element Vector{Vector{Float64}}:
 [1.0]
 [2.0]

julia> @time vertices_list(P; backend=LazySets.default_polyhedra_backend_1d(Float64))  # old behavior
  0.000092 seconds (51 allocations: 2.094 KiB)
2-element Vector{SVector{1, Float64}}:
 [2.0]
 [1.0]

julia> @time vertices_list(P; backend=LazySets.default_polyhedra_backend_nd(Float64))
glp_simplex: unable to recover undefined or non-optimal solution
  0.001231 seconds (2.28 k allocations: 55.672 KiB)
2-element Vector{Vector{Float64}}:
 [1.0]
 [2.0]

@mforets
Copy link
Member

mforets commented Jan 3, 2024

did you compare with @btime? running times can have quite big variance if used only with @time

@schillic
Copy link
Member Author

schillic commented Jan 3, 2024

It was about the allocations mainly. In general this is a non-issue because 1D sets are super fast anyway.

julia> @btime vertices_list(P)
  90.781 μs (691 allocations: 41.00 KiB)

julia> @btime vertices_list(P; backend=LazySets.default_polyhedra_backend_1d(Float64))
  7.331 μs (51 allocations: 2.09 KiB)

julia> @btime vertices_list(P; backend=LazySets.default_polyhedra_backend_nd(Float64))
  354.879 μs (2286 allocations: 55.78 KiB)

@schillic schillic marked this pull request as ready for review January 3, 2024 19:34
@schillic schillic merged commit 9b71efa into master Jan 5, 2024
6 of 7 checks passed
@schillic schillic deleted the schillic/3414 branch January 5, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

convex_hull of two 1D points modifies points in-place
2 participants