Este contenido no está disponible en el idioma seleccionado.
Chapter 12. Red Hat Build of OptaPlanner on the Red Hat build of Quarkus platform: an employee scheduler quick start guide
The employee scheduler quick start 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 scheduling 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. Moreover, an employee can have a contract that limits the number of hours that the employee can work in a single time period.
The Red Hat Build of OptaPlanner rules for this starter application use both hard and soft constraints. During an optimization, the Planner 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 Planner 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.
Prerequisites
- OpenJDK 11 or later is installed. Red Hat build of Open JDK is available from the Software Downloads page in the Red Hat Customer Portal (login required).
- Apache Maven 3.8 or higher is installed. Maven is available from the Apache Maven Project website.
- An IDE, such as IntelliJ IDEA, VSCode, or Eclipse is available.
12.1. Downloading and running the OptaPlanner employee scheduler Copiar enlaceEnlace copiado en el portapapeles!
Download the OptaPlanner employee scheduler quick start archive, start it in Quarkus development mode, and view the application in a browser. Quarkus development mode enables you to make changes and update your application while it is running.
Procedure
Navigate to the Software Downloads page in the Red Hat Customer Portal (login required), and select the product and version from the drop-down options:
- Product: Red Hat Build of OptaPlanner
- Version: 8.33
- Download Red Hat Build of OptaPlanner 8.33 Quick Starts.
-
Extract the
rhbop-8.33.0-optaplanner-quickstarts-sources.zip
file. -
Navigate to the
org.optaplanner.optaplanner-quickstarts-8.33.0.Final-redhat-00004/use-cases/employee-scheduling
directory. Enter the following command to start the OptaPlanner employee scheduler in development mode:
mvn quarkus:dev
$ mvn quarkus:dev
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To view the OptaPlanner employee scheduler, enter the following URL in a web browser.
http://localhost:8080/
http://localhost:8080/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To run the OptaPlanner employee scheduler, click Solve.
- Make changes to the source code then press the F5 key to refresh your browser. Notice that the changes that you made are now available.
12.2. Package and run the OptaPlanner employee scheduler Copiar enlaceEnlace copiado en el portapapeles!
When you have completed development work on the OptaPlanner employee scheduler in quarkus:dev
mode, run the application as a conventional jar file.
Prerequisites
- You have downloaded the OptaPlanner employee scheduling quick start.
Procedure
-
Navigate to the
/use-cases/vaccination-scheduling
directory. To compile the OptaPlanner employee scheduler, enter the following command:
mvn package
$ mvn package
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To run the compiled OptaPlanner employee scheduler, enter the following command:
java -jar ./target/quarkus-app/quarkus-run.jar
$ java -jar ./target/quarkus-app/quarkus-run.jar
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTo run the application on port 8081, add
-Dquarkus.http.port=8081
to the preceding command.To start the OptaPlanner employee scheduler, enter the following URL in a web browser.
http://localhost:8080/
http://localhost:8080/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow