I'm a student who has to use Python programming for a project, but I am not very good at it. In my project I need to create a number of arrays whose number is not determinate until the condition in the problem is met, in which case the problem stops and the output must be the arrays created. I coded the project as follows:
def a1(i, j, wi, a):
sum0 = 0
for z in range(0, i, 1):
sum0 = a[j][z] * wi[z] + sum0
return sum0
#__________________
rb = [125, 120, 81, 70, 60, 52, 48, 30, 28,22,18]
Ru = 645
n = len(rb)
wi = rb
import numpy as np
a = np.zeros((1000, len(wi)))
import math
a[1][0] = math.floor(a[1][0])
j = 1
while j < 2:
a[j][0] = (Ru / wi[0])
a[j][0] = math.floor(a[j][0])
for i in range(1, n, 1):
a[j][i] = ((Ru - a1(i, j, wi, a)) / wi[i])
a[j][i] = math.floor(a[j][i])
j = j + 1
j = j - 1
k = n - 2
while k >= 0:
if k >= 0:
while a[j][k] > 0:
j = j + 1
for i in range(0, n, 1):
if i < k:
a[j][i] = a[j - 1][i]
if i == k:
a[j][i] = a[j - 1][i] - 1
if i > k:
a[j][i] = ((Ru - a1(i, j, wi, a)) / wi[i])
a[j][i] = math.floor(a[j][i])
k = n - 2
k = k - 1
print(a)
To solve it, I defined a matrix of 1000 * n, when n <7 the program is running but for larger values the following error is observed:
a[j][i]=a[j-1][i]
IndexError: index 1000 is out of bounds for axis 0 with size 1000
I tried to fix this error, I changed the matrix size from 1000 to 10000000, which gives this error:
a = np.zeros((1000000000, len(wi)))
ValueError: array is too big;
arr.size * arr.dtype.itemsize
is larger than the maximum possible size.
Please help me if possible to solve this problem.
Thanks