1 /* This file is part of libDAI - http://www.libdai.org/
3 * libDAI is licensed under the terms of the GNU General Public License version
4 * 2, or (at your option) any later version. libDAI is distributed without any
5 * warranty. See the file COPYING for more details.
7 * Copyright (C) 2008-2009 Joris Mooij [joris dot mooij at libdai dot org]
12 * \brief Contains additional doxygen documentation
14 * \todo Write a concept/notations page for the documentation,
15 * explaining the concepts of "state" (index into a
16 * multi-dimensional array, e.g., one corresponding
17 * to the Cartesian product of statespaces of variables)
18 * and "linear index". This should make it easier to
19 * document index.h and varset.h
21 * \todo Document tests and utils
23 * \todo Implement routines for UAI probabilistic inference evaluation data
25 * \todo Improve SWIG interfaces
27 * \idea Adapt (part of the) guidelines in http://www.boost.org/development/requirements.html#Design_and_Programming
29 * \idea Use "gcc -MM" to generate dependencies for targets: http://make.paulandlesley.org/autodep.html
31 * \todo Replace VarSets by SmallSet<size_t> where appropriate, in order to minimize the use of FactorGraph::findVar().
33 * \idea Disentangle structures. In particular, ensure that graphical properties are not
34 * entangled with probabilistic properties. For example, a FactorGraph contains several components:
36 * - an array of variable labels
37 * - an array of variable state space sizes
38 * - an array of pointers to factor value vectors
39 * In this way, each factor could be implemented differently, e.g., we could have
40 * some sparse factors, some noisy-OR factors, some dense factors, some arbitrary
41 * precision factors, etcetera.
43 * \idea Use boost::uBLAS framework to deal with matrices, especially, with 2D sparse matrices.
44 * See http://www.boost.org/libs/numeric/ublas/doc/matrix_sparse.htm
45 * However: I read somewhere that boost::uBLAS concentrates more on correct implementation than on performance.
47 * \idea Introduce naming scheme:
48 * - all Vars should be named v_..., e.g. v_i instead of i
49 * - all VarSets should be named vs_..., e.g. v_i instead of i
50 * - all Factors should be named f_..., e.g. f_I instead of I
51 * - all indices should be named _..., e.g. _k instead of k
52 * - all iterators should be named i_, e.g. i_i is an iterator to i
53 * - all const_iterators should be named ci_, e.g. ci_i is an iterator to i
57 /** \mainpage Reference manual for libDAI - A free/open source C++ library for Discrete Approximate Inference methods
60 * \date January 12, 2010 - or later
63 * \section about About libDAI
64 * libDAI is a free/open source C++ library (licensed under GPL 2+) that provides
65 * implementations of various (approximate) inference methods for discrete
66 * graphical models. libDAI supports arbitrary factor graphs with discrete
67 * variables; this includes discrete Markov Random Fields and Bayesian
70 * The library is targeted at researchers. To be able to use the library, a
71 * good understanding of graphical models is needed.
73 * The best way to use libDAI is by writing C++ code that invokes the library;
74 * in addition, part of the functionality is accessibly by using the
75 * - command line interface
76 * - (limited) MatLab interface
77 * - (experimental) python interface
78 * - (experimental) octave interface.
80 * libDAI can be used to implement novel (approximate) inference algorithms
81 * and to easily compare the accuracy and performance with existing algorithms
82 * that have been implemented already.
84 * \section features Features
85 * Currently, libDAI supports the following (approximate) inference methods:
86 * - Exact inference by brute force enumeration;
87 * - Exact inference by junction-tree methods;
89 * - Loopy Belief Propagation [\ref KFL01];
90 * - Fractional Belief Propagation [\ref WiH03];
91 * - Tree-Reweighted Belief Propagation [\ref WJW03];
92 * - Tree Expectation Propagation [\ref MiQ04];
93 * - Generalized Belief Propagation [\ref YFW05];
94 * - Double-loop GBP [\ref HAK03];
95 * - Various variants of Loop Corrected Belief Propagation
96 * [\ref MoK07, \ref MoR05];
98 * - Clamped Belief Propagation [\ref EaG09].
100 * These inference methods can be used to calculate partition sums, marginals
101 * over subsets of variables, and MAP states (the joint state of variables that
102 * has maximum probability).
104 * In addition, libDAI supports parameter learning of conditional probability
105 * tables by Expectation Maximization.
107 * \section limitations Limitations
108 * libDAI is not intended to be a complete package for approximate inference.
109 * Instead, it should be considered as an "inference engine", providing
110 * various inference methods. In particular, it contains no GUI, currently
111 * only supports its own file format for input and output (although support
112 * for standard file formats may be added later), and provides very limited
113 * visualization functionalities. The only learning method supported currently
114 * is Expectation Maximization (or Maximum Likelihood if no data is missing)
115 * for learning factor parameters.
117 * \section rationale Rationale
119 * In my opinion, the lack of open source "reference" implementations hampers
120 * progress in research on approximate inference. Methods differ widely in terms
121 * of quality and performance characteristics, which also depend in different
122 * ways on various properties of the graphical models. Finding the best
123 * approximate inference method for a particular application therefore often
124 * requires empirical comparisons. However, implementing and debugging these
125 * methods takes a lot of time which could otherwise be spent on research. I hope
126 * that this code will aid researchers to be able to easily compare various
127 * (existing as well as new) approximate inference methods, in this way
128 * accelerating research and stimulating real-world applications of approximate
131 * \section language Language
132 * Because libDAI is implemented in C++, it is very fast compared with
133 * implementations in MatLab (a factor 1000 faster is not uncommon).
134 * libDAI does provide a (limited) MatLab interface for easy integration with MatLab.
135 * It also provides a command line interface and experimental python and octave
136 * interfaces (thanks to Patrick Pletscher).
138 * \section compatibility Compatibility
140 * The code has been developed under Debian GNU/Linux with the GCC compiler suite.
141 * libDAI compiles successfully with g++ versions 3.4, 4.1, 4.2 and 4.3.
143 * libDAI has also been successfully compiled with MS Visual Studio 2008 under Windows
144 * (but not all build targets are supported yet) and with Cygwin under Windows.
146 * Finally, libDAI has been compiled successfully on MacOS X.
148 * \section download Downloading libDAI
149 * The libDAI sources and documentation can be downloaded from the libDAI website:
150 * http://www.libdai.org.
152 * \section support Mailing list
153 * The Google group "libDAI" (http://groups.google.com/group/libdai)
154 * can be used for getting support and discussing development issues.
158 /** \page license License
160 * \section license-license License
162 * libDAI is free software; you can redistribute it and/or modify
163 * it under the terms of the GNU General Public License as published by
164 * the Free Software Foundation; either version 2 of the License, or
165 * (at your option) any later version.
167 * libDAI is distributed in the hope that it will be useful,
168 * but WITHOUT ANY WARRANTY; without even the implied warranty of
169 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170 * GNU General Public License for more details.
173 * \section license-gpl GNU General Public License version 2
175 * \verbinclude COPYING
179 /** \page citations Citing libDAI
181 * \section citations-citations Citing libDAI
183 * If you write a scientific paper describing research that made substantive use
184 * of this program, please:
185 * - mention the fashion in which this software was
186 * used, including the version number, with a citation to the literature,
187 * to allow replication;
188 * - mention this software in the Acknowledgements section.
190 * An appropriate citation would be:\n
191 * J. M. Mooij (2009) "libDAI 0.2.3: A free/open source C++ library for Discrete
192 * Approximate Inference", http://www.libdai.org
194 * Moreover, as a personal note, I would appreciate it if you would email
195 * (citations of) papers referencing this work to joris dot mooij at libdai dot org.
199 /** \page authors Authors
200 * \section authors-authors People who contributed to libDAI
202 * \verbinclude AUTHORS
206 /** \page build Building libDAI
208 * \section build-unix Building libDAI under UNIX variants (Linux / Cygwin / Mac OS X)
211 * - a recent version of gcc (at least version 3.4)
215 * - recent boost C++ libraries (at least version 1.34 if you have
216 * a recent version of GCC, otherwise at least version 1.37; however,
217 * version 1.37 shipped with Ubuntu 9.04 is known not to work)
219 * On Debian/Ubuntu, you can easily install all these packages with a single command:
220 * <pre> apt-get install g++ make doxygen graphviz libboost-dev libboost-graph-dev libboost-program-options-dev</pre>
221 * (root permissions needed).
223 * On Mac OS X (10.4 is known to work), these packages can be installed easily via MacPorts.
224 * If MacPorts is not already installed, install it according to the instructions at http://www.macports.org/.
226 * <pre> sudo port install gmake boost doxygen graphviz</pre>
227 * should be enough to install everything that is needed.
229 * On Cygwin, the prebuilt Cygwin package boost-1.33.1-x is known not to work.
230 * You can however obtain the latest boost version (you need at least 1.37.0)
231 * from http://www.boost.org/ and compile/install it with:
238 * To build the libDAI source, first copy a template Makefile.* to Makefile.conf
239 * (for example, copy Makefile.LINUX to Makefile.conf if you use GNU/Linux).
240 * Then, edit the Makefile.conf template to adapt it to your local setup.
241 * Especially directories may differ from system to system. Finally, run
243 * The build includes a regression test, which may take a while to complete.
245 * If the build was successful, you can test the example program:
246 * <pre> examples/example tests/alarm.fg</pre>
247 * or the more elaborate test program:
248 * <pre> tests/testdai --aliases tests/aliases.conf --filename tests/alarm.fg --methods JTREE_HUGIN BP_SEQMAX</pre>
252 * \section build-windows Building libDAI under Windows
255 * - A recent version of MicroSoft Visual Studio (2008 is known to work)
256 * - recent boost C++ libraries (version 1.37 or higher)
257 * - GNU make (can be obtained from http://gnuwin32.sourceforge.net)
259 * For the regression test, you need:
260 * - GNU diff, GNU sed (can be obtained from http://gnuwin32.sourceforge.net)
262 * To build the source, copy Makefile.WINDOWS to Makefile.conf. Then, edit
263 * Makefile.conf to adapt it to your local setup. Finally, run (from the command line)
265 * The build includes a regression test, which may take a while to complete.
267 * If the build was successful, you can test the example program:
268 * <pre> examples\\example tests\\alarm.fg</pre>
269 * or the more elaborate test program:
270 * <pre> tests\\testdai --aliases tests\\aliases.conf --filename tests\\alarm.fg --methods JTREE_HUGIN BP_SEQMAX</pre>
274 * \section build-matlab Building the libDAI MatLab interface
278 * - The platform-dependent requirements described above
280 * First, you need to build the libDAI source as described above for your
281 * platform. By default, the MatLab interface is disabled, so before compiling the
282 * source, you have to enable it in the Makefile.conf by setting
283 * <pre> WITH_MATLAB=true</pre>
284 * Also, you have to configure the MatLab-specific parts of
285 * Makefile.conf to match your system (in particular, the Makefile variables ME,
286 * MATLABDIR and MEX). The MEX file extension depends on your platform; for a
287 * 64-bit linux x86_64 system this would be "ME=.mexa64", for a 32-bit linux x86
288 * system "ME=.mexglx". If you are unsure about your MEX file
289 * extension: it needs to be the same as what the MatLab command "mexext" returns.
290 * The required MEX files are built by issuing
292 * from the command line. The MatLab interface is much less powerful than using
293 * libDAI from C++. There are two reasons for this: (i) it is boring to write MEX
294 * files; (ii) the large performance penalty paid when large data structures (like
295 * factor graphs) have to be converted between their native C++ data structure to
296 * something that MatLab understands.
298 * A simple example of how to use the MatLab interface is the following (entered
299 * at the MatLab prompt), which performs exact inference by the junction tree
300 * algorithm and approximate inference by belief propagation on the ALARM network:
301 * <pre> cd path_to_libdai/matlab
302 * [psi] = dai_readfg ('../examples/alarm.fg');
303 * [logZ,q,md,qv,qf] = dai (psi, 'JTREE', '[updates=HUGIN,verbose=0]')
304 * [logZ,q,md,qv,qf] = dai (psi, 'BP', '[updates=SEQMAX,tol=1e-9,maxiter=10000,logdomain=0]')</pre>
305 * where "path_to_libdai" has to be replaced with the directory in which libDAI
306 * was installed. For other algorithms and some default parameters, see the file
307 * tests/aliases.conf.
310 * \section build-doxygen Building the documentation
312 * Install doxygen, graphviz and a TeX distribution and use
313 * <pre> make doc</pre>
314 * to build the documentation. If the documentation is not clear enough, feel free
315 * to send me an email (or even better, to improve the documentation and send a patch!).
316 * The documentation can also be browsed online at http://www.libdai.org.
320 /** \page changelog Change Log
321 * \verbinclude ChangeLog
325 /** \page inference Graphical models and approximate inference
327 * \section inference-graphicalmodels Graphical models
329 * Commonly used graphical models are Bayesian networks and Markov random fields.
330 * In libDAI, both types of graphical models are represented by a slightly more
331 * general type of graphical model: a factor graph [\ref KFL01].
333 * An example of a Bayesian network is:
349 * The probability distribution of a Bayesian network factorizes as:
350 * \f[ P(\mathbf{x}) = \prod_{i\in\mathcal{V}} P(x_i \,|\, x_{\mathrm{pa}(i)}) \f]
351 * where \f$\mathrm{pa}(i)\f$ are the parents of node \a i in a DAG.
353 * The same probability distribution can be represented as a Markov random field:
371 * The probability distribution of a Markov random field factorizes as:
372 * \f[ P(\mathbf{x}) = \frac{1}{Z} \prod_{C\in\mathcal{C}} \psi_C(x_C) \f]
373 * where \f$ \mathcal{C} \f$ are the cliques of an undirected graph,
374 * \f$ \psi_C(x_C) \f$ are "potentials" or "compatibility functions", and
375 * \f$ Z \f$ is the partition sum which properly normalizes the probability
378 * Finally, the same probability distribution can be represented as a factor graph:
380 * graph factorgraph {
387 * f01 [shape="box",label=""];
388 * f02 [shape="box",label=""];
389 * f13 [shape="box",label=""];
390 * f124 [shape="box",label=""];
403 * The probability distribution of a factor graph factorizes as:
404 * \f[ P(\mathbf{x}) = \frac{1}{Z} \prod_{I\in \mathcal{F}} f_I(x_I) \f]
405 * where \f$ \mathcal{F} \f$ are the factor nodes of a factor graph (a
406 * bipartite graph consisting of variable nodes and factor nodes),
407 * \f$ f_I(x_I) \f$ are the factors, and \f$ Z \f$ is the partition sum
408 * which properly normalizes the probability distribution.
410 * Looking at the expressions for the joint probability distributions,
411 * it is obvious that Bayesian networks and Markov random fields can
412 * both be easily represented as factor graphs. Factor graphs most
413 * naturally express the factorization structure of a probability
414 * distribution, and hence are a convenient representation for approximate
415 * inference algorithms, which all try to exploit this factorization.
416 * This is why libDAI uses a factor graph as representation of a
417 * graphical model, implemented in the dai::FactorGraph class.
419 * \section inference-inference Inference tasks
421 * Given a factor graph, specified by the variable nodes \f$\{x_i\}_{i\in\mathcal{V}}\f$
422 * the factor nodes \f$ \mathcal{F} \f$, the graph structure, and the factors
423 * \f$\{f_I(x_I)\}_{I\in\mathcal{F}}\f$, the following tasks are important:
425 * - Calculating the partition sum:
426 * \f[ Z = \sum_{\mathbf{x}_{\mathcal{V}}} \prod_{I \in \mathcal{F}} f_I(x_I) \f]
427 * - Calculating the marginal distribution of a subset of variables
428 * \f$\{x_i\}_{i\in A}\f$:
429 * \f[ P(\mathbf{x}_{A}) = \frac{1}{Z} \sum_{\mathbf{x}_{\mathcal{V}\setminus A}} \prod_{I \in \mathcal{F}} f_I(x_I) \f]
430 * - Calculating the MAP state which has the maximum probability mass:
431 * \f[ \mathrm{argmax}_{\mathbf{x}}\,\prod_{I\in\mathcal{F}} f_I(x_I) \f]
433 * libDAI offers several inference algorithms, which solve (a subset of) these tasks either
434 * approximately or exactly, for factor graphs with discrete variables. The following
435 * algorithms are implemented:
438 * - Brute force enumeration: dai::ExactInf
439 * - Junction-tree method: dai::JTree
441 * Approximate inference:
442 * - Mean Field: dai::MF
443 * - (Loopy) Belief Propagation: dai::BP [\ref KFL01]
444 * - Fractional Belief Propagation: dai::FBP [\ref WiH03]
445 * - Tree-Reweighted Belief Propagation: dai::TRWBP [\ref WJW03]
446 * - Tree Expectation Propagation: dai::TreeEP [\ref MiQ04]
447 * - Generalized Belief Propagation: dai::HAK [\ref YFW05]
448 * - Double-loop GBP: dai::HAK [\ref HAK03]
449 * - Loop Corrected Belief Propagation: dai::MR [\ref MoR05] and dai::LC [\ref MoK07]
450 * - Gibbs sampling: dai::Gibbs
451 * - Clamped Belief Propagation: dai::CBP [\ref EaG09]
453 * Not all inference tasks are implemented by each method: calculating MAP states
454 * is only possible with dai::JTree and dai::BP, calculating partition sums is
455 * not possible with dai::MR, dai::LC and dai::Gibbs.
457 * \section inference-learning Parameter learning
459 * In addition, libDAI supports parameter learning of conditional probability
460 * tables by Expectation Maximization (or Maximum Likelihood, if there is no
461 * missing data). This is implemented in dai::EMAlg.
466 /** \page fileformats libDAI file formats
468 * \section fileformats-factorgraph Factor graph (.fg) file format
470 * This section describes the .fg file format used in libDAI to store factor graphs.
471 * Markov Random Fields are special cases of factor graphs, as are Bayesian
472 * networks. A factor graph can be specified as follows: for each factor, one has
473 * to specify which variables occur in the factor, what their respective
474 * cardinalities (i.e., number of possible values) are, and a table listing all
475 * the values of that factor for all possible configurations of these variables.
477 * A .fg file is not much more than that. It starts with a line containing the
478 * number of factors in that graph, followed by an empty line. Then all factors
479 * are specified, using one block for each factor, where the blocks are seperated
480 * by empty lines. Each variable occurring in the factor graph has a unique
481 * identifier, its label (which should be a nonnegative integer). Comment lines
482 * which start with # are ignored.
484 * \subsection fileformats-factorgraph-factor Factor block format
486 * Each block describing a factor starts with a line containing the number of
487 * variables in that factor. The second line contains the labels of these
488 * variables, seperated by spaces (labels are nonnegative integers and to avoid
489 * confusion, it is suggested to start counting at 0). The third line contains
490 * the number of possible values of each of these variables, also seperated by
491 * spaces. Note that there is some redundancy here, since if a variable appears
492 * in more than one factor, the cardinality of that variable appears several
493 * times in the .fg file; obviously, these cardinalities should be consistent.
494 * The fourth line contains the number of nonzero entries
495 * in the factor table. The rest of the lines contain these nonzero entries;
496 * each line consists of a table index, followed by white-space, followed by the
497 * value corresponding to that table index. The most difficult part is getting
498 * the indexing right. The convention that is used is that the left-most
499 * variables cycle through their values the fastest (similar to MatLab indexing
500 * of multidimensional arrays).
502 * \subsubsection fileformats-factorgraph-factor-example Example
504 * An example block describing one factor is:
525 * which corresponds to the following factor:
528 * \begin{array}{ccc|c}
529 * x_4 & x_8 & x_7 & \mbox{value}\\
546 * Note that the value of \f$x_4\f$ changes fastest, followed by that of \f$x_8\f$, and \f$x_7\f$
547 * varies the slowest, corresponding to the second line of the block ("4 8 7").
548 * Further, \f$x_4\f$ can take on three values, and \f$x_8\f$ and \f$x_7\f$ each have two possible
549 * values, as described in the third line of the block ("3 2 2"). The table
550 * contains 11 non-zero entries (all except for the fifth entry). Note that the
551 * eleventh and twelveth entries are interchanged.
553 * A final note: the internal representation in libDAI of the factor above is
554 * different, because the variables are ordered according to their indices
555 * (i.e., the ordering would be \f$x_4 x_7 x_8\f$) and the values of the table are
556 * stored accordingly, with the variable having the smallest index changing
560 * \begin{array}{ccc|c}
561 * x_4 & x_7 & x_8 & \mbox{value}\\
579 * \section fileformats-evidence Evidence (.tab) file format
581 * This section describes the .tab fileformat used in libDAI to store "evidence",
582 * i.e., a data set consisting of multiple samples, where each sample is the
583 * observed joint state of some variables.
585 * A .tab file is a tabular data file, consisting of a header line, followed by
586 * an empty line, followed by the data points, with one line for each data point.
587 * Each line (apart from the empty one) should have the same number of columns,
588 * where columns are separated by one tab character. Each column corresponds to
589 * a variable. The header line consists of the variable labels (corresponding to
590 * dai::Var::label()). The other lines are observed joint states of the variables, i.e.,
591 * each line corresponds to a joint observation of the variables, and each column
592 * of a line contains the state of the variable associated with that column.
593 * Missing data is handled simply by having two consecutive tab characters,
594 * without any characters in between.
596 * \subsection fileformats-evidence-example Example
606 * This would correspond to a data set consisting of three observations concerning
607 * the variables with labels 1, 3 and 2; the first observation being
608 * \f$x_1 = 0, x_3 = 0, x_2 = 1\f$, the second observation being
609 * \f$x_1 = 1, x_3 = 0, x_2 = 1\f$, and the third observation being
610 * \f$x_1 = 1, x_2 = 1\f$ (where the state of \f$x_3\f$ is missing).
612 * \section fileformats-emalg Expectation Maximization (.em) file format
614 * This section describes the file format of .em files, which are used
615 * to specify a particular EM algorithm. The .em files are complementary
616 * to .fg files; in other words, an .em file without a corresponding .fg
617 * file is useless. Furthermore, one also needs a corresponding .tab file
618 * containing the data used for parameter learning.
620 * An .em file starts with a line specifying the number of maximization steps,
621 * followed by an empty line. Then, each maximization step is described in a
622 * block, which should satisfy the format described in the next subsection.
624 * \subsection fileformats-emalg-maximizationstep Maximization Step block format
626 * A maximization step block of an .em file starts with a single line
627 * describing the number of shared parameters blocks that will follow.
628 * Then, each shared parameters block follows, in the format described in
629 * the next subsection.
631 * \subsection fileformats-emalg-sharedparameters Shared parameters block format
633 * A shared parameters block of an .em file starts with a single line
634 * consisting of the name of a ParameterEstimation subclass
635 * and its parameters in the format of a PropertySet. For example:
636 * <pre> CondProbEstimation [target_dim=2,total_dim=4,pseudo_count=1]</pre>
637 * The next line contains the number of factors that share their parameters.
638 * Then, each of these factors is specified on separate lines (possibly
639 * seperated by empty lines), where each line consists of several fields
640 * seperated by a space or a tab character. The first field contains
641 * the index of the factor in the factor graph. The following fields should
642 * contain the variable labels of the variables on which that factor depends,
643 * in a specific ordering. This ordering can be different from the canonical
644 * ordering of the variables used internally in libDAI (which would be sorted
645 * ascendingly according to the variable labels). The ordering of the variables
646 * specifies the implicit ordering of the shared parameters: when iterating
647 * over all shared parameters, the corresponding index of the first variable
648 * changes fastest (in the inner loop), and the corresponding index of the
649 * last variable changes slowest (in the outer loop). By choosing the right
650 * ordering, it is possible to let different factors (depending on different
651 * variables) share parameters in parameter learning using EM. This convention
652 * is similar to the convention used in factor blocks in a factor graph .fg
653 * file (see \ref fileformats-factorgraph-factor).
655 * \section fileformats-aliases Aliases file format
657 * An aliases file is basically a list of "macros" and the strings that they
658 * should be substituted with.
660 * Each line of the aliases file can be either empty, contain a comment
661 * (if the first character is a '#') or contain an alias. In the latter case,
662 * the line should contain a colon; the part before the colon contains the
663 * name of the alias, the part after the colon the string that it should be
664 * substituted with. Any whitespace before and after the colon is ignored.
666 * For example, the following line would define the alias \c BP_SEQFIX
667 * as a shorthand for "BP[updates=SEQFIX,tol=1e-9,maxiter=10000,logdomain=0]":
669 * BP_SEQFIX: BP[updates=SEQFIX,tol=1e-9,maxiter=10000,logdomain=0]
672 * Aliases files can be used to store default options for algorithms.
675 /** \page bibliography Bibliography
676 * \anchor EaG09 \ref EaG09
677 * F. Eaton and Z. Ghahramani (2009):
678 * "Choosing a Variable to Clamp",
679 * <em>Proceedings of the Twelfth International Conference on Artificial Intelligence and Statistics (AISTATS 2009)</em> 5:145-152,
680 * http://jmlr.csail.mit.edu/proceedings/papers/v5/eaton09a/eaton09a.pdf
682 * \anchor EMK06 \ref EMK06
683 * G. Elidan and I. McGraw and D. Koller (2006):
684 * "Residual Belief Propagation: Informed Scheduling for Asynchronous Message Passing",
685 * <em>Proceedings of the 22nd Annual Conference on Uncertainty in Artificial Intelligence (UAI-06)</em>,
686 * http://uai.sis.pitt.edu/papers/06/UAI2006_0091.pdf
688 * \anchor HAK03 \ref HAK03
689 * T. Heskes and C. A. Albers and H. J. Kappen (2003):
690 * "Approximate Inference and Constrained Optimization",
691 * <em>Proceedings of the 19th Annual Conference on Uncertainty in Artificial Intelligence (UAI-03)</em> pp. 313-320,
692 * http://www.snn.ru.nl/reports/Heskes.uai2003.ps.gz
694 * \anchor KFL01 \ref KFL01
695 * F. R. Kschischang and B. J. Frey and H.-A. Loeliger (2001):
696 * "Factor Graphs and the Sum-Product Algorithm",
697 * <em>IEEE Transactions on Information Theory</em> 47(2):498-519,
698 * http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=910572
700 * \anchor KoF09 \ref KoF09
701 * D. Koller and N. Friedman (2009):
702 * <em>Probabilistic Graphical Models - Principles and Techniques</em>,
703 * The MIT Press, Cambridge, Massachusetts, London, England.
705 * \anchor Min05 \ref Min05
707 * "Divergence measures and message passing",
708 * <em>MicroSoft Research Technical Report</em> MSR-TR-2005-173,
709 * http://research.microsoft.com/en-us/um/people/minka/papers/message-passing/minka-divergence.pdf
711 * \anchor MiQ04 \ref MiQ04
712 * T. Minka and Y. Qi (2004):
713 * "Tree-structured Approximations by Expectation Propagation",
714 * <em>Advances in Neural Information Processing Systems</em> (NIPS) 16,
715 * http://books.nips.cc/papers/files/nips16/NIPS2003_AA25.pdf
717 * \anchor MoK07 \ref MoK07
718 * J. M. Mooij and H. J. Kappen (2007):
719 * "Loop Corrections for Approximate Inference on Factor Graphs",
720 * <em>Journal of Machine Learning Research</em> 8:1113-1143,
721 * http://www.jmlr.org/papers/volume8/mooij07a/mooij07a.pdf
723 * \anchor MoK07b \ref MoK07b
724 * J. M. Mooij and H. J. Kappen (2007):
725 * "Sufficient Conditions for Convergence of the Sum-Product Algorithm",
726 * <em>IEEE Transactions on Information Theory</em> 53(12):4422-4437,
727 * http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4385778
729 * \anchor MoR05 \ref MoR05
730 * A. Montanari and T. Rizzo (2005):
731 * "How to Compute Loop Corrections to the Bethe Approximation",
732 * <em>Journal of Statistical Mechanics: Theory and Experiment</em> 2005(10)-P10011,
733 * http://stacks.iop.org/1742-5468/2005/P10011
735 * \anchor StW99 \ref StW99
736 * A. Steger and N. C. Wormald (1999):
737 * "Generating Random Regular Graphs Quickly",
738 * <em>Combinatorics, Probability and Computing</em> Vol 8, Issue 4, pp. 377-396,
739 * http://www.math.uwaterloo.ca/~nwormald/papers/randgen.pdf
741 * \anchor WiH03 \ref WiH03
742 * W. Wiegerinck and T. Heskes (2003):
743 * "Fractional Belief Propagation",
744 * <em>Advances in Neural Information Processing Systems</em> (NIPS) 15, pp. 438-445,
745 * http://books.nips.cc/papers/files/nips15/LT16.pdf
747 * \anchor WJW03 \ref WJW03
748 * M. J. Wainwright, T. S. Jaakkola and A. S. Willsky (2003):
749 * "Tree-reweighted belief propagation algorithms and approximate ML estimation by pseudo-moment matching",
750 * <em>9th Workshop on Artificial Intelligence and Statistics</em>,
751 * http://www.eecs.berkeley.edu/~wainwrig/Papers/WJW_AIStat03.pdf
753 * \anchor YFW05 \ref YFW05
754 * J. S. Yedidia and W. T. Freeman and Y. Weiss (2005):
755 * "Constructing Free-Energy Approximations and Generalized Belief Propagation Algorithms",
756 * <em>IEEE Transactions on Information Theory</em> 51(7):2282-2312,
757 * http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=1459044
761 /** \page discussion Ideas not worth exploring
762 * \section discuss_extendedgraphs Extended factorgraphs/regiongraphs
764 * A FactorGraph and a RegionGraph are often equipped with
765 * additional properties for nodes and edges. The code to initialize those
766 * is often quite similar. Maybe one could abstract this, e.g.:
768 * template <typename Node1Properties, typename Node2Properties, typename EdgeProperties>
769 * class ExtFactorGraph : public FactorGraph {
771 * std::vector<Node1Properties> node1Props;
772 * std::vector<Node2Properties> node2Props;
773 * std::vector<std::vector<EdgeProperties> > edgeProps;
779 * - Less code duplication.
780 * - Easier maintainability.
781 * - Easier to write new inference algorithms.
784 * - Cachability may be worse.
785 * - A problem is the case where there are no properties for either type of nodes or for edges.
786 * Maybe this can be solved using specializations, or using variadac template arguments?
787 * Another possible solution would be to define a "class Empty {}", and add some code
788 * that checks for the typeid, comparing it with Empty, and doing something special in that case
789 * (e.g., not allocating memory).
790 * - The main disadvantage of this approach seems to be that it leads to even more entanglement.
791 * Therefore this is probably a bad idea.
793 * \section discuss_templates Polymorphism by template parameterization
795 * Instead of polymorphism by inheritance, use polymorphism by template parameterization.
796 * For example, the real reason for introducing the complicated inheritance scheme of dai::InfAlg
797 * was for functions like dai::calcMarginal. Instead, one could use a template function:
799 * template<typename InfAlg>
800 * Factor calcMarginal( const InfAlg &obj, const VarSet &ns, bool reInit );
802 * This would assume that the type InfAlg supports certain methods. Ideally, one would use
803 * concepts to define different classes of inference algorithms with different capabilities,
804 * for example the ability to calculate logZ, the ability to calculate marginals, the ability to
805 * calculate bounds, the ability to calculate MAP states, etc. Then, one would use traits
806 * classes in order to be able to query the capabilities of the model. For example, one would be
807 * able to query whether the inference algorithm supports calculation of logZ. Unfortunately,
808 * this is compile-time polymorphism, whereas tests/testdai needs runtime polymorphism.
809 * Therefore this is probably a bad idea.