Examples
********

The following examples show how the HUGIN Python API can be used to manipulate belief networks and LIMIDs. 


**Running the examples**

To run the examples, the python interpreter must be able to load the
HUGIN Python API module. Depending on where the HUGIN python module is
placed one of the following command lines should work (i.e. for the build and propagate example):

* bap.py
* python bap.py
* PYTHONPATH=<PATH-TO-PYHUGIN-DIR> python bap.py
* set PYTHONPATH=<PATH-TO-PYHUGIN-DIR>
  
  python bap.py



Example: Build And Propagate
----------------------------

This example describes how a belief network can be constructed using
the HUGIN Python API. The network consists of three numbered
nodes. Two of the nodes take on values 0, 1, and 2. The third node is
the sum of the two other nodes. Once the Bayesian network is
constructed, the network is saved as a NET specification file, and an
initial propagation is performed. Finally, the marginals of the nodes
are printed on standard output.


.. literalinclude:: ../example/bap.py
   :linenos:


Example: Load And Propagate
---------------------------

This example shows how to load a belief network or a LIMID specified
as a (non-OOBN) NET file: A Domain object is constructed from the NET
file. The domain is then triangulated using the "best greedy"
heuristic, and the compilation process is completed. The (prior)
beliefs and expected utilities (if the network is a LIMID) are then
printed. If a case file is given, the file is loaded, the evidence is
propagated, and the updated results are printed.


.. literalinclude:: ../example/lap.py
   :linenos:
