This PR aims to rewrite and fix the whole class hierarchy used for the Factors.
The class structure in version up to 0.1.7 contains one fundamental flaw: the operations are not implemented in a seamless way across all factors. We have multiple factors that implements the same methods but from different interfaces. In Java this translates to the impossibility to use the same algorithm but with similar factors. The new hierarchy aims to fix this issue.
Another big change is that now all factors are Interface. Algorithms works with interfaces and not with the implementation. This allows us to have multiple implementations (i.e. BayesianDefaultFactor and BayesianLogFactor) for the same factor type (i.e. BayesianFactor). All implementations respond to the correct behavior and allows more flexibility for further implementation. As an example, we can now easily have BayesianSparseFactor (where the data storage is a sparse-matrix) and BayesianFunctionFactor(where there is no data and the probabilities are returned by a given function.).
More work on this direction soon.
Finally, all factors are now immutable. No more setData() on a factor after its instantiation. To allow more flexibility in the creation of the factors, several Factory utility classes has been added. These classes works like a "StringBuilder" for the new factors.
Summing up the major changes are the following:
New class hierarchy: all factors are now interfaces.
For each factor we can have multiple implementations.
Factors are immutable now: the creation of a new factor is delegated to the constructor or to a dedicated Factory class.
SymbolicFactors can now be used to keep track of operations done by algorithms.
This PR aims to rewrite and fix the whole class hierarchy used for the
Factors
.The class structure in version up to
0.1.7
contains one fundamental flaw: the operations are not implemented in a seamless way across all factors. We have multiple factors that implements the same methods but from different interfaces. In Java this translates to the impossibility to use the same algorithm but with similar factors. The new hierarchy aims to fix this issue.Another big change is that now all factors are
Interface
. Algorithms works with interfaces and not with the implementation. This allows us to have multiple implementations (i.e.BayesianDefaultFactor
andBayesianLogFactor
) for the same factor type (i.e.BayesianFactor
). All implementations respond to the correct behavior and allows more flexibility for further implementation. As an example, we can now easily haveBayesianSparseFactor
(where the data storage is a sparse-matrix) andBayesianFunctionFactor
(where there is no data and the probabilities are returned by a given function.). More work on this direction soon.Finally, all factors are now immutable. No more
setData()
on a factor after its instantiation. To allow more flexibility in the creation of the factors, severalFactory
utility classes has been added. These classes works like a "StringBuilder
" for the new factors.Summing up the major changes are the following:
factor
we can have multiple implementations.Factor
s are immutable now: the creation of a new factor is delegated to theconstructor
or to a dedicatedFactory
class.SymbolicFactor
s can now be used to keep track of operations done by algorithms.