Assign lessons to timeslots and rooms to produce a better schedule for teachers and students.
-
Git clone the optaplanner-quickstarts repo and navigate to this directory:
$ git clone https://github.com/kiegroup/optaplanner-quickstarts.git ... $ cd optaplanner-quickstarts/use-cases/school-timetabling
-
Start the application with Maven:
$ mvn quarkus:dev
or with Gradle:
$ gradle quarkusDev
-
Visit http://localhost:8080 in your browser.
-
Click on the Solve button.
Then try live coding:
-
Make some changes in the source code.
-
Refresh your browser (F5).
Notice that those changes are immediately in effect.
When you’re done iterating in quarkus:dev
mode,
package the application to run as a conventional jar file.
-
Build it with Maven:
$ mvn package
or with Gradle:
$ gradle clean build
-
Run the Maven output:
$ java -jar ./target/quarkus-app/quarkus-run.jar
or the Gradle output:
$ java -jar ./build/quarkus-app/quarkus-run.jar
NoteTo run it on port 8081 instead, add
-Dquarkus.http.port=8081
. -
Visit http://localhost:8080 in your browser.
-
Click on the Solve button.
To allow others to try this application in their browser, host it in the cloud and share the url with them.
Red Hat OpenShift is an open source Kubernetes cloud service which is ideal to host OptaPlanner applications.
To deploy the application on OpenShift:
-
Get a free Developer Sandbox account for OpenShift and launch the Developer Sandbox.
-
In the OpenShift web console, verify that the top left combobox is set to Developer (not Administrator).
-
In the menu, select Add to create an application.
-
Under Git Repository, click Import from Git and fill in these parameters:
-
Set Git Repo URL to
https://github.com/kiegroup/optaplanner-quickstarts
-
Under Show advanced Git options, set Context dir to
/use-cases/school-timetabling
-
Press the Create button.
-
-
In the Topology view, there is a new deployment:
-
Wait a minute until the build completes (watch the bottom left icon until it turns green).
-
Open the URL (click on the top right icon).
-
-
Click on the Solve button.
Requirements:
-
Install OpenShift Client (oc) tools
To deploy the application on OpenShift using the native build:
-
Get a free Developer Sandbox account for OpenShift and launch the Developer Sandbox.
-
In the OpenShift web console, verify that the top left combobox is set to Developer (not Administrator).
-
In the OpenShift web console, click your username (in the upper right corner) and select the "Copy login command" option.
-
In a bash terminal on your local machine, paste the login command.
-
In a local clone of the repo, navigate to the
use-cases/school-timetabling
directory. -
Run the command below:
$ mvn clean package -DskipTests -Dopenshift-native -Dquarkus.kubernetes.deploy=true -Dquarkus.native.container-build=true
-
When the command is finished, you should see two pods in the Topology view: one for the ephemeral Postgres database (data will not be saved), and one for the native Quarkus application. If you click the Quarkus' application link (small bubble with link icon at the top right of the Quarkus' application bubble), you will be navigated to the application. Alternatively, you can get the route from bash with the following command:
$ oc get routes
To increase startup performance for serverless deployments, build the application as a native executable:
-
Compile it natively. This takes a few minutes:
$ mvn package -Dnative -DskipTests
-
Run a database. By default,
application.properties
is configured for H2:-
Download the H2 database (Platform-independent zip) and unzip it.
-
Start the H2 server with the option
-ifNotExists
(not recommended in production):$ cd h2/bin $ java -cp h2*.jar org.h2.tools.Server -ifNotExists
-
-
Run the native executable:
$ ./target/*-runner
-
Visit http://localhost:8080 in your browser.
-
Click on the Solve button.
Visit www.optaplanner.org.