title: Finding the best combination of lists with maximum function value
body: <p>Assume I have N lists (vectors) and I want to choose x of them <code>1&lt;x&lt;[N]</code> (x is not predetermined)
  so I will get the maximum value of func(lists).</p>
  
  <p>For example:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Possible results:</p>
  
  <pre><code>[l1], [l2], [l3], [l1,l2], [l1,l3], [l2,l3], [l1,l2,l3]  
  </code></pre>
  
  <p>If I'll write a naive solution and just run all the combinations it will take forever 2^N.</p>
  
  <p>I'm trying to find a solution using <a href="http://www.cvxpy.org/en/latest/tutorial/intro/index.html" rel="nofollow">cvxpy</a> or maybe <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#scipy.optimize.minimize" rel="nofollow">scipy.optimize.minimize</a>
  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 <a href="http://nbviewer.jupyter.org/github/cvxgrp/cvx_short_course/blob/master/applications/portfolio_optimization.ipynb" rel="nofollow">portfolio optimization</a> instead.</p>