How to create rostering with Red Hat business optimizer

Li Khia
4 min readMar 19, 2021

This blog is to share how to implement a Duty Rostering with Red Hat Business Optimizer. Red Hat Business Optimizer is an AI constraint solver. It optimizes planning and scheduling problems such as Duty Rostering.

The requirements for Duty Rostering Use Case is to assign shifts to employees based on their respective duty (e.g. Cleaning, Drying, Delivery, etc) and with the following conditions met.

  1. Employees are only assigned one shift per day. [Hard Constraints]
  2. All shifts that require a particular employee duty are assigned an employee with that particular duty. [Hard Constraints]
  3. If an employee requests a shift off, the shift is reassigned to another employee. [Hard Constraints]
  4. No employee is assigned a shift that begins less than 10 hours after their previous shift ended. [Hard Constraints]
  5. All employees are assigned with the same number of shifts.. [Soft Constraints]

Before starting with the implementation, let’s plan out the resources required and draw out a domain model (Please refer to Diagram 1 below).

Diagram 1: Data Model

Classes required as resources here are Employee, Duty, Timeslot, Shift, DayOfRequest. These are referred to as the Problem Facts.

A class to represent as the planning result is ShiftAssignment class where it holds information on employee and assigned shift. This is referred to as the Planning Entity. Employee is the Planning variable that changes during the planning

A class to hold everything for the planning is DutyRoster class. This is referred to as a Planning Solution. It contains a list of employees which is the Planning Range.

Just to share my thought process to come out with this data model.

  1. Step 1 — List out all the resources required to come out with the rostering
  2. Step 2 — Identify the relationship between the resources. Normalize it by eliminating redundancy and inconsistent dependency.
  3. Step 3 — Create the class to hold information (e.g. shift timeslot, employee) about the rostering and which information within this class will change during the solving process. For this case, it is the employee as it will change depending on the rules defined.
  4. Step 4 — Create the class to hold all the information (e.g. DutyRoster class)
  5. Step 5 — Review the data model structure if it matches with the attributes required for rules (e.g soft constraints and hard constraints). Repeat the process till everything is in place.

The use case is developed using Red Hat Decision Manager 7.7. After installed Decision Manager on EAP, login to the Business Central and do the following:

  1. Create a new project.
  2. Create data objects for Employee, Duty, Timeslot, Shift, DayOfRequest as the problem facts.

3. Create the data object for ShiftAssignment as the planning entity.

4. Create the data object for DutyRoster as the planning solution. Click on the corresponding “blue planet icon” of the employeeList attribute and select the “Planning value range provider” checkbox and assign id as employeeRange.

5. Reopen shiftAssignmnet. Click on the corresponding “ blue planet icon” of employee attribute and select the “Planning variable” checkbox and assign value range id as employeeRange.

6. Define the (3) constraints. This means if the employee is having a shift off, he/she will not be assigned to the shift. By assigning negative value to hard score, it means that it must not be broken.

7. Define the (5) constraints. This means assigning all employees the same number of shifts. This is a soft constraint that should not be broken if it can be avoided.

8. Add Solver Configuration. It is using default algorithms (Construction Heuristic and Late acceptance).

9. Click on [Build].

10. If the above is successful, click on [Deploy]

11. Navigate to Execution Servers. Get the URL.

12. Open Postman. Open a Tab with URL as <Copied URL>/solvers/<Solver name> and method as PUT. Specify the body as shown below.

13. Open another tab with URL as <Copied URL>/solvers/<Solver name>/state/solving and method as POST. The body will be the XML format of Duty Roster class.

14. Open another tab with URL as <Copied URL>/solvers/<solver name>/bestsolution with method as GET. This will return the result from the planning engine.

Please refer to https://github.com/likhia/DutyRosterProject for the completed project and sample input files.

--

--