Skip to content

Commit

Permalink
update accuracy in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmarek committed Sep 6, 2019
1 parent 7e2cff4 commit 16363a3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const cache = MOIU.UniversalFallback(MOIU.Model{Float64}())
import SCS

for T in [SCS.Direct, SCS.Indirect]
optimizer = SCS.Optimizer(linear_solver=T, eps=1e-8)
optimizer = SCS.Optimizer(linear_solver=T, eps=1e-6)
MOI.set(optimizer, MOI.Silent(), true)

@testset "SolverName" begin
Expand Down
8 changes: 4 additions & 4 deletions test/MPB_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import MathProgBase
for T in [SCS.Direct, SCS.Indirect]
@testset "MathProgBase $T" begin
include(joinpath(dirname(dirname(pathof(MathProgBase))), "test", "conicinterface.jl"))
coniclineartest(SCS.SCSSolver(linear_solver=T, eps=1e-7, verbose=0),
coniclineartest(SCS.SCSSolver(linear_solver=T, eps=1e-6, verbose=0),
duals=true, tol=1e-5)
conicSOCtest(SCS.SCSSolver(linear_solver=T, verbose=0),
conicSOCtest(SCS.SCSSolver(linear_solver=T, eps=1e-6, verbose=0),
duals=true, tol=1e-5)
conicEXPtest(SCS.SCSSolver(linear_solver=T, verbose=0),
conicEXPtest(SCS.SCSSolver(linear_solver=T, eps=1e-6, verbose=0),
duals=true, tol=1e-5)
conicSDPtest(SCS.SCSSolver(linear_solver=T, eps=1e-7, verbose=0),
conicSDPtest(SCS.SCSSolver(linear_solver=T, eps=1e-6, verbose=0),
duals=true, tol=1e-5)
end
end
21 changes: 12 additions & 9 deletions test/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ m = MathProgBase.ConicModel(s)
MathProgBase.loadproblem!(m, -obj, A, rowub, [(:NonNeg,1:3)],[(:NonNeg,1:5)])
MathProgBase.optimize!(m)

@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-6, rtol=0.0)
@test !isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-7, rtol=0.0)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-9, rtol=0.0)
@test !isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-10, rtol=0.0)

# With eps = 1e-12, solution should be far more accurate
s = SCSSolver(eps=1e-12)
# With eps = 1e-14, solution should be far more accurate
s = SCSSolver(eps=1e-14)
m = MathProgBase.ConicModel(s)
MathProgBase.loadproblem!(m, -obj, A, rowub, [(:NonNeg,1:3)],[(:NonNeg,1:5)])
MathProgBase.optimize!(m)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-10, rtol=0.0)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-12, rtol=0.0)
@test !isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-14, rtol=0.0)

# With a warmstart from the eps = 1e-8 solution, solution should be extremely accurate even after 1 iteration
# With a warmstart from the eps = 1e-14 solution, solution should be extremely accurate even after 1 iteration
SCS.addoption!(m, :warm_start, true)
SCS.addoption!(m, :max_iters, 1)
MathProgBase.optimize!(m)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-10, rtol=0.0)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-12, rtol=0.0)
@test !isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-14, rtol=0.0)

# Now let's do the same warmstart, but on a new instance of the same problem
primal_sol = m.primal_sol
Expand All @@ -46,7 +48,8 @@ m = MathProgBase.ConicModel(s)
MathProgBase.loadproblem!(m, -obj, A, rowub, [(:NonNeg,1:3)],[(:NonNeg,1:5)])
MathProgBase.setwarmstart!(m, primal_sol; dual_sol = dual_sol, slack = slack)
MathProgBase.optimize!(m)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-10, rtol=0.0)
@test isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-12, rtol=0.0)
@test !isapprox(MathProgBase.getobjval(m), -99.0, atol=1e-14, rtol=0.0)

# tests for incorrect options
s = SCSSolver(eps=1e-12, epps=1.0)
Expand All @@ -61,7 +64,7 @@ catch ex
ex
end
@test err.msg == "Unrecognized option passed to SCS: epps;
Recognized options are: linear_solver, normalize, scale, rho_x, max_iters, eps, alpha, cg_rate, verbose, warm_start and acceleration_lookback."
Recognized options are: linear_solver, normalize, scale, rho_x, max_iters, eps, alpha, cg_rate, verbose, warm_start, acceleration_lookback and write_data_filename."

# tests for incorrect options
s = SCSSolver(linear_solver="AAA", eps=1e-12, epps=1.0)
Expand Down

0 comments on commit 16363a3

Please sign in to comment.