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