[aGrUM] add a new notification _onStateChange

parent 0d12d14b
......@@ -35,13 +35,13 @@ namespace gum {
* @ingroup bn_inference
*
*/
template <typename GUM_SCALAR>
class LoopyBeliefPropagation : public ApproximateInference<GUM_SCALAR> {
template < typename GUM_SCALAR >
class LoopyBeliefPropagation : public ApproximateInference< GUM_SCALAR > {
public:
/**
* Default constructor
*/
LoopyBeliefPropagation( const IBayesNet<GUM_SCALAR>* bn );
LoopyBeliefPropagation(const IBayesNet< GUM_SCALAR >* bn);
/**
* Destructor.
......@@ -49,23 +49,25 @@ namespace gum {
virtual ~LoopyBeliefPropagation();
protected:
virtual void _onEvidenceAdded( const NodeId id, bool isHardEvidence ){};
virtual void _onStateChanged(){};
virtual void _onEvidenceErased( const NodeId id, bool isHardEvidence ){};
virtual void _onEvidenceAdded(const NodeId id, bool isHardEvidence){};
virtual void _onAllEvidenceErased( bool contains_hard_evidence ){};
virtual void _onEvidenceErased(const NodeId id, bool isHardEvidence){};
virtual void _onEvidenceChanged( const NodeId id, bool hasChangedSoftHard ){};
virtual void _onAllEvidenceErased(bool contains_hard_evidence){};
virtual void _onBayesNetChanged( const IBayesNet<GUM_SCALAR>* bn ){};
virtual void _onEvidenceChanged(const NodeId id, bool hasChangedSoftHard){};
virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR >* bn){};
virtual void _updateOutdatedBNStructure();
virtual void _updateOutdatedBNPotentials(){};
virtual void _onMarginalTargetAdded( const NodeId id ){};
virtual void _onMarginalTargetAdded(const NodeId id){};
virtual void _onMarginalTargetErased( const NodeId id ){};
virtual void _onMarginalTargetErased(const NodeId id){};
virtual void _onAllMarginalTargetsAdded(){};
......@@ -73,25 +75,25 @@ namespace gum {
/// asks derived classes for the posterior of a given variable
/** @param id The variable's id. */
virtual const Potential<GUM_SCALAR>& _posterior( const NodeId id );
virtual const Potential< GUM_SCALAR >& _posterior(const NodeId id);
virtual void _makeInference();
// will be used in both directions :
// for x->y, (x,y) and (y,x) will be in __messages
ArcProperty<Potential<GUM_SCALAR>> __messages;
NodeProperty<Potential<GUM_SCALAR>> __posteriors;
ArcProperty< Potential< GUM_SCALAR > > __messages;
NodeProperty< Potential< GUM_SCALAR > > __posteriors;
void __initStats();
void __init_messages();
Potential<GUM_SCALAR> __computeProdPi( NodeId X );
Potential<GUM_SCALAR> __computeProdPi( NodeId X, NodeId except );
Potential<GUM_SCALAR> __computeProdLambda( NodeId node );
Potential<GUM_SCALAR> __computeProdLambda( NodeId X, NodeId except );
void __init_messages();
Potential< GUM_SCALAR > __computeProdPi(NodeId X);
Potential< GUM_SCALAR > __computeProdPi(NodeId X, NodeId except);
Potential< GUM_SCALAR > __computeProdLambda(NodeId node);
Potential< GUM_SCALAR > __computeProdLambda(NodeId X, NodeId except);
// return the max differential KL for this node
GUM_SCALAR __updateNodeMessage( NodeId X );
GUM_SCALAR __updateNodeMessage(NodeId X);
};
// extern template class LoopyBeliefPropagation<float>;
......
......@@ -95,8 +95,7 @@ namespace gum {
// we already are in target mode. So no this->_setTargetedMode(); is needed
_onAllJointTargetsErased();
__joint_targets.clear();
this->__state =
BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure;
this->__setState(BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure);
}
}
......@@ -147,8 +146,7 @@ namespace gum {
this->_setTargetedMode(); // does nothing if already in targeted mode
__joint_targets.insert( joint_target );
_onJointTargetAdded( joint_target );
this->__state =
BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure;
this->__setState(BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure);
}
......@@ -177,8 +175,7 @@ namespace gum {
// so, no this->_setTargetedMode(); is necessary
_onJointTargetErased( joint_target );
__joint_targets.erase( joint_target );
this->__state =
BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure;
this->__setState(BayesNetInference<GUM_SCALAR>::StateOfInference::OutdatedBNStructure);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment