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 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51  Parameter(const int32_t max_iter = 1000,
52  const float64_t obj_del_thr = 0.0002,
53  const float64_t int_gap_thr = 0.0002)
54  : m_max_iter(max_iter),
55  m_obj_del_thr(obj_del_thr),
56  m_int_gap_thr(int_gap_thr)
57  {}
58 #endif
59 
61  int32_t m_max_iter;
66  };
67 
68 public:
70  CGEMPLP();
71 
77  CGEMPLP(CFactorGraph* fg, Parameter param = Parameter());
78 
80  virtual ~CGEMPLP();
81 
83  virtual const char* get_name() const
84  {
85  return "GEMPLP";
86  }
87 
93  virtual float64_t inference(SGVector<int32_t> assignment);
94 
95 private:
97  void init();
98 
105  void update_messages(int32_t id_region);
106 
107 public:
114  void max_in_subdimension(SGNDArray<float64_t> tar_arr, SGVector<int32_t> &subset_inds, SGNDArray<float64_t> &max_res) const;
115 
122  int32_t find_intersection_index(SGVector<int32_t> region_A, SGVector<int32_t> region_B);
123 
132  SGNDArray<float64_t> convert_energy_to_potential(CFactor* factor);
133 
134 public:
140  vector<SGVector<int32_t> > m_all_intersections;
142  vector<set<int32_t> > m_region_intersections;
144  vector<vector<SGVector<int32_t> > > m_region_inds_intersections;
146  vector<SGNDArray<float64_t> > m_msgs_into_intersections;
148  vector<vector<SGNDArray<float64_t> > > m_msgs_from_region;
150  vector<SGNDArray<float64_t> > m_theta_region;
151 };
152 }
153 #endif
float64_t m_int_gap_thr
Definition: GEMPLP.h:65
Class CMAPInferImpl abstract class of MAP inference implementation.
Definition: MAPInference.h:98
vector< SGVector< int32_t > > m_all_intersections
Definition: GEMPLP.h:140
double float64_t
Definition: common.h:50
Parameter m_param
Definition: GEMPLP.h:136
vector< SGNDArray< float64_t > > m_theta_region
Definition: GEMPLP.h:150
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:148
virtual const char * get_name() const
Definition: GEMPLP.h:83
CDynamicObjectArray * m_factors
Definition: GEMPLP.h:138
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
float64_t m_obj_del_thr
Definition: GEMPLP.h:63
vector< set< int32_t > > m_region_intersections
Definition: GEMPLP.h:142
vector< vector< SGVector< int32_t > > > m_region_inds_intersections
Definition: GEMPLP.h:144
vector< SGNDArray< float64_t > > m_msgs_into_intersections
Definition: GEMPLP.h:146
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 机器学习工具包 - 项目文档