21 register_parameters();
29 register_parameters();
36 register_parameters();
52 #ifdef USE_REFERENCE_COUNTING
54 SG_DEBUG(
"CFactorGraph::~CFactorGraph(): m_factors->ref_count() = %d.\n",
m_factors->ref_count());
57 SG_DEBUG(
"CFactorGraph::~CFactorGraph(): m_datasources->ref_count() = %d.\n",
m_datasources->ref_count());
59 SG_DEBUG(
"CFactorGraph::~CFactorGraph(): this->ref_count() = %d.\n", this->ref_count());
63 void CFactorGraph::register_parameters()
73 void CFactorGraph::init()
82 #ifdef USE_REFERENCE_COUNTING
84 SG_DEBUG(
"CFactorGraph::init(): m_factors->ref_count() = %d.\n",
m_factors->ref_count());
101 if (m_dset->get_connected())
102 m_dset->set_connected(
false);
188 cumprod_cards[n] = num_assig;
193 for (int32_t ei = 0; ei < num_assig; ++ei)
212 if (m_dset->get_connected())
224 int32_t r0 = m_dset->find_set(vars[0]);
225 for (int32_t vi = 1; vi < vars.
size(); vi++)
230 int32_t ri = m_dset->find_set(vars[vi]);
238 r0 = m_dset->link_set(r0, ri);
244 m_dset->set_connected(
true);
254 return (m_dset->get_num_sets() == 1);
259 return (
m_has_cycle ==
false && m_dset->get_num_sets() == 1);
269 if (loss.
size() == 0)
275 int32_t num_vars = states_gt.
size();
288 for (int32_t vi = 0; vi < vars.
size(); vi++)
290 int32_t vv = vars[vi];
296 for (int32_t ei = 0; ei < energies.
size(); ei++)
302 if (states_gt[vv] == vstate)
316 int32_t min_var =
CMath::min(var_flags.vector, var_flags.vlen);
void set_energy(int32_t ei, float64_t value)
float64_t evaluate_energy(const SGVector< int32_t > state) const
static void fill_vector(T *vec, int32_t len, T value)
SGVector< int32_t > get_data() const
void add_factor(CFactor *factor)
void add_data_source(CFactorDataSource *datasource)
CTableFactorType * get_factor_type() const
int32_t get_num_edges() const
bool is_tree_graph() const
const SGVector< int32_t > get_variables() const
SGVector< float64_t > get_loss_weights() const
int32_t get_num_factors() const
CDynamicObjectArray * get_factors() const
int32_t get_num_elements() const
float64_t evaluate_energy(const SGVector< int32_t > state) const
CDisjointSet * get_disjoint_set() const
SGVector< float64_t > get_energies() const
CDynamicObjectArray * m_datasources
void set_cardinalities(SGVector< int32_t > cards)
Class SGObject is the base class of all shogun objects.
CDynamicObjectArray * get_factor_data_sources() const
int32_t get_num_vars() const
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...
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...
SGVector< float64_t > evaluate_energies() const
int32_t state_from_index(int32_t ei, int32_t var_index) const
all of classes and functions are contained in the shogun namespace
CDynamicObjectArray * m_factors
Class CFactorGraph a factor graph is a structured input in general.
Class CTableFactorType the way that store assignments of variables and energies in a table or a multi...
bool is_acyclic_graph() const
void connect_components()
SGVector< T > clone() const
CSGObject * get_element(int32_t index) const
void resize_vector(int32_t n)
void push_back(CSGObject *e)
SGVector< int32_t > get_cardinalities() const
virtual void loss_augmentation(CFactorGraphObservation *gt)
#define SG_UNSTABLE(func,...)
SGVector< int32_t > m_cardinalities
Class CFactor A factor is defined on a clique in the factor graph. Each factor can have its own data...
bool is_connected_graph() const