Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to implement employee rostering with Red Hat Business Optimizer

June 9, 2021
Li Khia Lim
Related topics:
Artificial intelligenceAutomation and managementJavaKubernetes
Related products:
Red Hat OpenShift

Share:

    This article discusses and demonstrates how you can implement duty rostering with Red Hat Business Optimizer. Business Optimizer, a component in Red Hat Decision Manager, is an AI (artificial intelligence) constraint solver that optimizes planning and scheduling problems with Decision Manager.

    The duty rostering use case requires us to assign shifts to employees based on their respective duty—for example, cleaning, drying, delivery, and so on. The following hard constraint conditions must be met:

    • Employees are only assigned one shift each day.
    • Any shifts that require a specific employee duty are assigned to an employee who can perform that particular duty.
    • Once an employee schedules a shift off, the shift is reassigned to another employee.
    • No employee is assigned to a shift that begins less than 10 hours after their previous shift ends.

    Additionally, there is a soft constraint that all employees should be assigned to the same number of shifts.

    Planning the employee roster domain model

    Before starting with the duty rostering implementation, let's first plan the resources we need to draw out a domain model, which is shown in Figure 1.

    The required resource classes here are Employee, Duty, Timeslot, Shift, and DayOfRequest. These classes are problem facts that do not change during the planning.

    The planning result class is ShiftAssignment. It holds information about an employee and their assigned shift representing a one-to-one relationship. This relationship is referred to as the planning entity that changes during solving. For example, the shift can be assigned to another employee. Employee is the planning variable that changes during planning.

    The class that holds everything needed for planning is called the DutyRoster class. This is the planning solution that contains the dataset for the solver to solve. The DutyRoster class contains a list of employees that comprise the planning range. This is the set of possible planning values for a planning variable.

    The example DutyRoster domain model.
    Figure 1: The example DutyRoster domain model.

    Just to share my thought process, here are the steps I took to create this data model:

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

    Use case implementation with Red Hat Decision Manager

    We will develop our use case using Red Hat Decision Manager 7.7. After installation, log in to Decision Central and perform the following steps:

    1. Create a new project.
    2. Create data objects for Employee, Duty, Timeslot, Shift, DayOfRequest as the problem facts, as you see in Figure 2.
      Using Decision Central to create a new project and data objects as the problem facts.
      Figure 2: Using Decision Central to create a new project and data objects as the problem facts.
    3. Create the data object for ShiftAssignment as the planning entity, as shown in Figure 3.
      Creating the data object for ShiftAssignment in Decision Central
      Figure 3: Create the data object for ShiftAssignment as the planning entity.
    4. Create the data object for DutyRoster as the planning solution, as shown in Figure 4. Click the employeeList attribute's corresponding “blue planet" icon, select the Planning Value Range Provider checkbox, and assign the Identifier as employeeRange.
      Creating the data object DutyRoster as the planning solution in Decision Central
      Figure 4: Create the data object DutyRoster as the planning solution.
    5. Reopen shiftAssignment. Click the employee attribute's corresponding blue planet icon, select the Planning variable checkbox, and assign employeeRange as the Value Range Id. See Figure 5.
      The planning variables and the value range ID are selected.
      Figure 5: Select the planning values (planning variables) and the value range ID.
    6. Define the third constraint: If the employee requested a shift off, they will not be assigned to the shift. Assigning a negative value to a hard score means that it must not be broken. See Figure 6.
      Configuring DayOffRequests as hard constraints.
      Figure 6: Create and assign DayOffRequests as hard constraints.
    7. Define the fifth constraint (Figure 7): All employees are assigned the same number of shifts. Ideally, this soft constraint should not be broken.
      Creating a guided rule that balances the employee shift number as soft constraints.
      Figure 7: Create and balance the employee shift number as soft constraints.
    8. Add the Solver configuration on the Score Director Factory page shown in Figure 8. This configuration uses the default algorithm, construction heuristic, and late acceptance.
      A sample Duty Roster Solver configuration shown on the Score Director Factory page.
      Figure 8: Add the Duty Roster Solver configuration on the Score Director Factory page.
    9. Click Build. Make sure the build is successful.
    10. When the build is successful, click Deploy. Make sure the deployment is successful.
    11. Get the URL of the rule on the Kie Server.
    12. Navigate to the execution servers. Get the URL as <Copied URL> (see Figure 9).

      A sample URL shown in the Kie Server.
      Figure 9: Get the URL from the Kie Server.
    13. Open Postman. Open a tab with the URL as <Copied URL>/solvers/<Solver name> and use the PUT method to specify and publish the body, as shown in Figure 10.
      Using the PUT method to specify and publish the body.
      Figure 10: Open the URL and use the PUT method to specify and publish the body.
    14. Open another tab with the URL as <Copied URL>/solvers/<Solver name>/state/solving and use the POST method. This posts the DutyRoster class in XML format—that is, the content of the planning solution (see Figure 11).
      Using the POST method to post the content of the planning solution.
      Figure 11: Open the URL and use the POST method to post the content of the planning solution.
    15. Open another tab with the URL as <Copied URL>/solvers/<solver name>/bestsolution and use the GET method, as shown in Figure 12. This returns the result from the planning engine.
      Using the GET method to return the result from the planning engine.
      Figure 12: Open the URL and use the GET method to return the result from the planning engine.

    Conclusion

    See the Duty Roster project on GitHub for the completed project and sample input files.

    Last updated: January 22, 2024

    Related Posts

    • Detecting credit card fraud with Red Hat Decision Manager 7

    • Quickly try Red Hat Decision Manager in your Cloud

    Recent Posts

    • Cloud bursting with confidential containers on OpenShift

    • Reach native speed with MacOS llama.cpp container inference

    • A deep dive into Apache Kafka's KRaft protocol

    • Staying ahead of artificial intelligence threats

    • Strengthen privacy and security with encrypted DNS in RHEL

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue