SHOGUN  4.1.0
GEMPLP.h
浏览该文件的文档.
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 using namespace std;
25 
26 namespace shogun
27 {
44 class CGEMPLP: public CMAPInferImpl
45 {
46 public:
48  struct Parameter
49  {
50  Parameter(const int32_t max_iter = 1000,
51  const float64_t obj_del_thr = 0.0002,
52  const float64_t int_gap_thr = 0.0002)
53  : m_max_iter(max_iter),
54  m_obj_del_thr(obj_del_thr),
55  m_int_gap_thr(int_gap_thr)
56  {}
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 
130  SGNDArray<float64_t> convert_energy_to_potential(CFactor* factor);
131 
132 public:
138  vector<SGVector<int32_t> > m_all_intersections;
140  vector<set<int32_t> > m_region_intersections;
142  vector<vector<SGVector<int32_t> > > m_region_inds_intersections;
144  vector<SGNDArray<float64_t> > m_msgs_into_intersections;
146  vector<vector<SGNDArray<float64_t> > > m_msgs_from_region;
148  vector<SGNDArray<float64_t> > m_theta_region;
149 };
150 }
151 #endif
float64_t m_int_gap_thr
Definition: GEMPLP.h:63
Class CMAPInferImpl abstract class of MAP inference implementation.
Definition: MAPInference.h:98
vector< SGVector< int32_t > > m_all_intersections
Definition: GEMPLP.h:138
double float64_t
Definition: common.h:50
Parameter m_param
Definition: GEMPLP.h:134
vector< SGNDArray< float64_t > > m_theta_region
Definition: GEMPLP.h:148
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
vector< vector< SGNDArray< float64_t > > > m_msgs_from_region
Definition: GEMPLP.h:146
virtual const char * get_name() const
Definition: GEMPLP.h:81
CDynamicObjectArray * m_factors
Definition: GEMPLP.h:136
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
Class CFactorGraph a factor graph is a structured input in general.
Definition: FactorGraph.h:27
Parameter(const int32_t max_iter=1000, const float64_t obj_del_thr=0.0002, const float64_t int_gap_thr=0.0002)
Definition: GEMPLP.h:50
float64_t m_obj_del_thr
Definition: GEMPLP.h:61
vector< set< int32_t > > m_region_intersections
Definition: GEMPLP.h:140
vector< vector< SGVector< int32_t > > > m_region_inds_intersections
Definition: GEMPLP.h:142
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 机器学习工具包 - 项目文档