title: Optimization problem with non-linear constraint
body: <p>I am new to Optimization problems and working on a simple maximization problem, that i can solve quite simply in Excel. However, I need to scale it in Python and need some help.</p>
  <p>I have a menu of different food items, and I need to maximize my energy output. Example:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Macros</th>
  <th>Food</th>
  <th>Calorie</th>
  <th>Energy</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Protein</td>
  <td>Fish</td>
  <td>100</td>
  <td>60</td>
  </tr>
  <tr>
  <td>Protein</td>
  <td>Lamb</td>
  <td>200</td>
  <td>40</td>
  </tr>
  <tr>
  <td>Protein</td>
  <td>Egg</td>
  <td>200</td>
  <td>38</td>
  </tr>
  <tr>
  <td>Carbs</td>
  <td>Banana</td>
  <td>200</td>
  <td>25</td>
  </tr>
  <tr>
  <td>Carbs</td>
  <td>Potato</td>
  <td>200</td>
  <td>30</td>
  </tr>
  <tr>
  <td>Carbs</td>
  <td>Rice</td>
  <td>200</td>
  <td>40</td>
  </tr>
  <tr>
  <td>Fat</td>
  <td>Avocado</td>
  <td>450</td>
  <td>50</td>
  </tr>
  <tr>
  <td>Fat</td>
  <td>Cheese</td>
  <td>400</td>
  <td>60</td>
  </tr>
  <tr>
  <td>Fat</td>
  <td>Cream</td>
  <td>500</td>
  <td>55</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need to Maximize Energy(e), given the following constraints:</p>
  <ol>
  <li>Only 1 of the food-items(i) per Macros(m) can be consumed. So I need an indicator variable (0/1) to select only 1 from each of m - Protein, Fat and Carbs.</li>
  <li>Total number of calories (c) should not exceed a constant value
  Assume 1 portion for each item (no constraint required for this)</li>
  </ol>
  <p><strong>Problem Formulation:</strong></p>
  <p><em>Variable:</em>
  X (m,i) → Binary Variable
  = {1 , if macro m and item i is chosen, 0 Otherwise}</p>
  <p>Maximize e(m,i) * X(m,i)</p>
  <p>Parameters:
  Calories (C) -&gt; Calories for each (Macro, fooditem)</p>
  <p>Subject to Constraints:
  For each m, Σ X (m,i) &lt;= 1 (only 1 item per each macro can be selected)
  Σ c(m,i) * X(m,i)/ X(i)  &lt;= N  ( calories consumer limited to constant N)</p>
  <p>So far, I see this as a Mixed Integer Problem with a Non-linear constraint.</p>
  <ol>
  <li>I have attempted using Pulp, but it fails due to non-linear constraint. If I remove the non-linearity, it works ok.</li>
  <li>I attempted with Scipy Optimize, but Scipy doesn't allow to create integer variables.</li>
  </ol>
  <p>How can I solve this using Python? Am I misinterpreting the problem here?</p>
  <p><strong>UPDATE:</strong>
  The above was missing the non-linear component that gets added due to the <code>mean</code>. I updated the problem from a constraint on the <code>total</code> to a constraint on the <code>mean</code>. In a non-mathematical lingo, I am taking the mean of the number I get after multiplying all the macros since I want my average calories to be less than the constant N.</p>
  <p>So mathematically,
  Σ c(m,i) * X(m,i)/ X(i)  &lt;= N  ( average calories consumer limited to constant N)</p>