PILOTS home WCL home

Tutorial index (Basic Examples Programming Running Learning Model Overview Linear Regression Example)

PILOTS is a programming language designed to enable a high level specification of streaming applications which handle spatio-temporal data. Specifically, PILOTS applications are able to monitor heterogeneous input streams and combine their data to produce output streams. The computational options for combining input data is limited due to the experimental nature of this language. Instead the focus of PILOTS applications should be on the input data and how they are related to each other. Currently as of v0.2.x, the input data for PILOTS applications is limited to the double type and can be generated in two ways: from a file with a special format or from a periodic thread which produces linear data. Input data generation falls under the responsibility of external software components, which will be discussed in the running tutorial.

With a high level specification, PILOTS programmers can rapidly prototype experiments on spatio-temporal objects in real time. The language incorporates a data selection model, and application model, and an error correction model.

A PILOTS program is compiled directly into Java (using Java CC) which utilizes TCP/IP sockets to handle input and output.
A PILOTS application, which is the compiled version of the program, runs on Java so it is compatible cross-platform as long as Java is installed.
This tutorial will explain how to write a PILOTS program.
First the PILOTS grammar is introduced, which is similar in style to Pascal.
Next a very simple example, called *Squared* is demonstrated as an equivalent to the famous "Hello World!" program.

The grammar of the language is separated into clauses which describe the inputs, outputs, and error correcting mechanics of a program.
A formal definition of the grammar can be seen in the figure below.
Every PILOTS program *must* have an inputs and outputs clause.
Only programs which incorporate error correcting code need to include the errors, signatures, and correct clauses.
The signatures clause enables both error correction and detection.
A program without a correct clause is still capable of error detection, but not correction. The *Corrects* and *Correct* fields will be removed after version 0.3.1.

Program | := | program Var; inputs Inputs;outputs Outputs;[errors Errors;][signatures Signatures;[correct Corrects;]]end |

Inputs | := | [(Input;)* Input] |

Input | := | Vars Dim using Methods |

Outputs | := | [(Output;)* Output] |

Output | := | Vars : Exps at every Time |

Errors | := | [(Error;)* Error] |

Error | := | Vars : Exps |

Signatures | := | [(Signature;)* Signature] |

Signature | := | Var[Const] : Var = Exps [Estimate][String] |

Estimate | := | estimate Var = Exp |

Corrects | := | [(Correct;)* Correct] |

Correct | := | Var[Const] : Var = Exps |

Vars | := | Var | Var, Vars |

Var | := | { a, b, c, ... } |

Const | := | ( Var ) |

String | := | { "a", "b", "c" } |

Dim | := | '(t)' | '(t,x)' | '(t,x,y)' | '(t,x,y,z)' | '(t,x,y,z,n)' |

Methods | := | Method | Method, Methods |

Method | := | (closest | euclidean | interpolate | predict) '(' Exps ')' |

Time | := | Number (msec | sec | min | hour | day) |

Exps | := | Exp | Exp, Exps |

Exp | := | Func()Exps | Exp Func Exp | '(' Exp ')' | Value |

Func | := | { +, -, *, /, sqrt, sin, cos, tan, abs, ...} |

Value | := | Number | Var |

Number | := | Sign Digits | Sign Digits'.'Digits |

Sign | := | '+' | '-' | '' |

Digits | := | Digit | Digit Digits |

Digit | := | { 0, 1, 2, ..., 9 } |

The input clause is where the spatio-temporal dimensions of each input variable is defined along with associated data selection operations. The possible data selection operations are

As an initial example we present Squared.plt, which simply squares input data.
This example can be found precompiled in *$PILOTS_HOME/examples/squared*.

program Squared; inputs x(t) using closest(t); outputs o: x*x at every 1 sec; end |

program Twice; inputs a(t) using closest(t); b(t) using closest(t); outputs o: b-2*a at every 1 sec; errors e: b-2*a; signatures s0: e = 0 "Normal mode"; s1(K): e = 2 * t + K "A failure" estimate a = b / 2; s2(K): e = -2 * t + K "B failure" estimate b = a * 2; s3(K): e = K, abs(K) > 20 "Out-of-sync"; end |

In this example input stream b is intended to always be twice that of stream a. We feature error detection and correction using error signatures depicted in the signatures clause. Each signature has a label followed by a pattern and an optional description string (which is used for debugging purposes). The pattern within the signatures is an expression that may include any input variable or error function. Additionaly, a constant K is used to denote the presence of an unknown. Internally this is handled by executing search over a (small) number of measured data points to find the best estimate for the unknown. Notice that the signature

program Twice; inputs a, b(t) using closest(t); c(t) using predict(linear_model, a); outputs o: b - c at every 1 sec; end |

In this example input stream b is intended to always be twice that of stream a. After the offline training process in machine learning component using existing data containing a and b, we use data stream a as parameter to the linear_model to generate a new data stream c, which is an estimation of b. Finally, we output the difference of b and c to verify the correctness of the trained model linear_model.

program Twice; inputs a(t) using closest(t); b(t) using closest(t); outputs o: b-2*a at every 1 sec; errors e: b-2*a; signatures s0: e = 0 "Normal mode"; s1(K): e = 2 * t + K "A failure"; s2(K): e = -2 * t + K "B failure"; s3(K): e = K, abs(K) > 20 "Out-of-sync"; correct s1: a = b / 2; s2: b = a * 2; end |

Same function as "Example with error detection/correction" with different grammar

Tutorial index (Basic Examples Programming Running Learning Model Overview Linear Regression Example Bayes Classifier Example)

PILOTS home WCL home

Worldwide Computing Laboratory |
Department of Computer Science |
Rensselaer Polytechnic Institute |