Skip to content

Commit 30341fe

Browse files
committed
add new test for Simplex
1 parent a6d9e60 commit 30341fe

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

test/testsimplex.jl

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
solve!(s)
1414

1515
@test s.converged
16-
@test isapprox(s.rhs[1], 16.666666666666664, atol = eps)
17-
@test isapprox(s.rhs[2], 66.66666666666667, atol = eps)
16+
@test isapprox(s.rhs[1], 16.666666666666664, atol=eps)
17+
@test isapprox(s.rhs[2], 66.66666666666667, atol=eps)
1818

19-
@test isapprox(s.objective_value, 183.33333, atol = eps)
19+
@test isapprox(s.objective_value, 183.33333, atol=eps)
2020

2121
end
2222

@@ -37,13 +37,43 @@
3737
solve!(s)
3838

3939
@test s.converged
40-
@test isapprox(s.rhs[1], 0.3333333333, atol = eps)
41-
@test isapprox(s.rhs[2], 1.3333333333, atol = eps)
42-
43-
@test isapprox(s.objective_value, 183.33333, atol = eps)
40+
@test isapprox(s.rhs[1], 0.3333333333, atol=eps)
41+
@test isapprox(s.rhs[2], 1.3333333333, atol=eps)
4442

43+
@test isapprox(s.objective_value, 183.33333, atol=eps)
4544
end
4645

46+
@testset "Maximization problem with single equality constraint" begin
47+
48+
# Maximize 3x + 5y
49+
# subject to x + y = 10
50+
# x, y >= 0
51+
# Result:
52+
# x = 0.0
53+
# y = 5.0
54+
# Objective value = 50.0
55+
56+
obj = [3.0, 5.0]
57+
amat = [1.0 1.0]
58+
rhs = [10.0]
59+
dirs = [EQ]
60+
opt = Maximize
61+
62+
s = SimplexProblem()
63+
setobjectivecoefs(s, obj)
64+
setlhs(s, amat)
65+
setrhs(s, rhs)
66+
setdirections(s, dirs)
67+
setopttype(s, opt)
68+
setautomaticvarnames(s)
69+
70+
solve!(s)
71+
72+
@test s.converged
73+
@test isapprox(s.rhs[1], 10.0)
74+
@test isapprox(s.objective_value, 50.0)
75+
76+
end
4777

4878

4979

0 commit comments

Comments
 (0)