aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
KTBNDatabaseGenerator.h File Reference

A database generator for k-order dynamic Bayesian networks. More...

#include <cstddef>
#include <string>
#include <vector>
#include <agrum/base/core/progressNotification.h>
#include <agrum/KTBN/KTBN.h>
#include <string_view>
#include <unordered_set>
#include <agrum/KTBN/database/KTBNDatabaseGenerator_tpl.h>
Include dependency graph for KTBNDatabaseGenerator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  gum::learning::KTBNDatabaseGenerator< GUM_SCALAR >
 Generates a database of trajectories from a k-DBN (one CSV per trajectory). More...
struct  gum::learning::KTBNDatabaseGenerator< GUM_SCALAR >::ParentRef
 a parent of a template node, precompiled for fast sampling More...
struct  gum::learning::KTBNDatabaseGenerator< GUM_SCALAR >::NodeRef
 a template node, precompiled for fast sampling More...

Namespaces

namespace  gum
 gum is the global namespace for all aGrUM entities
namespace  gum::learning
 include the inlined functions if necessary

Variables

template class GUM_PUBLIC_KTBN gum::learning::KTBNDatabaseGenerator< double >

Detailed Description

A database generator for k-order dynamic Bayesian networks.

gum::learning::KTBNDatabaseGenerator is the k-DBN counterpart of gum::learning::BNDatabaseGenerator. A plain Bayesian network has no notion of time, so its generator draws i.i.d. realizations of a fixed set of variables and writes them as a flat table. A k-DBN, on the contrary, describes a stochastic process, so its database is a set of trajectories.

It follows the same principle as BNDatabaseGenerator — forward (ancestral) sampling: nodes drawn in topological order, each by an inverse-CDF walk over its CPT, reusing a single gum::Instantiation and accumulating the log2-likelihood — but it does not unroll the k-DBN. It keeps only the \(k\)-slice template (via gum::KTBN::toBN(), which is small and independent of the horizon) and slides it forward in time, reading each parent's value from the trajectory under construction with the proper lag.

To keep the memory footprint independent of the number of trajectories, the generator never stores the whole database: it builds one trajectory at a time in a small \(O(T \times V)\) buffer and writes it straight to the CSV file. drawSamples() therefore only returns the per-trajectory log2-likelihoods.

The database is exported as one CSV file per trajectory: one column per base variable and \(T\) data rows, an atemporal variable keeping the same value across all \(T\) rows. Values may be exported as modality indices or as labels, with a configurable rendering for discretized variables.

gum::KTBN< double > kdbn = ...; // a k-DBN
// 1000 trajectories of length 10 -> out_dir/traj1.csv ... out_dir/traj1000.csv
std::vector< double > ll = gen.drawSamples(1000, 10, "out_dir", "traj");
template class GUM_PUBLIC_KTBN KTBNDatabaseGenerator< double >
template class GUM_PUBLIC_KTBN KTBN< double >
Definition KTBN.cpp:53
Author
Seth AGUILA & Anis KHACEF

Definition in file KTBNDatabaseGenerator.h.