Skip to content

Commit

Permalink
add test for gaussjordan inverse method
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Jan 10, 2025
1 parent 791628c commit 4c2afed
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions test/testsimplex.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
@testset "Simplex" begin
@testset "Simplex" verbose = true begin

@testset "Gauss Jordan" begin
@testset "Gauss Jordan" verbose=true begin

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

expected = [
0.142157 -0.151961 0.0784314;
-0.102941 0.161765 0.0294118;
0.151961 -0.0245098 -0.0196078
]
m = Float64[1.0 2 7; -1 6 5; 9 8 -3]

expected = [
0.142157 -0.151961 0.0784314;
-0.102941 0.161765 0.0294118;
0.151961 -0.0245098 -0.0196078
]

result = gaussjordan(m, verbose=false)

@test isapprox(result, expected, atol=0.0001)

end

@testset "4x4 matrix" begin

m = Float64[1 6 7 4; 5 4 3 2; 3 4 5 1; 5 5 7 5]

expected = [
-0.196429 0.0892857 0.0714286 0.107143;
0.309524 0.404762 -0.142857 -0.380952;
-0.14881 -0.386905 0.357143 0.202381;
0.0952381 0.047619 -0.428571 0.190476
]

result = gaussjordan(m, verbose=false)

@test isapprox(result, expected, atol=0.0001)
end
end

result = gaussjordan(m, verbose = false)

@test isapprox(result, expected, atol = 0.0001)
end

@testset "Maximization Problem" begin

Expand Down Expand Up @@ -93,7 +115,7 @@



@testset "Mini Transportation Problem" begin
@testset "Mini Transportation Problem" begin

eps = 0.001
# Mini Transportation Problem
Expand Down Expand Up @@ -123,8 +145,8 @@
@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
@test isapprox(lastiter.rhs, [10.0, 100.0, 110.0, 80.0, 0.0], atol=eps)
end



Expand Down

0 comments on commit 4c2afed

Please sign in to comment.