From d4885abfdb76192056fcd56576147be56aff6708 Mon Sep 17 00:00:00 2001 From: jbytecode Date: Tue, 12 Nov 2024 12:06:24 +0300 Subject: [PATCH] Add additional tests for Simplex --- CHANGELOG.md | 2 ++ test/runtests.jl | 2 +- test/testsimplex.jl | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 983059c..996c955 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - Rename `mmethodcorrection()` to `mmethodcorrection!()` just because the function mutates its input. - Add documentation for `simplexiterations`. +- Add additional tests for Simplex + ### 0.2.3 diff --git a/test/runtests.jl b/test/runtests.jl index 7fb086b..3d31287 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -17,7 +17,7 @@ include("testmst.jl") include("testpmedian.jl") include("testcpm.jl") include("testpert.jl") -include("testsimplex.jl") include("testlatex.jl") include("testknapsack.jl") +include("testsimplex.jl") diff --git a/test/testsimplex.jl b/test/testsimplex.jl index da709aa..0d0a2e0 100644 --- a/test/testsimplex.jl +++ b/test/testsimplex.jl @@ -77,4 +77,39 @@ + @testset "Mini Transportation Problem" begin + + eps = 0.001 + # Mini Transportation Problem + # M1 M2 M3 Supply + # F1 10 15 20 200 + # F2 17 13 9 100 + # Demand 110 80 110 - + obj = Float64[10, 15, 20, 17, 13, 9] + amat = Float64[ + 1 1 1 0 0 0; + 0 0 0 1 1 1; + 1 0 0 1 0 0; + 0 1 0 0 1 0; + 0 0 1 0 0 1 + ] + rhs = Float64[200, 100, 110, 80, 110] + dirs = [EQ, EQ, EQ, EQ, EQ] + opt = Minimize + + problem::SimplexProblem = createsimplexproblem(obj, amat, rhs, dirs, opt) + + iters = simplexiterations(problem) + + lastiter = iters[end] + + @test lastiter.converged + @test isapprox(lastiter.objective_value, 3400.0, atol=eps) + @test sort(lastiter.basicvariableindex) == [1, 2, 3, 6, 11] + @test sort(lastiter.artificialvariableindices) == [7, 8, 9, 10, 11] + @test isapprox(lastiter.rhs, [10.0, 100.0, 110.0, 80.0, 0.0], atol = eps) + end + + + end # end of test set Simplex