Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnTRWSInference.h
1 /*****************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnTRWSInference.h
9 ** AUTHOR(S): Hendra Gunadi <u4971560@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 
15 #include "drwnBase.h"
16 #include "drwnIO.h"
17 #include "drwnFactorGraph.h"
18 #include "drwnMapInference.h"
19 
20 using namespace std;
21 
22 // drwnTRWSInference -----------------------------------------------------------
26 
28 {
29  public:
30  static int CONVERGENCE_STEP;
31  static double EPSILON;
32  static double THETA_CONST;
33 
34  private:
35  int _numNodes;
36  vector<vector<int> > _next1; // Populate the sucessors in increasing direction
37  vector<vector<int> > _prev1; // Populate the predecessors in increasing direction
38  vector<vector<int> > _next2; // Populate the sucessors in decreasing direction
39  vector<vector<int> > _prev2; // Populate the predecessors in decreasing direction
40  vector<vector<const drwnTableFactor*> > _outFactor1; // Populate the index of table factor for the outgoing edges (inc)
41  vector<vector<const drwnTableFactor*> > _outFactor2; // Populate the index of table factor for the outgoing edges (dec)
42  vector<vector<drwnTableFactor*> > _tempOutFactor1; // Populate the index of temporary table factor for the outgoing edges (inc)
43  vector<vector<drwnTableFactor*> > _tempOutFactor2; // Populate the index of temporary table factor for the outgoing edges (dec)
44  vector<vector<const drwnTableFactor*> > _inFactor1; // Populate the index of table factor for the incoming edges (inc)
45  vector<vector<const drwnTableFactor*> > _inFactor2; // Populate the index of table factor for the incoming edges (dec)
46  vector<const drwnTableFactor*> _unary; // Populate the unary node
47  vector<vector<drwnTableFactor*> > _outMsg1; // Messages for sucessor(s) in increasing direction
48  vector<vector<drwnTableFactor*> > _inPrevMsg1; // Messages for predecessor(s) appear before the node in increasing direction
49  vector<vector<drwnTableFactor*> > _inMsg1; // Populate all the incoming messages in increasing direction
50  vector<vector<drwnTableFactor*> > _outMsg2; // Messages for sucessor(s) in decreasing direction
51  vector<vector<drwnTableFactor*> > _inPrevMsg2; // Messages for predecessor(s) appear before the node in decreasing direction
52  vector<vector<drwnTableFactor*> > _inMsg2; // Populate all the incoming messages in decreasing direction
53  vector<drwnTableFactor*> _calibrated; // Calibrated Unary Table Factor
54  vector<set<int> > _margin; // The set of variables to minimize over
55  vector<bool> _flag; // Populate the added unary
56  vector<vector<drwnFactorOperation*> > _incUnaryOp; // Unary factor operations (inc) mapping to be executed later
57  vector<vector<drwnFactorOperation*> > _decUnaryOp; // Unary factor operations (dec) mapping to be executed later
58  vector<vector<vector<drwnFactorOperation*> > > _incMsgOp; // Outgoing message factor operations (inc) mapping to be executed later
59  vector<vector<vector<drwnFactorOperation*> > > _decMsgOp; // Outgoing message factor operations (dec) mapping to be executed later
60  bool _initialized; // Indicate whether the object has been initialized
61 
62  public:
63  drwnTRWSInference(const drwnFactorGraph& graph);
65 
66  void clear();
67  pair<double, double> inference(drwnFullAssignment& mapAssignment);
68 
69  private:
70  void initialize();
71  void buildComputationGraph();
72 };
static int CONVERGENCE_STEP
number of steps checked in determining convergence
Definition: drwnTRWSInference.h:30
Implements the sequential tree-reweighted message passing (TRW-S) algorithm described in "Convergent ...
Definition: drwnTRWSInference.h:27
static double EPSILON
Used to define the treshold for stopping condition.
Definition: drwnTRWSInference.h:31
Container and utility functions for factor graphs.
Definition: drwnFactorGraph.h:40
std::vector< int > drwnFullAssignment
defines a complete assignment to all variables in the universe
Definition: drwnVarAssignment.h:36
Interface for various MAP inference (energy minimization) algorithms.
Definition: drwnMapInference.h:38
static double THETA_CONST
define the constant
Definition: drwnTRWSInference.h:32