title: finding best combination of date sets - given some constraints
body: <p>I am looking for the right approach for solve the following task (using python):</p>
  
  <p>I have a dataset which is a 2D matrix. Lets say:</p>
  
  <pre><code>1   2   3
  5   4   7
  8   3   9
  0   7   2
  </code></pre>
  
  <p>From each <strong>row</strong> I need to pick <strong>one number</strong> which is not 0 (I can also make it NaN if that's easier).<br>
  I need to find the combination with the lowest total sum.</p>
  
  <p>So far so easy. I take the lowest value of each row.</p>
  
  <p>The solution would be:</p>
  
  <pre><code>1   x   x
  x   4   x
  x   3   x
  x   x   2
  
  Sum:    10  
  </code></pre>
  
  <p>But: There is a variable minimum and a maximum sum allowed for each <strong>column</strong>. So just choosing the minimum of each row may lead to a not valid combination.</p>
  
  <p>Let's say min is defined as 2 in this example, no max is defined. Then the solution would be:</p>
  
  <pre><code>1   x   x
  5   x   x
  x   3   x
  x   x   2
  
  Sum:    11  
  </code></pre>
  
  <p>I need to choose 5 in row two as otherwise column one would be below the minimum (2).</p>
  
  <p><br>
  I could use brute force and test all possible combinations. But due to the amount of data which needs to be analyzed (amount of data sets, not size of each data set) that's not possible.</p>
  
  <p><br>
  Is this a common problem with a known mathematical/statistical or other solution?</p>
  
  <p>Thanks<br>
  Robert</p>