Direct Graphical Models  v.1.7.0
DirectGraphicalModels::CMessagePassing Class Referenceabstract

Abstract base class for message passing inference algorithmes. More...

#include <MessagePassing.h>

Inheritance diagram for DirectGraphicalModels::CMessagePassing:
Collaboration diagram for DirectGraphicalModels::CMessagePassing:

Public Member Functions

 CMessagePassing (CGraphPairwise &graph)
 Constructor. More...
 
virtual ~CMessagePassing (void)
 
virtual void infer (unsigned int nIt=1)
 Inference. More...
 
- Public Member Functions inherited from DirectGraphicalModels::CInfer
 CInfer (CGraph &graph)
 Constructor. More...
 
 CInfer (const CInfer &)=delete
 
virtual ~CInfer ()=default
 
const CInferoperator= (const CInfer &)=delete
 
vec_byte_t decode (unsigned int nIt=0, Mat &lossMatrix=EmptyMat)
 Approximate decoding. More...
 
vec_float_t getConfidence (void) const
 Returns the confidence of the perdiction. More...
 
vec_float_t getPotentials (byte state) const
 Returns the potnetials for the selected state (class) More...
 

Protected Member Functions

CGraphPairwisegetGraphPairwise (void) const
 Returns the graph. More...
 
virtual void calculateMessages (unsigned int nIt)=0
 Calculates messages, associated with the edges of corresponding graphical model. More...
 
void calculateMessage (Edge *edge, float *temp, float *&dst, bool maxSum=false)
 Calculates one message for the specified edge edge. More...
 
void createMessages (void)
 Allocates memory for Edge::msg and Edge::msg_temp containers for all edges in the graph. More...
 
void deleteMessages (void)
 Deletes memory for Edge::msg and Edge::msg_temp containers for all edges in the graph. More...
 
void swapMessages (void)
 Swaps Edge::msg and Edge::msg_temp for all edges in the graph. More...
 
- Protected Member Functions inherited from DirectGraphicalModels::CInfer
CGraphgetGraph (void) const
 Returns the reference to the graph. More...
 

Static Protected Member Functions

static float MatMul (const Mat &M, const float *v, float *&dst, bool maxSum=false)
 Specific matrix multiplication. More...
 

Detailed Description

Abstract base class for message passing inference algorithmes.

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 18 of file MessagePassing.h.

Constructor & Destructor Documentation

◆ CMessagePassing()

DirectGraphicalModels::CMessagePassing::CMessagePassing ( CGraphPairwise graph)
inline

Constructor.

Parameters
graphThe graph

Definition at line 25 of file MessagePassing.h.

◆ ~CMessagePassing()

virtual DirectGraphicalModels::CMessagePassing::~CMessagePassing ( void  )
inlinevirtual

Definition at line 26 of file MessagePassing.h.

Member Function Documentation

◆ calculateMessage()

void DirectGraphicalModels::CMessagePassing::calculateMessage ( Edge edge,
float *  temp,
float *&  dst,
bool  maxSum = false 
)
protected

Calculates one message for the specified edge edge.

PPL-safe function.

Parameters
[in]edgeGraph edge
[in]tempAuxilary array of nStates values. Introduced for higher perfomance reasons.
[out]dstDestination array for calculated message. Usually edge->msg or edge->msg_temp. If the pointer is NULL, destination container will be created as a new vector of length nStates.
[in]maxSumFlag indicating weather the message must be calculated according to the sum-product (false) or max-product (true) algorithm.

Definition at line 82 of file MessagePassing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateMessages()

virtual void DirectGraphicalModels::CMessagePassing::calculateMessages ( unsigned int  nIt)
protectedpure virtual

Calculates messages, associated with the edges of corresponding graphical model.

This function may modify Edge::msg and Edge::msg_temp containers of graph edges

Parameters
nItNumber of iterations

Implemented in DirectGraphicalModels::CInferChain, DirectGraphicalModels::CInferTree, DirectGraphicalModels::CInferTRW, and DirectGraphicalModels::CInferLBP.

Here is the caller graph for this function:

◆ createMessages()

void DirectGraphicalModels::CMessagePassing::createMessages ( void  )
protected

Allocates memory for Edge::msg and Edge::msg_temp containers for all edges in the graph.

Definition at line 113 of file MessagePassing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteMessages()

void DirectGraphicalModels::CMessagePassing::deleteMessages ( void  )
protected

Deletes memory for Edge::msg and Edge::msg_temp containers for all edges in the graph.

Definition at line 129 of file MessagePassing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGraphPairwise()

CGraphPairwise& DirectGraphicalModels::CMessagePassing::getGraphPairwise ( void  ) const
inlineprotected

Returns the graph.

Returns
The graph

Definition at line 36 of file MessagePassing.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ infer()

void DirectGraphicalModels::CMessagePassing::infer ( unsigned int  nIt = 1)
virtual

Inference.

This function estimates the marginal potentials for each graph node, and stores them as node potentials

This function modifies Node::Pot containers of graph nodes

Parameters
nItNumber of iterations
Note
This function must not to be linear, i.e. \( infer(\alpha\times N)\not\equiv\alpha\times infer(N) \)
This function substitutes the graph nodes' potentials with estimated marginal potentials

Implements DirectGraphicalModels::CInfer.

Reimplemented in DirectGraphicalModels::CInferTRW.

Definition at line 7 of file MessagePassing.cpp.

Here is the call graph for this function:

◆ MatMul()

float DirectGraphicalModels::CMessagePassing::MatMul ( const Mat &  M,
const float *  v,
float *&  dst,
bool  maxSum = false 
)
staticprotected

Specific matrix multiplication.

This function calculates the result of multiplying square of matrix M by vector v as following: \(\vec{dst} = (M\cdot M)^\top\times\vec{v}\)

Parameters
[in]MMatrix: Mat(size: M.height x M.width; type: CV_32FC1)
[in]vVector of length M.height
[out]dstResulting vector. If the pointer is NULL, destination container will be created as a new vector of length M.width.
[in]maxSumFlag indicating weather the max-sum multiplication should be performed
Returns
The sum of all elemts in vector dst

Definition at line 157 of file MessagePassing.cpp.

Here is the caller graph for this function:

◆ swapMessages()

void DirectGraphicalModels::CMessagePassing::swapMessages ( void  )
protected

Swaps Edge::msg and Edge::msg_temp for all edges in the graph.

Definition at line 147 of file MessagePassing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: