Assume I have N lists (vectors) and I want to choose x of them 1<x<[N]
(x is not predetermined)
so I will get the maximum value of func(lists).
For example:
l1 = [3,4,7,-2]
l2 = [0.5,3,6,2.7]
l3 = [0,5,8,3.6]
mat = [l1, l2, l3]
result = maximize(func, mat)
def func(mat):
# doing some math between lists. For Example:
sum_list = list(mat[0])
for li in mat[1:]:
sum_list = map(operator.add, sum_list, li)
accum_min_lst = []
for i, val in enumerate(sum_list):
x = sum_list[:i + 1]
accum_min_lst.append(val - max(x))
return min(accum_min_lst)
Possible results:
[l1], [l2], [l3], [l1,l2], [l1,l3], [l2,l3], [l1,l2,l3]
If I'll write a naive solution and just run all the combinations it will take forever 2^N.
I'm trying to find a solution using cvxpy or maybe scipy.optimize.minimize but I find it hard to understand the kind of function I need to use for my problem, thought maybe I should try evolutionary algorithm to find an approximate answer, Or maybe I should use portfolio optimization instead.