4. Type Declaration

The O3PRM language offers three kinds of discrete random variables: categorical (labelized), integer ranged variables and real-valued discretized variables. Since domains can be shared among attributes in a PRM, the random variables’ domains should be declared in a separate compilation unit called a type.

All types declarations start with the keyword type followed by the type’s name. The variable’s domain is enclosed inside parentheses.

Here is the full entry for types in the O3PRM BNF:

<type_unit>      ::= type <word> <type_body>
<type_body>      ::= <basic_type> | <subtype>
<basic_type>     ::= <labelized_type> | <integer_type> | <real_type>
<labelized_type> ::= labels "(" <word> ( "," <word> )+ )"
<integer_type>   ::= int "(" <integer> "," <integer> ")"
<real_type>      ::= real "(" <float> "," <float> ( "," <float> )+ ")"
<subtype>        ::= extends <path> "(" <word> ":" <word> ( "," <word>)+ ")"

4.1. Categorical Types

Categorical types are used to model categorical random variables, such as Booleans or colors (red, green and blue for example). The syntax is straightforward:

type t_state labels (OK, NOK);
type t_colors labels (red, green, blue);

4.1.1. The boolean type

The O3PRM comes with a single built-in type for Boolean random variables. The type is defined as follows:

type boolean labels (false, true);

4.2. Integer Types

Integer types are used to model ranges between two integer values. The domain includes all integers between the lower bound and the upper bound specified.

type power int (0,9);

4.3. Real Types

Real types are used to model discretized continuous variables. There must be at least three values and each interval is defined as ]x, y]. For example, the following declaration:

type angle real (0, 90, 180);

defines the 2-valued discrete random variable defined over ]0;90] and ]90;180].