Skip to content

Commit

Permalink
Test Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewStuber committed Mar 25, 2018
1 parent 5df0f8a commit c0501c7
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 1 deletion.
57 changes: 57 additions & 0 deletions test/ParamChk_Tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module ParamChk_Tests

using Compat
using Compat.Test
using IntervalArithmetic
using EAGOParametricInterval

# Tests strict inclusion procedure for interval vectors
Y = [Interval(0,5),Interval(0,5),Interval(0,5)]
X1 = [Interval(1,2),Interval(1,2),Interval(1,2)]
X2 = [Interval(1,2),Interval(-10,10),Interval(1,2)]
X3 = [Interval(1,2),Interval(1,2),Interval(0,5)]
flag1 = EAGOParametricInterval.Strict_XinY(X1,Y)
flag2 = EAGOParametricInterval.Strict_XinY(X2,Y)
flag3 = EAGOParametricInterval.Strict_XinY(X3,Y)
@test flag1 == true
@test flag2 == false
@test flag3 == false

# Checks extended division routine
B = Interval(1,2)
C = Interval(3,4)
A1 = Interval(0)
A2 = Interval(0,3)
A3 = Interval(-2,0)
A4 = Interval(-3,2)
ind1,B1,C1 = EAGOParametricInterval.extDivide(A1,B,C)
ind2,B2,C2 = EAGOParametricInterval.extDivide(A2,B,C)
ind3,B3,C3 = EAGOParametricInterval.extDivide(A3,B,C)
ind4,B4,C4 = EAGOParametricInterval.extDivide(A4,B,C)
@test ind1 == 0
@test ind2 == 1
@test ind3 == 2
@test ind4 == 3
@test B1 == Interval(-Inf,Inf)
@test 0.33333 - 1E-4 <= B2.lo <= 0.33333 + 1E-4
@test B2.hi == Inf
@test B3 == Interval(-Inf,-0.5)
@test B4.lo == -Inf
@test -0.33333 - 1E-4 <= B4.hi <= -0.33333 + 1E-4
@test C1 == Interval(-Inf,Inf)
@test C2 == Interval(Inf,Inf)
@test C3 == Interval(-Inf,-Inf)
@test C4 == Interval(0.5,Inf)

#=
N =
X =
Mii =
S1 =
S2 =
B =
rtol = 1E-4
indx1,box1,box2 = extProcess(N,X,Mii,S1,S2,B,rtol)
=#

end
51 changes: 50 additions & 1 deletion test/ParametricContractor_Tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ opt1 = Any[100 #Int64: Number of iterations
1.0E-6 #Float64: Add Interval(1E-8,1E8) to add to M[i,i] when
# processing extended interval division.
]
# Test Problem #1

# Test Problem #1 Out of place
P1 = [Interval(5.0,7.0),Interval(5.0,7.0)]
Z1 = [Interval(-1.5, 0.0),Interval(0.0, 0.5)]
h1(z,p) = [z[1]^2+z[2]^2+p[1]*z[1]+4;
Expand All @@ -33,6 +34,8 @@ krawczykCW1 = PI_KrawczykCW(Z1,P1,hj1,h1,opt1,Eflag,Iflag)
@test -1E-4 <= krawczykCW1[1][2].lo - 0.0473789 <= 1E-4
@test -1E-4 <= krawczykCW1[1][2].hi - 0.208486 <= 1E-4


# Test Problem #1 In place
function h1!(h,z,p)
h[1] = z[1]^2+z[2]^2+p[1]*z[1]+4
h[2] = z[1]+p[2]*z[2]
Expand All @@ -59,4 +62,50 @@ krawczykCW2 = PIn_KrawczykCW(Z1,P1,hj1!,h1!,opt1,Eflag,Iflag)
@test -1E-4 <= krawczykCW2[1][1].hi + 0.492759 <= 1E-4
@test -1E-4 <= krawczykCW2[1][2].lo - 0.0473789 <= 1E-4
@test -1E-4 <= krawczykCW2[1][2].hi - 0.208486 <= 1E-4

# Starts testing problem # 2
P2 = [Interval(6.0,9.0)]
Z2 = [Interval(-1.78, -0.1)]

# Test Problem #2 Out of Place
h2(x,p) = [x[1]^2 + p[1]*x[1] + 4.0]
hj2(x,p) = [2*x[1]+p[1]]
Eflag = false
Iflag = false
eDflag = false
newtonGS3 = PI_NewtonGS(Z2,P2,hj2,h2,opt1,Eflag,Iflag,eDflag)
krawczykCW3 = PI_KrawczykCW(Z2,P2,hj2,h2,opt1,Eflag,Iflag)
@test -0.772413 - 1E-4 <= krawczykCW3[1][1].lo <= -0.772413 + 1E-4
@test -0.383299 - 1E-4 <= krawczykCW3[1][1].hi <= -0.383299 + 1E-4
@test krawczykCW3[2] == false
@test krawczykCW3[3] == true
@test -0.769225 - 1E-4 <= newtonGS3[1][1].lo <= -0.769225 + 1E-4
@test -0.461725 - 1E-4 <= newtonGS3[1][1].hi <= -0.461725 + 1E-4
@test newtonGS3[3] == false
@test newtonGS3[4] == true

# Test Problem #2 Inplace
function h2!(hout,x,p)
hout[:] = [x[1]^2 + p[1]*x[1] + 4.0]
end
function hj2!(hout,x,p)
hout[:] = [2*x[1]+p[1]]
end
Eflag = false
Iflag = false
eDflag = false
newtonGS4 = PIn_NewtonGS(Z2,P2,hj2!,h2!,opt1,Eflag,Iflag,eDflag)
krawczykCW4 = PIn_KrawczykCW(Z2,P2,hj2!,h2!,opt1,Eflag,Iflag)
@test -0.772413 - 1E-4 <= krawczykCW4[1][1].lo <= -0.772413 + 1E-4
@test -0.383299 - 1E-4 <= krawczykCW4[1][1].hi <= -0.383299 + 1E-4
@test krawczykCW4[2] == false
@test krawczykCW4[3] == true
@test -0.769225 - 1E-4 <= newtonGS4[1][1].lo <= -0.769225 + 1E-4
@test -0.461725 - 1E-4 <= newtonGS4[1][1].hi <= -0.461725 + 1E-4
@test newtonGS4[3] == false
@test newtonGS4[4] == true

# Test Problem #3 Inplace
# Test Problem #3 Out of Place

end
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using EAGOParametricInterval

# write your own tests here
println("Testing Checks and Utilities...")
t = @elapsed include("ParamChk_Tests.jl")
println("done (took $t seconds).")

println("Testing Parametric Contractors...")
t = @elapsed include("ParametricContractor_Tests.jl")
println("done (took $t seconds).")
Expand Down

0 comments on commit c0501c7

Please sign in to comment.