77#ifndef GUM_LEARNING_IKTBN_LEARNER_H
78#define GUM_LEARNING_IKTBN_LEARNER_H
94#include <unordered_set>
109 template < GUM_Numeric GUM_SCALAR >
148 Size nb_decrease = 2) = 0;
177 std::string_view headNode) = 0;
182 std::string_view headBase,
187 std::string_view headNode) = 0;
192 std::string_view headBase,
197 std::string_view headNode) = 0;
202 std::string_view headBase,
207 std::string_view headNode) = 0;
212 std::string_view headBase,
217 std::string_view headBase) = 0;
221 std::string_view headBase)
226 std::string_view headBase) = 0;
230 std::string_view headBase) = 0;
259 std::string_view headBase,
264 std::string_view head) = 0;
269 std::string_view headBase,
274 std::string_view head) = 0;
312 std::string
_encode_(std::string_view base,
int slice)
const;
317 std::pair< std::string, int >
_determineNode_(
const std::string& name)
const;
327 std::string_view head,
328 std::string_view action)
const;
365 static std::unordered_set< std::string >
367 std::string_view csvBaseName,
369 const std::vector< std::string >& missingSymbols);
374#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
Class for fast parsing of CSV file (never more than one line in application memory).
Template implementation of the IKTBNLearner class.
Class representing k-order dynamic Bayesian networks (k-DBN).
Pure-virtual configuration interface shared by all k-TBN learners.
virtual IKTBNLearner< GUM_SCALAR > & erasePossibleEdge(std::string_view tail, std::string_view head)=0
Undo a previous addPossibleEdge using engine names (e.g. "X[1]", "C").
virtual IKTBNLearner< GUM_SCALAR > & eraseNoParentNode(std::string_view base, int slice)=0
Undo a previous addNoParentNode for a single (base, slice) node.
virtual IKTBNLearner< GUM_SCALAR > & useNMLCorrection()=0
virtual IKTBNLearner< GUM_SCALAR > & allowArcReversals(bool allow=true)=0
Allow or forbid arc reversals during structure search.
virtual bool _isKnownBase_(std::string_view base) const =0
Whether base is one of this learner's variables, temporal or atemporal. The second subclass-specific ...
virtual IKTBNLearner< GUM_SCALAR > & addForbiddenIntraSliceArc(std::string_view tailBase, std::string_view headBase)=0
Forbid tailBase -> headBase at every intra-slice position.
virtual IKTBNLearner< GUM_SCALAR > & addForbiddenArc(std::string_view tailNode, std::string_view headNode)=0
Forbid tailNode -> headNode (engine names, e.g. "X[1]", "C").
void _checkBaseIsTemporal_(std::string_view base, std::string_view context) const
Throw InvalidArgument unless base is a known temporal base. context completes "cannot appear in <cont...
virtual IKTBNLearner< GUM_SCALAR > & eraseMandatoryArc(std::string_view tailNode, std::string_view headNode)=0
Undo a previous addMandatoryArc (engine names).
virtual IKTBNLearner< GUM_SCALAR > & useScoreMDL()=0
virtual IKTBNLearner< GUM_SCALAR > & useExtendedGreedyHillClimbing()=0
void _checkArcTemporallyFeasible_(std::string_view tail, std::string_view head, std::string_view action) const
Reject an arc the k-TBN definition can never contain, so eraseForbiddenArc and addMandatoryArc both f...
virtual IKTBNLearner< GUM_SCALAR > & useScoreBD()=0
static std::unordered_set< std::string > _scanConstantColumns_(std::string_view dirPath, std::string_view csvBaseName, Size nbSamples, const std::vector< std::string > &missingSymbols)
Scans every trajectory and returns the base names classified atemporal: those whose value never chang...
virtual const std::unordered_set< std::string > & _atemporalVarNames_() const =0
The base names of the atemporal (static) variables. The only subclass-specific input to determineNode...
virtual IKTBNLearner< GUM_SCALAR > & addNoParentNode(std::string_view name)=0
Declare a single node (bracket notation, e.g. "X[2]" or "C") as a root.
static void _checkMinimalOrder_(Size order, std::string_view label)
Throw InvalidArgument unless order is at least 2, label naming the offending parameter ("k" for the f...
virtual IKTBNLearner< GUM_SCALAR > & eraseForbiddenIntraSliceArc(std::string_view tailBase, std::string_view headBase)=0
Undo a previous addForbiddenIntraSliceArc.
virtual IKTBNLearner< GUM_SCALAR > & useMIIC()=0
virtual IKTBNLearner< GUM_SCALAR > & addMandatoryArc(std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice)=0
Force one arc, lag stated explicitly via slices (KTBN::ATEMPORAL for static).
virtual IKTBNLearner< GUM_SCALAR > & eraseNoParentNode(std::string_view name)=0
Undo addNoParentNode for a node given by bracket notation.
virtual IKTBNLearner< GUM_SCALAR > & useGreedyHillClimbing()=0
virtual void useScorefNML()=0
virtual IKTBNLearner< GUM_SCALAR > & eraseNoChildrenNode(std::string_view base, int slice)=0
Undo a previous addNoChildrenNode for a single (base, slice) node.
virtual IKTBNLearner< GUM_SCALAR > & useMDLCorrection()=0
virtual IKTBNLearner< GUM_SCALAR > & addNoParentNode(std::string_view base, int slice)=0
Declare a single (base, slice) node as a root (no parents).
virtual IKTBNLearner< GUM_SCALAR > & addForbiddenArc(std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice)=0
Forbid one (base, slice) -> (base, slice) arc (KTBN::ATEMPORAL for static).
virtual IKTBNLearner< GUM_SCALAR > & eraseForbiddenArcAllSlices(std::string_view tailBase, std::string_view headBase)=0
Undo a previous addForbiddenArcAllSlices.
virtual IKTBNLearner< GUM_SCALAR > & eraseMandatoryArc(std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice)=0
Undo a previous addMandatoryArc.
virtual IKTBNLearner< GUM_SCALAR > & useScoreBIC()=0
virtual IKTBNLearner< GUM_SCALAR > & addNoChildrenNode(std::string_view name)=0
Declare a single node (bracket notation, e.g. "X[2]" or "C") as a leaf.
virtual IKTBNLearner< GUM_SCALAR > & useSmoothingPrior(double weight=1.0)=0
virtual IKTBNLearner< GUM_SCALAR > & useLocalSearchWithTabuList(Size tabu_size=100, Size nb_decrease=2)=0
virtual IKTBNLearner< GUM_SCALAR > & addPossibleEdge(std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice)=0
Add a candidate edge for MIIC (only edges explicitly listed are explored).
virtual IKTBNLearner< GUM_SCALAR > & eraseForbiddenArc(std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice)=0
Undo a previous addForbiddenArc for a specific (base, slice) pair.
virtual IKTBNLearner< GUM_SCALAR > & eraseNoChildrenNode(std::string_view name)=0
Undo addNoChildrenNode for a node given by bracket notation.
virtual IKTBNLearner< GUM_SCALAR > & setMaxIndegree(Size max_indegree)=0
Cap the number of parents of any single node.
virtual IKTBNLearner< GUM_SCALAR > & allowArcAdditions(bool allow=true)=0
Allow or forbid arc additions during structure search.
std::string _encode_(std::string_view base, int slice) const
(base, slice) -> engine name ("A[1]" / atemporal engine name). Pure function, shared by every learner...
virtual IKTBNLearner< GUM_SCALAR > & eraseForbiddenArc(std::string_view tailNode, std::string_view headNode)=0
Undo a previous addForbiddenArc (engine names).
virtual IKTBNLearner< GUM_SCALAR > & addForbiddenArcAllSlices(std::string_view tailBase, std::string_view headBase)=0
Forbid tailBase -> headBase at every causally-possible slice pair.
virtual IKTBNLearner< GUM_SCALAR > & addPossibleEdge(std::string_view tail, std::string_view head)=0
Add a candidate edge for MIIC using engine names (e.g. "X[1]", "C").
virtual IKTBNLearner< GUM_SCALAR > & useScoreLog2Likelihood()=0
virtual IKTBNLearner< GUM_SCALAR > & useScoreBDeu()=0
virtual IKTBNLearner< GUM_SCALAR > & useNoCorrection()=0
virtual IKTBNLearner< GUM_SCALAR > & addMandatoryArc(std::string_view tailNode, std::string_view headNode)=0
Force tailNode to be a parent of headNode (engine names).
virtual IKTBNLearner< GUM_SCALAR > & allowArcDeletions(bool allow=true)=0
Allow or forbid arc deletions during structure search.
virtual IKTBNLearner< GUM_SCALAR > & addNoChildrenNode(std::string_view base, int slice)=0
Declare a single (base, slice) node as a leaf (no children).
virtual KTBN< GUM_SCALAR > learnKTBN()=0
Learn a k-TBN (structure + CPTs) with the recorded configuration. The fixed-k learner learns for its ...
virtual IKTBNLearner< GUM_SCALAR > & erasePossibleEdge(std::string_view tailBase, int tailSlice, std::string_view headBase, int headSlice)=0
Undo a previous addPossibleEdge.
virtual ~IKTBNLearner()=default
virtual destructor (polymorphic base class)
std::pair< std::string, int > _determineNode_(const std::string &name) const
engine name -> (base, slice); atemporal names map to KTBN::ATEMPORAL. Shared by every learner; only t...
virtual IKTBNLearner< GUM_SCALAR > & useScoreAIC()=0
std::size_t Size
In aGrUM, hashed values are unsigned long int.
include the inlined functions if necessary
template class GUM_PUBLIC_KTBN IKTBNLearner< double >
gum is the global namespace for all aGrUM entities