libDAI
Ideas not worth exploring

Extended factorgraphs/regiongraphs

A FactorGraph and a RegionGraph are often equipped with additional properties for nodes and edges. The code to initialize those is often quite similar. Maybe one could abstract this, e.g.:

template <typename Node1Properties, typename Node2Properties, typename EdgeProperties>
class ExtFactorGraph : public FactorGraph {
public:
std::vector<Node1Properties> node1Props;
std::vector<Node2Properties> node2Props;
std::vector<std::vector<EdgeProperties> > edgeProps;
// ...
}

Advantages:

Disadvantages:

Polymorphism by template parameterization

Instead of polymorphism by inheritance, use polymorphism by template parameterization. For example, the real reason for introducing the complicated inheritance scheme of dai::InfAlg was for functions like dai::calcMarginal. Instead, one could use a template function:

template<typename InfAlg>
Factor calcMarginal( const InfAlg &obj, const VarSet &ns, bool reInit );

This would assume that the type InfAlg supports certain methods. Ideally, one would use concepts to define different classes of inference algorithms with different capabilities, for example the ability to calculate logZ, the ability to calculate marginals, the ability to calculate bounds, the ability to calculate MAP states, etc. Then, one would use traits classes in order to be able to query the capabilities of the model. For example, one would be able to query whether the inference algorithm supports calculation of logZ. Unfortunately, this is compile-time polymorphism, whereas tests/testdai needs runtime polymorphism. Therefore this is probably a bad idea.