Skip to content

Commit

Permalink
Merge pull request #795 from JuliaReach/schillic/var_name_fix
Browse files Browse the repository at this point in the history
Bugfix: wrong variable name
  • Loading branch information
schillic authored Oct 14, 2018
2 parents 9ac8fb3 + beeb847 commit d9e8959
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Intersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function ρ(d::AbstractVector{N},
end

# symmetric method
function ρ(::AbstractVector{N},
function ρ(d::AbstractVector{N},
cap::Intersection{N,
<:Union{HalfSpace{N}, Hyperplane{N}, Line{N}},
<:LazySet{N}};
Expand Down
24 changes: 17 additions & 7 deletions test/unit_Intersection.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Optim

for N in [Float64, Rational{Int}, Float32]
B = BallInf(ones(N, 2), N(3))
H = Hyperrectangle(ones(N, 2), ones(N, 2))
Expand Down Expand Up @@ -58,23 +60,31 @@ end
# Tests for Float64 only
# ======================

# Half-space - Ball1 intersection
# HalfSpace vs. Ball1 intersection
X = Ball1(zeros(2), 1.0);
H = HalfSpace([-1.0, 0.0], -1.0); # x >= 0
d = normalize([1.0, 0.0])

# line search using Optim
using Optim
# flat intersection at x = 1
H = HalfSpace([-1.0, 0.0], -1.0); # x >= 1

# default algorithm
@test ρ(d, X H) == ρ(d, H X) == 1.0

# Ball1 vs HalfSpace intersection using default algorithm
H = HalfSpace([1.0, 0.0], 0.0); # x = 0
# intersection at x = 0
H = HalfSpace([1.0, 0.0], 0.0); # x <= 0

# default algorithm
@test ρ(d, X H) < 1e-6 && ρ(d, H X) < 1e-6

# specify line search algorithm
@test ρ(d, X H, algorithm="line_search") < 1e-6 &&
ρ(d, H X, algorithm="line_search") < 1e-6

# Ball1 vs Hyperplane intersection
# HalfSpace vs. Ball2 intersection
B2 = Ball2(zeros(2), 1.0);
@test ρ(d, B2 H) < 1e-6 && ρ(d, H B2) < 1e-6

# Ball1 vs. Hyperplane intersection
H = Hyperplane([1.0, 0.0], 0.5); # x = 0.5
@test isapprox(ρ(d, X H, algorithm="line_search"), 0.5, atol=1e-6)
# For the projection algorithm, if the linear map is taken lazily we can use Ball1
Expand Down

0 comments on commit d9e8959

Please sign in to comment.