Deploying and using the employee roster starter application for Red Hat Business Optimizer on Red Hat OpenShift Container Platform

Red Hat Decision Manager 7.2

Red Hat Customer Content Services

Abstract

This document describes how to deploy and use the OptaShift Employee Rostering example included as an add-on in Red Hat Decision Manager 7.2.

Preface

As a business rules developer, you can test and interact with the Red Hat Business Optimizer functionality by quickly deploying the employee-rostering starter project included in the Red Hat Decision Manager distribution to OpenShift.

Prerequisites

  • You have access to a deployed OpenShift environment. For details, see the documentation for the OpenShift product that you use.

Chapter 1. Overview of the employee rostering starter application

The employee rostering starter application assigns employees to shifts on various positions in an organization. For example, you can use the application to distribute shifts in a hospital between nurses, guard duty shifts across a number of locations, or shifts on an assembly line between workers.

Optimal employee rostering must take a number of variables into account. For example, different skills can be required for shifts in different positions. Also, some employees might be unavailable for some time slots or might prefer a particular time slot.

The Red Hat Business Optimizer rules for this starter application use both hard and soft constraints. During an optimization, the Red Hat Business Optimizer engine may not violate hard constraints, for example, if an employee is unavailable (out sick), or that an employee cannot work two spots in a single shift. The Red Hat Business Optimizer engine tries to adhere to soft constraints, such as an employee’s preference to not work a specific shift, but can violate them if the optimal solution requires it.

Chapter 2. Installing and starting the employee rostering starter application on OpenShift

You can deploy the Red Hat Business Optimizer Employee Rostering starter application to Red Hat OpenShift Container Platform using an OpenShift template or using the provision.sh shell script that is provided in the add-ons distribution.

If you use an OpenShift template, Red Hat OpenShift Container Platform loads an image with the application from the Red Hat repository and deploys it. This method of deployment is a technological preview.

If you use the script, it builds and packages the application source code locally and uploads it to the OpenShift environment for deployment. You can use this method when Java developer tools (Java Development Kit and Maven) and a bash shell command line are available.

Important

In the deployed application, the data is held in memory and lost when the pod is restarted.

2.1. Deploying the application using the template

To deploy the application using the template, you must first ensure that the image streams for Red Hat Decision Manager are available and configure OpenShift registry authentication. Then you can deploy the template.

2.1.1. Ensuring the availability of image streams and the image registry

To deploy Red Hat Decision Manager components of Red Hat OpenShift Container Platform, you must ensure that OpenShift can download the correct images from the Red Hat registry. To download the images, OpenShift requires the information about their location (known as image streams). OpenShift also must be configured to authenticate with the Red Hat registry using your service account user name and password.

Some versions of the OpenShift environment include the required image streams. You must check if they are available. If image streams are available in OpenShift by default, you can use them if the OpenShift infrastructure is configured for registry authentication server. The administrator must complete the registry authentication configuration when installing the OpenShift environment.

Otherwise, you can configure registry authentication in your own project and install the image streams in the same project.

Procedure

  1. Determine whether Red Hat OpenShift Container Platform was configured with the user name and password for Red Hat registry access. For details about the required configuration, see Configuring a Registry Location. If you are using an OpenShift Online subscription, it is configured for Red Hat registry access.
  2. If Red Hat OpenShift Container Platform was configured with the user name and password for Red Hat registry access, run the following commands:

    $ oc get imagestreamtag -n openshift | grep rhdm72-decisioncentral-openshift
    $ oc get imagestreamtag -n openshift | grep rhdm72-kieserver-openshift

    If the outputs of both commands are not empty, the required image streams are available in the openshift namespace and no further action is required.

  3. If the output of one or both of the commands is empty or if OpenShift was not configured with the user name and password for Red Hat registry access, complete the following steps:

    1. Ensure you are logged in to OpenShift with the oc command and that your project is active.
    2. Complete the steps documented in Registry Service Accounts for Shared Environments. You must log on to Red Hat Customer Portal to access the document and to complete the steps to create a registry service account.
    3. Select the OpenShift Secret tab and click the link under Download secret to download the YAML secret file.
    4. View the downloaded file and note the name that is listed in the name: entry.
    5. Run the following commands:

      oc create -f <file_name>.yaml
      oc secrets link default <secret_name> --for=pull
      oc secrets link builder <secret_name> --for=pull

      Where <file_name> is the name of the downloaded file and <secret_name> is the name that is listed in the name: entry of the file.

    6. Download the rhdm-7.2.0-openshift-templates.zip product deliverable file from the Software Downloads page and extract the rhdm72-image-streams.yaml file.
    7. Complete one of the following actions:

      • Run the following command:

        $ oc create -f rhdm72-image-streams.yaml
      • Using the OpenShift Web UI, select Add to Project → Import YAML / JSON and then choose the file or paste its contents.

        Note

        If you complete these steps, you install the image streams into the namespace of your project. If you install the image streams using these steps, you must set the IMAGE_STREAM_NAMESPACE parameter to the name of this project when deploying templates.

