Replies: 2 comments 1 reply
-
|
Although there is a higher-level constraint before the balancing - skill requirement. But will balancing impossible assignments together affect the effectiveness of Balance.unfairness? Because when we plan the job manually, it is reasonable to separate and balance resources from different technologies. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
It possible, you can either do it as two seperate constraints: Constraint balanceNurses(ConstraintFactory constraintFactory) {
return constraintFactory.forEach(Shift.class)
.groupBy(Shift::getEmployee, ConstraintCollectors.count())
.complement(Employee.class, employee -> 0) // needed to consider employees with no shifts
.filter((employee, count) -> employee.isNurse())
.groupBy(ConstraintCollectors.loadBalance((employee, count) -> employee, (employee, count) -> count))
.penalizeBigDecimal(HardSoftBigDecimalScore.ONE_SOFT, LoadBalance::unfairness)
.asConstraint("balance nurses");
}
Constraint balanceDoctors(ConstraintFactory constraintFactory) {
return constraintFactory.forEach(Shift.class)
.groupBy(Shift::getEmployee, ConstraintCollectors.count())
.complement(Employee.class, employee -> 0) // needed to consider employees with no shifts
.filter((employee, count) -> employee.isDoctor())
.groupBy(ConstraintCollectors.loadBalance((employee, count) -> employee, (employee, count) -> count))
.penalizeBigDecimal(HardSoftBigDecimalScore.ONE_SOFT, LoadBalance::unfairness)
.asConstraint("balance doctors");
}Or as a single constraint: Constraint balanceEmployees(ConstraintFactory constraintFactory) {
return constraintFactory.forEach(Shift.class)
.groupBy(Shift::getEmployee, ConstraintCollectors.count())
.complement(Employee.class, employee -> 0) // needed to consider employees with no shifts
.groupBy((employee, count) -> employee.getEmployeeKind(), ConstraintCollectors.loadBalance((employee, count) -> employee, (employee, count) -> count))
.penalizeBigDecimal(HardSoftBigDecimalScore.ONE_SOFT, (kind, loadBalance) -> loadBalance.unfairness())
.asConstraint("balance employees by kind");
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, Teams,
With the method LoadBalance.unfairness, we can get a good balance in task assignment in constraint stream. But the task needs some skills; some tasks are assigned to a nurse, and others need a doctor to pick up. Balancing the workload between nurses and doctors is meaningless. Can we balance the task assignment for doctors and nurses separately?
Beta Was this translation helpful? Give feedback.
All reactions