Generalized VarSet to "template<typename T> small_set<T>"
[libdai.git] / TODO
1 - Idea: use a PropertySet as output of a DAIAlg, instead of functions like
2 maxDiff and Iterations().
3
4 - Idea: a FactorGraph and a RegionGraph are often equipped with
5 extra properties for nodes and edges. The code to initialize those
6 is often quite similar; maybe this can be abstracted to classes
7 like ExtFactorGraph and ExtRegionGraph (Ext stands for Extended), e.g.
8 template <typename NodeProperties, typename EdgeProperties>
9 class ExtFactorGraph : public FactorGraph {
10 public:
11 std::vector<NodeProperties> nodeProps;
12 std::vector<std::vector<EdgeProperties> > edgeProps;
13 // blabla
14 }
15 A disadvantage of this approach may be worse cachability.
16 A problem is if there are nog properties for nodes (type 1), nodes (type 2)
17 or edges. Maybe this can be solved using specializations, or using variadac
18 template arguments or something similar?
19 Idea: you could define a "class Empty {}", and add some code that checks for
20 the typeid, comparing it with Empty, and doing something special in that case
21 (e.g., not allocating memory).
22 The main disadvantage of this approach seems to be that it leads to even more
23 entanglement.
24
25 - THIS SMELLS LIKE A GOOD IDEA: instead of polymorphism by inheritance,
26 use polymorphism by template parameterization. For example, the real reason
27 you introduced the complicated inheritance scheme was for functions like
28 Factor calcMarginal( const InferenceAlgorithm & obj, const VarSet & ns, bool reInit );
29 Now instead, you could use a template function:
30 template<typename InferenceAlgorithm>
31 Factor calcMarginal( const InferenceAlgorithm &obj, const VarSet &ns, bool reInit );
32 This would assume that InferenceAlgorithm supports certain methods, like
33 clone(), grm(), ......
34 Ideally, you would use concepts to define different classes of inference
35 algorithms with different capabilities, for example the ability to calculate logZ,
36 the ability to calculate marginals, the ability to calculate bounds, the ability
37 to calculate MAP states, etcetera. Then, use traits classes in order to be able to
38 query the capabilities of the model. For example, you would be able to query whether
39 the inference algorithm supports calculation of logZ.
40
41 - If you ever do a rewrite, make sure that the graphical properties are
42 not entangled with the probabilistic properties. E.g., a factor graph
43 really should be represented as a bipartite graph, with a separate array
44 of variable labels and dimensions, and a seperate array of (pointers to)
45 factor tables. In this way, each factor could be implemented differently,
46 e.g., we could have some sparse factors, some noisy-OR factors, some dense
47 factors, some arbitrary precision factors, etc. Or we could make more use
48 of templates to have a more generic factor graph. Maybe in the end,
49 HasA relations are better than IsA relations...
50 Also, the current setup is stupid: I wrote a new function that works
51 on FactorGraphs, and I had to write boiler plate code for it in graphicalmodel.h
52 and in regiongraph.h (which is stupid).
53
54 - Use Boost::uBLAS framework to deal with matrices, especially, with
55 2D sparse matrices. See http://www.boost.org/libs/numeric/ublas/doc/matrix_sparse.htm
56 and tests/errorbounds/errorbounds3
57
58 - Introduce naming scheme:
59 all Vars and VarSets should be named v_..., e.g. v_i instead of i
60 all Factors should be named f_..., e.g. f_I instead of I
61 all indices should be named _..., e.g. _k instead of k
62 all iterators should be named i_, e.g. i_i is an iterator to i
63 all const_iterators should be named ci_, e.g. ci_i is an iterator to i
64
65 - Improve weightedgraph or use Boost::Graph
66
67 - Iterations and maxDiff are only interesting for iterative inference
68 algorithms. Yet, tests/test wants to know these values in a generic
69 way. Maybe we have to think of some way (e.g. using a Properties object)
70 to return these values from run(). Then we can simply look whether a
71 InferenceAlgorithm supports these fields. What other results could
72 we return? Time. MaxDiff during initialization for LC methods.
73 Or maybe we could use some traits mechanism which we can ask whether the
74 object has _iterations and _maxdiff variables.
75
76 - Think about whether the cavity initialization belongs to init() or to run().
77
78 - Fix LCLin.
79
80 - setFactor and setFactors should only change Probs, not Factors.
81
82 - Simplify Properties framework: each Property should be a std::string.
83 Each DAIAlg should have its own _properties struct and handle conversion.
84
85 - Forwardport the Bart patch
86
87 - Another design question that needs to be answered: should a BP object own a
88 FactorGraph, or only store a reference to a FactorGraph (which can optimize
89 memory), or should it be a FactorGraph with additional variables and functions?
90 Probably, the first or second option would be the best. Since FactorGraphs are
91 assumed to be rather static, it would make sense to store *references* to
92 FactorGraphs inside AIAlgs. Or maybe some smart_ptr? It would make sense to
93 prevent unnecessary copying of FactorGraphs. Also, general marginalization
94 functions now copy a complete object. Instead, it would make more sense that
95 they construct a new object without copying the FactorGraph. Or they can be made
96 simply methods of the general InfAlg class.
97
98 - Add comments in example.cpp, add documentation.
99
100 - Write documentation.
101
102 - Improve error handling.
103
104
105 DIFFICULT
106
107 - Bug: TreeEP sometimes returns NANs.
108
109 - Bug: TreeEP::logZ() seems to be wrong (?).
110
111 - Kees' trick for preventing NANs in GBP updates: if quantity smaller than epsilon, replace by epsilon.
112
113
114 OPTIONAL
115
116 - Use Expat XML parser for IO and define a XML based fileformat for .fg files?
117
118 - Port to GNU autotool chain?
119
120 - Another design question that needs to be answered: should a BP object own a
121 FactorGraph, or only store a reference to a FactorGraph (which can optimize
122 memory), or should it be a FactorGraph with additional variables and functions?
123 Probably, the first or second option would be the best. Since FactorGraphs are
124 assumed to be rather static, it would make sense to store *references* to
125 FactorGraphs inside AIAlgs. Or maybe some smart_ptr? It would make sense to
126 prevent unnecessary copying of FactorGraphs. Also, general marginalization
127 functions now copy a complete object. Instead, it would make more sense that
128 they construct a new object without copying the FactorGraph. Or they can be made
129 simply methods of the general InfAlg class.
130
131 - Forwardport the Bart/Max patch.
132
133 - Alternative implementation of undo factor changes: the only things that have to be
134 undone are setting a factor to all ones and setting a factor to a Kronecker delta. This
135 could also be implemented in the factor itself, which could maintain its state
136 (one/delta/full) and act accordingly.
137
138 - Think about the _fac2ind variable: a better implementation of this feature is
139 probably possible.
140
141 - Changed() methods?
142
143 - Optimize GBP with precalculated indices.
144
145 - Optimize all indices as follows: keep a cache of all indices that have been
146 computed (use a hash). Then, instead of computing on the fly, use the precomputed
147 ones.
148
149 - Variable elimination should be implemented generically using a function
150 object that tells you which variable to delete.
151
152 - Improve general support for graphs and trees.
153
154 - Add support for sparse potentials.
155
156 - Optimize BP_SEQMAX (it should use a better data structure than a vector for the residuals).