Help with Timefold Constraint Stream Type Mismatches in Employee Scheduling
I'm working on an employee scheduling system using Timefold (formerly OptaPlanner) and I'm running into type mismatch issues with my constraint streams. Specifically, I'm trying to implement a work percentage constraint that ensures employees are scheduled according to their preferred work percentage.
Here's the relevant part of my constraint:
I'm getting several type mismatch errors:
1. The
groupBy method is expecting BiConstraintCollector<Employee,Shift,ResultContainerA_,ResultA_> but getting UniConstraintCollector<Object,?,Integer>
2. The lambda in the sum collector can't resolve getStart() and getEnd() methods because it's seeing the parameter as Object instead of Shift
3. The functional interface type mismatch for Employee::getName
My domain classes are:
- Employee with @PlanningId String name and int workPercentage
- Shift with LocalDateTime start/end and @PlanningVariable Employee employee
I'm trying to:
1. Join employees with their shifts
2. Group by employee name
3. Sum up the total hours worked
4. Compare against their desired work percentage
Other constraints in my system (like shiftPreference) work fine, but I can't get the types right for this grouping operation. Any help would be appreciated!
Has anyone encountered similar issues with constraint streams and grouping operations? What's the correct way to handle these type parameters?1 Reply
⌛ This post has been reserved for your question.
Hey @dghf! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.