Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

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

    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

    • What GPU kernels mean for your distributed inference

    • Debugging image mode with Red Hat OpenShift 4.20: A practical guide

    • EvalHub: Because "looks good to me" isn't a benchmark

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    • Deploy with confidence: Continuous integration and continuous delivery for agentic AI

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.