Skip to content

Commit

Permalink
simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jul 5, 2019
1 parent 3d9c26c commit 1340ef9
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions test/unit_overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,30 @@ for N in [Float64, Float32]
@test lcl[7].b N(1)
@test lcl[8].a N[sqrt(2)/2, -sqrt(2)/2]
@test lcl[8].b N(1)
end

# decomposed intersection between cartesian product array and abstract polyhedron
for N in [Float64]
# decomposed linear map approximation
i1 = Interval(N[0, 1])
i2 = Interval(N[2, 3])
M = N[1 2; 0 1]
cpa = CartesianProductArray([i1, i2])
lm = M * cpa
d_oa = overapproximate(lm, CartesianProductArray{N, Interval{N}})
oa = overapproximate(lm, OctDirections)
@test oa d_oa

# decomposed intersection between Cartesian product array and polyhedron
h1 = Hyperrectangle(low=N[3, 4], high=N[5, 7])
h2 = Hyperrectangle(low=N[5, 5], high=N[6, 8])
cpa1 = CartesianProductArray([i1, i2, h1])
o_cpa1 = overapproximate(cpa1)
cpa2 = CartesianProductArray([i1, i2, h2])
o_cpa2 = overapproximate(cpa2)
G = HPolyhedron([HalfSpace(N[1, 0, 0, 0], N(1))])
G_3 = HPolyhedron([HalfSpace(N[0, 0, 1, 0], N(1))])
G_3_neg = HPolyhedron([HalfSpace(N[0, 0, -1, 0], N(0))])
G = HalfSpace(N[1, 0, 0, 0], N(1))
G_3 = HalfSpace(N[0, 0, 1, 0], N(1))
G_3_neg = HalfSpace(N[0, 0, -1, 0], N(0))
G_comb = HalfSpace(N[1, 1, 0, 0], N(2.5))

d_int_g = Intersection(cpa1, G)
d_int_g_3 = Intersection(cpa1, G_3)
Expand All @@ -183,31 +194,13 @@ for N in [Float64, Float32]
o_d_int_g_3 = overapproximate(d_int_g_3, CartesianProductArray, Hyperrectangle)
o_d_int_g_3_neg = overapproximate(d_int_g_3_neg, CartesianProductArray, Hyperrectangle)

@test overapproximate(o_d_int_g) == overapproximate(d_int_g)
@test overapproximate(o_d_int_g_3) == overapproximate(d_int_g_3) == EmptySet{N}()
@test overapproximate(o_d_int_g_3_neg) == overapproximate(d_int_g_3_neg)
@test overapproximate(o_d_int_g) overapproximate(d_int_g)
@test isempty(d_int_g_3) && o_d_int_g_3 == EmptySet{N}()
@test overapproximate(o_d_int_g_3_neg) overapproximate(d_int_g_3_neg)
@test overapproximate(d_int_cpa, Hyperrectangle) == l_int_cpa
@test all([X isa CartesianProductArray for X in [d_int_cpa, o_d_int_g, o_d_int_g_3_neg]])
end

for N in [Float64]
# decomposed linear map approximation
i1 = Interval(N[0, 1])
i2 = Interval(N[2, 3])
M = N[1 2; 0 1]
cpa = CartesianProductArray([i1, i2])
lm = M * cpa
d_oa = overapproximate(lm, CartesianProductArray{N, Interval{N}})
oa = overapproximate(lm, OctDirections)
@test oa d_oa

# decomposed intersection between cartesian product array and abstract polyhedron
i1 = Interval(N[0, 1])
i2 = Interval(N[2, 3])
h1 = Hyperrectangle(low=N[3, 4], high=N[5, 7])
cpa = CartesianProductArray([i1, i2, h1])
G_comb = HPolyhedron([HalfSpace(N[1, 1, 0, 0], N(2.5))])
int_g_comb = Intersection(cpa, G_comb)
int_g_comb = Intersection(cpa1, G_comb)
o_d_int_g_comb = overapproximate(int_g_comb, CartesianProductArray, Hyperrectangle)
o_bd_int_g_comb = overapproximate(int_g_comb, BoxDirections)
@test overapproximate(o_d_int_g_comb) overapproximate(o_bd_int_g_comb)
Expand Down

0 comments on commit 1340ef9

Please sign in to comment.