49#ifndef __CN_LOOPY_PROPAGATION__H__
50#define __CN_LOOPY_PROPAGATION__H__
58#define INF_ std::numeric_limits< GUM_SCALAR >::infinity()
72 template <
typename GUM_SCALAR >
75 using msg = std::vector< Tensor< GUM_SCALAR >* >;
187 const NodeId demanding_parent);
210 GUM_SCALAR& msg_l_max,
211 std::vector< GUM_SCALAR >& lx,
215 GUM_SCALAR& den_max);
234 void compute_ext_(std::vector< std::vector< GUM_SCALAR > >& combi_msg_p,
236 GUM_SCALAR& msg_l_min,
237 GUM_SCALAR& msg_l_max,
238 std::vector< GUM_SCALAR >& lx,
257 void enum_combi_(std::vector< std::vector< std::vector< GUM_SCALAR > > >& msgs_p,
259 GUM_SCALAR& msg_l_min,
260 GUM_SCALAR& msg_l_max,
261 std::vector< GUM_SCALAR >& lx,
285 void enum_combi_(std::vector< std::vector< std::vector< GUM_SCALAR > > >& msgs_p,
287 GUM_SCALAR& msg_p_min,
288 GUM_SCALAR& msg_p_max);
301 void compute_ext_(std::vector< std::vector< GUM_SCALAR > >& combi_msg_p,
303 GUM_SCALAR& msg_p_min,
304 GUM_SCALAR& msg_p_max);
400#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
401 extern template class CNLoopyPropagation< double >;
The base class for all directed edges.
Class representing the minimal interface for Bayesian network with no numerical data.
NodeProperty< GUM_SCALAR > NodesL_min_
"Lower" node information obtained by combinaison of children messages.
NodeProperty< GUM_SCALAR > NodesP_min_
"Lower" node information obtained by combinaison of parent's messages.
NodeProperty< GUM_SCALAR > NodesL_max_
"Upper" node information obtained by combinaison of children messages.
void msgL_(const NodeId X, const NodeId demanding_parent)
Sends a message to one's parent, i.e.
NodeProperty< NodeSet * > msg_l_sent_
Used to keep track of one's messages sent to it's parents.
InferenceType _inferenceType_
The choosen inference type.
void compute_ext_(GUM_SCALAR &msg_l_min, GUM_SCALAR &msg_l_max, std::vector< GUM_SCALAR > &lx, GUM_SCALAR &num_min, GUM_SCALAR &num_max, GUM_SCALAR &den_min, GUM_SCALAR &den_max)
Used by msgL_.
NodeProperty< bool > update_p_
Used to keep track of which node needs to update it's information coming from it's parents.
void refreshLMsPIs_(bool refreshIndic=false)
Get the last messages from one's parents and children.
NodeProperty< bool > update_l_
Used to keep track of which node needs to update it's information coming from it's children.
void makeInferenceNodeToNeighbours_()
Starts the inference with this inference type.
InferenceEngine< GUM_SCALAR > _infE_
To easily access InferenceEngine< GUM_SCALAR > methods.
void initialize_()
Topological forward propagation to initialize old marginals & messages.
std::vector< Tensor< GUM_SCALAR > * > msg
GUM_SCALAR calculateEpsilon_()
Compute epsilon.
void makeInferenceByRandomOrder_()
Starts the inference with this inference type.
const IBayesNet< GUM_SCALAR > * _bnet_
A pointer to it's IBayesNet used as a DAG.
ArcProperty< GUM_SCALAR > ArcsP_min_
"Lower" information coming from one's parent.
virtual ~CNLoopyPropagation()
Destructor.
InferenceType
Inference type to be used by the algorithm.
@ nodeToNeighbours
Uses a node-set so we don't iterate on nodes that can't send a new message.
@ randomOrder
Chooses a random arc ordering and sends messages accordingly.
@ ordered
Chooses an arc ordering and sends messages accordingly at all steps.
void msgP_(const NodeId X, const NodeId demanding_child)
Sends a message to one's child, i.e.
ArcProperty< GUM_SCALAR > ArcsL_max_
"Upper" information coming from one's children.
bool InferenceUpToDate_
TRUE if inference has already been performed, FALSE otherwise.
void updateMarginals_()
Compute marginals from up-to-date messages.
const CredalNet< GUM_SCALAR > * _cn_
A pointer to the CredalNet to be used.
void computeExpectations_()
Since the network is binary, expectations can be computed from the final marginals which give us the ...
NodeProperty< GUM_SCALAR > NodesP_max_
"Upper" node information obtained by combinaison of parent's messages.
void enum_combi_(std::vector< std::vector< std::vector< GUM_SCALAR > > > &msgs_p, const NodeId &id, GUM_SCALAR &msg_l_min, GUM_SCALAR &msg_l_max, std::vector< GUM_SCALAR > &lx, const Idx &pos)
Used by msgL_.
void makeInference()
Starts the inference.
InferenceType inferenceType()
Get the inference type.
void saveInference(const std::string &path)
void makeInferenceByOrderedArcs_()
Starts the inference with this inference type.
void eraseAllEvidence()
Erase all inference related data to perform another one.
void updateIndicatrices_()
Only update indicatrices variables at the end of computations ( calls msgP_ ).
virtual void insertEvidenceFile(const std::string &path)
Insert evidence from file.
NodeSet active_nodes_set
The current node-set to iterate through at this current step.
NodeSet next_active_nodes_set
The next node-set, i.e.
CNLoopyPropagation(const CredalNet< GUM_SCALAR > &credalNet)
Constructor.
ArcProperty< GUM_SCALAR > ArcsL_min_
"Lower" information coming from one's children.
ArcProperty< GUM_SCALAR > ArcsP_max_
"Upper" information coming from one's parent.
Class template representing a Credal Network.
virtual void insertEvidenceFile(const std::string &path)
Insert evidence from file.
InferenceEngine(const CredalNet< GUM_SCALAR > &credalNet)
Construtor.
const CredalNet< GUM_SCALAR > & credalNet() const
Get this creadal network.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
HashTable< Arc, VAL > ArcProperty
Property on graph elements.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Abstract class representing CredalNet inference engines.
gum is the global namespace for all aGrUM entities