Skip to content

Commit e353abe

Browse files
authored
Merge pull request #4062 from JuliaReach/schillic/issubset_zonotope_witness
Add witness production in `⊆` for `AbstractZonotope`
2 parents 9983477 + 0158a90 commit e353abe

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/ConcreteOperations/issubset.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ function _issubset_zonotope_in_polyhedron(Z::AbstractZonotope, P::LazySet,
236236
elseif !witness
237237
return false
238238
end
239-
throw(ArgumentError("witness production is not supported yet"))
239+
# fall back to default algorithm for witness production
240+
# TODO more efficient implementation
241+
return _issubset_constraints_list(Z, P, witness)
240242
end
241243

242244
# for documentation see

test/ConcreteOperations/issubset.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ for N in @tN([Float64, Float32, Rational{Int}])
8080
@test Z P && res && w == N[]
8181
P = HPolyhedron([HalfSpace(N[1, 0], N(1)), HalfSpace(N[-1, 0], N(0)),
8282
HalfSpace(N[0, 1], N(3)), HalfSpace(N[0, -1], N(0))])
83-
@test !(Z P)
84-
@test_throws ArgumentError issubset(Z, P, true) # not implemented; parser requires `issubset`
83+
res, w = (Z, P, true)
84+
@test !(Z P) && !res && w isa Vector{N} && w Z && w P
8585
# corner case: no generator
8686
Z = Zonotope(N[2], zeros(N, 1, 0))
8787
P = convert(HPolytope, Interval(N(1), N(3)))

test/Sets/Zonotope.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -674,18 +674,16 @@ for N in @tN([Float64, Float32, Rational{Int}])
674674

675675
# isstrictsubset
676676
@test_throws DimensionMismatch Z Z3
677-
for Z2 in (Z, P)
678-
@test !(Z2 Z)
679-
res, w = (Z2, Z, true)
677+
Z2a = Zonotope(N[1, 2], N[1 0; 0 1])
678+
for Z2b in (Z, P, Z2a)
679+
@test !(Z2b Z)
680+
res, w = (Z2b, Z, true)
680681
@test !res && w isa Vector{N} && isempty(w)
681682
end
682-
Z2 = Zonotope(N[1, 2], N[1 0; 0 1])
683-
@test_broken (Z2, Z, true) isa Tuple # TODO support witness production, then integrate in loop above
684683
Z2 = Zonotope(N[1, 2], N[4 0; 0 6])
685684
@test Z Z2
686-
@test_broken (Z, Z2, true) isa Tuple # TODO support witness production
687-
# res, w = ⊂(Z, Z2, true)
688-
# @test res && w isa Vector{N} && w ∉ Z && w ∈ Z2
685+
res, w = (Z, Z2, true)
686+
@test res && w isa Vector{N} && w Z && w Z2
689687

690688
# issubset
691689
@test_throws DimensionMismatch Z Z3
@@ -696,9 +694,8 @@ for N in @tN([Float64, Float32, Rational{Int}])
696694
end
697695
Z2 = Zonotope(N[3, 0], N[1 0; 0 1])
698696
@test Z Z2
699-
@test_broken (Z, Z2, true) isa Tuple # TODO this should work
700-
# res, w = ⊆(Z, Z2, true)
701-
# @test !res && w isa Vector{N} && w ∈ Z && w ∉ Z2
697+
res, w = (Z, Z2, true)
698+
@test !res && w isa Vector{N} && w Z && w Z2
702699

703700
# linear_combination
704701
@test_throws DimensionMismatch linear_combination(Z, Z3)

0 commit comments

Comments
 (0)