|
13 | 13 | solve!(s) |
14 | 14 |
|
15 | 15 | @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) |
18 | 18 |
|
19 | | - @test isapprox(s.objective_value, 183.33333, atol = eps) |
| 19 | + @test isapprox(s.objective_value, 183.33333, atol=eps) |
20 | 20 |
|
21 | 21 | end |
22 | 22 |
|
|
37 | 37 | solve!(s) |
38 | 38 |
|
39 | 39 | @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) |
44 | 42 |
|
| 43 | + @test isapprox(s.objective_value, 183.33333, atol=eps) |
45 | 44 | end |
46 | 45 |
|
| 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 |
47 | 77 |
|
48 | 78 |
|
49 | 79 |
|
|
0 commit comments