第12章 Examples provided with Red Hat Business Optimizer
Several Red Hat Business Optimizer examples are shipped with Red Hat Decision Manager. You can review the code for examples and modify it as necessary to suit your needs.
Red Hat does not provide support for the example code included in the Red Hat Decision Manager distribution.
12.1. Downloading and running the examples リンクのコピーリンクがクリップボードにコピーされました!
You can download the Red Hat Business Optimizer examples from the Red Hat Software Downloads website and run them.
12.1.1. Downloading Red Hat Business Optimizer examples リンクのコピーリンクがクリップボードにコピーされました!
You can download the examples as a part of the Red Hat Decision Manager add-ons package.
Procedure
-
Download the
rhdm-7.10.0-add-ons.zipfile from the Software Downloads page. - Decompress the file.
-
Decompress the
rhdm-7.10-planner-engine.zipfile from the decompressed directory.
Result
In the decompressed rhdm-7.10-planner-engine directory, you can find example source code under the following subdirectories: * examples/sources/src/main/java/org/optaplanner/examples * examples/sources/src/main/resources/org/optaplanner/examples * webexamples/sources/src/main/java/org/optaplanner/examples * webexamples/sources/src/main/resources/org/optaplanner/examples
The table of examples in 「Table of Business Optimizer examples」 lists directory names that are used for individual examples.
12.1.2. Running Business Optimizer examples リンクのコピーリンクがクリップボードにコピーされました!
Red Hat Business Optimizer includes a number of examples to demonstrate a variety of use cases.
Prerequisites
- You have downloaded and decompressed the examples. For instructions about these actions, see 「Downloading Red Hat Business Optimizer examples」.
Procedure
In the
rhdm-7.10.0-planner-enginefolder, open theexamplesdirectory and use the appropriate script to run the examples:Linux or Mac:
$ cd examples $ ./runExamples.shWindows:
$ cd examples $ runExamples.bat
Select and run an example from the GUI application window:
Red Hat Business Optimizer itself has no GUI dependencies. It runs just as well on a server or a mobile JVM as it does on the desktop.
12.1.3. Running the Red Hat Business Optimizer examples in an IDE (IntelliJ, Eclipse, or Netbeans) リンクのコピーリンクがクリップボードにコピーされました!
If you use an integrated development environment (IDE), such as IntelliJ, Eclipse, or Netbeans, you can run your downloaded Red Hat Business Optimizer examples within your development environment.
Prerequisites
- You have downloaded and extracted the examples. For instructions about these actions, see 「Downloading Red Hat Business Optimizer examples」.
Procedure
Open the Red Hat Business Optimizer examples as a new project:
-
For IntelliJ or Netbeans, open
examples/sources/pom.xmlas the new project. The Maven integration guides you through the rest of the installation; skip the rest of the steps in this procedure. -
For Eclipse, open a new project for the directory
examples/sources.
-
For IntelliJ or Netbeans, open
-
Add all the JARs to the classpath from the directory
binariesand the directoryexamples/binaries, except for theexamples/binaries/optaplanner-examples-*.jarfile. -
Add the Java source directory
src/main/javaand the Java resources directorysrc/main/resources. Create a run configuration:
-
Main class:
org.optaplanner.examples.app.OptaPlannerExamplesApp -
VM parameters (optional):
-Xmx512M -server -Dorg.optaplanner.examples.dataDir=examples/sources/data -
Working directory:
examples/sources
-
Main class:
- Run the run configuration.
12.1.4. Running the web examples リンクのコピーリンクがクリップボードにコピーされました!
Besides the GUI examples, Red Hat Decision Manager also includes a set of web examples for Red Hat Business Optimizer. The web examples include:
- Vehicle routing: Calculating the shortest possible route to pick up all items required for a number of different customers using either Leaflet or Google Maps visualizations.
- Cloud balancing: Assigning processes across computers with different specifications and costs.
Prerequisites
- You have downloaded and extracted the Red Hat Business Optimizer examples from the Red Hat Decision Manager add-ons package. For instructions, see 「Downloading Red Hat Business Optimizer examples」.
The web examples require several JEE APIs to run, such as the following APIs:
- Servlet
- JAX-RS
- CDI
These APIs are not required for Business Optimizer itself.
Procedure
- Download a JEE application server, such as JBoss EAP or WildFly and unzip it.
In the decompressed
rhdm-7.10.0-planner-enginedirectory, open the subdirectorywebexamples/binariesand deploy theoptaplanner-webexamples-*.warfile on the JEE application server.If using JBoss EAP in standalone mode, this can be done by adding the
optaplanner-webexamples-*.warfile to theJBOSS_home/standalone/deploymentsfolder.- Open the following address in a web browser: http://localhost:8080/optaplanner-webexamples/.