-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
103 lines (79 loc) · 1.78 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from primal_simplex import linear_problem as PL
def test(c, b, A, max_iterations=10):
pl = PL(c, b, A)
pl.solve(max_iterations)
print(pl)
c = [-1, 0, 0, 0, 0]
b = [6, 4, 2]
A = [[1, 2, 1, 0, 0], [1, -1, 0, 1, 0], [0, 1, 0, 0, 1]]
print("Example 1:", end=" ")
test(c, b, A)
c = [2, 1, 0, 0, 0]
b = [5, 4, 20]
A = [[1, 6.5, -1, 0, 0], [2, 1, 0, -1, 0], [5, 4, 0, 0, 1]]
print("Example 2:", end=" ")
test(c, b, A)
c = [-2, -2, 0, 0, 0, 0]
b = [-24, 21, 6, 3]
A = [
[8, -3, -1, 0, 0, 0],
[3, 5, 0, -1, 0, 0],
[3, -4, 0, 0, -1, 0],
[1, 0, 0, 0, 0, 1],
]
print("Example 3:", end=" ")
test(c, b, A)
c = [-1, -3, 0, 0, 0]
b = [0, 4, 15]
A = [
[1, -2, 1, 0, 0],
[-2, 1, 0, 1, 0],
[5, 3, 0, 0, 1],
]
print("Example 4:", end=" ")
test(c, b, A)
c = [2, 3, 0, 0, 0, 0, 0]
b = [4, 8, 4, 3, 3]
A = [
[1, 1, 1, 0.0, 0, 0, 0],
[6, 2, 0, -1, 0, 0, 0],
[1, 5, 0, 0, -1, 0, 0],
[1, 0, 0, 0.0, 0, 1, 0],
[0, 1, 0, 0.0, 0, 0, 1],
]
print("Example 5:", end=" ")
test(c, b, A)
c = [-3, 4, 0, 0]
b = [4, 18]
A = [[1, 1, 1, 0], [2, 3, 0, -1]]
print("Example 6:", end=" ")
test(c, b, A)
c = [-1, -3, 0, 0, 0]
b = [12, 4, 6]
A = [
[-3, 4, 1, 0, 0],
[1, -1, 0, 1, 0],
[1, 1, 0, 0, 1],
]
print("Example 7:", end=" ")
test(c, b, A)
c = [1, -1, 2, 0, 100]
b = [3, 4]
A = [[1, 1, 1, 0, 1], [2, -1, 3, 1, 0]]
print("Example 8:", end=" ")
test(c, b, A)
c = [-3, -2, -1, 0, 0]
b = [3, 6]
A = [[3, -3, 2, 1, 0], [-1, 2, 1, 0, 1]]
print("Example 9:", end=" ")
test(c, b, A)
c = [-3, -5, 0, 0, 0, 0]
b = [10, 15, 15, 1]
A = [[1, 1, 1, 0, 0, 0], [1, 2, 0, 1, 0, 0], [2, 1, 0, 0, 1, 0], [1, -2, 0, 0, 0, 1]]
print("Example 10:", end=" ")
test(c, b, A)
c = [-2, -2, 0, 0]
b = [-1, 2]
A = [[1, -1, -1, 0], [-0.5, 1, 0, 1]]
print("Example 11:", end=" ")
test(c, b, A)