Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: toConnected(Temporal)Ranges could return detailed overlap info #1398

Open
mcimbora opened this issue Feb 19, 2025 · 0 comments
Open

Feat: toConnected(Temporal)Ranges could return detailed overlap info #1398

mcimbora opened this issue Feb 19, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@mcimbora
Copy link
Contributor

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

Image

@mcimbora mcimbora added enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. labels Feb 19, 2025
@triceo triceo removed the process/needs triage Requires initial assessment of validity, priority etc. label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants