Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-2419

Consecutive Interval Constraint Collector

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 8.9.0.Final
    • None
    • optaplanner-core
    • None

      We should have a constraint collector that allows users to collect consecutive intervals

      Ex:

      Constraint atMostThreeConsecutiveShifts(ConstraintFactory constraintFactory) {
          return constraintFactory.from(Employee.class)
                           .join(Shift.class, Joiners.equal(Function.identity(), Shift::getEmployee)
                           .collect((employee, shift) -> employee, consecutiveIntervals((employee,shift) -> shift, Shift::getStartDateTime, Shift::getEndDateTime))
                           .flattenLast(IntervalCluster::getSequences)
                           .filter((employee,sequence) -> sequence.size() > 3)
                           .penalize("At most 3 consecutive shifts", HardSoftScore.ONE_HARD);
      } 
      

              cchianel Christopher Chianelli (Inactive)
              cchianel Christopher Chianelli (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: