-
Notifications
You must be signed in to change notification settings - Fork 160
-
Hello,
I'm using Timefold for resource scheduling with the TimeGrain pattern, where resources can be nurses, doctors, rooms, or equipment assigned to specific timeslots.
Use Case:
I need to handle scenarios where a single resource (e.g., a nurse) isn't available for the entire duration of a procedure. In such cases, I want to split the time allocation between multiple resources of the same type.
Requirements:
- Primary constraint: Prefer assigning a single nurse for the entire procedure duration
- Fallback constraint: If a single nurse isn't available, allow splitting the procedure time between 2 or more nurses
Question:
What's the recommended approach in Timefold to implement this flexible resource assignment?
Any suggestions or examples for handling split resource assignments would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 1 reply
-
Hi @yuvzc, sorry for the delay on the answer, Team Days for the Timefold Team.
Could you clarify your domain model? What are currently your variables (@PlanningVariable) and what are your entities (@PlanningEntity). Are the "timeslots" procedures?
I find your question slightly confusing since "Timeslot" is another pattern, distinct from the TimeGrain one.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hello Tom,
Thanks for your reply
Sorry for the confusion its TimeGrain
So I have Planning Entity which is Appointment Class, Having 2 Planning variable Resource and TimeGrain.
In my solution ApointmentSolution Class I initialize my MyValueRangeProviders List resources and List timeGrains 15 min slots. Starting from a startDateTime and endDateTime.
Thanks,
Yougal
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @yuvzc ,
In your design, an Appointment can only ever have 1 Resource (nurse). Your requirement to split a appointment across 2 nurses isn't going to work this way.
Rework to 1-to-many
In this case, there is a Many-2-Many relationship between Appointments and Resources. As per our Domain Modeling Guidelines , these should be avoided by introducing a new concept with One-To-Many relationships.
In this case, you might introduce a "AppointmentAssignment" class (PlanningEntity), which brings together the Appointment, the Resource and the TimeGrain (PlanningVariables).
This will also make it possible to add different resources (Room, Equipment, ..) to a single Appointment (through the AppointmentAssignment class).
Additional considerations
When looking at Resource and TimeGrain, there is a tight relationship between the 2 which may make it worth it to combine them into a single PlanningVariable, something like "ResourceTimeGrain". This would contain both the Resource and the Time.
- Upside: This makes it possible to only add TimeGrains for a resource when they are available. This means you will have less combinations where you'd break a "Resource is not available" constraint.
- Downside: If you have a lot of long appointments (which will need 3 (45min) or 4 (1h) timegrains), then it will be harder for the solver to find the exact ResourceTimeGrains to satisfy your "Prefer assigning a single nurse for the entire procedure duration" requirement. This may be remedied by changing the move-selectors or even implementing the custom moves>
Beta Was this translation helpful? Give feedback.