Skip to content

Commit

Permalink
Add solvers in test
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Apr 7, 2017
1 parent 26df7cf commit fe5ef82
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/optimize_stock.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "Optimize Stock" begin
@testset "Optimize Stock with $solver" for solver in lp_solvers
numScen = 2
C = 1
P = 2
Expand Down
2 changes: 1 addition & 1 deletion test/prob5.2.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function fulltest(m, num_stages, objval, solval, ws, wsσ)
function fulltest(m, num_stages, objval, solval, ws, wsσ, solver)
for K in [-1, 40]
for maxncuts in [-1, 7]
for newcut in [:InvalidateSolver]#[:AddImmediately, :InvalidateSolver]
Expand Down
4 changes: 2 additions & 2 deletions test/prob5.2_2stages.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "2 stages" begin
@testset "2 stages with $solver" for solver in lp_solvers
include("prob5.2_data.jl")

numScen = 2
Expand All @@ -21,7 +21,7 @@
@objective(M2, Min, dot(C, y2 * T))
end

fulltest(M1, 2, 340315.52, [5085,1311,3919,854], 334687.754566,15869.996575)
fulltest(M1, 2, 340315.52, [5085,1311,3919,854], 334687.754566, 15869.996575, solver)
# root = model2lattice(M1, 2, solver, cutmode)
# sol = SDDP(root, 2, cutmode, :All, verbose)
#
Expand Down
4 changes: 2 additions & 2 deletions test/prob5.2_3stages.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "3 stages" begin
@testset "3 stages with $solver" for solver in lp_solvers
include("prob5.2_data.jl")

numScen = 2
Expand Down Expand Up @@ -38,7 +38,7 @@
end
end

fulltest(M, 3, 406712.49, [2986,0,7329,854], 402593.71614, 17319.095064)
fulltest(M, 3, 406712.49, [2986,0,7329,854], 402593.71614, 17319.095064, solver)
# root = model2lattice(M, 3, solver, cutmode)
# sol = SDDP(root, 3, cutmode, :All, verbose)
#
Expand Down
4 changes: 2 additions & 2 deletions test/prob5.2_3stages_serial.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "3 stages serial" begin
@testset "3 stages serial with $solver" for solver in lp_solvers
include("prob5.2_data.jl")

numScen = 2
Expand Down Expand Up @@ -47,5 +47,5 @@
end
end

fulltest(models[1], 3, 406712.49, [2986,0,7329,854], 402593.71614, 17319.095064)
fulltest(models[1], 3, 406712.49, [2986,0,7329,854], 402593.71614, 17319.095064, solver)
end
25 changes: 19 additions & 6 deletions test/solvers.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Similar to JuMP/test/solvers.jl

function try_import(name::Symbol)
try
@eval import $name
return true
catch e
return false
end
end

#using ECOS
#solver = ECOS.ECOSSolver(verbose=false)
#using Clp
#solver = Clp.ClpSolver()
#using Gurobi
#solver = Gurobi.GurobiSolver(OutputFlag=0)
using GLPKMathProgInterface
solver = GLPKSolverLP()
clp = try_import(:Clp)
glp = try_import(:GLPKMathProgInterface)
gur = try_import(:Gurobi)

lp_solvers = Any[]
clp && push!(lp_solvers, Clp.ClpSolver())
glp && push!(lp_solvers, GLPKMathProgInterface.GLPKSolverLP())
gur && push!(lp_solvers, Gurobi.GurobiSolver())

0 comments on commit fe5ef82

Please sign in to comment.