EDITED: I found a similar topic but my question is different in that the resultant array will be very large and will not fit into memory (8 ** (2 ** 7)) iterations
I want to find the fastest algorithm to get all the combinations in the matrix.
I have follow solution:
def iter_matrix(self, matrix_of_all_comb):
for combination in itertools.product(*matrix_of_all_comb)):
if check_constr(combination):
yield np.array(combination)
for i in iter_matrix(arg):
print(i)
matrix_of_all_comb - any matrix with dim n*m (I have n > 8 and m > 9). Do not pay attention to "check_constr", this operation is instantaneous and does not affect the code.
My main problem is how to hack to maximize the speed of iteration (It is the generator that is needed to not record the result of all combinations), but it does not seem that it is possible. Do you have ideas?