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:

13 Martijn Leisink

14 Giuseppe Passino

15 Frederik Eaton

16 Charlie Vaske

17 Bastian Wemmenhove

18 Christian Wojek

19 Claudio Lima

20 Jiuxiang Hu

21 Peter Gober

22 Patrick Pletscher

23 Sebastian Nowozin

26 ----------------------------------------------------------------------------------

27 This file is part of libDAI.

29 libDAI is free software; you can redistribute it and/or modify

30 it under the terms of the GNU General Public License as published by

31 the Free Software Foundation; either version 2 of the License, or

32 (at your option) any later version.

34 libDAI is distributed in the hope that it will be useful,

35 but WITHOUT ANY WARRANTY; without even the implied warranty of

36 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

37 GNU General Public License for more details.

39 You should have received a copy of the GNU General Public License

40 along with libDAI; if not, write to the Free Software

41 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

42 ----------------------------------------------------------------------------------

45 SCIENTISTS: If you write a scientific paper describing research that made

46 substantive use of this program, please (a) mention the fashion in which

47 this software was used, including the version number, with a citation

48 to the literature, to allow replication; (b) mention this software in the

49 Acknowledgements section. The appropriate citation is:

51 J. M. Mooij (2008) "libDAI 0.2.2: A free/open source C++ library for Discrete

52 Approximate Inference methods", http://www.libdai.org

54 Moreover, as a personal note, I would appreciate it if you would email me with

55 citations of papers referencing this work so I can mention them to my funding

56 agent and tenure committee.

59 About libDAI

60 ------------

61 libDAI is a free/open source C++ library (licensed under GPL) that provides

62 implementations of various (approximate) inference methods for discrete

63 graphical models. libDAI supports arbitrary factor graphs with discrete

64 variables; this includes discrete Markov Random Fields and Bayesian Networks.

66 The library is targeted at researchers; to be able to use the library, a good

67 understanding of graphical models is needed.

70 Limitations

71 -----------

72 libDAI is not intended to be a complete package for approximate inference.

73 Instead, it should be considered as an "inference engine", providing various

74 inference methods. In particular, it contains no GUI, currently only supports

75 its own file format for input and output (although support for standard file

76 formats may be added later), and provides very limited visualization

77 functionalities.

80 Features

81 --------

82 Currently, libDAI supports the following (approximate) inference methods:

84 * Exact inference by brute force enumeration;

85 * Exact inference by junction-tree methods;

86 * Mean Field;

87 * Loopy Belief Propagation [KFL01];

88 * Tree Expectation Propagation [MiQ04];

89 * Generalized Belief Propagation [YFW05];

90 * Double-loop GBP [HAK03];

91 * Various variants of Loop Corrected Belief Propagation [MoK07, MoR05];

92 * Gibbs sampler;

93 * Conditioned BP [EaG09].

95 These inference methods can be used to calculate partition sums, marginals

96 over subsets of variables, and MAP states (the joint state of variables that

97 has maximum probability).

99 In addition, libDAI supports parameter learning of conditional probability

100 tables by Expectation Maximization.

103 Why C++?

104 --------

105 Because libDAI is implemented in C++, it is very fast compared with

106 implementations in MatLab (a factor 1000 faster is not uncommon). libDAI does

107 provide a (limited) MatLab interface for easy integration with MatLab.

110 Releases

111 --------

112 Releases can be obtained from www.libdai.org

113 License: GNU Public License v2 (or higher).

115 libDAI-0.2 December 1, 2006

116 libDAI-0.2.1 May 26, 2008

117 libDAI-0.2.2 September 30, 2008

120 Acknowledgments

121 ---------------

122 This work is part of the Interactive Collaborative Information Systems (ICIS)

123 project, supported by the Dutch Ministry of Economic Affairs, grant BSIK03024.

124 I would like to thank Martijn Leisink for providing the basis on which libDAI has been built.

127 Documentation

128 -------------

129 Some doxygen documentation is available. Install doxygen and use "make doc" to build the

130 documentation. If the documentation is not clear enough, feel free to send me an email

131 (or even better, to improve the documentation!).

133 A description of the factor graph (.fg) file format can be found in the file FILEFORMAT.

136 Compatibility

137 -------------

138 The code has been developed under Debian GNU/Linux with the GCC compiler suite.

139 libDAI compiles successfully with g++ versions 3.4, 4.1, 4.2 and 4.3.

141 libDAI has also been successfully compiled with MS Visual Studio 2008 under Windows

