title: Python Constraint Optimization Issue
body: <p>I am working on a Fantasy Football program and having an issue with a constraint. A fantasy team is made up of 1QB, 2RBs 3WRs 1TE, 1DEF and 1FLEX (which can be a RB, WR or TE)</p>
  <p>My output is duplicating players. So, For example, if John Doe fills the RB position, I need him to not fill the FLEX position. I am at a loss of how to get this constraint done. Maybe a name comparison to ensure names don't equal each other?</p>
  <p><strong>Any advice would be greatly appreciated!</strong></p>
  <p>Here is some sample data:</p>
  <pre><code>| position | displayName         | Roster   | Position | salary | points |
  |----------+---------------------+----------+----------+--------+--------|
  | RB       | Christian McCaffrey | 15033483 | RB/FLEX  | 10000  | 30.95  |
  | WR       | Michael Thomas      | 15033799 | WR/FLEX  | 9000   | 24.62  |
  | QB       | Lamar Jackson       | 15033397 | QB       | 8100   | 29.85  |
  | RB       | Dalvin Cook         | 15033485 | RB/FLEX  | 7900   | 21.62  |
  </code></pre>
  <pre><code># Set constraints
  ##################################################################
  salaries = {}
  points = {}
  
  for pos in availables.position.unique():
      available_pos = availables[availables.position == pos]
      salary = list(available_pos[[&quot;displayName&quot;,&quot;salary&quot;]].set_index(&quot;displayName&quot;).to_dict().values())[0]
      point = list(available_pos[[&quot;displayName&quot;,&quot;points&quot;]].set_index(&quot;displayName&quot;).to_dict().values())[0]
      salaries[pos] = salary
      points[pos] = point
  
  pos_num_available = {
      &quot;QB&quot;: 1,
      &quot;RB&quot;: 2,
      &quot;WR&quot;: 3,
      &quot;TE&quot;: 1,
      &quot;FLEX&quot;: 1,
      &quot;DST&quot;: 1
  }
  
  
  pos_flex = {
      &quot;QB&quot;: 0,
      &quot;RB&quot;: 1,
      &quot;WR&quot;: 1,
      &quot;TE&quot;: 1,
      &quot;FLEX&quot;: 0,
      &quot;DST&quot;: 0
  }
  
  
  pos_flex_available = 3
  SALARY_CAP = 50000
  
  _vars = {k: LpVariable.dict(k, v, cat=&quot;Binary&quot;) for k, v in points.items()}
  ##################################################################
  # Problem Definition
  ##################################################################
  
  prob = LpProblem(&quot;Fantasy&quot;, LpMaximize)
  rewards = []
  costs = []
  position_constraints = []
  
  
  for k, v in _vars.items():
       costs += lpSum([salaries[k][i] * _vars[k][i] for i in v])
       rewards += lpSum([points[k][i] * _vars[k][i] for i in v])
       prob += lpSum([_vars[k][i] for i in v]) &lt;= pos_num_available[k]
       prob += lpSum([pos_flex[k] * _vars[k][i] for i in v]) &lt;= pos_flex_available
  
  prob += lpSum(rewards)
  prob += lpSum(costs) &lt;= SALARY_CAP
  prob.solve()
  </code></pre>