1 libDAI - A free/open source C++ library for Discrete Approximate Inference methods
2 ==================================================================================
4 v 0.2.2 - September 30, 2008
7 Copyright (C) 2006-2008 Joris Mooij [joris dot mooij at tuebingen dot mpg dot de]
8 Radboud University Nijmegen, The Netherlands /
9 Max Planck Institute for Biological Cybernetics, Germany
11 with contributions from:
25 ----------------------------------------------------------------------------------
26 This file is part of libDAI.
28 libDAI is free software; you can redistribute it and/or modify
29 it under the terms of the GNU General Public License as published by
30 the Free Software Foundation; either version 2 of the License, or
31 (at your option) any later version.
33 libDAI is distributed in the hope that it will be useful,
34 but WITHOUT ANY WARRANTY; without even the implied warranty of
35 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 GNU General Public License for more details.
38 You should have received a copy of the GNU General Public License
39 along with libDAI; if not, write to the Free Software
40 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
41 ----------------------------------------------------------------------------------
44 SCIENTISTS: If you write a scientific paper describing research that made
45 substantive use of this program, please (a) mention the fashion in which
46 this software was used, including the version number, with a citation
47 to the literature, to allow replication; (b) mention this software in the
48 Acknowledgements section. The appropriate citation is:
50 J. M. Mooij (2008) "libDAI 0.2.2: A free/open source C++ library for Discrete
51 Approximate Inference methods", http://www.libdai.org
53 Moreover, as a personal note, I would appreciate it if you would email me with
54 citations of papers referencing this work so I can mention them to my funding
55 agent and tenure committee.
60 libDAI is a free/open source C++ library (licensed under GPL) that provides
61 implementations of various (approximate) inference methods for discrete
62 graphical models. libDAI supports arbitrary factor graphs with discrete
63 variables; this includes discrete Markov Random Fields and Bayesian Networks.
65 The library is targeted at researchers; to be able to use the library, a good
66 understanding of graphical models is needed.
71 libDAI is not intended to be a complete package for approximate inference.
72 Instead, it should be considered as an "inference engine", providing various
73 inference methods. In particular, it contains no GUI, currently only supports
74 its own file format for input and output (although support for standard file
75 formats may be added later), and provides very limited visualization
81 Currently, libDAI supports the following (approximate) inference methods:
83 * Exact inference by brute force enumeration;
84 * Exact inference by junction-tree methods;
86 * Loopy Belief Propagation [KFL01];
87 * Tree Expectation Propagation [MiQ04];
88 * Generalized Belief Propagation [YFW05];
89 * Double-loop GBP [HAK03];
90 * Various variants of Loop Corrected Belief Propagation [MoK07, MoR05];
92 * Conditioned BP [EaG09].
94 In addition, libDAI supports parameter learning of conditional probability
95 tables by Expectation Maximization.
100 Because libDAI is implemented in C++, it is very fast compared with
101 implementations in MatLab (a factor 1000 faster is not uncommon). libDAI does
102 provide a (limited) MatLab interface for easy integration with MatLab.
107 Releases can be obtained from www.libdai.org
108 License: GNU Public License v2 (or higher).
110 libDAI-0.2 December 1, 2006
111 libDAI-0.2.1 May 26, 2008
112 libDAI-0.2.2 September 30, 2008
117 This work is part of the Interactive Collaborative Information Systems (ICIS)
118 project, supported by the Dutch Ministry of Economic Affairs, grant BSIK03024.
119 I would like to thank Martijn Leisink for providing the basis on which libDAI has been built.
124 Some doxygen documentation is available. Install doxygen and use "make doc" to build the
125 documentation. If the documentation is not clear enough, feel free to send me an email
126 (or even better, to improve the documentation!).
128 A description of the factor graph (.fg) file format can be found in the file FILEFORMAT.
133 The code has been developed under Debian GNU/Linux with the GCC compiler suite.
134 libDAI compiles successfully with g++ versions 3.4, 4.1, 4.2 and 4.3.
136 libDAI has also been successfully compiled with MS Visual Studio 2008 under Windows
137 (but not all build targets are supported yet) and with Cygwin under Windows.
139 Finally, libDAI has been compiled successfully on MacOS X.
142 Quick start (linux/cygwin/Mac OS X)
143 -----------------------------------
145 - a recent version of gcc (at least version 3.4)
149 - recent boost C++ libraries (at least version 1.34, or 1.37 for cygwin)
151 On Debian/Ubuntu, you can easily install all these packages with a single command:
152 "apt-get install g++ make doxygen graphviz libboost-dev libboost-graph-dev libboost-program-options-dev"
153 (root permissions needed).
155 On Mac OS X (10.4 is known to work), these packages can be installed easily via MacPorts.
156 First, install MacPorts according to the instructions at http://www.macports.org/
157 Then, a simple "sudo port install gmake boost doxygen graphviz"
158 should be enough to install everything that is needed.
160 On Cygwin, the prebuilt Cygwin package boost-1.33.1-x is known not to work.
161 You can however obtain the latest boost version (you need at least 1.37.0)
162 from http://www.boost.org/ and compile/install it with:
169 To build the libDAI source, first copy a template Makefile.* to Makefile.conf
170 (for example, copy Makefile.LINUX to Makefile.conf if you use GNU/Linux).
171 Then, edit the Makefile.conf template to adapt it to your local setup.
172 Especially directories may differ from system to system. Finally, run
176 If the build was successful, you can test the example program:
178 ./example tests/alarm.fg
180 or the more elaborate test program:
182 tests/testdai --aliases tests/aliases.conf --filename tests/alarm.fg --methods JTREE_HUGIN BP_SEQMAX
185 Quick start (Windows)
186 ---------------------
188 - A recent version of MicroSoft Visual Studio (2008 works)
189 - recent boost C++ libraries (version 1.34 or higher)
190 - GNU make (can be obtained from http://gnuwin32.sourceforge.net)
191 For the regression test, you need:
192 - GNU diff, GNU sed (can be obtained from http://gnuwin32.sourceforge.net)
194 To build the source, copy Makefile.WINDOWS to Makefile.conf. Then, edit
195 Makefile.conf to adapt it to your local setup. Finally, run (from the command line)
199 If the build was successful, you can test the example program:
201 example tests\alarm.fg
203 or the more elaborate test program:
205 tests\testdai --aliases tests\aliases.conf --filename tests\alarm.fg --methods JTREE_HUGIN BP_SEQMAX
212 - The platform-dependent requirements described above
214 First, you need to build the libDAI source as described above for your
215 platform. By default, the MatLab interface is disabled, so before compiling the
216 source, you have to enable it in the Makefile.conf by setting
217 "WITH_MATLAB=true". Also, you have to configure the MatLab-specific parts of
218 Makefile.conf to match your system (in particular, the Makefile variables ME,
219 MATLABDIR and MEX). The MEX file extension depends on your platform; for a
220 64-bit linux x86_64 system this would be "ME=.mexa64", for a 32-bit linux x86
221 system this would be "ME=.mexglx". If you are unsure about your MEX file
222 extension: it needs to be the same as what the MatLab command "mexext" returns.
223 The required MEX files are built by issuing
227 from the command line. The MatLab interface is much less powerful than using
228 libDAI from C++. There are two reasons for this: (i) it is boring to write MEX
229 files; (ii) the large performance penalty paid when large data structures (like
230 factor graphs) have to be converted between their native C++ data structure to
231 something that MatLab understands.
233 A simple example of how to use the MatLab interface is the following (entered
234 at the MatLab prompt), which performs exact inference by the junction tree
235 algorithm and approximate inference by belief propagation on the ALARM network:
237 cd path_to_libdai/matlab
238 [psi] = dai_readfg ('../examples/alarm.fg');
239 [logZ,q,md,qv,qf] = dai (psi, 'JTREE', '[updates=HUGIN,verbose=0]')
240 [logZ,q,md,qv,qf] = dai (psi, 'BP', '[updates=SEQMAX,tol=1e-9,maxiter=10000,logdomain=0]')
242 where "path_to_libdai" has to be replaced with the directory in which libDAI
243 was installed. For other algorithms and their parameters, see