Node Class Reference

Stores all relevant information about a node in a factor graph. More...

#include <node.h>

List of all members.

Public Member Functions

 Node (int predId, SuperPred *const &superPred, Array< int > *const &constants, Domain *const &domain)
 Constructor.
 ~Node ()
 Destructor.
int getPredId ()
int getSuperPredId ()
int getParentSuperPredId ()
SuperPredgetSuperPred ()
Array< int > * getConstants ()
int getGroundNodeCount ()
int getNumLinks ()
 Returns the number of links of (or number of factors attached to) this node.
LinkgetLink (int index)
void getMessage (int index, double msgs[])
 Gets the incoming message from a certain link.
void addAuxLink (Link *link)
 Adds an auxiliary link (factor along with all the relevant information about counts etc.
void addLink (Link *link, double inpMsgs[2])
 Adds the link (factor along with all the relevant information about counts etc.
void addFactors (Array< Factor * > *const &allFactors, LinkIdToTwoWayMessageMap *const &lidToTWMsg)
 Adds the factors with appropriate counts, also add the node to the corresponding factor.
void receiveMessage (double *inpMsgs, Link *const &link)
 Receives the message sent over a link.
double getExp ()
double * getProbs (double *const &probs)
 Gets the probabilities for this node - it is simply the product of messages coming at this node.
void sendMessage ()
 Sends the messages to all the factor nodes connected to this node.
void sendAuxMessage ()
 Sends the messages to all the auxiliary factor nodes connected to this node.
void moveToNextStep ()
 Updates the stored msgs and update the msgProduct.
ostream & print (ostream &out)


Detailed Description

Stores all relevant information about a node in a factor graph.

Definition at line 90 of file node.h.


Member Function Documentation

void Node::getMessage ( int  index,
double  msgs[] 
) [inline]

Gets the incoming message from a certain link.

Parameters:
index Index of the link
msgs msgs[0] contains the message from the node when it is false, msgs[1] contains the message from the node when it is true.

Definition at line 177 of file node.h.

00178   {
00179     msgs[0] = (*msgsArr_)[index][0];
00180     msgs[1] = (*msgsArr_)[index][1];
00181   }

void Node::addAuxLink ( Link link  )  [inline]

Adds an auxiliary link (factor along with all the relevant information about counts etc.

).

Definition at line 187 of file node.h.

References Array< Type >::append().

00188   {
00189     auxLinks_->append(link);
00190   }

void Node::addLink ( Link link,
double  inpMsgs[2] 
) [inline]

Adds the link (factor along with all the relevant information about counts etc.

).

Definition at line 196 of file node.h.

References Array< Type >::append(), and Link::getCount().

Referenced by addFactors().

00197   {
00198     links_->append(link);
00199     double *msgs;
00200     msgs = new double[2];
00201 
00202     double cnt = link->getCount(); 
00203     for (int i = 0; i < 2; i++)
00204     {
00205       if (inpMsgs)
00206       {
00207         msgs[i] = inpMsgs[i];
00208       }
00209       else
00210       {
00211         msgs[i] = 0;
00212       }
00213       msgProds_[i] = msgProds_[i] + cnt*msgs[i];
00214     }
00215 
00216     msgsArr_->append(msgs);
00217     msgs = new double[2];
00218     nextMsgsArr_->append(msgs);
00219   }


The documentation for this class was generated from the following files:
Generated on Sun Jun 7 11:55:27 2009 for Alchemy by  doxygen 1.5.1