aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber > Class Template Reference

<agrum/BN/generator/MCayesNetGenerator.h> More...

#include <MCBayesNetGenerator.h>

+ Inheritance diagram for gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >:
+ Collaboration diagram for gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >:

Public Member Functions

Constructors / Destructor
 MCBayesNetGenerator (Size nbrNodes, Size maxArcs, Idx maxModality=2, Size iteration=5000, Idx p=30, Idx q=40)
 Constructor. More...
 
 MCBayesNetGenerator (BayesNet< GUM_SCALAR > bayesNet, Size iteration=5000, Idx p=30, Idx q=40)
 Constructor. More...
 
 ~MCBayesNetGenerator () override
 Destructor. More...
 
BN generation methods
void generateBN (BayesNet< GUM_SCALAR > &bayesNet) override
 Generates a random Bayesian network. More...
 
void disturbBN (BayesNet< GUM_SCALAR > &bayesNetinit, Size iteration=0)
 Change randomly the topology of a specific Bayesian networks. More...
 
Getters
Size iteration () const
 Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator. More...
 
Idx p () const
 Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator. More...
 
Idx q () const
 Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator. More...
 
Setters
void setIteration (Size iteration)
 Modifies the value of the number of iterations impose on the BayesNetGenerator. More...
 
void setP (Idx p)
 Modifies the value of the probability p imposed on the BayesNetGenerator. More...
 
void setQ (Idx q)
 Modifies the value of the probability q imposed on the BayesNetGenerator. More...
 
BN generation methods
void fillCPT ()
 function that insert random values in the CPT of each nodes according to the CPTGenerator. More...
 
Getters
Size nbrNodes () const
 Return a constant reference to the number of nodes imposed on the IBayesNetGenerator. More...
 
Size maxArcs () const
 Return a constant reference to the maximum number of arcs imposed on the IBayesNetGenerator. More...
 
Size maxModality () const
 Return a constant reference to the maximum modality imposed on the IBayesNetGenerator. More...
 
Setters
void setNbrNodes (Size nbrNodes)
 Modifies the value of the number of nodes imposed on the BayesGenerator. More...
 
void setMaxArcs (Size maxArcs)
 Modifies the value of the number of nodes imposed on the BayesGenerator. More...
 
void setMaxModality (Size maxModality)
 Modifies the value of the number of nodes imposed on the BayesGenerator. More...
 

Protected Attributes

Size iteration_
 
Idx p_
 
Idx q_
 
bool disturbing_
 
BayesNet< GUM_SCALAR > bayesNettemp_
 
HashTable< NodeId, Potential< GUM_SCALAR > *> hashMarginal_
 
Size nbrNodes_
 
Size maxArcs_
 
Size maxModality_
 
BayesNet< GUM_SCALAR > bayesNet_
 

Protected Member Functions

bool _isPolytree_ ()
 The function that verify if graph is a polytree. More...
 
bool _connect_ (NodeId i, NodeId j)
 The function that verify if node i and j are connected. More...
 
bool _directedPath_ (NodeId tail, NodeId head)
 The function that verify if there is a oriented path from node i to node j. More...
 
void _insertArc_ (NodeId i, NodeId j)
 The function that will insert an arc between node i to node j, but only if there isn't any cycle created. More...
 
void _eraseArc_ (NodeId i, NodeId j, bool mustbeconnex=true)
 The function that will remove the arc between node i and node j. More...
 
void _PMMx_poly_ ()
 In the case that the graph is a polytree, the function will, according to the probability p and q, choose which change of state must occure( AorR or AR or jump) then will assert that the imposed constraint are respected and if not, will return to the previous topology. More...
 
void _PMMx_multi_ ()
 In the case that the graph is a multiconnected graph, the function will, according to the probability p and q, choose which change of state must occure( AorR or jump) then will assert that the imposed constraint are respected and if not, will return to the previous topology. More...
 
void _jump_poly_ ()
 In the case that the graph is a polytree, the function will add a ramdom arc by the use of the function insertArc if the arc does not exist allready. More...
 
void _jump_multi_ ()
 In the case that the graph is a multiconnect graph, the function will choose randomly two nodes and will remove the arc between them by the use of the function insertArc if the arc exists. More...
 
void _AorR_ ()
 The function will add or remove a random arc in the graph using the functions insertArc and removeArc. More...
 
void _AR_ ()
 The function will remove and add a random arc changing the topology of the graph but asserting its connectivity. More...
 
virtual bool _checkConditions_ ()
 The boolean function that will assert the respect of the constraint. More...
 
bool _connect_ (NodeId i, NodeId j, NodeSet &excluded)
 The internal function used by the previous connect. More...
 
bool _directedPath_ (NodeId tail, NodeId head, NodeSet &excluded)
 The internal function used by the previous directedPath. More...
 
