# Bayesian SAR-HMM

## Source Code

The code is written in Objective Caml. The linear algebra operations are done with the GNU Scientific Library which is called from OCaml via the ocamlgsl wrapper. Ocamlmpi is used to distribute the computation accross multiple machines.

See the included README file for compilation instructions.

## Training

The Bayesian SAR-HMM is initialised from an initialised (or trained) SAR-HMM.

```
./arhmm_to_bsarhmm arhmm-initialised.dat bsarhmm-initialised.dat
```

First, we need to set up a file with the list of machines we want to use. This file, let's call it machines.lst, should have the form

```
machine1 1
machine2 2
machine3 2
...
```

where the numbers in the second column refer to the number of tasks to be executed on each machine. Note that at least two task slots must be available; one for the controller and one for a worker. If you have only one machine, then you simply define

```
machine 2
```

We then start lam.

```
lamboot -v machines.lst
```

We can now train a model using a command similar to that used for the SAR-HMM, the only difference being that it must be launched via `mpirun`

.

```
mpirun N ./bsarhmm_train bsarhmm-initialised.dat train.lst bsarhmm-trained.dat
```