In [6]:
from numpy import *
In [11]:
A = array([[-1, 3, 0, 6, 0], [0, 2, 1, 3, 0], [0, 1, 0, -1, 1]])
In [12]:
b = array([[18,24,4]])
In [13]:
print b
In [61]:
def LP_verts(A,b):
l1 = len(A)
l2 = len(A[0])
verts = []
ind = 1
for i in range(0,3):
for j in range(i + 1 , 4):
for k in range(j + 1, 5):
matrix = A[:, [i,j,k]]
x = array([[0] * l2])
x[0, i], x[0, j], x[0, k] = dot(linalg.inv(matrix), b)[[i,j,k],0]
if sum(x >= 0) == len(x):
verts.append(x)
return verts
In [62]:
range(0,3)
Out[62]:
In [63]:
LP_verts(A,b.T)
In [65]:
x = array([[0] * 5])
In [35]:
x
Out[35]:
In [66]:
x[0, 0], x[0, 1], x[0, 2]
Out[66]:
In [38]:
x[0, 0], x[0, 1], x[0, 2] = dot(linalg.inv(matrix), b)[[0,1,2],0]
In [39]:
x
Out[39]:
In [43]:
range(3)
Out[43]:
In [ ]: