I working off of the Optaweb (currently discontinued) platform, and I have an EmployeeAvailability class where I can define a startDateTime and an endDateTime and the state (one of the following: UNAVAILABLE, UNDESIRED, DESIRED). However these are singular events. What I want is for the EmployeeAvailability to be a recurring event. Where I can define its recurrence (e.g. every Friday) and then it automatically handles that when planning shifts. How can I do that? I'm not looking for very specific instructions, but higher level understanding of how this could be done.
For now, I have tried solving this by setting a flag isRecurring on each EmployeeAvailability and then when I'm planning the next week, I run a function to duplicate all EmployeeAvailability with isRecurring == True in the past week. This works for weekly recurrences, but its a pretty manual process.
Ideally, I would want:
- Ability to define any recurrence pattern (weekly, monthly, daily etc). Perhaps I can store recurrence via https://www.kanzaki.com/docs/ical/rrule.html
- Not have individual
EmployeeAvailabilityobjects in database, instead just have one object which defines the recurrence pattern. This object can be then converted into individual objects when they need to be shown on the frontend OR when they need to be solved by the solver?? I'm going off of the recommendation of this: https://github.com/bmoeskau/Extensible/blob/master/recurrence-overview.md
One way to do it is to create a new class,
EmployeeAvailabilityPattern, which have a method,appliesToShift(Shift), which return true if the Shift matches the availability pattern, false otherwise. Then the constraint that matchesEmployeeAvailabilityPatternwould look like this: