SHOGUN  v3.0.0
 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 
15 #include <shogun/lib/SGVector.h>
19 
20 namespace shogun
21 {
22 
25 class CFactorGraph : public CSGObject
26 {
27 
28 public:
29  CFactorGraph();
30 
35  CFactorGraph(const SGVector<int32_t> card);
36 
41  CFactorGraph(const CFactorGraph &fg);
42 
44  ~CFactorGraph();
45 
47  virtual const char* get_name() const { return "FactorGraph"; }
48 
53  void add_factor(CFactor* factor);
54 
59  void add_data_source(CFactorDataSource* datasource);
60 
63 
66 
68  int32_t get_num_factors() const;
69 
72 
78 
80  void compute_energies();
81 
86  float64_t evaluate_energy(const SGVector<int32_t> state) const;
87 
93 
96 
99 
101  int32_t get_num_edges() const;
102 
104  int32_t get_num_vars() const;
105 
110  void connect_components();
111 
113  bool is_acyclic_graph() const;
114 
116  bool is_connected_graph() const;
117 
119  bool is_tree_graph() const;
120 
125  virtual void loss_augmentation(CFactorGraphObservation* gt);
126 
132  virtual void loss_augmentation(SGVector<int32_t> states_gt, \
134 
135 private:
137  void register_parameters();
138 
140  void init();
141 
142 protected:
143  // TODO: FactorNode, VariableNode, such that they have IDs
144 
147 
150 
153 
156 
159 
161  int32_t m_num_edges;
162 
163 };
164 
165 }
166 
167 #endif
168 

SHOGUN Machine Learning Toolbox - Documentation