2.1.2. Deploying the OpenShift template

Prerequisites

  • You must be logged in to the target OpenShift environment using the Web UI or using the oc command line tool. For more information about this tool, see CLI Reference.

Procedure

  1. Download the rhdm-openshift-templates.zip file from the Software Downloads page for Red Hat Decision Manager 7.2.
  2. Unzip the downloaded archive and locate the rhdm72-optaweb-employee-rostering-trial-ephemeral.yaml file.
  3. Use one of the following methods to deploy the template:

    • In the OpenShift Web UI, select Add to Project → Import YAML / JSON and then select or paste the rhdm72-optaweb-employee-rostering-trial-ephemeral.yaml file. In the Add Template window, ensure Process the template is selected and click Continue.
    • To use the OpenShift command line console, prepare the following command line:

      oc new-app -f <template-path>/rhdm72-optaweb-employee-rostering-trial-ephemeral.yaml

      In this command line:

      • Replace <template-path> with the path to the downloaded template file.
      • Add as many -p PARAMETER=value pairs as needed to set the required parameters. You can view the template file to see descriptions for all parameters.
  4. Set the following parameters as necessary:

    • Application Name (APPLICATION_NAME): The name of the OpenShift application. It is used in the default URL for the application.
    • OptaWeb Admin User (OPTAWEB_ADMIN_USER): The user name for the administrative user in the application. The default user name is adminUser.
    • OptaWeb Admin Password (OPTAWEB_ADMIN_PWD): The password for the administrative user in the application. The default password is RedHat.
    • ImageStream Namespace (IMAGE_STREAM_NAMESPACE): The namespace where the image streams are available. If the image streams were already available in your OpenShift environment (see Section 2.1.1, “Ensuring the availability of image streams and the image registry”), the namespace is openshift. If you installed the image streams file, the namespace is the name of the OpenShift project.
    • Optaweb Employee Rostering Container Memory Limit (OPTAWEB_MEMORY_LIMIT): The memory limit for the application container. The higher the limit, the more employees and shifts are supported. The default is 1 Gi.
    • Optaweb Employee Rostering Generator Zone ID (OPTAWEB_GENERATOR_ZONE_ID): The time zone that is set in the generated example data sets in the application. The default is the local time zone of the OpenShift server.
  5. Complete the creation of the environment, depending on the method that you are using:

    • In the OpenShift Web UI, click Create.

      • If the This will create resources that may have security or project behavior implications pop-up message is displayed, click Create Anyway.
    • Complete and run the command line.

2.2. Deploying the application using the provided script

You can deploy the Red Hat Business Optimizer Employee Rostering starter application to Red Hat OpenShift Container Platform using the provided script. The script builds and packages the application source code locally and uploads it to the OpenShift environment for deployment.

Prerequisites

  • You must be logged in to the target OpenShift environment using the oc command line tool. For more information about this tool, see CLI Reference.

    1. Java Development Kit and Maven must be installed on your local machine.
    2. A bash shell environment must be available on your local machine.

Procedure

  1. Download the rhdm-7.2.0-add-ons.zip file from the Software Downloads page for Red Hat Decision Manager 7.2.
  2. Unzip the downloaded archive.
  3. Unzip the employee rostering zip file (rhdm-7.2.0-employee-rostering.zip) that is extracted from the add-ons archive.
  4. Using the command line, change to the optashift-employee-rostering-7.14.0.Final-redhat-00002/sources folder.
  5. Run the provision script to build and deploy the application:

    ./provision.sh setup employee-rostering --binary
    Note

    If the current OpenShift user name contains characters that are not letters or numbers, the deployment might fail. You can resolve this issue by providing an additional parameter: ./provision.sh setup employee-rostering --binary --project-suffix optaweb. This example uses "optaweb", but you can use any value for the suffix.

    Compilation and packaging might take several minutes to complete. They continually show progress on the command line output.

    When the operation is completed, the following message is displayed: Uploading file "target/ROOT.war" as binary input for the build …​.

  6. Use the OpenShift web UI to view the details for the deployed application. Click the link in the Routes section to open the starter application. The first startup can take up to a minute as additional building is completed on the OpenShift platform.

