49#ifndef AGRUM_GRAPHICALMODELINFERENCE_H
50#define AGRUM_GRAPHICALMODELINFERENCE_H
104 template <
typename GUM_SCALAR >
196 virtual
void clear();
199 virtual StateOfInference
state() const noexcept final;
238 virtual
void addEvidence(const
std::
string& nodeName, const
std::
string& label) final;
259 const
std::vector< GUM_SCALAR >& vals) final;
335 virtual
void chgEvidence(const
std::
string& nodeName, const
std::
string& label) final;
356 const
std::vector< GUM_SCALAR >& vals) final;
391 virtual
bool hasEvidence(const
std::
string& nodeName) const final;
GraphicalModelInference()
default constructor with a null model (useful for virtual inheritance)
const NodeSet & softEvidenceNodes() const
returns the set of nodes with soft evidence
virtual bool hasHardEvidence(NodeId id) const final
indicates whether node id has received a hard evidence
virtual void prepareInference() final
prepare the internal inference structures for the next inference
void _computeDomainSizes_()
computes the domain sizes of the random variables
virtual bool isInferenceOutdatedStructure() const noexcept final
returns whether the inference object is in a OutdatedStructure state
virtual void setState_(const StateOfInference state) final
set the state of the inference engine and call the notification onStateChanged_ when necessary (i....
virtual void onAllEvidenceErased_(bool contains_hard_evidence)=0
fired before all the evidence are erased
virtual void onStateChanged_()=0
fired when the stage is changed
virtual void onEvidenceChanged_(const NodeId id, bool hasChangedSoftHard)=0
fired after an evidence is changed, in particular when its status (soft/hard) changes
GraphicalModelInference(const GraphicalModel *model)
default constructor
virtual void chgEvidence(NodeId id, const Idx val) final
change the value of an already existing hard evidence
virtual void addListOfEvidence(const List< const Tensor< GUM_SCALAR > * > &potlist) final
adds a new list of evidence
NodeProperty< const Tensor< GUM_SCALAR > * > _evidence_
the set of evidence entered into the network
virtual const NodeProperty< Size > & domainSizes() const final
get the domain sizes of the random variables of the model
virtual void onModelChanged_(const GraphicalModel *model)=0
fired after a new Bayes net has been assigned to the engine
void setModel_(const GraphicalModel *model)
bool _isHardEvidence_(const Tensor< GUM_SCALAR > &pot, Idx &val) const
checks whether a tensor corresponds to a hard evidence or not
NodeSet _soft_evidence_nodes_
the set of nodes that received soft evidence
virtual void addEvidence(NodeId id, const Idx val) final
adds a new hard evidence on node id
virtual Size nbrSoftEvidence() const final
returns the number of soft evidence entered into the Bayesian network
virtual StateOfInference state() const noexcept final
returns the state of the inference engine
virtual void eraseAllEvidence() final
removes all the evidence entered into the network
StateOfInference _state_
the current state of the inference (outdated/ready/done)
const NodeSet & hardEvidenceNodes() const
returns the set of nodes with hard evidence
NodeProperty< Size > _domain_sizes_
the domain sizes of the random variables
const NodeProperty< const Tensor< GUM_SCALAR > * > & evidence() const
returns the set of evidence
virtual ~GraphicalModelInference()
destructor
void setModelDuringConstruction_(const GraphicalModel *model)
assigns a model during the inference engine construction
virtual bool isInferenceReady() const noexcept final
returns whether the inference object is in a ready state
virtual void makeInference() final
perform the heavy computations needed to compute the targets' posteriors
virtual Size nbrEvidence() const final
returns the number of evidence entered into the Bayesian network
virtual bool hasEvidence() const final
indicates whether some node(s) have received evidence
virtual void updateOutdatedTensors_()=0
prepares inference when the latter is in OutdatedTensors state
virtual void onEvidenceAdded_(const NodeId id, bool isHardEvidence)=0
fired after a new evidence is inserted
const NodeProperty< Idx > & hardEvidence() const
indicate for each node with hard evidence which value it took
virtual void makeInference_()=0
called when the inference has to be performed effectively
virtual void clear()
clears all the data structures allocated for the last inference
void setOutdatedTensorsState_()
puts the inference into an OutdatedTensors state if it is not already in an OutdatedStructure state
virtual void addSetOfEvidence(const Set< const Tensor< GUM_SCALAR > * > &potset) final
adds a new set of evidence
virtual Size nbrHardEvidence() const final
returns the number of hard evidence entered into the Bayesian network
virtual void updateOutdatedStructure_()=0
prepares inference when the latter is in OutdatedStructure state
virtual void eraseEvidence(NodeId id) final
removed the evidence, if any, corresponding to node id
virtual bool hasSoftEvidence(NodeId id) const final
indicates whether node id has received a soft evidence
StateOfInference
current state of the inference
Tensor< GUM_SCALAR > _createHardEvidence_(NodeId id, Idx val) const
create the internal structure for a hard evidence
virtual bool isInferenceDone() const noexcept final
returns whether the inference object is in a InferenceDone state
virtual const GraphicalModel & model() const final
Returns a constant reference over the IBayesNet referenced by this class.
NodeSet _hard_evidence_nodes_
the set of nodes that received hard evidence
virtual bool isInferenceOutdatedTensors() const noexcept final
returns whether the inference object is in a OutdatedTensor state
const GraphicalModel * _model_
the Bayes net on which we perform inferences
NodeProperty< Idx > _hard_evidence_
assign to each node with a hard evidence the index of its observed value
void setOutdatedStructureState_()
put the inference into an outdated model structure state
virtual void onEvidenceErased_(const NodeId id, bool isHardEvidence)=0
fired before an evidence is removed
Virtual base class for probabilistic graphical models.
Generic doubly linked lists.
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Implementation of the non pure virtual methods of class GraphicalModelInference.
Class representing probabilistic DAG model.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
Header of the Tensor class.