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

#883 - Intersection of two polygons does not detect tighter constraints correctly #884

Merged
merged 6 commits into from
Nov 8, 2018

Conversation

schillic
Copy link
Member

@schillic schillic commented Nov 7, 2018

Closes #883.

@schillic schillic requested a review from mforets November 7, 2018 22:23
@mforets
Copy link
Member

mforets commented Nov 8, 2018

This example now returns a bounds error:

ph = convert(HPolygon, p)
qh = convert(HPolygon, q)
intersection(ph, qh)

BoundsError: attempt to access 5-element Array{HalfSpace{Float64},1} at index [7:7]

Stacktrace:
 [1] throw_boundserror(::Array{HalfSpace{Float64},1}, ::Tuple{UnitRange{Int64}}) at ./abstractarray.jl:492
 [2] checkbounds at ./abstractarray.jl:457 [inlined]
 [3] getindex(::Array{HalfSpace{Float64},1}, ::UnitRange{Int64}) at ./array.jl:737
 [4] (::getfield(LazySets, Symbol("#add_remaining_constraints!#75")))(::Array{HalfSpace{Float64},1}, ::Int64, ::Array{HalfSpace{Float64},1}, ::Int64, ::Int64) at /Users/forets/.julia/dev/LazySets/src/concrete_intersection.jl:133
 [5] (::getfield(LazySets, Symbol("#choose_first_diff_dir!#76")){getfield(LazySets, Symbol("#add_remaining_constraints!#75"))})(::Array{HalfSpace{Float64},1}, ::Int64, ::Int64, ::Int64, ::Array{HalfSpace{Float64},1}, ::Array{HalfSpace{Float64},1}, ::Int64) at /Users/forets/.julia/dev/LazySets/src/concrete_intersection.jl:141
 [6] intersection(::HPolygon{Float64}, ::HPolygon{Float64}) at /Users/forets/.julia/dev/LazySets/src/concrete_intersection.jl:207
 [7] top-level scope at In[79]:3

@schillic
Copy link
Member Author

schillic commented Nov 8, 2018

Thanks, I had introduced a new bug. This is fixed now and a new unit test checks it.

@mforets
Copy link
Member

mforets commented Nov 8, 2018

Ok. Now it returns the same peaked object as before, so the fix should be somewhere else. BTW note that

function intersection2(P1, P2)
    P = HPolygon()
    addconstraint!.(P, constraints_list(P1))
    addconstraint!.(P, constraints_list(P2))
    return P
end

runs in 2.875 ms (797 allocations: 50.73 KiB) for that example, whereas intersection takes
2.226 μs (3 allocations: 288 bytes) 💯

@schillic schillic merged commit 08b4fc3 into master Nov 8, 2018
@schillic schillic deleted the schillic/883 branch November 8, 2018 11:40
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.

2 participants