I am trying to add more data to the matrices to analyze and solve for the , but as it stands currently it is performing the brute operation, it exceeds python's limits if I add another column to the analysis. Is there a solver method availalbe that would find a similar result rather than having to brute through combinations? The sample.csv is also listed below. Thanks for any advice.
import csv
import itertools as it
import numpy as np
C = 2618.08
B = 933.15
A = 932.37
adjust = 1
D = csv.reader(open('sample.csv'))
float_ABC = []
OUT = np.zeros((3, 9)) - 100
for row in D:
float_ABC.append([str(x) for x in row])
float_ABC = float_ABC.astype(np.float)
Alpha=float_ABC[:, [0,3,6,9,12,15]]
Beta=float_ABC[:, [2,5,8,11,14,17]]
Phi=float_ABC[:, [1,4,7,10,13,16]]
plines1 = it.product(Alpha[0],Alpha[1],Alpha[2],Alpha[3],
Alpha[4],Alpha[5],Alpha[6],Alpha[7],
Alpha[8])
plines2 = it.product(Beta[0],Beta[1],Beta[2],Beta[3],
Beta[4],Beta[5],Beta[6],Beta[7],
Beta[8])
plines3 = it.product(Phi[0],Phi[1],Phi[2],Phi[3],
Phi[4],Phi[5],Phi[6],Phi[7],
Phi[8])
for count in range(0,6**9):
sumA = next(plines1)
sumB = next(plines2)
sumC = next(plines3)
if (sum(sumC)+B)/(sum(sumA)+C) <= (B+adjust)/(C) and \
(sum(sumC)+B)/(sum(sumA)+C) >= (B+adjust-10)/(C) and \
(sum(sumB)+A)/(sum(sumA)+C) > (sum(OUT[2])+A)/(sum(OUT[0])+C):
print("#",count,"- new option found!")
OUT = np.vstack((sumA,sumC,sumB))
and sample.csv:
13.4,-18.81,-24.75,5.82,-8.21,-10.8,0,0,0,3.3,1.56,2.05,-2.1,5.36,7.05,2.6,5.65,7.44
0,-11.01,-14.49,0,-4.87,-6.41,0,0,0,0.6,2.24,2.95,1,4,5.26,1.7,2.73,3.59
0,-40.74,-53.6,0,-17.86,-23.5,0,0,0,3.5,6.53,8.59,2.9,9.36,12.31,1.9,2.61,3.44
1000,-1000,-1000,0,0,0,20.76,21.78,15.66,18.48,23.44,16.96,27.72,26.46,19.92,32.28,29.58,23.08
1000,-1000,-1000,-2.28,-6.12,-4.16,-2.28,-2.53,-1.73,0,0,0,1.92,-1.85,-1.26,1.08,-1.27,-0.86
1000,-1000,-1000,0,0,0,6.78,7.38,5.07,6.66,8.93,6.14,8.46,8.41,5.78,9.42,10.37,7.14
1000,-1000,-1000,0,0,0,28.8,34.28,27.86,37.2,39.64,33.32,45.6,42.76,36.63,54,45.88,40.03
1000,-1000,-1000,0,-4.95,-3.36,0,0,0,1.8,0.59,0.4,1.2,1.85,1.27,3.72,0.17,0.11
1000,-1000,-1000,0,0,0,27.6,19.3,13.71,32.76,23.68,17.15,37.8,20.56,14.71,22.56,27.58,21.06