Learning Model Overview


PILOTS home     WCL home
Tutorial index     (Basic ExamplesProgrammingRunningLearning Model OverviewLinear Regression Example)

This page details instructions on how to execute a given PILOTS example with machine learning and serves as a guide for constructing and implementing new learning models.

Running a PILOTS program entails calling operations on the machine learning server, which can train machine learning models, validate the accuracy of these models, or calculate the results of these models models on specified data which can be used by other programs.

Note: The following commands shown for the command line are assumed to be implemented in the bash shell


Overview of Interaction with Machine Learning Component

The steps for interacting with the machine learning component of PILOTS are as follows:

  1. Installation of necessary packages
  2. Build a PILOTS jar file (from home directory)
  3. Configure aliases (from home directory)
  4. Train any new necessary learning models (offline)
  5. (If using simulation) Add Data for Producers
  6. Run the learning model server
  7. Compile and run the plt program with Producer and Output Handler
  8. (If using simulation) Output producer data to Output Handler

Installation of Necessary Packages

Make sure to install the following before working with the learning model component of PILOTS:

  1. python-pip
  2. virtualenv

Then simply run at the root directory of the project:

virtualenv .
source bin/activate

Finally run the following in the pilots/util/model/ directory:

pip3 install -r requirements.txt

Build a PILOTS jar file

In $PILOTS_HOME, run the build script

$ ./build.sh    // (for Windows, use build.bat instead)

After doing so, pilots.jar will be created under the $PILOTS_HOME/lib directory.

Configure aliases

In order to make sure that aliases for the plc and plcsim compiler commands are correctly figured as well as the definition of $PILOTS_HOME, make sure that you are in the root directory of the project and then use the following command:

source setenv

Training a Learning Model (Offline)

Training a model requires that the machine learning algorithm is implemented and you have a training PILOTS program to train that algorithm. The available machine learning algorithms can be found in the model code directory.. To implement a custom algorithm follow the Application Programming Interface (API) given in Example.py file.

The result of training a machine learning algorithms is a model file, which can be found in the trained models directory. These files are used by normal PILOTS programs to estimate values given to the model during runtime.

To train a model run a compiled trainer file (.trn) along with the machine learning server and the resulting trained model file will be produced. Compiling a .trn can be done using the pilots compiler with the -t flag, e.g.

plc -t example_trainer_file.trn

Add Data for Producers

Make sure that the data that you intend to use for your producers in a simulation are stored in the data directory.

Follow the format similar to a.txt from the PredictionTest linear regression example.

Note: Notice that the first line of the file must be a header beginning with a pound sign (#). If you are expecting an output for the input, based on the learning model, then make sure to also include the label of the output similar to that defined in the model training data.

Running Learning Model Server

A socket connection must be made with the learning model server client in order to interact with the PILOTS machine learning component. Therefore, before running the plt program, run the learning model server by executing the server.sh script in pilots/util/model/

./server.sh

(Note: you may need to wait a few seconds for the server to start up)

Running the plt program with Producer and Output Handler

Once the previous procedures are completed, follow these 3 main steps:

  1. Run the desired output handler script for the corresponding PILOTS program in a new terminal.
  2. In a separate terminal, follow the instructions in the Compiling and running a program section of the PILOTS: Running Tutorial page. This involves the PILOTS compiler, javac, and execution.
  3. In a separate terminal, run the necessary producer script that will provide the input data.

(If using simulation) Output Producer Data to Output Handler

If a simulation is being run, go back to the terminal running the class generated from the plt file, and press enter. (After this, some warning messages may appear in this terminal, but they do not hinder the simulation.)

Learning Model Examples

For some simple examples of the execution of a PILOTS program with the machine learning component (offline), refer to the:


Tutorial index     (Basic ExamplesProgrammingRunningLearning Model OverviewLinear Regression ExampleBayes Classifier Example)
PILOTS home     WCL home

Worldwide Computing Laboratory

Department of Computer Science

Rensselaer Polytechnic Institute