# Documentation

The inference engines provided by this package are

- fojt.LiftedJTEngine (Lifted Junction Tree Algorithm, default)
- jt.JTEngine (Standard Junction Tree Algorithm)
- ve.VarElimEngine (Basic Variable Elimination)
- fove.LiftedVarElim (First Order Variable Elimination)

To specify the engine use the -e parameter (see below).

### Parameters

As the LJT package provides only exact inference algorithms, sampling options are unavailable in this distribution. The following parameters are available

Parameter | Description |
---|---|

-e <s>, --engine <s> | Use inference engine class <s> |

--package <s> | Parser looks for classes in package <s> |

-d, --[no]debug | Print model, evidence, and queries |

-o <s>, --output <s> | Output stats to file <s> |

-P<key>=<value> | Set inference configuration properties |

-a <n>, --alpha <n> | Fuse FOJT with depth <n> |

-v, --verbose | Verbose (print a lot of information) |

# Building Models

FOJT is an extension to BLOG. Input models for the FOJT engine are written in the BLOG language and its extensions from v0.3. As in basic BLOG, models consist of

- type definitions and their extensions
- fixed variables
- random variables
- evidence.
- factors and parfactors

The FOJT engine relies on exact inference, so sampling options from the basic BLOG language are not allowed in the models. This section is only a short overview of how to specify BLOG models. For more details, please refer to the resources linked above.

##### Type definitions

Type definitions have the form

type X;

guaranteed X x[<n>];

Here, we introduce the type X, where the second line is optional and guarantees at least <n> instances of the X type, named x1, x2, ... xn.

##### Random variables

As in BLOG, a random variable Y is defined by

random <type> Y(<S>);

where <type> can be one of the BLOG built-in types

- Boolean
- Integer
- Real
- Character
- String

or one of the user-defined types. The parameter <S> denotes the set of random variables the new random variable depends on. Let's assume, we want to model a Boolean random variable that indicates wheter a Person attends a Workshop:

random Boolean Attends(Person, Workshop);

As in BLOG, fixed variables are also allowed. Fixed variables are introduced with the keyword fixed:

fixed real pi = 3.141592653;

##### Factors and Parfactors

Factors and parfactors are specified as described in the BLOG manual for v0.3. A factor is defined as a Matrix

factor MultiArrayPotential[<M>](<S>);

Where <M> = [t1, ... tm] is the row vector specifying the factor and <S> is the set of randvars shared by the factor. To model the fact that R is true with probability 0.1 we would write

random Boolean R;

factor MultiArrayPotential[[0.1, 0.9]](R);

Parfactors are specified in a similar way

parfactor <type> R. MultiArrayPotential[<M>](<S(R)>)

where the type definition specifies the domain of the logvar used in the parfactor. As in BLOG, multiple logvars of different types are allowed (see example below).

##### Evidence

Evidence is introduced with the obs keyword. If we observe Person p2 attending workshop w1 and person p3 attending w2 then we would write

obs Attends(p2, w1) = true;

obs Attends(p3, w2) = true;

(Note that due to technical limitations, in the above example, only the X will be lifted, whereas w1 and w2 will be grounded)