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

#2646 - Add intersection between star set and halfspace #2654

Merged
merged 9 commits into from
Apr 19, 2021

Conversation

SebastianGuadalupe
Copy link
Member

Closes #2646.

Copy link
Member

@mforets mforets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm if tests pass

we could also add a check of the in-place transformation.

src/Sets/Star.jl Outdated Show resolved Hide resolved
@SebastianGuadalupe
Copy link
Member Author

The new test doesn't pass in my machine, but I don't see why it wouldn't

Copy link
Member

@schillic schillic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general!

src/Sets/Star.jl Outdated Show resolved Hide resolved
src/Sets/Star.jl Outdated Show resolved Hide resolved
src/Sets/Star.jl Outdated Show resolved Hide resolved
@mforets
Copy link
Member

mforets commented Apr 13, 2021

👍 let's wait until tests & docs pass..

@schillic
Copy link
Member

This in-place intersection is problematic if the constraints use a vector type different from Vector. For example convert(HPolyhedron, ::BallInf) creates an HPolyhedron with SingleEntryVector constraints. The new constraint that we want to add does not use this vector type and hence you cannot add it.

julia> using LazySets
julia> N = Float64;
julia> S = Star(N[3, 3], N[1 0; 0 1], BallInf(N[0, 0], N(1)));
julia> H = HalfSpace(N[0, 1], N(0));
julia> I = intersection(S, H)
ERROR: MethodError: Cannot `convert` an object of type 
  HalfSpace{Float64{},Vector{Float64}} to an object of type 
  HalfSpace{Float64{},LazySets.Arrays.SingleEntryVector{Float64}}

I do not see an easy way out. I suggest that in the method

function intersection(X::STAR{N, VN, MN, PT}, H::HalfSpace) where {N, VN, MN, PT<:Union{HPoly, HPolygon, HPolygonOpt}}
    return intersection!(copy(X), H)
end

we check whether the vector type is Vector and if not we first convert X to a STAR with that type.

src/Sets/Star.jl Outdated Show resolved Hide resolved
Co-authored-by: Christian Schilling <[email protected]>
Copy link
Member

@schillic schillic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from my comment here this looks good!

@mforets
Copy link
Member

mforets commented Apr 15, 2021

LazySets.Star: Test Failed at /home/travis/build/JuliaReach/LazySets.jl/test/Sets/Star.jl:47
  Expression: isequivalent(S, P)
Stacktrace:
 [1] top-level scope at /home/travis/build/JuliaReach/LazySets.jl/test/Sets/Star.jl:47
 [2] include(::String) at ./client.jl:457
 [3] macro expansion at /home/travis/build/JuliaReach/LazySets.jl/test/runtests.jl:136 [inlined]
 [4] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1119 [inlined]
 [5] macro expansion at /home/travis/build/JuliaReach/LazySets.jl/test/runtests.jl:136 [inlined]
 [6] macro expansion at ./timing.jl:174 [inlined]
 [7] top-level scope at /home/travis/build/JuliaReach/LazySets.jl/test/runtests.jl:136
LazySets.Star: Test Failed at /home/travis/build/JuliaReach/LazySets.jl/test/Sets/Star.jl:47
  Expression: isequivalent(S, P)

@mforets
Copy link
Member

mforets commented Apr 15, 2021

┌ Error: 1 docstring not included in the manual:
│ 
│     LazySets.intersection :: Tuple{AffineMap{N,PT,N,MN,VN} where PT<:AbstractPolyhedron{N} where MN<:AbstractArray{N,2} where VN<:AbstractArray{N,1} where N,HalfSpace}
│ 
│ 
│ These are docstrings in the checked modules (configured with the modules keyword)
│ that are not included in @docs or @autodocs blocks.
└ @ Documenter.DocChecks ~/.julia/packages/Documenter/6vUwN/src/DocChecks.jl:69
[ Info: Populate: populating indices.
ERROR: LoadError: `makedocs` encountered an error. Terminating build
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] runner(::Type{Documenter.Builder.RenderDocument}, ::Documenter.Documents.Document) at /home/travis/.julia/packages/Documenter/6vUwN/src/Builder.jl:255
 [3] dispatch(::Type{Documenter.Builder.DocumentPipeline}, ::Documenter.Documents.Document) at /home/travis/.julia/packages/Documenter/6vUwN/src/Utilities/Selectors.jl:170
 [4] #2 at /home/travis/.julia/packages/Documenter/6vUwN/src/Documenter.jl:247 [inlined]
 [5] cd(::Documenter.var"#2#3"{Documenter.Documents.Document}, ::String) at ./file.jl:104
 [6] #makedocs#1 at /home/travis/.julia/packages/Documenter/6vUwN/src/Documenter.jl:246 [inlined]
 [7] top-level scope at /home/travis/build/JuliaReach/LazySets.jl/docs/make.jl:7
 [8] include(::Function, ::Module, ::String) at ./Base.jl:380

docs/src/lib/sets/Star.md Outdated Show resolved Hide resolved
@mforets mforets merged commit d265855 into master Apr 19, 2021
@mforets mforets deleted the sguadalupe/2646 branch April 19, 2021 17:13
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.

Concrete intersection of star set with half-space
3 participants