Optimization in Employee Rostering: Minimizing Employees while Maximizing Shift Assignments

64 Views Asked by At

I'm working on an employee rostering problem where I want to minimize the number of employees used while ensuring that each employee is assigned to the maximum number of shifts possible. I have implemented a constraint, but I'm looking for alternative or more effective approaches to achieve this objective.

Here's the constraint I've implemented in Java using OptaPlanner:

Constraint constraint = constraintFactory.forEach(Shift.class)
    .groupBy(Shift::getEmployee, ConstraintCollectors.count())
    .filter((employee, shiftCount) -> shiftCount > 0)
    .penalizeConfigurable((c, count) -> 1)
    .asConstraint("MINIMIZE_EMPLOYEES");

This constraint penalizes the use of every additional employee, which achieves my goal of reducing the number of employees but might not be the most effective approach.

I'd like to get suggestions on alternative approaches or enhancements to this constraint to better balance the objective of minimizing employees while maximizing shift assignments.

Any insights or examples of how similar problems have been approached would be greatly appreciated. Thank you!

1

There are 1 best solutions below

2
On

countDistinct is probably what you need:

Constraint constraint = constraintFactory.forEach(Shift.class)
    .groupBy(ConstraintCollectors.countDistinct(Shift::getEmployee))
    .penalizeConfigurable(assignedEmployees -> assignedEmployees)
    .asConstraint("MINIMIZE_EMPLOYEES");