title: Constraining Pulp Binary Variable Selection Based on Another Variable
body: <p>I'm creating an optimisation script for Fantasy Football. It starts off quite easily- loading in players &amp; their relevant details.</p>
  
  <p>The key in this game is that 15 players can be selected in your squad but only 11 can be fielded per week.</p>
  
  <p>What I would like to do is have 2 variables- one defining that the player is in your squad and a sub-variable that determines whether you put the player in your starting 11. </p>
  
  <p>I have tried a few things- one broad solution is that have 2 unrelated variables. 1 that selects 11 starters and a second that selects 4 subs. This works well for 1 week, but for example one week Player A from your squad might be best starting and the next he's better on the bench. Therefore I would get a more optimal solution if I can make the starting 11 variable a subset of the squad variable.</p>
  
  <p>I've attached the code defining the variables and my attempt at creating a constraint that would link them together. (there are other constraints that all successfully work. For example I can pick a starting 11 or a squad of 15 to maximize expected results without issue, but I cannot pick a starting 11 within a squad of 15. </p>
  
  <pre><code>#VECTORS OF BINARY DECISIONS VARIABLES
  squad_variables = []
  for rownum in ID:
      variable = str('x' + str(rownum))
      variable = pulp.LpVariable(str(variable), lowBound = 0, upBound = 1, cat= 'Integer') 
      squad_variables.append(variable)
  
  xi_variables = []
  for rownum in ID:
      bariable = str('y' + str(rownum))
      bariable = pulp.LpVariable(str(bariable), lowBound = 0, upBound = 1, cat= 'Integer') 
      xi_variables.append(bariable)
  </code></pre>
  
  <p>The code below is not working for this task and is the root of the problem..</p>
  
  <pre><code>#ID CONSTRAINTS (ie. only 15 unique id selection across both systems)
  id_usage = ""
  for rownum in ID:
      for i, player in enumerate(squad_variables):
          if rownum == i:
              formula = max(1*xi_variables[rownum],(1*player))
              id_usage += formula
  prob += (id_usage ==15)
  </code></pre>
  
  <p>Any help would be greatly appreciated- perhaps this is simply a non-linear problem. Thank you :)</p>