49#ifndef GUM_CN_LOOPY_PROPAGATION_H
50#define GUM_CN_LOOPY_PROPAGATION_H
60#define INF_ std::numeric_limits< GUM_SCALAR >::infinity()
74 template < GUM_Numeric GUM_SCALAR >
77 using msg = std::vector< Tensor< GUM_SCALAR >* >;
191 const NodeId demanding_parent);
214 GUM_SCALAR& msg_l_max,
215 std::vector< GUM_SCALAR >& lx,
219 GUM_SCALAR& den_max);
238 void compute_ext_(std::vector< std::vector< GUM_SCALAR > >& combi_msg_p,
240 GUM_SCALAR& msg_l_min,
241 GUM_SCALAR& msg_l_max,
242 std::vector< GUM_SCALAR >& lx,
261 void enum_combi_(std::vector< std::vector< std::vector< GUM_SCALAR > > >& msgs_p,
263 GUM_SCALAR& msg_l_min,
264 GUM_SCALAR& msg_l_max,
265 std::vector< GUM_SCALAR >& lx,
289 void enum_combi_(std::vector< std::vector< std::vector< GUM_SCALAR > > >& msgs_p,
291 GUM_SCALAR& msg_p_min,
292 GUM_SCALAR& msg_p_max);
305 void compute_ext_(std::vector< std::vector< GUM_SCALAR > >& combi_msg_p,
307 GUM_SCALAR& msg_p_min,
308 GUM_SCALAR& msg_p_max);
399#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
The base class for all directed edges.
Class representing the minimal interface for Bayesian network with no numerical data.
<agrum/CN/CNLoopyPropagation.h>
void insertEvidenceFile(std::string_view path) override
Starts the inference.
void makeInference() override
Starts the inference.
NodeProperty< GUM_SCALAR > NodesL_min_
"Lower" node information obtained by combinaison of children messages.
void eraseAllEvidence() override
Erase all inference related data to perform another one.
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 chosen 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
~CNLoopyPropagation() override
Destructor.
GUM_SCALAR calculateEpsilon_()
Compute epsilon.
void saveInference(std::string_view path)
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.
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.
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_.
InferenceType inferenceType()
Get the inference type.
const class gum::Arc * cArcP
void makeInferenceByOrderedArcs_()
Starts the inference with this inference type.
NodeSet active_nodes_set_
The current node-set to iterate through at this current step.
void updateIndicatrices_()
Only update indicatrices variables at the end of computations ( calls msgP_ ).
NodeSet next_active_nodes_set_
The next node-set, i.e.
CNLoopyPropagation(const CredalNet< GUM_SCALAR > &credalNet)
Constructor.
bool inference_up_to_date_
TRUE if inference has already been performed, FALSE otherwise.
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.
InferenceEngine(const CredalNet< GUM_SCALAR > &credalNet)
Construtor.
const CredalNet< GUM_SCALAR > & credalNet() const
Get this credal 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