void _chooseNodes_ (NodeId &i, NodeId &j)
 The function that randomly choose two nodes of the graph. More...
 
void _chooseCloseNodes_ (NodeId &i, NodeId &j)
 The function that randomly choose two neighbours nodes of the graph. More...
 
void _transformPoly_ (Idx nbiter)
 The function that randomly change the simple tree into a polytree. More...
 
void _createTree_ (Size BNSize)
 The function that randomly generate a simple tree. More...
 
NodeId _createPartTree_ (Size BNSize, Idx &n)
 The internal function used by createTree that randomly generate a simple tree. More...
 

Detailed Description

template<typename GUM_SCALAR, template< typename > class ICPTGenerator = SimpleCPTGenerator, template< typename > class ICPTDisturber = SimpleCPTDisturber>
class gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >

<agrum/BN/generator/MCayesNetGenerator.h>

Class for generating Bayesian networks with Markov chains.

This class randomly generates a Bayesian network given 6 parameters: the number of nodes, the maximum number of arcs the and of iterations the maximum modality.

Warning
Be Careful when entering the parameters, high Values may cause the density of the Bayesian network to be too high resulting in the failure of most of the inference Methods.

This Generation method require the use of two probability parameters(p, q) defining the choice of processes that will provoke the change of state. You can see in the graph below how the probabilities are used.

Definition at line 159 of file MCBayesNetGenerator.h.

Constructor & Destructor Documentation

