Skip to content

Commit d4885ab

Browse files
committed
Add additional tests for Simplex
1 parent 30341fe commit d4885ab

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Rename `mmethodcorrection()` to `mmethodcorrection!()` just because the function mutates its input.
44
- Add documentation for `simplexiterations`.
5+
- Add additional tests for Simplex
6+
57

68
### 0.2.3
79

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ include("testmst.jl")
1717
include("testpmedian.jl")
1818
include("testcpm.jl")
1919
include("testpert.jl")
20-
include("testsimplex.jl")
2120
include("testlatex.jl")
2221
include("testknapsack.jl")
22+
include("testsimplex.jl")
2323

test/testsimplex.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,39 @@
7777

7878

7979

80+
@testset "Mini Transportation Problem" begin
81+
82+
eps = 0.001
83+
# Mini Transportation Problem
84+
# M1 M2 M3 Supply
85+
# F1 10 15 20 200
86+
# F2 17 13 9 100
87+
# Demand 110 80 110 -
88+
obj = Float64[10, 15, 20, 17, 13, 9]
89+
amat = Float64[
90+
1 1 1 0 0 0;
91+
0 0 0 1 1 1;
92+
1 0 0 1 0 0;
93+
0 1 0 0 1 0;
94+
0 0 1 0 0 1
95+
]
96+
rhs = Float64[200, 100, 110, 80, 110]
97+
dirs = [EQ, EQ, EQ, EQ, EQ]
98+
opt = Minimize
99+
100+
problem::SimplexProblem = createsimplexproblem(obj, amat, rhs, dirs, opt)
101+
102+
iters = simplexiterations(problem)
103+
104+
lastiter = iters[end]
105+
106+
@test lastiter.converged
107+
@test isapprox(lastiter.objective_value, 3400.0, atol=eps)
108+
@test sort(lastiter.basicvariableindex) == [1, 2, 3, 6, 11]
109+
@test sort(lastiter.artificialvariableindices) == [7, 8, 9, 10, 11]
110+
@test isapprox(lastiter.rhs, [10.0, 100.0, 110.0, 80.0, 0.0], atol = eps)
111+
end
112+
113+
114+
80115
end # end of test set Simplex

0 commit comments

Comments
 (0)