feat: maximum function over connected ranges#2137
feat: maximum function over connected ranges#2137plentydone wants to merge 1 commit intoTimefoldAI:mainfrom
Conversation
fe481bf to
5aacd1b
Compare
| (activeJobList, duration) -> { | ||
| var required = activeJobList.stream().mapToInt(Job::getCapacityRequired).sum() | ||
| var capacity = equipment.getCapacity() - (activeJobList.size() - 1); // Lose a little capacity per additional job | ||
| return Math.max(0, capacity - required); |
There was a problem hiding this comment.
could do something like multiplying by the duration here to get a scaled penalty
|
Hello @plentydone, and thanks for the PR! After a first quick read, I have 2 comments:
|
|
@triceo love the feedback, agreed with all points. This spun off a discussion where @Christopher-Chianelli mentioned that he saw value in the max feature, so I figured I would prompt some ideas with an MR. Do you think the feature should be in line with my comment |
TBH I cannot really imagine right now how that would look. Do you have an API strawman you wanna paste here in chat? FYI we are already working on joiners which allow for overlap of different collections. |
Let me know what you think about the concept of this feature and it's implementation. I brought it up in Discord some weeks back. Naming things is hard.
The (very minimal) doc example is more or less my use case, calculating equipment usage at all times based on a job attribute, compared to an equipment capacity value that is lessened based on the quantity of jobs. Sort of an enhanced version of maximum overlap.
In implementing it I was starting to feel like a grouping joiner that yields tuples for distinct overlapping ranges of values (possibly with an optional filter function?) would be a more flexible and maintainable interface, but I wanted to send something along to see if you have any early opinions. It feels like a lot of use cases would be answered by a tuple of
(Collection of Range_ simultaneously overlapping), (start Point_ of overlapping range), (end Point_ of overlapping range)Happy to refactor any of the interface, implementation, tests, docs, etc according to your input.