◆ MCBayesNetGenerator() [1/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::MCBayesNetGenerator ( Size  nbrNodes,
Size  maxArcs,
Idx  maxModality = 2,
Size  iteration = 5000,
Idx  p = 30,
Idx  q = 40 
)

Constructor.

Use by default the SimpleCPTGenerator for generating the BNs CPT and the SimpleCPTDisturber to tweak the CPT when the dimension of the table changes.

Parameters
nbrNodesThe number of nodes in the generated BN.
maxArcsThe maximum number of Arcs.
maxModalityEach DRV has from 2 to maxModality modalities
iterationThe number of iterations wanted to repeat the algorithm
pprobability for the change of the state (see use of p and q )
qprobability for the change of the state (see use of p and q )

Definition at line 57 of file MCBayesNetGenerator_tpl.h.

63  :
64  IBNG(nbrNodes, maxArcs, maxModality),
66  if (p + q > 100)
67  GUM_ERROR(OperationNotAllowed,
68  "the sum of the probabilities p and q must be at most equal to 100");
69 
71  p_ = p;
72  q_ = q;
73  disturbing_ = false;
74 
75  GUM_CONSTRUCTOR(MCBayesNetGenerator);
76  }
MCBayesNetGenerator(Size nbrNodes, Size maxArcs, Idx maxModality=2, Size iteration=5000, Idx p=30, Idx q=40)
Constructor.
Idx q() const
Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.
Size nbrNodes() const
Return a constant reference to the number of nodes imposed on the IBayesNetGenerator.
HashTable< NodeId, Potential< GUM_SCALAR > *> hashMarginal_
#define IBNG
Size maxArcs() const
Return a constant reference to the maximum number of arcs imposed on the IBayesNetGenerator.
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
BayesNet< GUM_SCALAR > bayesNettemp_
Idx p() const
Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ MCBayesNetGenerator() [2/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::MCBayesNetGenerator ( BayesNet< GUM_SCALAR >  bayesNet,
Size  iteration = 5000,
Idx  p = 30,
Idx  q = 40 
)
explicit

Constructor.

Use by default the SimpleCPTGenerator for generating the BNs CPT and the SimpleCPTDisturber to tweak the CPT when the dimension of the table changes.

Parameters
bayesNetthe IBayesNet used as reference to fill the parameters nbrNodes, maxArcs and maxModality
iterationThe number of iterations wanted to repeat the algorithm
pprobability for the change of the state (see probability_p_q )
qprobability for the change of the state (see probability_p_q )

Definition at line 83 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

87  :
88  MCBayesNetGenerator(bayesNet.size(),
89  (Size)(bayesNet.sizeArcs() * 1.1),
90  getMaxModality(bayesNet)) {
92  p_ = p;
93  q_ = q;
94  disturbing_ = false;
95  }
MCBayesNetGenerator(Size nbrNodes, Size maxArcs, Idx maxModality=2, Size iteration=5000, Idx p=30, Idx q=40)
Constructor.
Idx q() const
Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.
gum::Size getMaxModality(gum::BayesNet< GUM_SCALAR > &bayesNet)
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
Idx p() const
Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator.
+ Here is the call graph for this function:

◆ ~MCBayesNetGenerator()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::~MCBayesNetGenerator ( )
override

Destructor.

Definition at line 103 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

103  {
104  GUM_DESTRUCTOR(MCBayesNetGenerator);
105  }
MCBayesNetGenerator(Size nbrNodes, Size maxArcs, Idx maxModality=2, Size iteration=5000, Idx p=30, Idx q=40)
Constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ _AorR_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_AorR_ ( )
protected

The function will add or remove a random arc in the graph using the functions insertArc and removeArc.

Definition at line 287 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

287  {
288  NodeId i, j;
289  _chooseNodes_(i, j);
290  const DAG _dag_ = this->bayesNet_.dag();
291 
292  if (_dag_.existsArc(i, j)) {
293  _eraseArc_(i, j);
294 
295  return;
296  } else
297  _insertArc_(i, j);
298  }
void _insertArc_(NodeId i, NodeId j)
The function that will insert an arc between node i to node j, but only if there isn&#39;t any cycle crea...
void _chooseNodes_(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
BayesNet< GUM_SCALAR > bayesNet_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void _eraseArc_(NodeId i, NodeId j, bool mustbeconnex=true)
The function that will remove the arc between node i and node j.
+ Here is the call graph for this function:

◆ _AR_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_AR_ ( )
protected

The function will remove and add a random arc changing the topology of the graph but asserting its connectivity.

Definition at line 305 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

305  {
306  NodeId i, j, head, tail;
307  _chooseNodes_(i, j);
308  const DAG _dag_ = this->bayesNet_.dag();
309 
310  if (_dag_.existsArc(i, j) || _dag_.existsArc(j, i)) {
311  return;
312  } else {
313  Idx per = randomValue(100);
314 
315  if (per < 50) {
316  head = i;
317  tail = j;
318  } else {
319  head = j;
320  tail = i;
321  }
322 
323  for (auto node: _dag_.parents(j)) {
324  NodeSet excluded;
325  excluded.insert(j);
326 
327  if (_connect_(node, i, excluded)) {
328  this->bayesNet_.eraseArc(node, j);
329  this->bayesNet_.addArc(head, tail);
330  return;
331  }
332  }
333 
334  for (auto node: _dag_.children(j)) {
335  NodeSet excluded;
336  excluded.insert(j);
337 
338  if (_connect_(node, i, excluded)) {
339  this->bayesNet_.eraseArc(j, node);
340  this->bayesNet_.addArc(head, tail);
341  return;
342  }
343  }
344  }
345  }
bool _connect_(NodeId i, NodeId j)
The function that verify if node i and j are connected.
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
void _chooseNodes_(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
BayesNet< GUM_SCALAR > bayesNet_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
+ Here is the call graph for this function:

◆ _checkConditions_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE bool gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_checkConditions_ ( )
protectedvirtual

The boolean function that will assert the respect of the constraint.

Reimplemented in gum::MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >, and gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >.

Definition at line 182 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

182  {
183  return this->maxArcs_ >= this->bayesNet_.sizeArcs();
184  }
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ _chooseCloseNodes_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_chooseCloseNodes_ ( NodeId i,
NodeId j 
)
protected

The function that randomly choose two neighbours nodes of the graph.

Definition at line 440 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

442  {
443  NodeId temp = randomValue(this->bayesNet_.size());
444  Size co = 0;
445 
446  if (this->bayesNet_.parents(temp).size()) {
447  j = temp;
448  auto it = this->bayesNet_.parents(j).begin();
449  co = randomValue(this->bayesNet_.parents(j).size());
450 
451  while (co--) {
452  ++it;
453  }
454 
455  i = *it;
456  } else if (this->bayesNet_.children(temp).size()) {
457  i = temp;
458  auto it = this->bayesNet_.children(i).begin();
459  co = randomValue(this->bayesNet_.children(i).size());
460 
461  while (co--) {
462  ++it;
463  }
464 
465  j = *it;
466  } else {
467  GUM_ERROR(FatalError, "Sorry Misconstructed BN because of isolated node.")
468  }
469  }
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
BayesNet< GUM_SCALAR > bayesNet_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ _chooseNodes_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_chooseNodes_ ( NodeId i,
NodeId j 
)
protected

The function that randomly choose two nodes of the graph.

Definition at line 426 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

427  {
428  i = randomValue(this->bayesNet_.size());
429  j = randomValue(this->bayesNet_.size());
430 
431  while (i == j)
432  j = randomValue(this->bayesNet_.size());
433  }
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ _connect_() [1/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
bool gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_connect_ ( NodeId  i,
NodeId  j 
)
protected

The function that verify if node i and j are connected.

Definition at line 552 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

553  {
554  const DAG _dag_ = this->bayesNet_.dag();
555 
556  if (_dag_.existsArc(i, j) || _dag_.existsArc(j, i))
557  return true;
558  else {
559  NodeSet excluded;
560  excluded.insert(i);
561 
562  for (auto par: _dag_.parents(i)) {
563  if (!excluded.exists(par) && _connect_(par, j, excluded)) return true;
564  }
565 
566  for (auto chi: _dag_.children(i)) {
567  if (!excluded.exists(chi) && _connect_(chi, j, excluded)) return true;
568  }
569 
570  return false;
571  }
572  }
bool _connect_(NodeId i, NodeId j)
The function that verify if node i and j are connected.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
BayesNet< GUM_SCALAR > bayesNet_
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
+ Here is the call graph for this function:

◆ _connect_() [2/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
bool gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_connect_ ( NodeId  i,
NodeId  j,
NodeSet excluded 
)
protected

The internal function used by the previous connect.

It asserts the existence of an unoriented path between node i and node j avoiding passing through nodes listed in excluded.

Definition at line 580 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

582  {
583  const DAG _dag_ = this->bayesNet_.dag();
584 
585  if (_dag_.existsArc(i, j) || _dag_.existsArc(j, i))
586  return true;
587  else {
588  excluded.insert(i);
589 
590  for (auto par: _dag_.parents(i)) {
591  if (!excluded.exists(par) && _connect_(par, j, excluded)) return true;
592  }
593 
594  for (auto chi: _dag_.children(i)) {
595  if (!excluded.exists(chi) && _connect_(chi, j, excluded)) return true;
596  }
597 
598  return false;
599  }
600  }
bool _connect_(NodeId i, NodeId j)
The function that verify if node i and j are connected.
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ _createPartTree_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
NodeId gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_createPartTree_ ( Size  BNSize,
Idx n 
)
protected

The internal function used by createTree that randomly generate a simple tree.

n : id number for node label

Definition at line 499 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

500  {
501  Size nb_mod = 2 + randomValue(this->maxModality_ - 1);
502  std::stringstream strBuff;
503  strBuff << "n_" << n++;
504  NodeId root = this->bayesNet_.add(LabelizedVariable(strBuff.str(), "", nb_mod));
505  Size maxNodes = BNSize - 1;
506  Size SubG = 0;
507 
508  while (maxNodes) {
509  SubG = randomValue(maxNodes) + 1;
510  maxNodes = maxNodes - SubG;
511  NodeId rootS = _createPartTree_(SubG, n);
512  this->bayesNet_.addArc(root, rootS);
513  }
514 
515  return root;
516  }
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
NodeId _createPartTree_(Size BNSize, Idx &n)
The internal function used by createTree that randomly generate a simple tree.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
BayesNet< GUM_SCALAR > bayesNet_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ _createTree_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_createTree_ ( Size  BNSize)
protected

The function that randomly generate a simple tree.

Definition at line 476 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

476  {
477  Idx n = 0;
478  Size nb_mod = 2 + randomValue(this->maxModality_ - 1);
479  std::stringstream strBuff;
480  strBuff << "n_" << n++;
481  NodeId root = this->bayesNet_.add(LabelizedVariable(strBuff.str(), "", nb_mod));
482  Size maxNodes = BNSize - 1;
483  Size SubG = 0;
484 
485  while (maxNodes) {
486  SubG = randomValue(maxNodes) + 1;
487  maxNodes = maxNodes - SubG;
488  NodeId rootS = _createPartTree_(SubG, n);
489  this->bayesNet_.addArc(root, rootS);
490  }
491  }
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
NodeId _createPartTree_(Size BNSize, Idx &n)
The internal function used by createTree that randomly generate a simple tree.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
BayesNet< GUM_SCALAR > bayesNet_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ _directedPath_() [1/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
bool gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_directedPath_ ( NodeId  tail,
NodeId  head 
)
protected

The function that verify if there is a oriented path from node i to node j.

Definition at line 608 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

609  {
610  const DAG _dag_ = this->bayesNet_.dag();
611 
612  if (_dag_.existsArc(tail, head))
613  return true;
614  else {
615  NodeSet excluded;
616  excluded.insert(tail);
617 
618  for (auto node: _dag_.children(tail)) {
619  if (_directedPath_(node, head, excluded)) return true;
620  }
621 
622  return false;
623  }
624  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
bool _directedPath_(NodeId tail, NodeId head)
The function that verify if there is a oriented path from node i to node j.
BayesNet< GUM_SCALAR > bayesNet_
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
+ Here is the call graph for this function:

◆ _directedPath_() [2/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
bool gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_directedPath_ ( NodeId  tail,
NodeId  head,
NodeSet excluded 
)
protected

The internal function used by the previous directedPath.

It asserts the existence of an oriented path between node i and node j avoiding passing through nodes listed in excluded.

Definition at line 631 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

634  {
635  const DAG _dag_ = this->bayesNet_.dag();
636 
637  if (_dag_.existsArc(tail, head))
638  return true;
639  else {
640  excluded.insert(tail);
641 
642  for (auto node: _dag_.children(tail)) {
643  if (!excluded.exists(node) && _directedPath_(node, head, excluded)) return true;
644  }
645 
646  return false;
647  }
648  }
bool _directedPath_(NodeId tail, NodeId head)
The function that verify if there is a oriented path from node i to node j.
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ _eraseArc_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_eraseArc_ ( NodeId  i,
NodeId  j,
bool  mustbeconnex = true 
)
protected

The function that will remove the arc between node i and node j.

If the boolean parameter mustbeconnex is true, the function will assert that the graph remain connected and will restore the arc otherwise.

Definition at line 397 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

400  {
401  if (disturbing_) {
402  const BayesNet< GUM_SCALAR > bayesNet(this->bayesNet_);
403  Potential< GUM_SCALAR > potj;
404  potj.copy(this->bayesNet_.cpt(j));
405  this->bayesNet_.eraseArc(i, j);
406 
407  if (_connect_(i, j) || !mustbeconnex) {
408  auto marg = *hashMarginal_[i];
409 
410  this->disturbReducCPT(j, this->bayesNet_, potj, marg);
411  } else
412  this->bayesNet_.addArc(i, j);
413  } else {
414  this->bayesNet_.eraseArc(i, j);
415 
416  if (!_connect_(i, j) && mustbeconnex) { this->bayesNet_.addArc(i, j); }
417  }
418  }
bool _connect_(NodeId i, NodeId j)
The function that verify if node i and j are connected.
HashTable< NodeId, Potential< GUM_SCALAR > *> hashMarginal_
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ _insertArc_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_insertArc_ ( NodeId  i,
NodeId  j 
)
protected

The function that will insert an arc between node i to node j, but only if there isn't any cycle created.

Definition at line 379 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

380  {
381  if (_directedPath_(j, i)) return;
382 
383  if (disturbing_) {
384  auto potj = this->bayesNet_.cpt(j);
385  this->bayesNet_.addArc(i, j);
386 
387  this->disturbAugmCPT(j, this->bayesNet_, potj, (GUM_SCALAR)0.5);
388  } else
389  this->bayesNet_.addArc(i, j);
390  }
bool _directedPath_(NodeId tail, NodeId head)
The function that verify if there is a oriented path from node i to node j.
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ _isPolytree_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE bool gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_isPolytree_ ( )
protected

The function that verify if graph is a polytree.

Definition at line 542 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

542  {
543  const DAG _dag_ = this->bayesNet_.dag();
544  return this->bayesNet_.size() - 1 == this->bayesNet_.sizeArcs();
545  }
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ _jump_multi_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_jump_multi_ ( )
protected

In the case that the graph is a multiconnect graph, the function will choose randomly two nodes and will remove the arc between them by the use of the function insertArc if the arc exists.

Definition at line 365 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

365  {
366  NodeId i, j;
367  _chooseNodes_(i, j);
368  const DAG _dag_ = this->bayesNet_.dag();
369 
370  if (_dag_.existsArc(i, j)) { _eraseArc_(i, j); }
371  }
void _chooseNodes_(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
BayesNet< GUM_SCALAR > bayesNet_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void _eraseArc_(NodeId i, NodeId j, bool mustbeconnex=true)
The function that will remove the arc between node i and node j.
+ Here is the call graph for this function:

◆ _jump_poly_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_jump_poly_ ( )
protected

In the case that the graph is a polytree, the function will add a ramdom arc by the use of the function insertArc if the arc does not exist allready.

Definition at line 352 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

352  {
353  NodeId i, j;
354  _chooseNodes_(i, j);
355  const DAG _dag_ = this->bayesNet_.dag();
356 
357  if (!_dag_.existsArc(i, j)) _insertArc_(i, j);
358  }
void _insertArc_(NodeId i, NodeId j)
The function that will insert an arc between node i to node j, but only if there isn&#39;t any cycle crea...
void _chooseNodes_(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
BayesNet< GUM_SCALAR > bayesNet_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ _PMMx_multi_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_PMMx_multi_ ( )
protected

In the case that the graph is a multiconnected graph, the function will, according to the probability p and q, choose which change of state must occure( AorR or jump) then will assert that the imposed constraint are respected and if not, will return to the previous topology.

Definition at line 239 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

239  {
240  if (!iteration_--) return;
241 
242  Idx per = randomValue(100);
243 
244  if (per < p_ + q_) {
245  _AorR_();
246 
247  if (_checkConditions_()) {
248  if (_isPolytree_()) {
249  if (per < p_) {
250  bayesNettemp_ = this->bayesNet_;
251  _PMMx_poly_();
252  } else {
253  this->bayesNet_ = bayesNettemp_;
254  _PMMx_multi_();
255  }
256  } else {
257  bayesNettemp_ = this->bayesNet_;
258  _PMMx_multi_();
259  }
260  } else {
261  this->bayesNet_ = bayesNettemp_;
262  _PMMx_multi_();
263  }
264  } else {
265  _jump_multi_();
266 
267  if (_checkConditions_()) {
268  bayesNettemp_ = this->bayesNet_;
269 
270  if (_isPolytree_())
271  _PMMx_poly_();
272  else
273  _PMMx_multi_();
274 
275  } else {
276  this->bayesNet_ = bayesNettemp_;
277  _PMMx_multi_();
278  }
279  }
280  }
virtual bool _checkConditions_()
The boolean function that will assert the respect of the constraint.
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
void _PMMx_poly_()
In the case that the graph is a polytree, the function will, according to the probability p and q...
bool _isPolytree_()
The function that verify if graph is a polytree.
void _PMMx_multi_()
In the case that the graph is a multiconnected graph, the function will, according to the probability...
void _jump_multi_()
In the case that the graph is a multiconnect graph, the function will choose randomly two nodes and w...
BayesNet< GUM_SCALAR > bayesNet_
BayesNet< GUM_SCALAR > bayesNettemp_
void _AorR_()
The function will add or remove a random arc in the graph using the functions insertArc and removeArc...
+ Here is the call graph for this function:

◆ _PMMx_poly_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_PMMx_poly_ ( )
protected

In the case that the graph is a polytree, the function will, according to the probability p and q, choose which change of state must occure( AorR or AR or jump) then will assert that the imposed constraint are respected and if not, will return to the previous topology.

Definition at line 194 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

194  {
195  if (!iteration_--) return;
196 
197  Idx per = randomValue(100);
198 
199  if (per < p_) {
200  _AorR_();
201 
202  if (_checkConditions_()) {
203  bayesNettemp_ = this->bayesNet_;
204  _PMMx_multi_();
205  } else {
206  this->bayesNet_ = bayesNettemp_;
207  _PMMx_poly_();
208  }
209  } else {
210  if (per < p_ + q_) {
211  _AR_();
212 
213  if (!_checkConditions_()) {
214  this->bayesNet_ = bayesNettemp_;
215  } else
216  bayesNettemp_ = this->bayesNet_;
217 
218  _PMMx_poly_();
219  } else {
220  _jump_poly_();
221 
222  if (_checkConditions_()) {
223  bayesNettemp_ = this->bayesNet_;
224  _PMMx_multi_();
225 
226  } else {
227  this->bayesNet_ = bayesNettemp_;
228  _PMMx_poly_();
229  }
230  }
231  }
232  }
void _jump_poly_()
In the case that the graph is a polytree, the function will add a ramdom arc by the use of the functi...
virtual bool _checkConditions_()
The boolean function that will assert the respect of the constraint.
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
void _PMMx_poly_()
In the case that the graph is a polytree, the function will, according to the probability p and q...
void _PMMx_multi_()
In the case that the graph is a multiconnected graph, the function will, according to the probability...
BayesNet< GUM_SCALAR > bayesNet_
void _AR_()
The function will remove and add a random arc changing the topology of the graph but asserting its co...
BayesNet< GUM_SCALAR > bayesNettemp_
void _AorR_()
The function will add or remove a random arc in the graph using the functions insertArc and removeArc...
+ Here is the call graph for this function:

◆ _transformPoly_()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_transformPoly_ ( Idx  nbiter)
protected

The function that randomly change the simple tree into a polytree.

Definition at line 525 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

525  {
526  while (nbiter--) {
527  NodeId i, j;
528  _chooseCloseNodes_(i, j);
529  bayesNettemp_ = this->bayesNet_;
530  _eraseArc_(i, j, false);
531  this->bayesNet_.addArc(j, i);
532 
533  if (!_checkConditions_()) this->bayesNet_ = bayesNettemp_;
534  }
535  }
void _chooseCloseNodes_(NodeId &i, NodeId &j)
The function that randomly choose two neighbours nodes of the graph.
virtual bool _checkConditions_()
The boolean function that will assert the respect of the constraint.
BayesNet< GUM_SCALAR > bayesNet_
BayesNet< GUM_SCALAR > bayesNettemp_
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void _eraseArc_(NodeId i, NodeId j, bool mustbeconnex=true)
The function that will remove the arc between node i and node j.
+ Here is the call graph for this function:

◆ disturbBN()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN ( BayesNet< GUM_SCALAR > &  bayesNetinit,
Size  iteration = 0 
)

Change randomly the topology of a specific Bayesian networks.

Parameters
bayesNetinitIBayesNet to be modify
iterationThe number of iterations wanted to repeat the algorithm
Returns
null but modify inputed Bayesian network
Exceptions
OperationNotAllowif the initial state of the IBayesNet is not respecting the wanted conditions if iteration = 0, it is assumed that the number of iteration wanted is the same as the one specified in the constructor

Definition at line 134 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

136  { // insert option for the variation
137  disturbing_ = true;
138  Size iter = iteration_;
139 
141 
142  this->bayesNet_ = bayesNetinit;
143 
144  if (_checkConditions_()) {
145  LazyPropagation< GUM_SCALAR > inf(&bayesNetinit);
146  inf.makeInference();
147 
148  for (auto node: bayesNetinit.nodes()) {
149  auto pottemp = new Potential< GUM_SCALAR >();
150  pottemp->copy(inf.posterior(node));
151  hashMarginal_.insert(node, pottemp);
152  }
153 
154  bayesNettemp_ = this->bayesNet_;
155 
156  if (_isPolytree_())
157  _PMMx_poly_();
158  else
159  _PMMx_multi_();
160 
161  bayesNetinit = (this->bayesNet_);
162 
163  while (hashMarginal_.size()) {
164  delete (hashMarginal_.begin().val());
165  hashMarginal_.erase(hashMarginal_.beginSafe()); // safe iterator needed here.
166  }
167 
168  } else {
169  std::cout << this->bayesNet_.toDot() << std::endl;
170  GUM_ERROR(OperationNotAllowed, "BN is not valid cause it does not respect constraint ")
171  }
172 
173  iteration_ = iter;
174  disturbing_ = false;
175  }
virtual bool _checkConditions_()
The boolean function that will assert the respect of the constraint.
void _PMMx_poly_()
In the case that the graph is a polytree, the function will, according to the probability p and q...
HashTable< NodeId, Potential< GUM_SCALAR > *> hashMarginal_
bool _isPolytree_()
The function that verify if graph is a polytree.
void _PMMx_multi_()
In the case that the graph is a multiconnected graph, the function will, according to the probability...
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
BayesNet< GUM_SCALAR > bayesNet_
BayesNet< GUM_SCALAR > bayesNettemp_
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ fillCPT()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
void gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::fillCPT ( )
inherited

function that insert random values in the CPT of each nodes according to the CPTGenerator.

Returns
null but modify inputed empty Bayesian network

Definition at line 62 of file IBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

62  {
63  for (auto node: bayesNet_.nodes())
64  this->generateCPT(bayesNet_.cpt(node).pos(bayesNet_.variable(node)), bayesNet_.cpt(node));
65  }
BayesNet< GUM_SCALAR > bayesNet_
+ Here is the call graph for this function:

◆ generateBN()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::generateBN ( BayesNet< GUM_SCALAR > &  bayesNet)
overridevirtual

Generates a random Bayesian network.

Parameters
bayesNetempty IBayesNet to generate.
Returns
null but modify inputed Bayesian network

Implements gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >.

Definition at line 112 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

113  {
115 
116  // this->bayesNet_ = bayesNet;
117  _createTree_(this->nbrNodes_);
118  _transformPoly_(this->nbrNodes_ / 2);
119  bayesNettemp_ = this->bayesNet_;
120  _PMMx_poly_();
121 
122  this->fillCPT();
124 
125  bayesNet = this->bayesNet_;
126  }
void fillCPT()
function that insert random values in the CPT of each nodes according to the CPTGenerator.
void _PMMx_poly_()
In the case that the graph is a polytree, the function will, according to the probability p and q...
void _createTree_(Size BNSize)
The function that randomly generate a simple tree.
void _transformPoly_(Idx nbiter)
The function that randomly change the simple tree into a polytree.
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
BayesNet< GUM_SCALAR > bayesNet_
BayesNet< GUM_SCALAR > bayesNettemp_
+ Here is the call graph for this function:

◆ iteration()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE Size gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::iteration ( ) const

Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator.

Definition at line 655 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

655  {
656  return iteration_;
657  }
+ Here is the call graph for this function:

◆ maxArcs()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
INLINE Size gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::maxArcs ( ) const
inherited

Return a constant reference to the maximum number of arcs imposed on the IBayesNetGenerator.

Definition at line 78 of file IBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

78  {
79  return maxArcs_;
80  }
+ Here is the call graph for this function:

◆ maxModality()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
INLINE Size gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::maxModality ( ) const
inherited

Return a constant reference to the maximum modality imposed on the IBayesNetGenerator.

Definition at line 68 of file IBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

68  {
69  return maxModality_;
70  }
+ Here is the call graph for this function:

◆ nbrNodes()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
INLINE Size gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::nbrNodes ( ) const
inherited

Return a constant reference to the number of nodes imposed on the IBayesNetGenerator.

Definition at line 73 of file IBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

73  {
74  return nbrNodes_;
75  }
+ Here is the call graph for this function:

◆ p()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE Idx gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::p ( ) const

Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator.

Definition at line 664 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

664  {
665  return p_;
666  }
+ Here is the call graph for this function:

◆ q()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE Idx gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::q ( ) const

Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.

Definition at line 673 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

673  {
674  return q_;
675  }
+ Here is the call graph for this function:

◆ setIteration()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setIteration ( Size  iteration)

Modifies the value of the number of iterations impose on the BayesNetGenerator.

Definition at line 683 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

683  {
685  }
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
+ Here is the call graph for this function:

◆ setMaxArcs()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
INLINE void gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::setMaxArcs ( Size  maxArcs)
inherited

Modifies the value of the number of nodes imposed on the BayesGenerator.

Definition at line 98 of file IBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

98  {
99  if (maxArcs < nbrNodes_ - 1 || maxArcs > (nbrNodes_ * (nbrNodes_ - 1)) / 2)
100  GUM_ERROR(OperationNotAllowed, " maxArcs value not possible ")
101 
102  maxArcs_ = maxArcs;
103  }
Size maxArcs() const
Return a constant reference to the maximum number of arcs imposed on the IBayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ setMaxModality()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
INLINE void gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::setMaxModality ( Size  maxModality)
inherited

Modifies the value of the number of nodes imposed on the BayesGenerator.

Definition at line 83 of file IBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

83  {
84  if (maxModality < 2)
85  GUM_ERROR(OperationNotAllowed, " maxModality must be at least equal to two ")
86 
88  }
Size maxModality() const
Return a constant reference to the maximum modality imposed on the IBayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ setNbrNodes()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
INLINE void gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::setNbrNodes ( Size  nbrNodes)
inherited

Modifies the value of the number of nodes imposed on the BayesGenerator.

Definition at line 90 of file IBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

90  {
91  if ((maxArcs_ < nbrNodes - 1) || (maxArcs_ > (nbrNodes * (nbrNodes - 1)) / 2))
92  GUM_ERROR(OperationNotAllowed, " nbrNodes value not possible ")
93 
95  }
Size nbrNodes() const
Return a constant reference to the number of nodes imposed on the IBayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ setP()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setP ( Idx  p)

Modifies the value of the probability p imposed on the BayesNetGenerator.

Definition at line 691 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

691  {
692  p_ = p;
693 
694  if (p + q_ > 100)
695  GUM_ERROR(OperationNotAllowed,
696  "the sum of the probabilities p and q must be at most equal to 100");
697  }
Idx p() const
Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ setQ()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setQ ( Idx  q)

Modifies the value of the probability q imposed on the BayesNetGenerator.

Definition at line 703 of file MCBayesNetGenerator_tpl.h.

References gum::Set< Key, Alloc >::emplace().

703  {
704  q_ = q;
705 
706  if (p_ + q > 100)
707  GUM_ERROR(OperationNotAllowed,
708  "the sum of the probabilities p and q must be at most equal to 100");
709  }
Idx q() const
Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

Member Data Documentation

◆ bayesNet_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
BayesNet< GUM_SCALAR > gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::bayesNet_
protectedinherited

Definition at line 166 of file IBayesNetGenerator.h.

◆ bayesNettemp_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator = SimpleCPTGenerator, template< typename > class ICPTDisturber = SimpleCPTDisturber>
BayesNet< GUM_SCALAR > gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::bayesNettemp_
protected

Definition at line 289 of file MCBayesNetGenerator.h.

◆ disturbing_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator = SimpleCPTGenerator, template< typename > class ICPTDisturber = SimpleCPTDisturber>
bool gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbing_
protected

Definition at line 288 of file MCBayesNetGenerator.h.

◆ hashMarginal_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator = SimpleCPTGenerator, template< typename > class ICPTDisturber = SimpleCPTDisturber>
HashTable< NodeId, Potential< GUM_SCALAR >* > gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::hashMarginal_
protected

Definition at line 290 of file MCBayesNetGenerator.h.

◆ iteration_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator = SimpleCPTGenerator, template< typename > class ICPTDisturber = SimpleCPTDisturber>
Size gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::iteration_
protected

Definition at line 286 of file MCBayesNetGenerator.h.

◆ maxArcs_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
Size gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::maxArcs_
protectedinherited

Definition at line 164 of file IBayesNetGenerator.h.

◆ maxModality_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
Size gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::maxModality_
protectedinherited

Definition at line 165 of file IBayesNetGenerator.h.

◆ nbrNodes_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
Size gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::nbrNodes_
protectedinherited

Definition at line 163 of file IBayesNetGenerator.h.

◆ p_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator = SimpleCPTGenerator, template< typename > class ICPTDisturber = SimpleCPTDisturber>
Idx gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::p_
protected

Definition at line 287 of file MCBayesNetGenerator.h.

◆ q_

template<typename GUM_SCALAR , template< typename > class ICPTGenerator = SimpleCPTGenerator, template< typename > class ICPTDisturber = SimpleCPTDisturber>
Idx gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::q_
protected

Definition at line 287 of file MCBayesNetGenerator.h.


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