TimefoldAI / TimefoldAI/timefold-solver
Feat: toConnected(Temporal)Ranges could return detailed overlap info
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 228
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 46
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the toConnectedTemporalRanges collector and the ConnectedRangeChain::getConnectedRanges entry point shown in the issue, then compare them with the linked Stack Overflow workaround. Define how each sub-interval and its maxOverlap should be represented; done means the range object exposes the detailed overlap information illustrated in the requested output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100