title: Conditional Constraint Linear Program in Python's Pulp Module
body: <p>Is there a way to add a constraint within pulp in python that would count all the variables above 5 and require that count to be greater than lets say 10? I currently have the following code but it only calls the function once;</p>
  
  <pre><code>def min_qty_constraint(vars):
      count = 0
      for v in vars:
          if v.varValue &gt; 5 :
              count += 1
      print count
      return -count
  
  prob = pulp.LpProblem('problem',pulp.LpMaximize)
  prob +=  min_qty_constraint(vars) &lt;= 10
  </code></pre>
  
  <p>so for example if i had vars = [x1,x2,..,x20] where xi is a pulp.Lpvariable and x1,..,x10 = 6 then then 10 of these variables are greater than 5 thus fulfilling the contraitns that at least 10 variables have values greater than 5.</p>