Unverified Commit bace15a0 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

mass change GLPK to Tulip

parent 065dbcfa
......@@ -24,7 +24,6 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Clp = "0.8"
DistributedData = "0.1.3"
Documenter = "0.26"
GLPK = "0.14"
JSON = "0.21"
JuMP = "0.21"
Literate = "2.8"
......@@ -40,7 +39,6 @@ julia = "1"
Clp = "e2554f3b-3117-50c0-817c-e040a3ddf72d"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
OSQP = "ab2f91bb-94b4-55e3-9ba0-7f65df51de79"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
......@@ -48,4 +46,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Tulip = "6dd1b50a-3aae-11e9-10b5-ef983d2400fa"
[targets]
test = ["Clp", "Downloads", "GLPK", "OSQP", "SHA", "Test", "Tulip"]
test = ["Clp", "Downloads", "OSQP", "SHA", "Test", "Tulip"]
@testset "Flux balance analysis with CoreModel" begin
cp = test_simpleLP()
lp = flux_balance_analysis(cp, GLPK.Optimizer)
lp = flux_balance_analysis(cp, Tulip.Optimizer)
@test termination_status(lp) === MOI.OPTIMAL
sol = JuMP.value.(lp[:x])
@test sol [1.0, 2.0]
......@@ -12,7 +12,7 @@
# test the maximization of the objective
cp = test_simpleLP2()
lp = flux_balance_analysis(cp, GLPK.Optimizer)
lp = flux_balance_analysis(cp, Tulip.Optimizer)
@test termination_status(lp) === MOI.OPTIMAL
sol = JuMP.value.(lp[:x])
@test sol [-1.0, 2.0]
......@@ -27,16 +27,16 @@
cp = load_model(CoreModel, model_path)
expected_optimum = 0.9219480950504393
lp = flux_balance_analysis(cp, GLPK.Optimizer)
lp = flux_balance_analysis(cp, Tulip.Optimizer)
@test termination_status(lp) === MOI.OPTIMAL
sol = JuMP.value.(lp[:x])
@test objective_value(lp) expected_optimum
@test cp.c' * sol expected_optimum
# test the "nicer output" variants
fluxes_vec = flux_balance_analysis_vec(cp, GLPK.Optimizer)
fluxes_vec = flux_balance_analysis_vec(cp, Tulip.Optimizer)
@test all(fluxes_vec .== sol)
fluxes_dict = flux_balance_analysis_dict(cp, GLPK.Optimizer)
fluxes_dict = flux_balance_analysis_dict(cp, Tulip.Optimizer)
rxns = reactions(cp)
@test all([fluxes_dict[rxns[i]] == sol[i] for i in eachindex(rxns)])
end
......
@testset "Flux variability analysis" begin
cp = test_simpleLP()
optimizer = GLPK.Optimizer
optimizer = Tulip.Optimizer
fluxes = flux_variability_analysis(cp, optimizer)
@test size(fluxes) == (2, 2)
......@@ -12,7 +12,7 @@
fluxes = flux_variability_analysis(cp, [2], optimizer)
@test size(fluxes) == (1, 2)
@test fluxes == Matrix{Float64}([2 2])
@test isapprox(fluxes, [2 2], atol=TEST_TOLERANCE)
# a special testcase for slightly sub-optimal FVA (gamma<1)
cp = CoreModel(
......@@ -25,39 +25,38 @@
["m1"],
)
fluxes = flux_variability_analysis(cp, optimizer)
@test fluxes [
@test isapprox(fluxes, [
1.0 1.0
0.0 0.0
-1.0 -1.0
]
], atol=TEST_TOLERANCE)
fluxes = flux_variability_analysis(cp, optimizer; bounds = gamma_bounds(0.5))
@test fluxes [
@test isapprox(fluxes, [
0.5 1.0
0.0 0.5
-1.0 -0.5
]
], atol=TEST_TOLERANCE)
fluxes = flux_variability_analysis(cp, optimizer; bounds = _ -> (0, Inf))
@test fluxes [
@test isapprox(fluxes, [
0.0 1.0
0.0 1.0
-1.0 0.0
]
], atol=TEST_TOLERANCE)
@test isempty(flux_variability_analysis(cp, Vector{Int}(), GLPK.Optimizer))
@test_throws DomainError flux_variability_analysis(cp, [-1], GLPK.Optimizer)
@test_throws DomainError flux_variability_analysis(cp, [99999999], GLPK.Optimizer)
@test isempty(flux_variability_analysis(cp, Vector{Int}(), Tulip.Optimizer))
@test_throws DomainError flux_variability_analysis(cp, [-1], Tulip.Optimizer)
@test_throws DomainError flux_variability_analysis(cp, [99999999], Tulip.Optimizer)
end
@testset "Parallel FVA" begin
cp = test_simpleLP()
pids = addprocs(2, topology = :master_worker)
@everywhere using COBREXA, GLPK
fluxes = flux_variability_analysis(cp, [1, 2], GLPK.Optimizer; workers = pids)
@test fluxes [
@everywhere using COBREXA, Tulip
fluxes = flux_variability_analysis(cp, [1, 2], Tulip.Optimizer; workers = pids)
@test isapprox(fluxes, [
1.0 1.0
2.0 2.0
]
rmprocs(pids)
], atol = TEST_TOLERANCE)
end
@testset "Flux variability analysis with StandardModel" begin
......
@testset "Solve LP" begin
cp = test_simpleLP()
optimizer = GLPK.Optimizer
optimizer = Tulip.Optimizer
lp = optimize_model(cp, optimizer)
@test termination_status(lp) === MOI.OPTIMAL
sol = JuMP.value.(lp[:x])
......
......@@ -3,7 +3,6 @@ using COBREXA, Test
using Clp
using Distributed
using Downloads
using GLPK
using JSON
using JuMP
using LinearAlgebra
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment