title: Constrained integer optimization in Python
body: <p>I'd like to minimize a function, which takes a 3x8 matrix of non-negative integers as input. Each row specifies a variable, whereas each column specifies a certain time point in the system. See the input in CSV format below.</p>
  
  <pre><code>   ,Time0,Time1,Time2
  U_i,0,0,0
  U_o,0,0,0
  C_i,0,0,0
  C_o,0,0,0
  T_i,0,0,0
  T_o,0,0,0
  D_i,0,0,0
  D_o,0,0,0
  </code></pre>
  
  <p>The constraints for each column is:</p>
  
  <pre><code>C_i + T_i &gt;= U_i
  C_o + T_o &gt;= U_o
  D_i &lt;= 15
  D_o &lt;= 15
  D_i = 0 if C_i == 0
  D_o = 0 if C_o == 0
  </code></pre>
  
  <p>And the overall constraint across rows is <code>C_i + C_o + T_i + T_o = 5</code>. I've looked at scipy.optimize, but cannot find a proper method that handles integers. Could someone give me a hint or a MWE on how to do this?</p>