142 (but not all build targets are supported yet) and with Cygwin under Windows.

144 Finally, libDAI has been compiled successfully on MacOS X.

147 Quick start (linux/cygwin/Mac OS X)

148 -----------------------------------

149 You need:

150 - a recent version of gcc (at least version 3.4)

151 - GNU make

152 - doxygen

153 - graphviz

154 - recent boost C++ libraries (at least version 1.34, or 1.37 for cygwin;

155 version 1.37 shipped with Ubuntu 9.04 is known not to work)

157 On Debian/Ubuntu, you can easily install all these packages with a single command:

158 "apt-get install g++ make doxygen graphviz libboost-dev libboost-graph-dev libboost-program-options-dev"

159 (root permissions needed).

161 On Mac OS X (10.4 is known to work), these packages can be installed easily via MacPorts.

162 First, install MacPorts according to the instructions at http://www.macports.org/

163 Then, a simple "sudo port install gmake boost doxygen graphviz"

164 should be enough to install everything that is needed.

166 On Cygwin, the prebuilt Cygwin package boost-1.33.1-x is known not to work.

167 You can however obtain the latest boost version (you need at least 1.37.0)

168 from http://www.boost.org/ and compile/install it with:

170 ./configure

171 make

172 make install

175 To build the libDAI source, first copy a template Makefile.* to Makefile.conf

176 (for example, copy Makefile.LINUX to Makefile.conf if you use GNU/Linux).

177 Then, edit the Makefile.conf template to adapt it to your local setup.

178 Especially directories may differ from system to system. Finally, run

180 make

182 If the build was successful, you can test the example program:

184 ./example tests/alarm.fg

186 or the more elaborate test program:

188 tests/testdai --aliases tests/aliases.conf --filename tests/alarm.fg --methods JTREE_HUGIN BP_SEQMAX

191 Quick start (Windows)

192 ---------------------

193 You need:

194 - A recent version of MicroSoft Visual Studio (2008 works)

195 - recent boost C++ libraries (version 1.34 or higher)

196 - GNU make (can be obtained from http://gnuwin32.sourceforge.net)

197 For the regression test, you need:

198 - GNU diff, GNU sed (can be obtained from http://gnuwin32.sourceforge.net)

200 To build the source, copy Makefile.WINDOWS to Makefile.conf. Then, edit

201 Makefile.conf to adapt it to your local setup. Finally, run (from the command line)

203 make

205 If the build was successful, you can test the example program:

207 example tests\alarm.fg

209 or the more elaborate test program:

211 tests\testdai --aliases tests\aliases.conf --filename tests\alarm.fg --methods JTREE_HUGIN BP_SEQMAX

214 Quick start (MatLab)

215 --------------------

216 You need:

217 - MatLab

218 - The platform-dependent requirements described above

220 First, you need to build the libDAI source as described above for your

221 platform. By default, the MatLab interface is disabled, so before compiling the

222 source, you have to enable it in the Makefile.conf by setting

223 "WITH_MATLAB=true". Also, you have to configure the MatLab-specific parts of

224 Makefile.conf to match your system (in particular, the Makefile variables ME,

225 MATLABDIR and MEX). The MEX file extension depends on your platform; for a

226 64-bit linux x86_64 system this would be "ME=.mexa64", for a 32-bit linux x86

227 system this would be "ME=.mexglx". If you are unsure about your MEX file

228 extension: it needs to be the same as what the MatLab command "mexext" returns.

229 The required MEX files are built by issuing

231 make

233 from the command line. The MatLab interface is much less powerful than using

234 libDAI from C++. There are two reasons for this: (i) it is boring to write MEX

235 files; (ii) the large performance penalty paid when large data structures (like

236 factor graphs) have to be converted between their native C++ data structure to

237 something that MatLab understands.

239 A simple example of how to use the MatLab interface is the following (entered

240 at the MatLab prompt), which performs exact inference by the junction tree

241 algorithm and approximate inference by belief propagation on the ALARM network:

243 cd path_to_libdai/matlab

244 [psi] = dai_readfg ('../examples/alarm.fg');

245 [logZ,q,md,qv,qf] = dai (psi, 'JTREE', '[updates=HUGIN,verbose=0]')

246 [logZ,q,md,qv,qf] = dai (psi, 'BP', '[updates=SEQMAX,tol=1e-9,maxiter=10000,logdomain=0]')

248 where "path_to_libdai" has to be replaced with the directory in which libDAI

249 was installed. For other algorithms and their parameters, see

250 tests/aliases.conf.