Closed cbonesana closed 3 years ago
I have just updated the code in the examples folder for working with the new version. I have also made a tiny change at CredalApproxLP leading to a null pointer exception when running examples/PGMpaper2.java.
In general, I am ok with the changes.
Updated also the other code files in the examples folder and docs subfolder.
Examples under examples/docs
are linked to the sphinx documentation by specifying the lines. If lines are added or removed, this will not be coherent with the docs. Just fixed.
I know and I checked that, twice. I don't know why there were missing line.
New hierarchy for Inference
There is now a unique
Inference
interface. This is the main interface to implement for all the inference algorithm and offers two main methods:query(model, evidence, query)
query(model, int query)
By default, the second method call the first with an empty
TIntIntHashMap
.In the case an algorithm support the inference over multiple variables, to produce a join probability, there is the
InferenceJoined
interface. This interface offers the same methods but whit an array as queries.These two classes are intended for stateless algorithm: the input model is manipulated and the inference done without keeping an internal cache of the inference used or the model used.
In case one wants this stateful behavior, there are the cascade interfaces:
InferenceCascade
andInferenceCascadeJoined
are the same asInference
andInferenceJoined
but they expect that the inference engine implement a way to keep the state of the model, so that it is possible to run multiple queries without pre-process again the model. This work is delegated to the developer.New hierarchy for Preprocessing
Classes in the preprocess package have been refactored and a new hierarchy of interface has been added. In this ways it is much more clear for the developer to understand which method is available for each pre-processing algorithm available.
Preprocessor*
interfaces are used to perform an inplace modifications to the model: they WILL change the input model the algorithm is working on.Converter*
classes, instead, will generate a NEW model without change the original model (i.e. they do a copy before apply the algorithm). Finally,Transformer*
interfaces are justConverter*
where the types of input and output models are the same.Currently we have three specification for these interfaces:
*Model
: need to know only the model to apply the algorithm;*Evidence
: need to know the model and the evidence to apply the algorithm;*Query
: need to know the model, the evidence, and the query to apply the algorithm.New Model
We have a new
MixedModel
: this model has the ability to mix different types ofFactors
and to return aFactor
converted in a specific class, if possible. This model is used in particular by theBinarizeEvidenze
, that will always add a newBayesianFactor
node to the given model.New test suite
We are using
JUnit 5
now.