title: Single Source Multi commodity transportation problem in PuLP
body: <p>I am currently working on a project, that I am trying to solve using a transportation problem. Essentially what I need to do is assign students to their schools based on where they live. Since they can study different things I am modeling it as a Multi commodity transportation problem. One of the restrictions that have been imposed on the project is that every student of the same study direction and the same place of living need to be assigned to the same school.
  This would give the following mathematical model:
  <img src="https://i.stack.imgur.com/loEYv.png" alt="Model" /></p>
  <p>I have managed to implement all constraints except for that last one. My attempt was to do it the following way.</p>
  <pre><code>for g in communes:
      for l in studies:
          model.addConstraint(pulp.LpConstraint(
              e=pulp.lpSum(x[g,s,l] - students[g,l] if x[g,s,l]==students[g,l] else x[g,s,l] for s in schools if (g,s,l) in x),
              sense=pulp.LpConstraintEQ,
              name='Unique_assignment[{}, {}]'.format(g,l),
              rhs=0
          ))
  </code></pre>
  <p>Adding this last constraint causes PuLP to ignore all other ones, which I do not understand. Can anyone give me a pointer as to how I would need to go about implementing a condition like this?</p>