I am trying to come up with a Dynamic employee scheduling python code for a small ice cream chain based on the customer traffic everyday.

Some of the complex Constraints are:

- there are no fixed shifts per day
- min hours one can work is 4 and max hours is 9.
- one shall only work 5 days in a week.
- only a person in manager role should open and close the store.
- if someone is working more than 4 hrs they shall have a 30min break break and another employee must join before the break.
- I can hire as many people to serve customer traffic i.e., no fixed employees per day or per week.

Although I tried playing with PySchedule and Google OR Tools, but i was not able to code the above constraints. Also, I am not sure if there is another open source library available for these type of dynamic constraints.

I expect the end result something like this in the link below:

I would appreciate if someone can throw light and point me in right direction.

You should create all possible shifts for one day, marking the one that must be assigned to a manager.

Then you have two options

1) optimally select the best combination per day. Then reconstruct full shifts from that 2) in the above selection, introduce the notion of weekly schedule for 1 employee and build.

The first part version is a simple enumeration. The second part is a set covering/partitioning using a MIP solver or CP-SAT.