aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::StatesChecker Class Reference

<agrum/FMDP/simulation/statesChecker.h> More...

#include <statesChecker.h>

Collaboration diagram for gum::StatesChecker:

Public Member Functions

Constructor & destructor.
 StatesChecker ()
 Default constructor.
 ~StatesChecker ()
 Default destructor.
Miscelleanous methods
bool checkState (const Instantiation &state)
void addState (const Instantiation &)
Idx nbVisitedStates ()
void reset (const Instantiation &)

Private Member Functions

void _insertState_ (const Instantiation &, NodeId, Idx)

Private Attributes

Idx _nbVisitedStates_
MultiDimFunctionGraph< bool > * _checker_
NodeId _checkerTrueId_
NodeId _checkerFalseId_
Set< Instantiation * > _visitedStates_

Detailed Description

<agrum/FMDP/simulation/statesChecker.h>

Provides the necessary to check whether or not states have been already visited.

Definition at line 69 of file statesChecker.h.

Constructor & Destructor Documentation

◆ StatesChecker()

gum::StatesChecker::StatesChecker ( )

Default constructor.

Definition at line 46 of file statesChecker.cpp.

46 :
49 GUM_CONSTRUCTOR(StatesChecker);
50 }
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getTreeInstance()
Returns an arborescent instance.
MultiDimFunctionGraph< bool > * _checker_
StatesChecker()
Default constructor.

References StatesChecker(), _checker_, _checkerFalseId_, _checkerTrueId_, and _nbVisitedStates_.

Referenced by StatesChecker(), and ~StatesChecker().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~StatesChecker()

gum::StatesChecker::~StatesChecker ( )

Default destructor.

Definition at line 52 of file statesChecker.cpp.

52 {
53 delete _checker_;
54 GUM_DESTRUCTOR(StatesChecker);
55 }

References StatesChecker(), and _checker_.

Here is the call graph for this function:

Member Function Documentation

◆ _insertState_()

void gum::StatesChecker::_insertState_ ( const Instantiation & state,
NodeId parentId,
Idx parentModa )
private

Definition at line 84 of file statesChecker.cpp.

84 {
85 Idx varIter = 0;
86 if (parentId) varIter = state.variablesSequence().pos(_checker_->node(parentId)->nodeVar()) + 1;
87
88
89 for (; varIter < state.variablesSequence().size(); ++varIter) {
90 const DiscreteVariable* curVar = state.variablesSequence().atPos(varIter);
91 NodeId varId = _checker_->manager()->addInternalNode(curVar);
92 if (parentId) _checker_->manager()->setSon(parentId, parentModa, varId);
93 else _checker_->manager()->setRootNode(varId);
94 for (Idx moda = 0; moda < curVar->domainSize(); ++moda) {
95 if (moda == state.valFromPtr(curVar)) parentModa = moda;
96 else _checker_->manager()->setSon(varId, moda, _checkerFalseId_);
97 }
98 parentId = varId;
99 }
100 _checker_->manager()->setSon(parentId, parentModa, _checkerTrueId_);
101 }
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.

References _checker_, _checkerFalseId_, _checkerTrueId_, gum::DiscreteVariable::domainSize(), gum::Instantiation::valFromPtr(), and gum::Instantiation::variablesSequence().

Referenced by addState(), and reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addState()

void gum::StatesChecker::addState ( const Instantiation & state)

Definition at line 72 of file statesChecker.cpp.

72 {
74
75 NodeId parId = _checker_->root();
76 Idx parModa = state.valFromPtr(_checker_->node(parId)->nodeVar());
77 while (_checker_->node(parId)->son(parModa) != _checkerFalseId_) {
78 parId = _checker_->node(parId)->son(parModa);
79 parModa = state.valFromPtr(_checker_->node(parId)->nodeVar());
80 }
81 _insertState_(state, parId, parModa);
82 }
void _insertState_(const Instantiation &, NodeId, Idx)

References _checker_, _checkerFalseId_, _insertState_(), _nbVisitedStates_, and gum::Instantiation::valFromPtr().

Here is the call graph for this function:

◆ checkState()

bool gum::StatesChecker::checkState ( const Instantiation & state)
inline

Definition at line 93 of file statesChecker.h.

93{ return _checker_->get(state); }

References _checker_.

◆ nbVisitedStates()

Idx gum::StatesChecker::nbVisitedStates ( )
inline

Definition at line 97 of file statesChecker.h.

97{ return _nbVisitedStates_; }

References _nbVisitedStates_.

◆ reset()

void gum::StatesChecker::reset ( const Instantiation & initialState)

Definition at line 57 of file statesChecker.cpp.

57 {
58 _checker_->clear();
59 for (SequenceIteratorSafe< const DiscreteVariable* > varIter
60 = initialState.variablesSequence().beginSafe();
61 varIter != initialState.variablesSequence().endSafe();
62 ++varIter)
63 _checker_->add(**varIter);
64
66 _checkerFalseId_ = _checker_->manager()->addTerminalNode(false);
67 _checkerTrueId_ = _checker_->manager()->addTerminalNode(true);
68
69 _insertState_(initialState, 0, 0);
70 }

References _checker_, _checkerFalseId_, _checkerTrueId_, _insertState_(), _nbVisitedStates_, and gum::Instantiation::variablesSequence().

Here is the call graph for this function:

Member Data Documentation

◆ _checker_

MultiDimFunctionGraph< bool >* gum::StatesChecker::_checker_
private

◆ _checkerFalseId_

NodeId gum::StatesChecker::_checkerFalseId_
private

Definition at line 109 of file statesChecker.h.

Referenced by StatesChecker(), _insertState_(), addState(), and reset().

◆ _checkerTrueId_

NodeId gum::StatesChecker::_checkerTrueId_
private

Definition at line 109 of file statesChecker.h.

Referenced by StatesChecker(), _insertState_(), and reset().

◆ _nbVisitedStates_

Idx gum::StatesChecker::_nbVisitedStates_
private

Definition at line 106 of file statesChecker.h.

Referenced by StatesChecker(), addState(), nbVisitedStates(), and reset().

◆ _visitedStates_

Set< Instantiation* > gum::StatesChecker::_visitedStates_
private

Definition at line 111 of file statesChecker.h.


The documentation for this class was generated from the following files: