Improved documentation of bipgraph.h and added example_bipgraph.cpp
[libdai.git] / ChangeLog
1 libDAI-0.2.2 (2008-09-30)
2 -------------------------
3
4 New features:
5 * Approximate inference methods now report the number of iterations needed.
6 * Added damping to various algorithms to improve convergence properties.
7 * Added more features to utils/createfg for creating factor graphs.
8 * Added ExactInf class for brute force exact inference.
9 * [Giuseppe Pasino] Added "logdomain" property to BP, a boolean that controls
10 whether calculations are done in the log-domain or in the linear domain;
11 doing calculations in the log-domain may help if the numerical range
12 of a double is too small.
13 * [Claudio Lima] Added Max-Product functionality to BP.
14 * Improved documentation.
15
16 Improved architecture:
17 * Added Exceptions framework.
18 * Pervasive change of BipartiteGraph implementation (based on an idea by
19 Giuseppe Passino). BipartiteGraph no longer stores the node properties
20 (former _V1 and _V2), nor does it store a dense adjacency matrix anymore,
21 nor an edge list. Instead, it stores the graph structure as lists of
22 neighboring nodes. This yields a significant memory/speed improvement for
23 large factor graphs, and is more elegant as well. Iterating over neighbors is
24 made easy by using boost::foreach.
25 * Added conditional compilation of inference methods.
26 * VarSet is now implemented using a std::vector<Var> instead of a
27 std::set<Var>, which yields a significant speed improvement. Furthermore,
28 the implementation has been generalized, resulting in the small_set<T> class
29 which can be used to represent sets of small cardinality; VarSet is the
30 specialization with T = Var.
31 * Improved ClusterGraph implementation, yielding significant speedups
32 for the JunctionTree algorithm on large factorgraphs.
33
34 Code cleanup:
35 * Moved everything into namespace "dai".
36 * Renamed DEBUG to DAI_DEBUG to avoid conflicts.
37 * Replaced ENUM2,ENUM3,ENUM4,ENUM5,ENUM6 by single DAI_ENUM macro.
38 * Removed utils/remove_short_loops and matlab/remove_short_loops.
39 * Replaced sub_nb class in mr.h by boost::dynamic_bitset.
40 * Improved index.h:
41 - Renamed Index -> IndexFor
42 - Added some .reserve()'s to IndexFor methods which yields a
43 25% speedup of testregression
44 - Replaced multind by Permute
45 - Added MultiFor
46 - Added State
47 * New funcstionality of factor.h.
48 * Moved Properties and MaxDiff frameworks from InfAlg to each individual
49 inference algorithm, because the Properties framework was not as
50 convenient as I hoped, and not every inference algorithm needs a maxdiff
51 variable. Also, replaced some FactorGraph functionality in InfAlg by a
52 function that returns the FactorGraph. The result is cleaner (less
53 entangled) code.
54 * Removed x2x.
55 * Replaced Complex with real numbers (negative potentials are just too rare
56 to warrant the additional "complexity" :)).
57
58 Miscellaneous improvements:
59 * Now compiles also with MS Visual C++ (thanks to Jiuxiang Hu) and with
60 GCC under cygwin.
61 * Contributions by Peter Gober:
62 - Renamed variable _N in mr.* for compatibility with g++ under cygwin.
63 * Misc contributions by Giuseppe Passino:
64 - removed "using namespace std;" from header files - bad practice;
65 - moved header files in include/dai and sources in src;
66 - changed #ifndefs to GNU style;
67 - added extra warning checks (-W -Wextra) and fixed resulting warnings;
68 - dai::TProb:
69 o removed copy constructor and assignment operators (redundant);
70 o implementation of some methods via STL algorithms;
71 o added methods takeExp, takeLog, takeLog0 for transformation in-place;
72 o explicit constructor (prevents implicit conversion from size_t to TProb);
73 o added operator+,+=,-,-=, with argument T (for calculations in log-scale);
74 * Misc contributions by Christian Wojek:
75 - New FactorGraph constructor that constructs from given ranges of factors
76 and variables;
77 - Optimization of FactorGraph constructors using tr1::unordered_map.
78 * FactorGraph constructors no longer check for short loops (huge speed
79 increase for large factor graphs), nor for negative entries. Also, the
80 normtype is now Prob::NORMPROB by default.
81 * Improved MaxSpanningTreePrims algorithm (uses boost::graph).
82
83 Interface changes:
84 * VarSet::
85 - VarSet::stateSpace() -> nrStates(const VarSet &)
86 - VarSet( const std::set<Var> ) -> VarSet( begin, end, sizeHint=0 )
87 - VarSet( const std::vector<Var> ) -> VarSet( begin, end, sizeHint=0 )
88 - removed bool operator||
89 - operator&&(const VarSet&) -> intersects(const VarSet&)
90 - operator&&(const Var&) -> contains(const Var&)
91 * FactorGraph::
92 - delta(const Var &) -> delta(size_t)
93 - Delta(const Var &) -> Delta(size_t)
94 - makeCavity(const Var &) -> makeCavity(size_t)
95 - vars() -> vars
96 - factors() -> factors
97 - removed MakeFactorCavity(size_t)
98 - removed ExactMarginal(const VarSet &)
99 - removed ExactlogZ()
100 - removed updatedFactor(size_t)
101 - removed _normtype and NormType()
102 - removed hasShortLoops(...) and removeShortLoops(...)
103 - WriteToDotFile(const char *filename) -> printDot( std::ostream& os )
104 - undoProb(size_t) -> restoreFactor(size_t)
105 - saveProb(size_t) -> backupFactor(size_t)
106 - undoProbs(const VarSet &) -> restoreFactors(const VarSet &)
107 - saveProbs(const VarSet &) -> backupFactors(const VarSet &)
108 - ReadFromFile(const char*) returns void (throws on error)
109 - WriteToFile(const char*) returns void (throws on error)
110 - removed hasNegatives()
111 * RegionGraph::
112 - nr_ORs() -> nrORs()
113 - nr_IRs() -> nrIRs()
114 - ORs() -> ORs
115 - IRs() -> IRs
116 * *::Regenerate() -> *::construct()
117 * Renamed Index -> IndexFor
118 * Diffs:
119 - max() -> maxDiff()
120 - max_size() -> maxSize()
121 * Prob::max() -> Prob::maxVal()
122 * Factor::
123 - max() -> maxVal()
124 - part_sum() -> partSum()
125 * toc() in util.h now returns seconds as a double
126 * VarSet::operator&&
127 * Properties -> PropertySet
128
129
130 libDAI-0.2.1 (2008-05-26)
131 -------------------------
132
133 Bugfix release.
134 * added missing cstdio header in util.h
135 * fixed Properties in MR_CLAMPING_* and MR_EXACT_*
136 * added description of the factor graph fileformat
137 * improved Makefile
138
139
140 libDAI-0.2.0 (2006-11-30)
141 -------------------------
142
143 First public release.
144
145
146 0.1.5 (2006-11-30)
147 ------------------
148
149 Regressions
150
151 - tests/testlcbp and tests/testlcbp are broken.
152 - EXACT method does not work anymore.
153 - The Properties framework gives a speed penalty because of the lookup
154 costs involved; inner loops should be optimized.
155
156 General framework
157
158 - DAIAlg is now a template class; typedefs for DAIAlg<FactorGraph> and for
159 DAIAlg<RegionGraph> are provided. In this way, we do not have to write "wrapper"
160 functions to forward functionality from either FactorGraph or RegionGraph
161 to DAIAlg. Functionality like clamping can be implemented in FactorGraph
162 and in RegionGraph and no explicit interface is needed in descendants.
163 - New abstract base class InfAlg added, representing an inference algorithm,
164 from which DAIAlg<T> inherits. This solves the incompatibility problems of
165 DAIAlg<T> for different T (e.g. DAIAlg<FactorGraph> was incompatible with
166 DAIAlg<RegionGraph>). More work is required to reduce code duplication
167 (make FactorGraph part of InfAlg).
168 - Added generic interface (nrVars(), Vars(), nrFactors(), factor(size_t),
169 beliefs(), belief(VarSet &), ...) to InfAlg and descendants.
170 - Added a saveProbs/undoProbs interface to InfAlg and descendants that enables
171 one to save a few factors, modify them (e.g. clamp them), and then restore them
172 to their old values. Undo should also init the corresponding messages / beliefs.
173 This can be used if a given factor graph repeatedly needs to be clamped in
174 different ways and an approximation method is run for each clamping; using the
175 saveProbs/undoProbs can give a significant speed increase.
176 - Switched to a general Properties framework that handles the parameters of
177 all inference methods in a uniform manner. The Properties class is a map of
178 several properties in boost::any objects, indexed by their names (strings).
179 It can read from a stream and write to a stream. It is recursive, in the sense
180 that a Properties object can hold a variable of type Properties as well.
181 - Added a generic way of constructing inference algorithms from a factor graph,
182 name and properties object. Added the newInfAlg function which constructs
183 the requested object. This is used by LCBP, the Matlab interface and the
184 command line (test) interface.
185 - Added a generic enum framework for enum parameters. Although implemented as a
186 hack, it is quite useful in that it drastically simplifies and reduces the
187 amount of code for handling enum parameters.
188 - Provided generic functions for calculating marginals in different ways that
189 work for all approximate inference methods.
190
191 Bugfixes
192
193 - Fixed GBP free energy.
194 - Fixed bug in junctiontree (it didn't init the _vars variable).
195 - Corrected two bugs in operator&& and operator|| in VarSet (they returned
196 the logical NOT of what they should return).
197 - Fixed bug in RegionGraph::RecomputeOR(s).
198 - Fixed bug in utils/create_dreg_fg:
199 graph structure was not random for given parameters (forgot to call srand()).
200 - TreeEP bug workaround: use the complete junction tree instead of a subtree.
201 - Fixed bug in JTree::HUGIN() and JTree:ShaferShenoy() in case of junction tree
202 that consists of one outer region only.
203 - Fixed INIT bug in LCBP2::UpdatePancake().
204 - Fixed MaxDiffs flow (except for MR).
205
206 New functionality
207
208 - HAK supports several default cluster choices:
209 minimal (only factors)
210 delta (Markov blankets)
211 loop (all loops consisting of loops consisting of <loopdepth> or less variables)
212 Only the maximal clusters are used as outer clusters.
213 - Implemented TreeEP. It generalizes the heuristic method described in the
214 Minka & Qi paper for obtaining a tree with the most relevant interactions to
215 higher order interactions. Almost all optimizations described in the Minka & Qi
216 paper are used, except that evidence is passed over the whole tree instead of
217 relevant subsets (the latter is almost implemented but buggy). Also added
218 alternative (worst-case) algorithm that uses a maximum spanning tree on the
219 weighted graph where the weight between neighbours i and j is given by
220 N(psi,i,j), where psi is the product of all the factors involving both i and j
221 (which is an upper bound on the effective interaction between i and j).
222 - Implemented MR (MontanariRizzo) based on Bastian's code, but extended it
223 to be able to handle connectivities larger than 3 (in principle, up to 32).
224 It supports different initialization methods (the original RESPPROP,
225 the CLAMPING method and EXACT which uses JTree) and different update methods
226 (FULL and LINEAR).
227 - Implemented LCBP2, an analogon of LCBP which represents pancakes as little
228 networks and uses some approximate inference method on them for calculating
229 marginals.
230 - Now there are several LCBP variants (LCBP, LCBPI, LCBPJ, LCBPK, LCBPL);
231 LCBPJ works only for pairwise, LCBPK is LCBP improved for higher order
232 interactions and LCBPL is LCBPI improved for higher-order interactions.
233 - Wrote one single program utils/createfg for creating various types of
234 random factor graphs.
235 - Wrote utility to visualize factor graphs using graphviz.
236 (it uses the BOOST Program Options library)
237 - Added fginfo utility that displays some info about a .fg file.
238 - Implemented Factor::strength function that calculates the potential strength
239 N(psi,i,j) between variables i and j as described in cs.IT:0504030
240 - Wrote a general MatLab interface matlab/dai (similar to tests/test);
241 this unified the matlab functions dai, dai_bp, dai_mf, dai_jt, dai_tep, dai_cvm.
242 - Added MATLAB routine that returns contraction matrix A for BP convergence analysis.
243 - Implemented a MATLAB interface ai_potstrength for Factor::strength
244 - Added Martijn's x2x
245
246 Improvements of existing code
247
248 - Reimplemented RegionGraph and descendants: a RegionGraph ISA FactorGraph
249 and also a BipartiteGraph<FRegion,Region>. It now also keeps a map that
250 associates outer region indices to factor indices (no powers yet, this
251 is deemed superfluous) and provides functions to recompute (some of) the
252 outer regions from the factors.
253 - InfAlg descendants run() methods now stop immediately and return NAN in case
254 they detect NANs. Only BP does not do NAN checking for performance reasons.
255 - LCBP now works with factors containing zeroes (by defining x/0 = 0).
256 - HAK, GBP and DoubleLoop now conform to the standards for verbose reporting,
257 timing and convergence criteria.
258 - Implemented logZ() for JTree. It does the calculation during message-passing.
259 - Marginal2ndO now optionally divides by the single node beliefs (to the power n-2);
260 hopefully this will give more accurate approximations.
261 - Marginal and Marginal2ndO (optionally) use the new saveProbs/undoProbs functionality
262 for a faster way of calculating marginals, which does not require a call to init()
263 nor cloning the whole object for each clamping. This leads to a significant speedup.
264 - LCBP (and LCBP2) now have complete flexibility in the specification of the
265 inner method, i.e. the method used to generate the initial cavity approximations.
266 One can pass two strings, a name and a properties string, and LCBP simply invokes
267 newInfAlg to construct the corresponding inference algorithm and uses the generic
268 marginal functions to approximate cavity marginals.
269 - Replaced the global "method" variable by local properties and removed ai.h
270 - Added some methods to Factor (operators *, *=, /, /= with doubles as
271 second argument, operators -, +=, -= with other Factors as second
272 arguments, randomize(), RemoveFirstOrderInteractions) and similar
273 operations to Prob
274 - Moving towards boost::program_options for handling command line arguments
275 (tests/test is done).
276 - Renamed some FactorGraph methods:
277 nr_vars -> nrVars
278 nr_factors -> nrFactors
279 varind -> findVar
280 factorind -> findFactor
281 makeFacCavity -> makeFactorCavity
282 - LCBP_SEQMAXRES has been removed because it did strange things.
283 - Implemented RandomDRegularGraph
284 - Implemented JTree::calcMarginal for marginals that are not confined
285 within one cluster (using cut-set conditioning).
286 - Added isConnected() method to FactorGraph (some methods do not work with
287 disconnected factor graphs).
288 - Pair beliefs are now calculated in a symmetrical way by calcPairBeliefs
289 - Removed single node interaction "correction" code from clamping methods
290 - Removed calcCavityDist and calcCavityDist2ndO
291 - No longer depends on GSL.
292 - Increased portability by combining platform dependant utility functions
293 in util.{h,cpp}.
294 - Wrote *.m files providing help
295
296 Testing framework
297
298 - Made a new and significantly improved testing framework that provides most
299 functionality from the command line.
300 - The basis is provided by tests/test, which uses the newInfAlg functionality
301 and enables the user to easily compare from the command line different
302 inference methods on a given factorgraph. All parameters can be specified.
303 Output consists of CPU time, average and maximum single variable marginal
304 errors, relative logZ error and MaxDiff().
305 - tests/aliases.conf contains aliases for standard combinations of methods
306 and their options (which can be used in tests/test).
307 - tests/large contains several bash/python scripts that create random factor
308 graphs, compare several approximate inference algorithms (using tests/test) and
309 allow for easy visualization of the results using PyX.
310 - Added several .fg files for test purposes to /tests (e.g. two ALARM versions
311 alarm.fg and alarm_bnt.fg; testfast.fg, a 4x4 periodic Ising grid for
312 regression testing).
313 - Added a regression test to the Makefile which is included in the standard
314 target. It compares all inference methods on tests/testfast.fg with the
315 results stored in tests/testfast.out
316
317 Miscellaneous
318
319 - Expanded all tabs to spaces (":set tabstop 4\n:set expandtab\n:retab" in vim)
320 - Experimental MATLAB code added for StarEP approximation on cavity
321 - Renamed project to libDAI and changed directory name accordingly.
322 - Renamed JunctionTree to JTree.
323 - Fixed licensing (now it's officially GPL).
324 - Improved README
325
326
327 revision 252
328 ------------
329
330 Functionality
331 - Added RegionGraph, GBP, CVM and HAK (double-loop).
332 - Added JunctionTree (with two update algorithms, HUGIN and Shafer-Shenoy), which is a
333 RegionGraph.
334 - NormType is now chosen automatically (in case of negative factors, Prob::NORMLINF is used,
335 otherwise the default Prob::NORMPROB is used). Also, in case of negative factors, the
336 RegionGraph constructors assign each Factor to a unique outer region instead of dividing
337 it over all subsuming outer regions. See README for when negative factors are known to work
338 and when not.
339 - FactorGraph::FactorGraph(const vector<Factor>) only gives a warning in case of short loops,
340 it does not automatically merge factors anymore.
341 - Removed BP_SEQMAXRESNOCLEAR (all cavity initialization methods now are implicitly NOCLEAR)
342 - Added MATLAB interface functions ai_readfg, ai_removeshortloops and ai_bp
343 - Added LCBP-III type that should be equivalent to LCBP-II, but can handle zeroes
344 in potentials. Note that it is significantly slower than LCBP-II (and has to be reimplemented
345 such that it does not store the complete pancakes, but represents them as little factor graphs).
346
347 Implementation / code
348 - Made a seperate type WeightedGraph, which until now only implements Prim's
349 maximal spanning tree algorithm and is only used by the junction tree code. It might
350 be good to make it a class somewhere in the future and extend it's interface.
351 - Made a seperate class ClusterGraph, which is only used by the junction tree
352 code. It's main purpose is a graph-theoretical variable elimination algorithm.
353 - Implemented the heuristic "minimum-new-edges-in-clique-graph" for variable elimination.
354 - Massive code cleanup, moving towards "generic" programming style, using
355 multiple inheritance and polymorphism.
356 o BP, LCBP, MF, HAK and JunctionTree now inherit from a common DAIAlg class
357 o Made generic functions Marginal, Marginal2ndO, calcCavityDist, calcCavityDist2ndO, clamp
358 that can be used by FactorGraph-based DAIAlgs.
359 o Created TProb<T> class, which stores a probability vector (without the accompanying indexing
360 and VarSet) and provides functionality for it (which is used by TFactor<T>).
361 o Rewrote the VarSet class. It now caches its statespace(). It now privately inherits from set<Var>.
362 I had to overload the insert methods of set<Var> so that they calculate the new statespace.
363 o Rewrote the TFactor class. The TFactor class now HAS a TProb and HAS a VarSet.
364 - Rewrote BP to use the new TProb<T> interface. Performance of BP improved up to a factor 6 by:
365 o using Prob's instead of Factor's;
366 o splitting the multiplication of the messages into two parts (thanks to Vicenc!);
367 o optimizing the calculation of the beliefs (only the message calculations were optimized till now).
368 o replacing FactorGraph::_nb1 and _nb2 (which were set<size_t>) by vector<size_t>
369 - LCBP now seperately stores cavitydists and pancakes. Added InitPancakes() method
370 that takes the cavitydists and multiplies them with the relevant factors. This
371 resulted in an API change in AI which now accepts and returns initial cavitydists
372 instead of initial pancakes.
373
374 Minor changes
375 - Started writing DoxyGen documentation
376 - Renamed lcptab2fg.m matlab/ai_writefg.m
377 - Moved all matlab stuff to matlab/
378 - More detailed reporting (also reports clocks used).
379 - Marginal and Marginal2ndO now use *differences* in logZ to avoid NaNs.
380 - Improved testing suite.
381 - Removed logreal support.
382 - FactorGraph now also supports input streams and ignores comment lines in .fg files.
383 - Added tests/create_full_fg.cpp and tests/create_ising_fg.cpp which create
384 full and periodic 2D Ising networks according to some command line parameters.
385 - Now logZ really returns logZ instead of -logZ.
386 - Added FactorGraph::WriteToDotFile
387
388
389 0.1.4 (2006-04-13)
390 ------------------
391 - Added file IO routines to read and write factorgraphs.
392 - Added L-infinity normalization for use with (partially) negative factors.
393 - Renamed BetheF, MFF to logZ, which now use complex numbers to be able to
394 handle (partially) negative factors.
395 - Added test suite.
396 - All probabilities are now represented using double instead of LogReal<double>.
397 - Combined Alg and Alg3 into LCBP. Several update schemes possible.
398 - Combined several variants of BP into doBP. Several update schemes possible.
399 Now uses precalculated indices for optimization.
400 - Renamed Node -> Var and Potential -> Factor.
401 - Extensive code cleanup. More use of OO techniques. Changed API.
402 - MaxIter now means maximum number of passes (corresponding to number of
403 _parallel_ updates).
404 - MaxDiff now means the maximum L-infinity distance between the updated and
405 original single variable beliefs, for all AI methods.
406 - Implemented RBP which converges faster than BP for difficult problems.
407 - Now uses method parameter which is a bitmask combining outmethod and inmethod
408 (see ai.h).
409
410
411 0.1.3 (2006-03-22)
412 --------------------
413 - All AI methods now return maxdiff
414 - ai.cpp:
415 o Now returns maxdiffinner and maxdiffouter
416 o New BP2ndO innermethod (estimate only 2nd order cavity interactions)
417 o New InitCav outermethod (only create initial cavity distributions)
418 - bp.cpp:
419 o New CavityDist2ndO which estimates 2nd order cavity interactions
420 - Makefile:
421 o Bugfix: removed dependencies on algwim.*
422
423
424 0.1.2 (2006-02-28)
425 --------------------
426 - Cleaned up alg.cpp (removed Alg2 and its corresponding data structures).
427 - Added the possibility to provide initial cavity distributions as an input
428 argument to ai (not much error checking is done, so be careful).
429 - Potentials2mx now correctly sets the dimensions of the P field (i.e. for
430 the output arguments Q, Q0 of ai).
431 - Removed algwim.* since it does not work.
432
433
434 0.1.1 (2006-02-28)
435 --------------------
436 - The constructors of (Log)FactorGraph and LogFactorGraph from a
437 vector<(Log)Potential> now merge potentials to prevent short loops (of length
438 4) in the factor graph. These are used in ai to construct the factor graphs
439 from the psi argument. If compiled with DEBUG defined, the method calc_nb()
440 of BipGraph checks for the existence of short loops.
441 - Changed calling syntax of ai (now the actual syntax *does* correspond to its
442 description in the help).
443 - ai does not hook cout anymore (which caused weird segfaults).
444 - Fixed a bug in an assert statement in the matlab interface code in ai.cpp.
445 - Removed network.* since it is not useful.
446
447
448 0.1.0 (2006-02-28)
449 --------------------
450 First version worthy a version number.