Reputation: 91
I am looking into the example use cases from OptaPlanner. And I could not find any similar example which can solve multiple planning variables in one planning entity. For example, in nurse rostering, each ShiftAssignment(PlanningEntity)
for one shift might require multiple assigned Employee(PlanningVariables)
. In this case, how can we make use of planner and write rules?
Upvotes: 2
Views: 1191
Reputation: 27312
Instead of making the OneToMany side a planning variable, make the ManyToOne side a planning variable. If you have a ManyToMany side, introduce a class between (like in relational database design) and acts as a ManyToOne-OneToMany.
In the nurse rostering example, an example can need 4 nurses on the Shift
at ShiftDate
1-JAN for ShiftType
Early. In that case, Shift
has requiredEmployeeSize
4, and 4 ShiftAssignments
are created for that single Shift
, each with a different indexInShift
. That way, the ShiftAssignment
has a planning variable Employee
which is a ManyToOne relationship, (even though between Shift
and Employee
there's a ManyToMany relationship).
Upvotes: 2