title: Using an average in a ompr linear programming constraint
body: <p>I'm using the <code>ompr</code> package for solving integer program. I wanted to include a constraint that based on the average value of another binary variable. </p>
  
  <p>In the example below, I have some food and I want to find at least 5 items and minimize the cost. I would like the average calorie count to be above some minimum. In the code below, the first constraint is that the <em>sum</em> of the calories is above <code>min_avg_cal</code>. Can this be rewritten so the constraint is that the <em>average</em> calorie of the chosen food is above <code>min_avg_cal</code>? </p>
  
  <pre><code>library(dplyr)
  library(ROI)
  library(ROI.plugin.glpk)
  library(ompr)
  library(ompr.roi)
  
  
  n &lt;- 20
  cost &lt;- runif(n, 0, 10)
  calories &lt;- runif(n, 100, 200)
  min_avg_cal &lt;- 140
  
  model &lt;- MIPModel() %&gt;%
    add_variable(x[i], i =1:n, type = "binary") %&gt;%
    set_objective(sum_expr(cost[i] * x[i], i = 1:n), "min") %&gt;%
    add_constraint(sum_expr(calories[i] * x[i], i = 1:n) &gt;= min_avg_cal) %&gt;% 
    add_constraint(sum_expr(x[i], i = 1:n) &gt;= 5) 
  
  result &lt;- solve_model(model, with_ROI(solver = "glpk", verbose = TRUE))
  result$solution
  </code></pre>