Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnADLPInference.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 // drwnADLPInference -----------------------------------------------------------
26 
28 {
29  public:
30  static int MAX_ITERATIONS;
31  static double EPSILON;
32  static double PENALTY_PARAMETER;
33 
34  private:
35  int _numNodes; // Total number of variables involved
36  int _cliqueSize; // Total number of clique with more than 1 variables involved
37  vector<const drwnTableFactor* > _unary; // Populate the unary variables
38  vector<drwnTableFactor* > _unary_bar; // Temporary tables used to store immediate result (especially in update delta)
39  vector<const drwnTableFactor* > _clique; // Populate the cliques
40  vector<drwnTableFactor* > _clique_bar; // Temporary tables used to store immediate result (especially in update lambda)
41  vector<vector<drwnTableFactor* > > _message_unary; // Populate the tables to store messages from unary variables to clique(s) -> delta
42  vector<vector<drwnTableFactor* > > _message_unary_bar; // Populate the tables to store calibrated messages from unary variables to clique(s) -> delta bar
43  vector<vector<drwnTableFactor* > > _message_clique; // Populate the messages received by each clique (the same entries as the message_unary)
44  vector<vector<drwnTableFactor* > > _message_clique_bar; // Populate the calibrated messages received by each clique (the same entries as the message_unary_bar)
45  vector<vector<drwnTableFactor* > > _gamma; // Populate the dual parameter gamma for each message from unary
46  vector<vector<drwnTableFactor* > > _gamma_clique; // Populate the dual parameter gamma sent for each clique
47  vector<drwnTableFactor* > _mu; // Populate the dual parameter mu for each clique
48  vector<drwnTableFactor* > _tempMu; // Temporary tables used to store immediate result (especially in update mu)
49  vector<drwnTableFactor* > _lambda; // Populate the parameter lambda for each clique
50  vector<vector<set<int> > > _marginalizer; // Sets of variables used to marginalize (used in update delta bar)
51  vector<vector<drwnTableFactor*> > _margin_result_lambda; // Temporary table to store marginalized lambda (in updating delta bar operation)
52  vector<vector<drwnTableFactor*> > _margin_result_mu; // Temporary table to store marginalized mu (in updating delta bar operation)
53  vector<bool> _flag; // Populate the added unary
54  vector<vector<drwnFactorOperation*> > _updateLambdaOp; // Pre-computed computation graph required for updating lambda
55  vector<vector<vector<drwnFactorOperation*> > > _updateDeltaBarOp; // Pre-computed computation graph required for updating delta bar
56  vector<vector<drwnFactorOperation*> > _updateMuOp; // Pre-computed computation graph required for updating mu
57  vector<vector<drwnFactorOperation*> > _decodeOp; // Pre-computed computation graph required for decoding assignment
58 
59  public:
60  drwnADLPInference(const drwnFactorGraph& graph);
62 
63  void clear();
64  pair<double, double> inference(drwnFullAssignment& mapAssignment);
65 
66  private:
67  double TRIM(drwnTableFactor* v, double z); // Internal functions to implement the TRIM function described in the paper
68  void buildComputationGraph(); // Construct pre-computed computation graphs
69 };
static int MAX_ITERATIONS
maximum number of iterations
Definition: drwnADLPInference.h:30
Implements the alternating direction method algorithm described in "An Alternating Direction Method f...
Definition: drwnADLPInference.h:27
Container and utility functions for factor graphs.
Definition: drwnFactorGraph.h:40
Factor which stores the value of each assignment explicitly in table form.
Definition: drwnTableFactor.h:144
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 EPSILON
Used to define the treshold for stopping condition.
Definition: drwnADLPInference.h:31
static double PENALTY_PARAMETER
Used to define initial Rho.
Definition: drwnADLPInference.h:32