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