Skip to content

Commit

Permalink
Add additional tests for Simplex
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Nov 12, 2024
1 parent 30341fe commit d4885ab
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

35 changes: 35 additions & 0 deletions test/testsimplex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d4885ab

Please sign in to comment.