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) = 0;
189 std::string_view headNode) = 0;
194 std::string_view headBase,
199 std::string_view headNode) = 0;
204 std::string_view headBase,
209 std::string_view headNode) = 0;
214 std::string_view headBase,
219 std::string_view headNode) = 0;
224 std::string_view headBase,
229 std::string_view headBase) = 0;
233 std::string_view headBase)
238 std::string_view headBase) = 0;
242 std::string_view headBase) = 0;
271 std::string_view headBase,
276 std::string_view head) = 0;
281 std::string_view headBase,
286 std::string_view head) = 0;
338 std::string
_encode_(std::string_view base,
int slice)
const;
343 std::pair< std::string, int >
_determineNode_(
const std::string& name)
const;
353 std::string_view head,
354 std::string_view action)
const;
391 static std::unordered_set< std::string >
393 std::string_view csvBaseName,
395 const std::vector< std::string >& missingSymbols);
400#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 > & useSmoothingPrior(double weight)=0
smoothing prior with the default weight (key priorWeight of the section learning of gum::Configuratio...
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
local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the...
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.
static double defaultPriorWeight_()
virtual IKTBNLearner< GUM_SCALAR > & useMIIC()=0
local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the...
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 > & useGreedyThickThinning()=0
local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the...
virtual IKTBNLearner< GUM_SCALAR > & useGreedyHillClimbing()=0
local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the...
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 > & usePC()=0
local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the...
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.
static Size defaultTabuListSize_()
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 > & 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 > & useLocalSearchWithTabuList(Size tabu_size, Size nb_decrease)=0
local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the...
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 > & useFCI()=0
local search with tabu list, with the default number of decreasing changes (key tabuNbDecrease of the...
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
static Size defaultTabuNbDecrease_()
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