If the application does not open for more than a minute after clicking the link, perform a hard refresh of your browser page.

  1. Optionally, you can use other actions provided by the provision script:

    1. Deploy updates to the code to an existing deployment:
./provision.sh deploy employee-rostering --binary

+ .. Remove the application:

./provision.sh delete employee-rostering

Chapter 3. Using the employee rostering starter application

You can use the Web interface to use the employee rostering starter application. The interface is developed using the GWT toolkit. You can also access the REST API to create a custom user interface as necessary.

3.1. The draft and published periods

At any particular moment, you can use the application to create the roster for a time period called a draft period; by default, the length of a draft period is three weeks.

When the roster is final for the first week of the draft period, you can publish the roster. At this time, the roster for the first week of the current draft period becomes a published period. Ina published period, the roster is fixed and you can no longer change it automatically (however, emergency manual changes are still possible). This roster can then be distributed to employees so they can plan their time around it. The draft period is shifted a week later.

For example, assume that a draft period of September 1 to September 21 is set. You can automatically create the employee roster for this period. Then, when you publish the roster, the period up to September 7 becomes published. The new draft period is September 8 to September 28.

For instructions about publishing the roster, see Section 3.11, “Publishing the shift roster”.

3.2. The rotation pattern

The employee rostering application supports a rotation pattern for shifts and employees.

The rotation pattern is a "model" period of any time starting from two days. The pattern is not tied to a particular date.

You can set the shift times for every day of the rotation. Optionally, the names of the default employees for each shift in each day can also be set.

Note

In the current version, you cannot enter the names of employees in the rotation period. However, you can see the operation of rotation periods with default employees in the example tenants.

When you publish the roster, the application adds a new week to the draft period. At this time, the shifts and, if applicable, default employee names are copied from the rotation pattern to the new part of the draft period.

When the end of the rotation pattern is reached, it is automatically restarted from the beginning.

If weekend shift patterns in your environment are different from weekday shift patterns, use a rotation pattern of one week or a whole number of weeks (for example, 14, 12, or 28 days; the default length is 28 days). Then the pattern is always repeated on the same weekdays and you can set the shifts for different weekdays.

Note

In the current version, you have to set every single shift manually. To save time when setting up initial data, use a shorter rotation pattern, for example, 7 days.

For instructions about editing the rotation pattern, see Section 3.12, “Viewing and editing the rotation pattern”.

3.3. Selecting or creating a tenant

The application supports multiple tenants. Each tenant is a completely independent set of data, including inputs and roster outputs. Changing data for one tenant does not affect other tenants. You can switch between tenants to use several independent data sets, for example, to prepare employee rosters for different locations.

Several sample tenants are present after installation, representing several typical enterprise types such as a factory or hospital. You can select any of these tenants and modify them to suit your needs. You can also create a new tenant to enter data from a blank slate.

3.3.1. Selecting a tenant

You can select a tenant at any time. After you select a tenant, all the displayed information refers to this tenant and any changes you make affect only this tenant.

Procedure

In the top right part of the browser window, click the Tenant list and select a tenant.

3.3.2. Creating a tenant

You can create a new tenant to enter data from a blank slate. When creating a tenant, you can set several parameters that determine how the application prepares the output for this tenant.

Important

You cannot change tenant parameters after you create the tenant.

Procedure

  1. In the top right part of the browser window, click the Admin tab.
  2. Click Add Tenant.
  3. Set the following values:

    • Name: The name of the new tenant. This name is displayed in the list of tenants.
    • Schedule Start Date: The start date of the initial draft period. After you publish the roster, this date becomes the start date of the published period. The weekday of this date always remains the weekday that starts the draft period, any particular published period, and the first use of the rotation pattern. So it is usually most convenient to set the start date to the start of a week (Sunday or Monday).
    • Draft Length (days): The length of the draft period. The draft period stays the same length for the lifetime of the tenant.
    • Publish Notice (days): The length of the publish notice period. Aspire to publish the final roster for any day at least this time in advance, so employees have enough notice to plan their personal life around their shift times. In the current version, this setting is not enforced in any way.
    • Publish Length (days): The length of the period that becomes published (fixed) every time you publish the roster. In the current version, this setting is fixed at 7 days.
    • Rotation Length (days): The length of the rotation pattern.
    • Timezone: The timezone of the environment to which the roster applies. This timezone is used to determine the "current" date for user interface display.
  4. Click Save.

The tenant is created with blank data.

3.4. Entering skills

