SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FactorGraph.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) 2013 Shell Hu
8  * Copyright (C) 2013 Shell Hu
9  */
10 
11 #ifndef __FACTORGRAPH_H__
12 #define __FACTORGRAPH_H__
13 
14 #include <shogun/lib/config.h>
15 
17 #include <shogun/lib/SGVector.h>
21 
22 namespace shogun
23 {
24 
27 class CFactorGraph : public CSGObject
28 {
29 
30 public:
31  CFactorGraph();
32 
37  CFactorGraph(const SGVector<int32_t> card);
38 
43  CFactorGraph(const CFactorGraph &fg);
44 
46  ~CFactorGraph();
47 
49  virtual const char* get_name() const { return "FactorGraph"; }
50 
55  void add_factor(CFactor* factor);
56 
61  void add_data_source(CFactorDataSource* datasource);
62 
65 
68 
70  int32_t get_num_factors() const;
71 
74 
80 
82  void compute_energies();
83 
88  float64_t evaluate_energy(const SGVector<int32_t> state) const;
89 
95 
98 
101 
103  int32_t get_num_edges() const;
104 
106  int32_t get_num_vars() const;
107 
112  void connect_components();
113 
115  bool is_acyclic_graph() const;
116 
118  bool is_connected_graph() const;
119 
121  bool is_tree_graph() const;
122 
127  virtual void loss_augmentation(CFactorGraphObservation* gt);
128 
134  virtual void loss_augmentation(SGVector<int32_t> states_gt, \
136 
137 private:
139  void register_parameters();
140 
142  void init();
143 
144 protected:
145  // TODO: FactorNode, VariableNode, such that they have IDs
146 
149 
152 
155 
158 
161 
163  int32_t m_num_edges;
164 
165 };
166 
167 }
168 
169 #endif
170 

SHOGUN Machine Learning Toolbox - Documentation