SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
structure
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/DynamicObjectArray.h
>
15
#include <
shogun/lib/SGVector.h
>
16
#include <
shogun/structure/Factor.h
>
17
#include <
shogun/labels/FactorGraphLabels.h
>
18
#include <
shogun/structure/DisjointSet.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
62
CDynamicObjectArray
*
get_factors
()
const
;
63
65
CDynamicObjectArray
*
get_factor_data_sources
()
const
;
66
68
int32_t
get_num_factors
()
const
;
69
71
SGVector<int32_t>
get_cardinalities
()
const
;
72
77
void
set_cardinalities
(
SGVector<int32_t>
cards);
78
80
void
compute_energies
();
81
86
float64_t
evaluate_energy
(
const
SGVector<int32_t>
state)
const
;
87
92
float64_t
evaluate_energy
(
const
CFactorGraphObservation
* obs)
const
;
93
95
SGVector<float64_t>
evaluate_energies
()
const
;
96
98
CDisjointSet
*
get_disjoint_set
()
const
;
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, \
133
SGVector<float64_t>
loss =
SGVector<float64_t>
());
134
135
private
:
137
void
register_parameters();
138
140
void
init();
141
142
protected
:
143
// TODO: FactorNode, VariableNode, such that they have IDs
144
146
SGVector<int32_t>
m_cardinalities
;
147
149
CDynamicObjectArray
*
m_factors
;
150
152
CDynamicObjectArray
*
m_datasources
;
153
155
CDisjointSet
*
m_dset
;
156
158
bool
m_has_cycle
;
159
161
int32_t
m_num_edges
;
162
163
};
164
165
}
166
167
#endif
168
SHOGUN
Machine Learning Toolbox - Documentation