aGrUM  0.14.3
gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber > Class Template Reference

maxInducedWidthMCBayesNetGenerator.h <agrum/BN/generator/SimpleMCayesNetGenerator.h> More...

#include <maxInducedWidthMCBayesNetGenerator.h>

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

Public Member Functions

Constructors / Destructor
 MaxInducedWidthMCBayesNetGenerator (Size nbrNodes, Size maxArcs, Size maxModality=2, Size maxInducedWidth=3, Idx iteration=5000, Idx p=30, Idx q=40)
 Constructor. More...
 
 MaxInducedWidthMCBayesNetGenerator (BayesNet< GUM_SCALAR > bayesNet, Size maxInducedWidth=3, Idx iteration=5000, Idx p=30, Idx q=40)
 Constructor. More...
 
 ~MaxInducedWidthMCBayesNetGenerator () final
 Destructor. More...
 
Getters
Size maxlog10InducedWidth () const
 Return a constant reference to the number of maximum parents imposed on the Markov Chain BayesNetGenerator. More...
 
Setters
void setMaxlog10InducedWidth (Size maxlog10InducedWidth)
 Modifies the value of the number of maximum parents imposed on the BayesNetGenerator. 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 _maxlog10InducedWidth
 
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 __connect (NodeId i, NodeId j, NodeSet &excluded)
 The internal function used by the previous __connect. More...
 
bool __directedPath (NodeId tail, NodeId head)
 The function that verify if there is a oriented path from node i to node j. More...
 
bool __directedPath (NodeId tail, NodeId head, NodeSet &excluded)
 The internal function used by the previous __directedPath. 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...
 
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::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >

maxInducedWidthMCBayesNetGenerator.h <agrum/BN/generator/SimpleMCayesNetGenerator.h>

Class for generating bayesian networks with Markov chains.

This class is inherited from MCBayesNetGenerator and is an example of Markov Chain Bayesian Network Generator that can be implemented. Here a constraint is added which is the maximum number of parents that nodes can have.

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.

Definition at line 73 of file maxInducedWidthMCBayesNetGenerator.h.

Constructor & Destructor Documentation

