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