aGrUM 3.0.0
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 50 of file statesChecker.cpp.

50 :
53 GUM_CONSTRUCTOR(StatesChecker);
54 }
static MultiDimFunctionGraph< GUM_ELEMENT, 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 56 of file statesChecker.cpp.

56 {
57 delete _checker_;
58 GUM_DESTRUCTOR(StatesChecker);
59 }

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 88 of file statesChecker.cpp.

88 {
89 Idx varIter = 0;
90 if (parentId) varIter = state.variablesSequence().pos(_checker_->node(parentId)->nodeVar()) + 1;
91
92
93 for (; varIter < state.variablesSequence().size(); ++varIter) {
94 const DiscreteVariable* curVar = state.variablesSequence().atPos(varIter);
95 NodeId varId = _checker_->manager()->addInternalNode(curVar);
96 if (parentId) _checker_->manager()->setSon(parentId, parentModa, varId);
97 else _checker_->manager()->setRootNode(varId);
98 for (Idx moda = 0; moda < curVar->domainSize(); ++moda) {
99 if (moda == state.valFromPtr(curVar)) parentModa = moda;
100 else _checker_->manager()->setSon(varId, moda, _checkerFalseId_);
101 }
102 parentId = varId;
103 }
104 _checker_->manager()->setSon(parentId, parentModa, _checkerTrueId_);
105 }
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 76 of file statesChecker.cpp.

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

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

Here is the call graph for this function:

◆ checkState()

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

Definition at line 48 of file statesChecker_inl.h.

48 {
49 return _checker_->get(state);
50 }

References _checker_.

◆ nbVisitedStates()

INLINE Idx gum::StatesChecker::nbVisitedStates ( )

Definition at line 52 of file statesChecker_inl.h.

52{ return _nbVisitedStates_; }

References _nbVisitedStates_.

◆ reset()

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

Definition at line 61 of file statesChecker.cpp.

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

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: