SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 
float64_t evaluate_energy(const SGVector< int32_t > state) const
void add_factor(CFactor *factor)
Definition: FactorGraph.cpp:95
void add_data_source(CFactorDataSource *datasource)
int32_t get_num_edges() const
bool is_tree_graph() const
int32_t get_num_factors() const
CDynamicObjectArray * get_factors() const
CDisjointSet * get_disjoint_set() const
CDynamicObjectArray * m_datasources
Definition: FactorGraph.h:154
void set_cardinalities(SGVector< int32_t > cards)
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
CDynamicObjectArray * get_factor_data_sources() const
int32_t get_num_vars() const
double float64_t
Definition: common.h:50
Class CFactorGraphObservation is used as the structured output.
Class CFactorDataSource Source for factor data. In some cases, the same data can be shared by many fa...
Definition: Factor.h:27
CDisjointSet * m_dset
Definition: FactorGraph.h:157
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
Class CDisjointSet data structure for linking graph nodes It's easy to identify connected graph...
Definition: DisjointSet.h:26
SGVector< float64_t > evaluate_energies() const
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CDynamicObjectArray * m_factors
Definition: FactorGraph.h:151
Class CFactorGraph a factor graph is a structured input in general.
Definition: FactorGraph.h:27
bool is_acyclic_graph() const
SGVector< int32_t > get_cardinalities() const
virtual void loss_augmentation(CFactorGraphObservation *gt)
SGVector< int32_t > m_cardinalities
Definition: FactorGraph.h:148
Class CFactor A factor is defined on a clique in the factor graph. Each factor can have its own data...
Definition: Factor.h:89
virtual const char * get_name() const
Definition: FactorGraph.h:49
bool is_connected_graph() const

SHOGUN Machine Learning Toolbox - Documentation