Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Splitting Resource Assignments Across Multiple Time Grains in Timefold #1623

yuvzc started this conversation in General
Discussion options

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:

  1. Primary constraint: Prefer assigning a single nurse for the entire procedure duration
  2. 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.

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

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.

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
1 reply
Comment options

TomCools Jun 5, 2025
Collaborator

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /