[python] Constraint2

Viewer

copydownloadembedprintName: Constraint2
  1.     def const_maxDaysInCalendarWeek(self, maxWorkedDays: int = 5) :
  2.         """
  3.         No worker can work more than maxWorkedDays in any maxRange of consecutive days in the same calendar week
  4.         """        
  5.  
  6.         for cycle in self.cycles:
  7.  
  8.             for day in self.days :
  9.  
  10.                 if (day % 7 == 0) :
  11.  
  12.                     cd = sum(self.assignments[(cycle, d)] for d in range(day, day + 7))
  13.                     self.model.Add(cd <= maxWorkedDays)

Editor

You can edit this paste and save as new:


File Description
  • Constraint2
  • Paste Code
  • 09 Jun-2023
  • 477 Bytes
You can Share it: