title: Google OR Tools: Scheduling worker to work multiple shifts
body: <p>I'm building off of the shift scheduling code from OR Tools (<a href="https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py" rel="nofollow noreferrer">https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py</a>) and trying to have the option to schedule an employee to multiple shifts only if necessary.</p>
  
  <p>I have 7 employees who have different schedules and work a different number of days per week. I also have 8 shifts (plus the option to be off), but not all of them need to be covered every day. Each shift needs to be only covered by 1 person. Most of the time, due to shifts not having to be covered, I have enough (or more) employees than needed to cover each shift. However, sometimes I have 1 fewer employee than shifts to be covered. Specifically, I want to have the flexibility to assign shift 1 and shift 2 (they both occur everyday) to the same person if needed.</p>
  
  <p>I have tried modifying the lines of code constraining number of shifts per day.</p>
  
  <p>Original:</p>
  
  <pre class="lang-py prettyprint-override"><code>for e in range(num_employees):
          for d in range(num_days):
              model.Add(sum(work[e, s, d] for s in range(num_shifts)) == 1)
  </code></pre>
  
  <p>I have tried adding the following code snippet to allow shifts 1 and 2 to be scheduled together (and thus sum up to 2).</p>
  
  <pre class="lang-py prettyprint-override"><code>for e in range(num_employees):
          for d in range(num_days):
              model.Add((work[e, 1, d] + work[e, 2, d]) &lt;= 2)
  </code></pre>
  
  <p>However, this seems to schedule worker 0 as having both shifts 1 and 2 extremely frequently.</p>