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