[python] Constraint

Viewer

copydownloadembedprintName: Constraint
  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 % 6 == 0) :
  11.  
  12.                     cd = sum(self.assignments[(cycle, d)] for d in range(day, day + 6))
  13.                     self.model.Add(cd <= maxWorkedDays)

Editor

You can edit this paste and save as new:


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