Direct Graphical Models  v.1.5.3
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 (CGraph *pGraph)
 Constructor. More...
 
virtual ~CMessagePassing (void)
 
virtual void infer (unsigned int nIt=1)
 Inference. More...
 
- Public Member Functions inherited from DirectGraphicalModels::CInfer
 CInfer (CGraph *pGraph)
 Constructor. More...
 
virtual ~CInfer (void)
 
virtual vec_byte_t decode (unsigned int nIt=0, Mat &lossMatrix=Mat())
 Approximate decoding. More...
 
vec_float_t getConfidence (void) const
 Returns the confidence of the prediction. More...
 
vec_float_t getPotentials (byte state) const
 Returns the potnetials for the selected state (class) More...
 

Protected Member Functions

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::CDecode
 CDecode (CGraph *pGraph)
 Constructor. More...
 
void setState (vec_byte_t &state, qword configuration) const
 Sets the state according to the configuration index configuration. More...
 
void incState (vec_byte_t &state) const
 Increases the state by one, i.e. switches the state array to the consequent configuration. More...
 
vec_float_t calculatePotentials (void) const
 Calculates potentials for all possible configurations. More...
 
virtual ~CDecode (void)
 
virtual vec_byte_t decode (unsigned int nIt=0, Mat &lossMatrix=Mat()) const
 Approximate decoding. More...
 

Static Protected Member Functions

static float MatMul (const Mat &M, const float *v, float *&dst, bool maxSum=false)
 Specific matrix multiplication. More...
 
- Static Protected Member Functions inherited from DirectGraphicalModels::CDecode
static vec_byte_t decode (const CGraph *pGraph, Mat &lossMatrix=Mat())
 Approximate decoding. More...
 
static Mat getDefaultLossMatrix (byte nStates)
 Returns a default loss matrix \(L\). More...
 

Additional Inherited Members

- Protected Attributes inherited from DirectGraphicalModels::CDecode
CGraphm_pGraph
 Pointer to the graph. 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 17 of file MessagePassing.h.

Constructor & Destructor Documentation

◆ CMessagePassing()

DirectGraphicalModels::CMessagePassing::CMessagePassing ( CGraph pGraph)
inline

Constructor.

Parameters
pGraphThe graph

Definition at line 24 of file MessagePassing.h.

◆ ~CMessagePassing()

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

Definition at line 25 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 84 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 115 of file MessagePassing.cpp.

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 131 of file MessagePassing.cpp.

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 159 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 149 of file MessagePassing.cpp.

Here is the caller graph for this function:

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