Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpo authored and abelsiqueira committed Apr 1, 2020
1 parent 5de6b77 commit 174c648
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
16 changes: 8 additions & 8 deletions test/test_lbfgs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function test_lbfgs()
@testset ExtendedTestSet "LBFGS" begin
n = 10
mem = 5
B = LBFGSOperator(n, mem, scaling=false)
H = InverseLBFGSOperator(n, mem, scaling=false)
B = LBFGSOperator(n, mem=mem, scaling=false)
H = InverseLBFGSOperator(n, mem=mem, scaling=false)

for t = 1:2 # Run again after reset!
@test norm(diag(B) - diag(Matrix(B))) <= rtol
Expand Down Expand Up @@ -64,7 +64,7 @@ function test_lbfgs()

# test against full BFGS without scaling
mem = n
LB = LBFGSOperator(n, mem, scaling=false)
LB = LBFGSOperator(n, mem=mem, scaling=false)
B = Matrix(1.0I, n, n)

function bfgs!(B, s, y, damped=false)
Expand All @@ -91,8 +91,8 @@ function test_lbfgs()
end

# test damped L-BFGS
B = LBFGSOperator(n, mem, damped=true, scaling=false, σ₂=0.8, σ₃=Inf)
H = InverseLBFGSOperator(n, mem, damped=true, scaling=false, σ₂=0.8, σ₃=Inf)
B = LBFGSOperator(n, mem=mem, damped=true, scaling=false, σ₂=0.8, σ₃=Inf)
H = InverseLBFGSOperator(n, mem=mem, damped=true, scaling=false, σ₂=0.8, σ₃=Inf)

insert_B = insert_H = 0
for i = 1 : mem+2
Expand Down Expand Up @@ -126,7 +126,7 @@ function test_lbfgs()

# test against full BFGS without scaling
mem = n
LB = LBFGSOperator(n, mem, damped=true, scaling=false)
LB = LBFGSOperator(n, mem=mem, damped=true, scaling=false)
B = Matrix(1.0I, n, n)

@test norm(Matrix(LB) - B) < rtol * norm(B)
Expand All @@ -146,8 +146,8 @@ function test_lbfgs()
n = 10
mem = 5
for T in (Float16, Float32, Float64, BigFloat)
B = LBFGSOperator(T, n, mem)
H = InverseLBFGSOperator(T, n, mem)
B = LBFGSOperator(T, n, mem=mem)
H = InverseLBFGSOperator(T, n, mem=mem)
s = ones(T, n)
y = ones(T, n)
push!(B, s, y)
Expand Down
9 changes: 5 additions & 4 deletions test/test_lsr1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function test_lsr1()
@testset ExtendedTestSet "LSR1" begin
n = 10
mem = 5
B = LSR1Operator(n, mem, scaling=false)
B = LSR1Operator(n, mem=mem, scaling=false)

for t = 1:2
@test norm(diag(B) - diag(Matrix(B))) <= rtol
Expand All @@ -16,7 +16,8 @@ function test_lsr1()
# Test that only valid updates are accepted.
s = simple_vector(Float64, n)
y = B * s
push!(B, s, y); @test B.data.insert == 1
push!(B, s, y)
@test B.data.insert == 1

# Insert a few {s,y} pairs.
for i = 1 : mem+2
Expand All @@ -37,7 +38,7 @@ function test_lsr1()

# test against full SR1 without scaling
mem = n
LB = LSR1Operator(n, mem, scaling=false)
LB = LSR1Operator(n, mem=mem, scaling=false)
B = Matrix(1.0I, n, n)

function sr1!(B, s, y)
Expand Down Expand Up @@ -67,7 +68,7 @@ function test_lsr1()
n = 10
mem = 5
for T in (Float16, Float32, Float64, BigFloat)
B = LSR1Operator(T, n, mem)
B = LSR1Operator(T, n, mem=mem)
s = ones(T, n)
y = ones(T, n)
push!(B, s, y)
Expand Down

0 comments on commit 174c648

Please sign in to comment.