SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GEMPLP.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2014 Jiaolong Xu
8  * Copyright (C) 2014 Jiaolong Xu
9  */
10 
11 #ifndef __GEMPLP_H__
12 #define __GEMPLP_H__
13 
14 #include <shogun/lib/config.h>
15 #include <shogun/lib/SGVector.h>
19 #include <shogun/lib/SGNDArray.h>
20 
21 #include <vector>
22 #include <set>
23 
24 namespace shogun
25 {
42 class CGEMPLP: public CMAPInferImpl
43 {
44 public:
46  struct Parameter
47  {
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
49  Parameter(const int32_t max_iter = 1000,
50  const float64_t obj_del_thr = 0.0002,
51  const float64_t int_gap_thr = 0.0002)
52  : m_max_iter(max_iter),
53  m_obj_del_thr(obj_del_thr),
54  m_int_gap_thr(int_gap_thr)
55  {}
56 #endif
57 
59  int32_t m_max_iter;
64  };
65 
66 public:
68  CGEMPLP();
69 
75  CGEMPLP(CFactorGraph* fg, Parameter param = Parameter());
76 
78  virtual ~CGEMPLP();
79 
81  virtual const char* get_name() const
82  {
83  return "GEMPLP";
84  }
85 
91  virtual float64_t inference(SGVector<int32_t> assignment);
92 
93 private:
95  void init();
96 
103  void update_messages(int32_t id_region);
104 
105 public:
112  void max_in_subdimension(SGNDArray<float64_t> tar_arr, SGVector<int32_t> &subset_inds, SGNDArray<float64_t> &max_res) const;
113 
120  int32_t find_intersection_index(SGVector<int32_t> region_A, SGVector<int32_t> region_B);
121 
131 
132 public:
138  std::vector<SGVector<int32_t> > m_all_intersections;
140  std::vector<std::set<int32_t> > m_region_intersections;
142  std::vector<std::vector<SGVector<int32_t> > > m_region_inds_intersections;
144  std::vector<SGNDArray<float64_t> > m_msgs_into_intersections;
146  std::vector<std::vector<SGNDArray<float64_t> > > m_msgs_from_region;
148  std::vector<SGNDArray<float64_t> > m_theta_region;
149 };
150 }
151 #endif
std::vector< SGVector< int32_t > > m_all_intersections
Definition: GEMPLP.h:138
float64_t m_int_gap_thr
Definition: GEMPLP.h:63
virtual ~CGEMPLP()
Definition: GEMPLP.cpp:34
std::vector< std::vector< SGNDArray< float64_t > > > m_msgs_from_region
Definition: GEMPLP.h:146
std::vector< std::vector< SGVector< int32_t > > > m_region_inds_intersections
Definition: GEMPLP.h:142
Class CMAPInferImpl abstract class of MAP inference implementation.
Definition: MAPInference.h:98
double float64_t
Definition: common.h:50
Parameter m_param
Definition: GEMPLP.h:134
virtual float64_t inference(SGVector< int32_t > assignment)
Definition: GEMPLP.cpp:190
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
void max_in_subdimension(SGNDArray< float64_t > tar_arr, SGVector< int32_t > &subset_inds, SGNDArray< float64_t > &max_res) const
Definition: GEMPLP.cpp:335
virtual const char * get_name() const
Definition: GEMPLP.h:81
SGNDArray< float64_t > convert_energy_to_potential(CFactor *factor)
Definition: GEMPLP.cpp:133
CDynamicObjectArray * m_factors
Definition: GEMPLP.h:136
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
int32_t find_intersection_index(SGVector< int32_t > region_A, SGVector< int32_t > region_B)
Definition: GEMPLP.cpp:157
Class CFactorGraph a factor graph is a structured input in general.
Definition: FactorGraph.h:27
std::vector< std::set< int32_t > > m_region_intersections
Definition: GEMPLP.h:140
float64_t m_obj_del_thr
Definition: GEMPLP.h:61
std::vector< SGNDArray< float64_t > > m_theta_region
Definition: GEMPLP.h:148
std::vector< SGNDArray< float64_t > > m_msgs_into_intersections
Definition: GEMPLP.h:144
Class CFactor A factor is defined on a clique in the factor graph. Each factor can have its own data...
Definition: Factor.h:89

SHOGUN Machine Learning Toolbox - Documentation