On Debian/Ubuntu, you can easily install the required packages with a single command:
apt-get install g++ make doxygen graphviz libboost-dev libboost-graph-dev libboost-program-options-dev libboost-test-dev cimg-dev(root permissions needed).
On Mac OS X (10.4 is known to work), these packages can be installed easily via MacPorts. If MacPorts is not already installed, install it according to the instructions at http://www.macports.org/. Then, a simple
sudo port install gmake boost doxygen graphvizshould be enough to install everything that is needed.
On Cygwin, the prebuilt Cygwin package boost-1.33.1-x is known not to work. You can however obtain the latest boost version (you need at least 1.37.0) from http://www.boost.org/ and build it as described in the next subsection.
./bootstrap.sh --with-libraries=program_options,math,graph,test --prefix=/boost_root/ ./bjam
export PATH=$PATH:/boost_root/stage/lib
makeThe build includes a regression test, which may take a while to complete.
If the build is successful, you can test the example program:
examples/example tests/alarm.fgor the more extensive test program:
tests/testdai --aliases tests/aliases.conf --filename tests/alarm.fg --methods JTREE_HUGIN BP_SEQMAX
For the regression test, you need:
boost-build.jam
in the main boost directory to change the BOOST_BUILD
directory to the place where you put Boost.Build (use UNIX / instead of Windows \ in pathnames).bjam.exe
executable into the main boost directory. Now if you issue "bjam --version"
you should get a version and no errors. Issueing "bjam --show-libraries"
will show the libraries that will be built.bjam --with-graph --with-math --with-program_options --with-test link=static runtime-link=shared
makeThe build includes a regression test, which may take a while to complete.
If the build is successful, you can test the example program:
examples\example tests\alarm.fgor the more extensive test program:
tests\testdai --aliases tests\aliases.conf --filename tests\alarm.fg --methods JTREE_HUGIN BP_SEQMAX
First, you need to build the libDAI source as described above for your platform. By default, the MatLab interface is disabled, so before compiling the source, you have to enable it in Makefile.ALL by setting
WITH_MATLAB=trueAlso, you have to configure the MatLab-specific parts of Makefile.conf to match your system (in particular, the Makefile variables ME, MATLABDIR and MEX). The MEX file extension depends on your platform; for a 64-bit linux x86_64 system this would be "ME=.mexa64", for a 32-bit linux x86 system "ME=.mexglx". If you are unsure about your MEX file extension: it needs to be the same as what the MatLab command "mexext" returns. The required MEX files are built by issuing
makefrom the command line. The MatLab interface is much less powerful than using libDAI from C++. There are two reasons for this: (i) it is boring to write MEX files; (ii) the large performance penalty paid when large data structures (like factor graphs) have to be converted between their native C++ data structure to something that MatLab understands.
A simple example of how to use the MatLab interface is the following (entered at the MatLab prompt), which performs exact inference by the junction tree algorithm and approximate inference by belief propagation on the ALARM network:
cd path_to_libdai/matlab [psi] = dai_readfg ('../tests/alarm.fg'); [logZ,q,md,qv,qf] = dai (psi, 'JTREE', '[updates=HUGIN,verbose=0]') [logZ,q,md,qv,qf] = dai (psi, 'BP', '[updates=SEQMAX,tol=1e-9,maxiter=10000,logdomain=0]')where "path_to_libdai" has to be replaced with the directory in which libDAI was installed. For other algorithms and some default parameters, see the file tests/aliases.conf.
make docto build the documentation. If the documentation is not clear enough, feel free to send me an email (or even better, to improve the documentation and send a patch!). The documentation can also be browsed online at http://www.libdai.org.