You can set all skills that can be necessary in any position within the roster. For example, a 24-hour diner can require cooking, serving, bussing, and hosting skills, in addition to skills such as general human resources and restaurant operations.

Procedure

  1. To enter or change skills, click the Skills tab.

    You can see the numbers of currently visible skills in the top right part of the browser window, for example, 1-15 of 34. You can use the < and > buttons to display other skills in the list.

  2. Complete the following steps to add a new skill:

    1. Click Add Skill.
    2. Enter the name of the new skill into the text field under Skill name.
    3. Click Save Skill.
  3. To edit the name of a skill, click the Edit Skill icon (pencil shape) next to the skill.
  4. To delete a skill, click the Delete Skill icon (trashcan shape) next to the skill.
Note

Within each tenant, skill names must be unique. You cannot delete a skill if the skill is associated with an employee or spot.

3.5. Entering spots

You must enter the list of spots, which represent various positions at the business. For a diner, spots include the bar, the bussing stations, the front counter, the various kitchen stations, the serving areas, and the office.

For each spot, you can select one or more required skills from the list that you entered in the Skills tab. The application rosters only employees that have all of the required skills for a spot into that spot. If the spot has no required skill, the application can roster any employee into the spot.

Procedure

  1. To enter or change spots, click the Spots tab.

    You can see the numbers of currently visible spots in the top right part of the browser window, for example, 1-15 of 34. You can use the < and > buttons to display other spots in the list.

  2. Complete the following steps to add a new spot:

    1. Click Add Spot.
    2. Enter the name of the new spot into the text field under Spot name.
    3. Optionally, select one or more skills from the drop-down list under Required skill set.
    4. Click Save Spot.
  3. To edit the name and required skills for a spot, click the Edit Spot icon (pencil shape) next to the spot.
  4. To delete a spot, click the Delete Spot icon (trashcan shape) next to the spot.
Note

Within each tenant, spot names must be unique. You cannot delete a spot when any shifts are created for it.

3.6. Entering the list of employees

You must enter the list of all employees of the business and the skills they possess. The application rosters these employees to spots according to their skills.

Procedure

  1. To enter or change the list of employees, click the Spots tab.

    You can see the numbers of currently visible employees in the top right part of the browser window, for example, 1-15 of 34. You can use the < and > buttons to display other employees in the list.

  2. Complete the following steps to add a new employee:

    1. Click Add Employee.
    2. Enter the name of the employee into the text field under Employee name.
    3. Optionally, select one or more skills from the drop-down list under Skill set.
    4. Click Save Employee.
  3. To edit the name and required skills for a spot, click the Edit Employee icon (pencil shape) next to the name of the employee.
  4. To delete a spot, click the Delete Employee icon (trashcan shape) next to the name of the employeeemployee.
Note

Within each tenant, employee names must be unique. You cannot delete employees if they are rostered to any shifts.

3.7. Setting employee availability

You can set the availability of employees for particular time spans.

If an employee is unavailable for a particular time span, the employee can never be assigned to any shift during this time span (for example, if the employee has called in sick or is on vacation). Undesired and desired are employee preferences for particular time spans; the application accommodates them when possible.

Procedure

  1. To view and edit employee availability, click the Availability Roster tab.

    In the top left part of the window, you can see the dates for which the roster is displayed. To view other weeks, you can use the < and > buttons next to the Week of field. Alternatively, you can click the date field and change the date to view the week that includes this date.

    You can see the numbers of currently visible employees in the top right part of the browser window, for example, 1-10 of 34. You can use the < and > buttons next to the numbers to display other employees in the list.

  2. To create an availability entry for an employee, click empty space on the intersection of a date (column) and an employee (row). Initially, an Unavailable entry for the entire day is created.
  3. To change an availability entry, double-click the entry. You can change the following settings:

    • From and To date and time: The time span to which the availability entry applies.
    • Status: you can select Unavailable, Desired, or Undesired status from a drop-down list.

      To save the entry, click Apply.

  4. To delete an availability entry, double-click the entry, then click Delete availability.
Important

If an employee is already assigned to a shift and then you create or change an availability entry during this shift, the assignment is not changed automatically. You must create the employee roster again to apply new or changed availability entries.

3.8. Viewing and editing shifts in the shift roster

The Shift Roster is a table of all spots and all possible time spans.

If an employee must be present in a spot during a time span, a shift must exist for this spot and this time span. If a spot requires several employees at the same time, you can create several shifts for the same spot and time span.

Each shift is represented by a rectangle at the intersection of a spot (row) and time span (column).

