Skip to content

Commit 4c2afed

Browse files
committed
add test for gaussjordan inverse method
1 parent 791628c commit 4c2afed

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

test/testsimplex.jl

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
1-
@testset "Simplex" begin
1+
@testset "Simplex" verbose = true begin
22

3-
@testset "Gauss Jordan" begin
3+
@testset "Gauss Jordan" verbose=true begin
44

5-
m = Float64[1.0 2 7; -1 6 5; 9 8 -3]
5+
@testset "3x3 matrix" begin
66

7-
expected = [
8-
0.142157 -0.151961 0.0784314;
9-
-0.102941 0.161765 0.0294118;
10-
0.151961 -0.0245098 -0.0196078
11-
]
7+
m = Float64[1.0 2 7; -1 6 5; 9 8 -3]
8+
9+
expected = [
10+
0.142157 -0.151961 0.0784314;
11+
-0.102941 0.161765 0.0294118;
12+
0.151961 -0.0245098 -0.0196078
13+
]
14+
15+
result = gaussjordan(m, verbose=false)
16+
17+
@test isapprox(result, expected, atol=0.0001)
18+
19+
end
20+
21+
@testset "4x4 matrix" begin
22+
23+
m = Float64[1 6 7 4; 5 4 3 2; 3 4 5 1; 5 5 7 5]
24+
25+
expected = [
26+
-0.196429 0.0892857 0.0714286 0.107143;
27+
0.309524 0.404762 -0.142857 -0.380952;
28+
-0.14881 -0.386905 0.357143 0.202381;
29+
0.0952381 0.047619 -0.428571 0.190476
30+
]
31+
32+
result = gaussjordan(m, verbose=false)
33+
34+
@test isapprox(result, expected, atol=0.0001)
35+
end
36+
end
1237

13-
result = gaussjordan(m, verbose = false)
1438

15-
@test isapprox(result, expected, atol = 0.0001)
16-
end
1739

1840
@testset "Maximization Problem" begin
1941

@@ -93,7 +115,7 @@
93115

94116

95117

96-
@testset "Mini Transportation Problem" begin
118+
@testset "Mini Transportation Problem" begin
97119

98120
eps = 0.001
99121
# Mini Transportation Problem
@@ -123,8 +145,8 @@
123145
@test isapprox(lastiter.objective_value, 3400.0, atol=eps)
124146
@test sort(lastiter.basicvariableindex) == [1, 2, 3, 6, 11]
125147
@test sort(lastiter.artificialvariableindices) == [7, 8, 9, 10, 11]
126-
@test isapprox(lastiter.rhs, [10.0, 100.0, 110.0, 80.0, 0.0], atol = eps)
127-
end
148+
@test isapprox(lastiter.rhs, [10.0, 100.0, 110.0, 80.0, 0.0], atol=eps)
149+
end
128150

129151

130152

0 commit comments

Comments
 (0)