Feat: toConnected(Temporal)Ranges could return detailed overlap info
Hey team, I'm using the following construct to get ranges with overlapping intervals.
constraintFactory.forEach(Interval.class)
.groupBy(ConstraintCollectors.toConnectedTemporalRanges(
shift -> interval.getStart().toInstant(),
shift -> interval.getEnd().toInstant()))
.flattenLast(ConnectedRangeChain::getConnectedRanges)
.filter(range -> ...
It pretty much does what I'd want. I can get the max number of concurrent shifts in intervals. One thing that'd be useful is getting additional info about the violations in different sub-intervals from the range object without the need to calculate it manually. Let me explain - see the example (screenshot) below. The first pair of overlapping shifts has an overlap of 2 hours, the second pair has an overlap of 4 hours. From the quality-of-the-solution perspective, both examples are wrong, but the first one is better, since the overlap is smaller.
FYI I successfully workarounded the problem by following @Christopher-Chianelli 's advice here https://stackoverflow.com/a/78209756/9698517.
Current (first interval pair - example below):
interval
- start: 8:00
- end: 22:00
- maxOverlap: 2
Desired (first interval pair - example below):
- start: 8:00
- end: 22:00
- maxOverlap: 2
- intervals
-- interval 1
--- start: 08:00
--- end: 14:00
--- maxOverlap: 1
-- interval 2
--- start: 14:00
--- end: 16:00
--- maxOverlap: 2
-- interval 3
--- start: 16:00
--- end: 22:00
--- maxOverlap: 1
I would also appreciate that feature. I raised the same discussion here: https://github.com/TimefoldAI/timefold-solver/discussions/1717#discussion-8646355