When new time is added to the draft period, the application copies the shifts (and default employees, if present) from the rotation pattern into this new part of the draft period. You can also manually add and edit shifts in the draft period.

Procedure

  1. To view and edit the shift roster, click the Shift Roster tab.

    In the top left part of the window, you can see the dates for which the roster is displayed. To view other weeks, you can use the < and > buttons next to the Week of field. Alternatively, you can click the date field and change the date to view the week that includes this date.

    You can see the numbers of currently visible spots in the top right part of the browser window, for example, 1-10 of 34. You can use the < and > buttons next to the numbers to display other spots in the list.

  2. To add a shift, click an open area of the schedule. The application adds a shift, determining the slot and time span automatically from the location of the click.
  3. To edit a shift, click the shift. You can set the following values for a shift:

    • From and To date and time: The exact time and duration of the shift.
    • Employee: The employee assigned to the shift.
    • Pinned: Whether the employee is pinned to the shift. If an employee is pinned, automatic employee rostering cannot change the assignment of the employee to the shift. A pinned employee is not automatically replicated to any other shift.

      To save the changes, click Apply.

  4. To delete a shift, click the shift, and then click Delete shift.

3.9. Creating and viewing the employee shift roster

You can use the application to create and view the optimal shift roster for all employees.

Procedure

  1. To view and edit the shift roster, click the Shift Roster tab.
  2. To create the optimal shift roster, click Solve. The application takes 30 seconds to find the optimal solution.

Result

When the operation is finished, the Shift Roster view contains the optimal shift roster. The new roster is created for the draft period; the operation does not modify the published periods.

In the top left part of the window, you can see the dates for which the roster is displayed. To view other weeks, you can use the < and > buttons next to the Week of field. Alternatively, you can click the date field and change the date to view the week that includes this date.

You can see the numbers of currently visible spots in the top right part of the browser window, for example, 1-10 of 34. You can use the < and > buttons next to the numbers to display other spots in the list.

In the draft period, the borders of boxes that represent shifts are dotted lines. In the published periods, the borders are unbroken lines.

The color of the boxes that represent shifts shows the constraint status of every shift:

  • Strong green: Soft constraint matched; for example, the shift is in a "desired" timeslot for the employee.
  • Pale green: No constraint broken.
  • Grey: Soft constraint broken; for example, the shift is in an "undesired" timeslot for the employee.
  • Yellow: Medium constraint broken; for example, no employee is assigned to the shift.
  • Red: Hard constraint broken; for example, an employee has two shifts at the same time.

3.10. Viewing employee shifts

You can view the assigned shifts for particular employees in an employee-centric table. The information is the same as the Shift Roster, but the viewing format might be more convenient for informing employees about their assigned shifts.

Procedure

  1. To view a table of employees and shifts, click the Availability Roster tab.

    In the top left part of the window, you can see the dates for which the roster is displayed. To view other weeks, you can use the < and > buttons next to the Week of field. Alternatively, you can click the date field and change the date to view the week that includes this date.

    You can see the numbers of currently visible employees in the top right part of the browser window, for example, 1-10 of 34. You can use the < and > buttons next to the numbers to display other employees in the list.

In the draft period, the borders of boxes representing shifts are dotted lines. In the published periods, the borders are unbroken lines.

3.11. Publishing the shift roster

When you publish the shift roster, the first week of the draft period becomes published. Automatic employee rostering no longer changes any shift assignments in the published period, though emergency manual changing is still possible. The draft period is shifted one week later. For details about draft and published periods, see Section 3.1, “The draft and published periods”.

Procedure

  1. To view and edit the shift roster, click the Shift Roster tab.
  2. Review the shift roster for the first week of the draft period to ensure that it is acceptable.
  3. Click Publish.

3.12. Viewing and editing the rotation pattern

The rotation pattern contains shifts that are automatically replicated for every period. For details about the rotation pattern, see Section 3.2, “The rotation pattern”.

You can view the rotation pattern, add, move, and delete shifts.

Procedure

  1. To view and edit the rotation pattern, click the Rotation tab.
  2. To view additional days of the rotation pattern, use the horizontal scroll bar at the bottom of the browser window.
  3. To add a shift, click an empty area of the table. The application adds a shift, determining the slot and time span automatically from the location of the click.
  4. To change the start or end time of a shift, move the mouse pointer to the left or right border of the box representing the shift and drag the border.
  5. To delete a shift, hold the Shift key on the keyboard and click a shift.

Appendix A. Versioning information

Documentation last updated on Wednesday, March 27, 2019.

Legal Notice

Copyright © 2019 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.