[optaweb-employee-rostering] Add more constraint

232 views
Skip to first unread message

Dat Huynh

unread,
Oct 4, 2019, 10:01:46 PM10/4/19
to OptaPlanner development
Hi Everyone,

I am a newbie on OptaPlanner Employee scheduling. I found that this forum is quite useful for sharing knowledge and ask question.
I want to add more constraint for this.
My problem was descrided as below:
Input data: 
- I create an unassigned shift in spot. This shift last more than 8 hour.For example this unassigned shift YYY look like: 8:00 ~ 19:00
- In Availability Roster (Employee availability), there was a lot of available time of employee. For example: Employee A has available time on 8:00 ~ 12:00; Employee B has available time on 12:00~17:00; Employee C has available time on 16:00~ 20:00,...

Normally, 1 shift will be assign to one employee. But in this case, I want to make the constraint look like more flexibility.  For example Shift YYY will be assign to 3 member that the sum their availability 
will be fix for Shift YYY required time. In another way, I want to make a constraint that split the Shift YYY into smaller shift in other to assign to more employee.

The desired result:
Shift YYY will be split into 3 shift and assign as below: 
 employeeA: 8:00~12:00 
 employeeB: 12:00~16:00 
 employeeC: 16:00~19:00

Could you guys give me some advice?
Looking forward to hearing from all of you.

Thank you.

mtal...@redhat.com

unread,
Oct 10, 2019, 4:53:39 PM10/10/19
to OptaPlanner development
Hi Dat,

This is an interesting question, so basically you want to assign a shift to multiple employees. I don't think this can be accomplished by adding additional constraints or modifying existing ones, it requires modifying the problem domain.

OptaPlanner assigns a PlanningEntity (Shift) a PlanningVariable (Employee) which has to be a POJO, in the current domain design a Shift has only one @PlanningVariable field (Employee), so it can be assigned to only one employee. In order to accomplish your goal without redesigning the model on thing I can think of is changing the shifts duration, so instead of one 10-hour shift you'll have 2 5-hour shifts or 5 2-hour shifts. And then add additional constraints to reward assigning consecutive shifts of less than x hours to the same employee.

Hope this helps.

Dat Huynh

unread,
Oct 12, 2019, 11:36:07 PM10/12/19
to OptaPlanner development
Hi Talluzi,

I am very happy to hear the answer from you.
Thank you for your answer. This help me find the way to accomplish my goal above.
I will try to change shift duration and modify constraint rule.
I plan to do as below:
  • Delete the constraint "At most one shift assignment per day per employee"
  • Add more medium constraint "Employee can work consecutive shifts of less than x hours"
Again thank you very much. If I find some problem on the way to solve it, Could I ask you more?

Best regards,
Dat
Reply all
Reply to author
Forward
0 new messages