FactorGraph Class Reference

Class for a factor graph. More...

#include <factorgraph.h>

List of all members.

Public Member Functions

 FactorGraph (bool lifted, MLN *mln, Domain *domain, Array< Array< Predicate * > * > *queryFormulas=NULL)
 Constructor.
 ~FactorGraph ()
 Destructor.
void init ()
 Builds the factor graph.
void printNetwork (ostream &out)
 Prints out the network.
LinkIdToTwoWayMessageMap * getLinkIdToTwoWayMessageMap ()
 Returns the link to message map.
const int getNumNodes ()
 Returns the number of nodes in the graph.
const int getNumFactors ()
 Returns the number of factors in the graph.
const int getNumAuxFactors ()
 Returns the number of auxiliary factors in the graph.
NodegetNode (const int &index)
 Returns a node in the graph.
FactorgetFactor (const int &index)
 Returns a factor in the graph.
AuxFactorgetAuxFactor (const int &index)
 Returns an auxiliary factor in the graph.
DomaingetDomain ()
 Returns the domain on which the factor graph is built.


Detailed Description

Class for a factor graph.

It consists of an array of nodes and an array of factors. The graph can be lifted or not, depending on if the lifted_ flag is set or not. An optional array of auxiliary factors holds factors which are attached to some nodes, but which do not send messages. These are used to compute probabilities of query formulas (after inference is run, the messages from the nodes attached to the auxiliary factors are to be sent. Marginal probabilities are read directly from the nodes after inference is run.

Definition at line 87 of file factorgraph.h.


Constructor & Destructor Documentation

FactorGraph::FactorGraph ( bool  lifted,
MLN mln,
Domain domain,
Array< Array< Predicate * > * > *  queryFormulas = NULL 
) [inline]

Constructor.

Data structures are initialized.

Definition at line 94 of file factorgraph.h.

References Array< Type >::append().

00096   {
00097     lifted_ = lifted;
00098     
00099     lidToTWMsg_ = new LinkIdToTwoWayMessageMap();
00100     superClausesArr_ = new Array<Array<SuperClause*>*>();
00101     factors_ = new Array<Factor*>();
00102     nodes_ = new Array<Node*>();
00103     mln_ = mln;
00104     domain_ = domain;
00105     
00106     auxFactors_ = NULL;
00107     if (queryFormulas)
00108     {
00109       auxFactors_ = new Array<AuxFactor*>();
00110       for (int i = 0; i < queryFormulas->size(); i++)
00111         auxFactors_->append(new AuxFactor((*queryFormulas)[i]));
00112     }
00113   }

FactorGraph::~FactorGraph (  )  [inline]

Destructor.

Data structures are destroyed.

Definition at line 118 of file factorgraph.h.

00119   {
00120     delete lidToTWMsg_;
00121     delete superClausesArr_;
00122     delete factors_;
00123     delete nodes_;
00124     if (auxFactors_) delete auxFactors_;
00125   }


Member Function Documentation

void FactorGraph::init (  )  [inline]

Builds the factor graph.

If lifted_ is true, then the graph will be in a lifted representation.

Definition at line 131 of file factorgraph.h.

References Timer::printTime(), Timer::reset(), and Timer::time().

Referenced by BP::init().

00132   {
00133     Timer timer1;
00134     cout << "Building ";
00135     if (lifted_) cout << "Lifted ";
00136     cout << "Factor Graph..." << endl;
00137 
00138     if (lifted_)
00139     {
00140       createSuper();
00141       createSuperNetwork();
00142     }
00143     else
00144     {
00145       createGround();
00146       createGroundNetwork();
00147     }
00148     
00149     if (fgdebug)
00150     {
00151       cout << "[init] ";
00152       Timer::printTime(cout, timer1.time());
00153       cout << endl;
00154       timer1.reset();
00155     }
00156   }

Node* FactorGraph::getNode ( const int &  index  )  [inline]

Returns a node in the graph.

Parameters:
index Index of the node to be retrieved.

Definition at line 217 of file factorgraph.h.

Referenced by BP::getProbability(), BP::infer(), and BP::printProbabilities().

00218   {
00219     return (*nodes_)[index];
00220   }

Factor* FactorGraph::getFactor ( const int &  index  )  [inline]

Returns a factor in the graph.

Parameters:
index Index of the factor to be retrieved.

Definition at line 227 of file factorgraph.h.

Referenced by BP::infer().

00228   {
00229     return (*factors_)[index];
00230   }

AuxFactor* FactorGraph::getAuxFactor ( const int &  index  )  [inline]

Returns an auxiliary factor in the graph.

Parameters:
index Index of the auxiliary factor to be retrieved.

Definition at line 237 of file factorgraph.h.

Referenced by BP::infer().

00238   {
00239     return (*auxFactors_)[index];
00240   }


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