◆ MaxInducedWidthMCBayesNetGenerator() [1/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::MaxInducedWidthMCBayesNetGenerator ( Size  nbrNodes,
Size  maxArcs,
Size  maxModality = 2,
Size  maxInducedWidth = 3,
Idx  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
maxInducedWidthThe number of maximum variable allow in the cliques of the junction tree of the bayesian Network.
iterationThe number of iterations wanted to repeat the algorithm
pprobability for the change of the state (see useof p and q" )
qprobability for the change of the state (see useof p and q" )

Definition at line 47 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

References gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_maxlog10InducedWidth, and GUM_ERROR.

53  :
54  MCBG(nbrNodes, maxArcs, maxModality, iteration, p, q) {
55  if (maxInducedWidth == 0)
56  GUM_ERROR(OperationNotAllowed,
57  "maxInducedWidth must be at least equal "
58  "to 1 to have a connexe graph");
59 
60  _maxlog10InducedWidth = maxInducedWidth;
61  GUM_CONSTRUCTOR(MaxInducedWidthMCBayesNetGenerator);
62  }
MaxInducedWidthMCBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality=2, Size maxInducedWidth=3, Idx iteration=5000, Idx p=30, Idx q=40)
Constructor.
Size nbrNodes() const
Return a constant reference to the number of nodes imposed on the IBayesNetGenerator.
Size maxArcs() const
Return a constant reference to the maximum number of arcs imposed on the IBayesNetGenerator.
Size maxModality() const
Return a constant reference to the maximum modality imposed on the IBayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ MaxInducedWidthMCBayesNetGenerator() [2/2]

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::MaxInducedWidthMCBayesNetGenerator ( BayesNet< GUM_SCALAR >  bayesNet,
Size  maxInducedWidth = 3,
Idx  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
maxInducedWidthThe number of maximum variable allow in the cliques of the junction tree of the bayesian Network.
iterationThe number of iterations wanted to repeat the algorithm
pprobability for the change of the state (see useof p and q" )
qprobability for the change of the state (see useof p and q" )

Definition at line 72 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

References gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_maxlog10InducedWidth.

76  :
77  MCBG(bayesNet, iteration, p, q) {
78  _maxlog10InducedWidth = maxInducedWidth;
79  GUM_CONSTRUCTOR(MaxInducedWidthMCBayesNetGenerator);
80  }
MaxInducedWidthMCBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality=2, Size maxInducedWidth=3, Idx iteration=5000, Idx p=30, Idx q=40)
Constructor.

◆ ~MaxInducedWidthMCBayesNetGenerator()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::~MaxInducedWidthMCBayesNetGenerator ( )
final

Destructor.

Definition at line 105 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

105  {
106  GUM_DESTRUCTOR(MaxInducedWidthMCBayesNetGenerator);
107  // delete BayesNetGenerator<GUM_SCALAR>::_cptGenerator;
108  }
MaxInducedWidthMCBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality=2, Size maxInducedWidth=3, Idx iteration=5000, Idx p=30, Idx q=40)
Constructor.

Member Function Documentation

◆ __AorR()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
void gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR ( )
protectedinherited

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

Definition at line 292 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__eraseArc(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__insertArc(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, and gum::ArcGraphPart::existsArc().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_multi(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly().

292  {
293  NodeId i, j;
294  __chooseNodes(i, j);
295  const DAG __dag = this->_bayesNet.dag();
296 
297  if (__dag.existsArc(i, j)) {
298  __eraseArc(i, j);
299 
300  return;
301  } else
302  __insertArc(i, j);
303  }
BayesNet< GUM_SCALAR > _bayesNet
void __chooseNodes(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
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 __eraseArc(NodeId i, NodeId j, bool mustbeconnex=true)
The function that will remove the arc between node i and node j.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:
+ Here is the caller 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 ( )
protectedinherited

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

Definition at line 310 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_poly(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::ArcGraphPart::children(), gum::ArcGraphPart::existsArc(), gum::Set< Key, Alloc >::insert(), gum::ArcGraphPart::parents(), and gum::randomValue().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly().

310  {
311  NodeId i, j, head, tail;
312  __chooseNodes(i, j);
313  const DAG __dag = this->_bayesNet.dag();
314 
315  if (__dag.existsArc(i, j) || __dag.existsArc(j, i)) {
316  return;
317  } else {
318  Idx per = randomValue(100);
319 
320  if (per < 50) {
321  head = i;
322  tail = j;
323  } else {
324  head = j;
325  tail = i;
326  }
327 
328  for (auto node : __dag.parents(j)) {
329  NodeSet excluded;
330  excluded.insert(j);
331 
332  if (__connect(node, i, excluded)) {
333  this->_bayesNet.eraseArc(node, j); // TODO reflect
334  this->_bayesNet.addArc(head, tail);
335  return;
336  }
337  }
338 
339  for (auto node : __dag.children(j)) {
340  NodeSet excluded;
341  excluded.insert(j);
342 
343  if (__connect(node, i, excluded)) {
344  this->_bayesNet.eraseArc(j, node);
345  this->_bayesNet.addArc(head, tail);
346  return;
347  }
348  }
349  }
350  }
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 ...
bool __connect(NodeId i, NodeId j)
The function that verify if node i and j are connected.
BayesNet< GUM_SCALAR > _bayesNet
void __chooseNodes(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
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:610
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __checkConditions()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
bool gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions ( )
finalprivatevirtual

function to holding the the specification wanted for the Bayesian markov.

Returns
boolean state that verify the conditions

Reimplemented from gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >.

Definition at line 117 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_maxlog10InducedWidth, gum::HashTable< Key, Val, Alloc >::insert(), and gum::Triangulation::maxLog10CliqueDomainSize().

117  {
118  NodeProperty< Size > __modalitiesMap;
119 
120  for (auto node : this->_bayesNet.nodes())
121  __modalitiesMap.insert(node, this->_bayesNet.variable(node).domainSize());
122 
123  DefaultTriangulation tri(&(this->_bayesNet.moralGraph()), &__modalitiesMap);
124 
125  if (tri.maxLog10CliqueDomainSize() > _maxlog10InducedWidth) return false;
126 
127  return MCBG::__checkConditions();
128  }
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 
)
protectedinherited

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

Definition at line 446 of file MCBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, GUM_ERROR, and gum::randomValue().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseNodes(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__transformPoly().

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

The function that randomly choose two nodes of the graph.

Definition at line 432 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseCloseNodes(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, and gum::randomValue().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__eraseArc(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_multi(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_poly().

432  {
433  i = randomValue(this->_bayesNet.size());
434  j = randomValue(this->_bayesNet.size());
435 
436  while (i == j)
437  j = randomValue(this->_bayesNet.size());
438  }
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:
+ Here is the caller 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 
)
protectedinherited

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

Definition at line 560 of file MCBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::ArcGraphPart::children(), gum::Set< Key, Alloc >::exists(), gum::ArcGraphPart::existsArc(), gum::Set< Key, Alloc >::insert(), and gum::ArcGraphPart::parents().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__eraseArc().

561  {
562  const DAG __dag = this->_bayesNet.dag();
563 
564  if (__dag.existsArc(i, j) || __dag.existsArc(j, i))
565  return true;
566  else {
567  NodeSet excluded;
568  excluded.insert(i);
569 
570  for (auto par : __dag.parents(i)) {
571  if (!excluded.exists(par) && __connect(par, j, excluded)) return true;
572  }
573 
574  for (auto chi : __dag.children(i)) {
575  if (!excluded.exists(chi) && __connect(chi, j, excluded)) return true;
576  }
577 
578  return false;
579  }
580  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
bool __connect(NodeId i, NodeId j)
The function that verify if node i and j are connected.
BayesNet< GUM_SCALAR > _bayesNet
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:610
+ Here is the call graph for this function:
+ Here is the caller 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 
)
protectedinherited

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 587 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::ArcGraphPart::children(), gum::Set< Key, Alloc >::exists(), gum::ArcGraphPart::existsArc(), gum::Set< Key, Alloc >::insert(), and gum::ArcGraphPart::parents().

588  {
589  const DAG __dag = this->_bayesNet.dag();
590 
591  if (__dag.existsArc(i, j) || __dag.existsArc(j, i))
592  return true;
593  else {
594  excluded.insert(i);
595 
596  for (auto par : __dag.parents(i)) {
597  if (!excluded.exists(par) && __connect(par, j, excluded)) return true;
598  }
599 
600  for (auto chi : __dag.children(i)) {
601  if (!excluded.exists(chi) && __connect(chi, j, excluded)) return true;
602  }
603 
604  return false;
605  }
606  }
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 
)
protectedinherited

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

n : id number for node label

Definition at line 506 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__transformPoly(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_maxModality, and gum::randomValue().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__createTree().

506  {
507  Size nb_mod = 2 + randomValue(this->_maxModality - 1);
508  std::stringstream strBuff;
509  strBuff << "n_" << n++;
510  NodeId root =
511  this->_bayesNet.add(LabelizedVariable(strBuff.str(), "", nb_mod));
512  Size maxNodes = BNSize - 1;
513  Size SubG = 0;
514 
515  while (maxNodes) {
516  SubG = randomValue(maxNodes) + 1;
517  maxNodes = maxNodes - SubG;
518  NodeId rootS = __createPartTree(SubG, n);
519  this->_bayesNet.addArc(root, rootS);
520  }
521 
522  return root;
523  }
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
BayesNet< GUM_SCALAR > _bayesNet
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:45
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:
+ Here is the caller 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)
protectedinherited

The function that randomly generate a simple tree.

Definition at line 481 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__createPartTree(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_maxModality, and gum::randomValue().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::generateBN().

482  {
483  Idx n = 0;
484  Size nb_mod = 2 + randomValue(this->_maxModality - 1);
485  std::stringstream strBuff;
486  strBuff << "n_" << n++;
487  NodeId root =
488  this->_bayesNet.add(LabelizedVariable(strBuff.str(), "", nb_mod));
489  Size maxNodes = BNSize - 1;
490  Size SubG = 0;
491 
492  while (maxNodes) {
493  SubG = randomValue(maxNodes) + 1;
494  maxNodes = maxNodes - SubG;
495  NodeId rootS = __createPartTree(SubG, n);
496  this->_bayesNet.addArc(root, rootS);
497  }
498  }
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
BayesNet< GUM_SCALAR > _bayesNet
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:45
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:
+ Here is the caller 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 
)
protectedinherited

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

Definition at line 614 of file MCBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::ArcGraphPart::children(), gum::ArcGraphPart::existsArc(), and gum::Set< Key, Alloc >::insert().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__insertArc().

614  {
615  const DAG __dag = this->_bayesNet.dag();
616 
617  if (__dag.existsArc(tail, head))
618  return true;
619  else {
620  NodeSet excluded;
621  excluded.insert(tail);
622 
623  for (auto node : __dag.children(tail)) {
624  if (__directedPath(node, head, excluded)) return true;
625  }
626 
627  return false;
628  }
629  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
BayesNet< GUM_SCALAR > _bayesNet
bool __directedPath(NodeId tail, NodeId head)
The function that verify if there is a oriented path from node i to node j.
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:610
+ Here is the call graph for this function:
+ Here is the caller 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 
)
protectedinherited

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 637 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::ArcGraphPart::children(), gum::Set< Key, Alloc >::exists(), gum::ArcGraphPart::existsArc(), and gum::Set< Key, Alloc >::insert().

637  {
638  const DAG __dag = this->_bayesNet.dag();
639 
640  if (__dag.existsArc(tail, head))
641  return true;
642  else {
643  excluded.insert(tail);
644 
645  for (auto node : __dag.children(tail)) {
646  if (!excluded.exists(node) && __directedPath(node, head, excluded))
647  return true;
648  }
649 
650  return false;
651  }
652  }
BayesNet< GUM_SCALAR > _bayesNet
bool __directedPath(NodeId tail, NodeId head)
The function that verify if there is a oriented path from node i to node j.
+ 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 
)
protectedinherited

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 405 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_disturbing, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_hashMarginal, and gum::MultiDimContainer< GUM_SCALAR >::copy().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_multi(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__transformPoly().

406  {
407  if (_disturbing) {
408  const BayesNet< GUM_SCALAR > bayesNet(this->_bayesNet);
409  Potential< GUM_SCALAR > potj;
410  potj.copy(this->_bayesNet.cpt(j));
411  this->_bayesNet.eraseArc(i, j);
412 
413  if (__connect(i, j) || !mustbeconnex) {
414  auto marg = *_hashMarginal[i];
415 
416  this->disturbReducCPT(j, this->_bayesNet, potj, marg);
417  } else
418  this->_bayesNet.addArc(i, j);
419  } else {
420  this->_bayesNet.eraseArc(i, j);
421 
422  if (!__connect(i, j) && mustbeconnex) { this->_bayesNet.addArc(i, j); }
423  }
424  }
bool __connect(NodeId i, NodeId j)
The function that verify if node i and j are connected.
BayesNet< GUM_SCALAR > _bayesNet
HashTable< NodeId, Potential< GUM_SCALAR > *> _hashMarginal
+ Here is the call graph for this function:
+ Here is the caller 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 
)
protectedinherited

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 386 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_disturbing.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_poly().

387  {
388  if (__directedPath(j, i)) return;
389 
390  if (_disturbing) {
391  auto potj = this->_bayesNet.cpt(j);
392  this->_bayesNet.addArc(i, j);
393 
394  this->disturbAugmCPT(j, this->_bayesNet, potj, (GUM_SCALAR)0.5);
395  } else
396  this->_bayesNet.addArc(i, j);
397  }
BayesNet< GUM_SCALAR > _bayesNet
bool __directedPath(NodeId tail, NodeId head)
The function that verify if there is a oriented path from node i to node j.
+ Here is the call graph for this function:
+ Here is the caller 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 ( )
protectedinherited

The function that verify if graph is a polytree.

Definition at line 550 of file MCBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_multi(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__transformPoly(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN().

550  {
551  const DAG __dag = this->_bayesNet.dag();
552  return this->_bayesNet.size() - 1 == this->_bayesNet.sizeArcs();
553  }
BayesNet< GUM_SCALAR > _bayesNet
+ Here is the caller 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 ( )
protectedinherited

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 372 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__eraseArc(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, and gum::ArcGraphPart::existsArc().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_poly(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_multi().

372  {
373  NodeId i, j;
374  __chooseNodes(i, j);
375  const DAG __dag = this->_bayesNet.dag();
376 
377  if (__dag.existsArc(i, j)) { __eraseArc(i, j); }
378  }
BayesNet< GUM_SCALAR > _bayesNet
void __chooseNodes(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
void __eraseArc(NodeId i, NodeId j, bool mustbeconnex=true)
The function that will remove the arc between node i and node j.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:
+ Here is the caller 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 ( )
protectedinherited

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 358 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__insertArc(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_multi(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, and gum::ArcGraphPart::existsArc().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly().

358  {
359  NodeId i, j;
360  __chooseNodes(i, j);
361  const DAG __dag = this->_bayesNet.dag();
362 
363  if (!__dag.existsArc(i, j)) __insertArc(i, j);
364  }
BayesNet< GUM_SCALAR > _bayesNet
void __chooseNodes(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
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...
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:
+ Here is the caller 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 ( )
protectedinherited

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 244 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__isPolytree(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_multi(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_bayesNettemp, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_iteration, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_p, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_q, and gum::randomValue().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN().

244  {
245  if (!_iteration--) return;
246 
247  Idx per = randomValue(100);
248 
249  if (per < _p + _q) {
250  __AorR();
251 
252  if (__checkConditions()) {
253  if (__isPolytree()) {
254  if (per < _p) {
255  _bayesNettemp = this->_bayesNet;
256  __PMMx_poly();
257  } else {
258  this->_bayesNet = _bayesNettemp;
259  __PMMx_multi();
260  }
261  } else {
262  _bayesNettemp = this->_bayesNet;
263  __PMMx_multi();
264  }
265  } else {
266  this->_bayesNet = _bayesNettemp;
267  __PMMx_multi();
268  }
269  } else {
270  __jump_multi();
271 
272  if (__checkConditions()) {
273  _bayesNettemp = this->_bayesNet;
274 
275  if (__isPolytree())
276  __PMMx_poly();
277  else
278  __PMMx_multi(); // TODO verification required
279 
280  } else {
281  this->_bayesNet = _bayesNettemp;
282  __PMMx_multi();
283  }
284  }
285  }
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...
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
void __jump_multi()
In the case that the graph is a multiconnect graph, the function will choose randomly two nodes and w...
bool __isPolytree()
The function that verify if graph is a polytree.
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 __remov...
void __PMMx_multi()
In the case that the graph is a multiconnected graph, the function will, according to the probability...
+ Here is the call graph for this function:
+ Here is the caller 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 ( )
protectedinherited

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 198 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_poly(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_multi(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_bayesNettemp, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_iteration, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_p, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_q, and gum::randomValue().

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_multi(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::generateBN().

198  {
199  if (!_iteration--) return;
200 
201  Idx per = randomValue(100);
202 
203  if (per < _p) {
204  __AorR();
205 
206  if (__checkConditions()) {
207  _bayesNettemp = this->_bayesNet;
208  __PMMx_multi();
209  } else {
210  this->_bayesNet = _bayesNettemp;
211  __PMMx_poly();
212  }
213  } else {
214  if (per < _p + _q) {
215  __AR();
216 
217  if (!__checkConditions()) {
218  this->_bayesNet = _bayesNettemp;
219  } else
220  _bayesNettemp = this->_bayesNet;
221 
222  __PMMx_poly();
223  } else {
224  __jump_poly();
225 
226  if (__checkConditions()) {
227  _bayesNettemp = this->_bayesNet;
228  __PMMx_multi();
229 
230  } else {
231  this->_bayesNet = _bayesNettemp;
232  __PMMx_poly();
233  }
234  }
235  }
236  }
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...
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
BayesNet< GUM_SCALAR > _bayesNet
BayesNet< GUM_SCALAR > _bayesNettemp
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...
void __AR()
The function will remove and add a random arc changing the topology of the graph but asserting its co...
void __AorR()
The function will add or remove a random arc in the graph using the functions __insertArc and __remov...
void __PMMx_multi()
In the case that the graph is a multiconnected graph, the function will, according to the probability...
+ Here is the call graph for this function:
+ Here is the caller 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)
protectedinherited

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

Definition at line 532 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseCloseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__eraseArc(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__isPolytree(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_bayesNettemp.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__createPartTree(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::generateBN().

532  {
533  while (nbiter--) {
534  NodeId i, j;
535  __chooseCloseNodes(i, j);
536  _bayesNettemp = this->_bayesNet;
537  __eraseArc(i, j, false);
538  this->_bayesNet.addArc(j, i);
539 
540  if (!__checkConditions()) this->_bayesNet = _bayesNettemp;
541  }
542  }
virtual bool __checkConditions()
The boolean function that will assert the respect of the constraint.
BayesNet< GUM_SCALAR > _bayesNet
BayesNet< GUM_SCALAR > _bayesNettemp
void __eraseArc(NodeId i, NodeId j, bool mustbeconnex=true)
The function that will remove the arc between node i and node j.
void __chooseCloseNodes(NodeId &i, NodeId &j)
The function that randomly choose two neighbours nodes of the graph.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:
+ Here is the caller 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 
)
inherited

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::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__isPolytree(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_multi(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_bayesNettemp, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_disturbing, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_hashMarginal, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_iteration, gum::MultiDimContainer< GUM_SCALAR >::copy(), GUM_ERROR, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::iteration(), gum::BayesNetInference< GUM_SCALAR >::makeInference(), gum::DAGmodel::nodes(), and gum::JointTargetedInference< GUM_SCALAR >::posterior().

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(
166  _hashMarginal.beginSafe()); // safe iterator needed here.
167  }
168 
169  } else {
170  std::cout << this->_bayesNet.toDot() << std::endl;
171  GUM_ERROR(OperationNotAllowed,
172  "BN is not valid cause it does not respect constraint ");
173  }
174 
175  _iteration = iter;
176  _disturbing = false;
177  }
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...
bool __isPolytree()
The function that verify if graph is a polytree.
BayesNet< GUM_SCALAR > _bayesNet
BayesNet< GUM_SCALAR > _bayesNettemp
Size iteration() const
Return a constant reference to the number of iteration imposed on the Markov Chain BayesNetGenerator...
void __PMMx_multi()
In the case that the graph is a multiconnected graph, the function will, according to the probability...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
HashTable< NodeId, Potential< GUM_SCALAR > *> _hashMarginal
+ 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 61 of file IBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet.

Referenced by gum::SimpleBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::generateBN(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::generateBN().

61  {
62  for (auto node : _bayesNet.nodes())
63  this->generateCPT(_bayesNet.cpt(node).pos(_bayesNet.variable(node)),
64  _bayesNet.cpt(node)); // TODO ASSERT THE LINE
65  }
BayesNet< GUM_SCALAR > _bayesNet
+ Here is the caller 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)
overridevirtualinherited

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::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__createTree(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__transformPoly(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_bayesNettemp, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_iteration, gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_nbrNodes, gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::fillCPT(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::iteration().

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 __PMMx_poly()
In the case that the graph is a polytree, the function will, according to the probability p and q...
void fillCPT()
function that insert random values in the CPT of each nodes according to the CPTGenerator.
BayesNet< GUM_SCALAR > _bayesNet
BayesNet< GUM_SCALAR > _bayesNettemp
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...
void __createTree(Size BNSize)
The function that randomly generate a simple tree.
+ 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
inherited

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

Definition at line 660 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_iteration.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::generateBN(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::MCBayesNetGenerator(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setIteration().

661  {
662  return _iteration;
663  }
+ Here is the caller 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 79 of file IBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_maxArcs.

Referenced by gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::IBayesNetGenerator(), and gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::setMaxArcs().

79  {
80  return _maxArcs;
81  }
+ Here is the caller graph for this function:

◆ maxlog10InducedWidth()

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

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

Definition at line 138 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

References gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_maxlog10InducedWidth.

Referenced by gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setMaxlog10InducedWidth().

+ Here is the caller 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 69 of file IBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_maxModality.

Referenced by gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::IBayesNetGenerator(), and gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::setMaxModality().

69  {
70  return _maxModality;
71  }
+ Here is the caller 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 74 of file IBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_nbrNodes.

Referenced by gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::IBayesNetGenerator(), and gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::setNbrNodes().

74  {
75  return _nbrNodes;
76  }
+ Here is the caller 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
inherited

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

Definition at line 671 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_p.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::MCBayesNetGenerator(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setP().

671  {
672  return _p;
673  }
+ Here is the caller 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
inherited

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

Definition at line 681 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_q.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::MCBayesNetGenerator(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setQ().

681  {
682  return _q;
683  }
+ Here is the caller 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)
inherited

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

Definition at line 691 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_iteration, and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::iteration().

692  {
694  }
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 103 of file IBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_maxArcs, gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_nbrNodes, GUM_ERROR, and gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::maxArcs().

103  {
104  if (maxArcs < _nbrNodes - 1 || maxArcs > (_nbrNodes * (_nbrNodes - 1)) / 2)
105  GUM_ERROR(OperationNotAllowed, " maxArcs value not possible ");
106 
107  _maxArcs = maxArcs;
108  }
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:52
+ Here is the call graph for this function:

◆ setMaxlog10InducedWidth()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator, template< typename > class ICPTDisturber>
INLINE void gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::setMaxlog10InducedWidth ( Size  maxlog10InducedWidth)

Modifies the value of the number of maximum parents imposed on the BayesNetGenerator.

Definition at line 150 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

References gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_maxlog10InducedWidth, GUM_ERROR, and gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::maxlog10InducedWidth().

150  {
151  if (maxlog10InducedWidth == 0)
152  GUM_ERROR(OperationNotAllowed,
153  "maxInducedWidth must be at least equal "
154  "to 1 to have a connexe graph");
155 
157  }
Size maxlog10InducedWidth() const
Return a constant reference to the number of maximum parents imposed on the Markov Chain BayesNetGene...
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 84 of file IBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_maxModality, GUM_ERROR, and gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::maxModality().

85  {
86  if (maxModality < 2)
87  GUM_ERROR(OperationNotAllowed,
88  " maxModality must be at least equal to two ");
89 
91  }
Size maxModality() const
Return a constant reference to the maximum modality imposed on the IBayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 94 of file IBayesNetGenerator_tpl.h.

References gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_maxArcs, gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_nbrNodes, GUM_ERROR, and gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::nbrNodes().

94  {
95  if ((_maxArcs < nbrNodes - 1) || (_maxArcs > (nbrNodes * (nbrNodes - 1)) / 2))
96  GUM_ERROR(OperationNotAllowed, " nbrNodes value not possible ");
97 
99  }
Size nbrNodes() const
Return a constant reference to the number of nodes imposed on the IBayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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)
inherited

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

Definition at line 701 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_p, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_q, GUM_ERROR, and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::p().

701  {
702  _p = p;
703 
704  if (p + _q > 100)
705  GUM_ERROR(
706  OperationNotAllowed,
707  "the sum of the probabilities p and q must be at most equal to 100");
708  }
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:52
+ 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)
inherited

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

Definition at line 715 of file MCBayesNetGenerator_tpl.h.

References gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_p, gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::_q, GUM_ERROR, and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::q().

715  {
716  _q = q;
717 
718  if (_p + q > 100)
719  GUM_ERROR(
720  OperationNotAllowed,
721  "the sum of the probabilities p and q must be at most equal to 100");
722  }
Idx q() const
Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 165 of file IBayesNetGenerator.h.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::MaxInducedWidthMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MaxParentsMCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__checkConditions(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseCloseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__chooseNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__createPartTree(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__createTree(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__eraseArc(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__insertArc(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__isPolytree(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_multi(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_poly(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_multi(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__PMMx_poly(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__transformPoly(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN(), gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::fillCPT(), gum::SimpleBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::generateBN(), and gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::generateBN().

◆ _bayesNettemp

◆ _disturbing

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

◆ _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
protectedinherited

◆ _iteration

◆ _maxArcs

◆ _maxlog10InducedWidth

◆ _maxModality

◆ _nbrNodes

◆ _p

◆ _q


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