aGrUM  0.16.0
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 76 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 50 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

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

56  :
57  MCBG(nbrNodes, maxArcs, maxModality, iteration, p, q) {
58  if (maxInducedWidth == 0)
59  GUM_ERROR(OperationNotAllowed,
60  "maxInducedWidth must be at least equal "
61  "to 1 to have a connexe graph");
62 
63  _maxlog10InducedWidth = maxInducedWidth;
64  GUM_CONSTRUCTOR(MaxInducedWidthMCBayesNetGenerator);
65  }
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:55

◆ 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 75 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

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

79  :
80  MCBG(bayesNet, iteration, p, q) {
81  _maxlog10InducedWidth = maxInducedWidth;
82  GUM_CONSTRUCTOR(MaxInducedWidthMCBayesNetGenerator);
83  }
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 108 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

108  {
109  GUM_DESTRUCTOR(MaxInducedWidthMCBayesNetGenerator);
110  // delete BayesNetGenerator<GUM_SCALAR>::_cptGenerator;
111  }
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 295 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().

295  {
296  NodeId i, j;
297  __chooseNodes(i, j);
298  const DAG __dag = this->_bayesNet.dag();
299 
300  if (__dag.existsArc(i, j)) {
301  __eraseArc(i, j);
302 
303  return;
304  } else
305  __insertArc(i, j);
306  }
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:98
+ 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 313 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().

313  {
314  NodeId i, j, head, tail;
315  __chooseNodes(i, j);
316  const DAG __dag = this->_bayesNet.dag();
317 
318  if (__dag.existsArc(i, j) || __dag.existsArc(j, i)) {
319  return;
320  } else {
321  Idx per = randomValue(100);
322 
323  if (per < 50) {
324  head = i;
325  tail = j;
326  } else {
327  head = j;
328  tail = i;
329  }
330 
331  for (auto node : __dag.parents(j)) {
332  NodeSet excluded;
333  excluded.insert(j);
334 
335  if (__connect(node, i, excluded)) {
336  this->_bayesNet.eraseArc(node, j); // TODO reflect
337  this->_bayesNet.addArc(head, tail);
338  return;
339  }
340  }
341 
342  for (auto node : __dag.children(j)) {
343  NodeSet excluded;
344  excluded.insert(j);
345 
346  if (__connect(node, i, excluded)) {
347  this->_bayesNet.eraseArc(j, node);
348  this->_bayesNet.addArc(head, tail);
349  return;
350  }
351  }
352  }
353  }
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:98
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
+ 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 120 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().

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

449  {
450  NodeId temp = randomValue(this->_bayesNet.size());
451  Size co = 0;
452 
453  if (this->_bayesNet.parents(temp).size()) {
454  j = temp;
455  auto it = this->_bayesNet.parents(j).begin();
456  co = randomValue(this->_bayesNet.parents(j).size());
457 
458  while (co--) {
459  ++it;
460  }
461 
462  i = *it;
463  } else if (this->_bayesNet.children(temp).size()) {
464  i = temp;
465  auto it = this->_bayesNet.children(i).begin();
466  co = randomValue(this->_bayesNet.children(i).size());
467 
468  while (co--) {
469  ++it;
470  }
471 
472  j = *it;
473  } else {
474  GUM_ERROR(FatalError, "Sorry Misconstructed BN because of isolated node.");
475  }
476  }
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:48
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ 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 435 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().

435  {
436  i = randomValue(this->_bayesNet.size());
437  j = randomValue(this->_bayesNet.size());
438 
439  while (i == j)
440  j = randomValue(this->_bayesNet.size());
441  }
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 563 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().

564  {
565  const DAG __dag = this->_bayesNet.dag();
566 
567  if (__dag.existsArc(i, j) || __dag.existsArc(j, i))
568  return true;
569  else {
570  NodeSet excluded;
571  excluded.insert(i);
572 
573  for (auto par : __dag.parents(i)) {
574  if (!excluded.exists(par) && __connect(par, j, excluded)) return true;
575  }
576 
577  for (auto chi : __dag.children(i)) {
578  if (!excluded.exists(chi) && __connect(chi, j, excluded)) return true;
579  }
580 
581  return false;
582  }
583  }
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:613
+ 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 590 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().

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

509  {
510  Size nb_mod = 2 + randomValue(this->_maxModality - 1);
511  std::stringstream strBuff;
512  strBuff << "n_" << n++;
513  NodeId root =
514  this->_bayesNet.add(LabelizedVariable(strBuff.str(), "", nb_mod));
515  Size maxNodes = BNSize - 1;
516  Size SubG = 0;
517 
518  while (maxNodes) {
519  SubG = randomValue(maxNodes) + 1;
520  maxNodes = maxNodes - SubG;
521  NodeId rootS = __createPartTree(SubG, n);
522  this->_bayesNet.addArc(root, rootS);
523  }
524 
525  return root;
526  }
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:48
Size NodeId
Type for node ids.
Definition: graphElements.h:98
+ 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 484 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().

485  {
486  Idx n = 0;
487  Size nb_mod = 2 + randomValue(this->_maxModality - 1);
488  std::stringstream strBuff;
489  strBuff << "n_" << n++;
490  NodeId root =
491  this->_bayesNet.add(LabelizedVariable(strBuff.str(), "", nb_mod));
492  Size maxNodes = BNSize - 1;
493  Size SubG = 0;
494 
495  while (maxNodes) {
496  SubG = randomValue(maxNodes) + 1;
497  maxNodes = maxNodes - SubG;
498  NodeId rootS = __createPartTree(SubG, n);
499  this->_bayesNet.addArc(root, rootS);
500  }
501  }
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:48
Size NodeId
Type for node ids.
Definition: graphElements.h:98
+ 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 617 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().

617  {
618  const DAG __dag = this->_bayesNet.dag();
619 
620  if (__dag.existsArc(tail, head))
621  return true;
622  else {
623  NodeSet excluded;
624  excluded.insert(tail);
625 
626  for (auto node : __dag.children(tail)) {
627  if (__directedPath(node, head, excluded)) return true;
628  }
629 
630  return false;
631  }
632  }
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:613
+ 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 640 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().

640  {
641  const DAG __dag = this->_bayesNet.dag();
642 
643  if (__dag.existsArc(tail, head))
644  return true;
645  else {
646  excluded.insert(tail);
647 
648  for (auto node : __dag.children(tail)) {
649  if (!excluded.exists(node) && __directedPath(node, head, excluded))
650  return true;
651  }
652 
653  return false;
654  }
655  }
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 408 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().

409  {
410  if (_disturbing) {
411  const BayesNet< GUM_SCALAR > bayesNet(this->_bayesNet);
412  Potential< GUM_SCALAR > potj;
413  potj.copy(this->_bayesNet.cpt(j));
414  this->_bayesNet.eraseArc(i, j);
415 
416  if (__connect(i, j) || !mustbeconnex) {
417  auto marg = *_hashMarginal[i];
418 
419  this->disturbReducCPT(j, this->_bayesNet, potj, marg);
420  } else
421  this->_bayesNet.addArc(i, j);
422  } else {
423  this->_bayesNet.eraseArc(i, j);
424 
425  if (!__connect(i, j) && mustbeconnex) { this->_bayesNet.addArc(i, j); }
426  }
427  }
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 389 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().

390  {
391  if (__directedPath(j, i)) return;
392 
393  if (_disturbing) {
394  auto potj = this->_bayesNet.cpt(j);
395  this->_bayesNet.addArc(i, j);
396 
397  this->disturbAugmCPT(j, this->_bayesNet, potj, (GUM_SCALAR)0.5);
398  } else
399  this->_bayesNet.addArc(i, j);
400  }
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 553 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().

553  {
554  const DAG __dag = this->_bayesNet.dag();
555  return this->_bayesNet.size() - 1 == this->_bayesNet.sizeArcs();
556  }
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 375 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().

375  {
376  NodeId i, j;
377  __chooseNodes(i, j);
378  const DAG __dag = this->_bayesNet.dag();
379 
380  if (__dag.existsArc(i, j)) { __eraseArc(i, j); }
381  }
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:98
+ 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 361 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().

361  {
362  NodeId i, j;
363  __chooseNodes(i, j);
364  const DAG __dag = this->_bayesNet.dag();
365 
366  if (!__dag.existsArc(i, j)) __insertArc(i, j);
367  }
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:98
+ 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 247 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().

247  {
248  if (!_iteration--) return;
249 
250  Idx per = randomValue(100);
251 
252  if (per < _p + _q) {
253  __AorR();
254 
255  if (__checkConditions()) {
256  if (__isPolytree()) {
257  if (per < _p) {
258  _bayesNettemp = this->_bayesNet;
259  __PMMx_poly();
260  } else {
261  this->_bayesNet = _bayesNettemp;
262  __PMMx_multi();
263  }
264  } else {
265  _bayesNettemp = this->_bayesNet;
266  __PMMx_multi();
267  }
268  } else {
269  this->_bayesNet = _bayesNettemp;
270  __PMMx_multi();
271  }
272  } else {
273  __jump_multi();
274 
275  if (__checkConditions()) {
276  _bayesNettemp = this->_bayesNet;
277 
278  if (__isPolytree())
279  __PMMx_poly();
280  else
281  __PMMx_multi(); // TODO verification required
282 
283  } else {
284  this->_bayesNet = _bayesNettemp;
285  __PMMx_multi();
286  }
287  }
288  }
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 201 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().

201  {
202  if (!_iteration--) return;
203 
204  Idx per = randomValue(100);
205 
206  if (per < _p) {
207  __AorR();
208 
209  if (__checkConditions()) {
210  _bayesNettemp = this->_bayesNet;
211  __PMMx_multi();
212  } else {
213  this->_bayesNet = _bayesNettemp;
214  __PMMx_poly();
215  }
216  } else {
217  if (per < _p + _q) {
218  __AR();
219 
220  if (!__checkConditions()) {
221  this->_bayesNet = _bayesNettemp;
222  } else
223  _bayesNettemp = this->_bayesNet;
224 
225  __PMMx_poly();
226  } else {
227  __jump_poly();
228 
229  if (__checkConditions()) {
230  _bayesNettemp = this->_bayesNet;
231  __PMMx_multi();
232 
233  } else {
234  this->_bayesNet = _bayesNettemp;
235  __PMMx_poly();
236  }
237  }
238  }
239  }
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 535 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().

535  {
536  while (nbiter--) {
537  NodeId i, j;
538  __chooseCloseNodes(i, j);
539  _bayesNettemp = this->_bayesNet;
540  __eraseArc(i, j, false);
541  this->_bayesNet.addArc(j, i);
542 
543  if (!__checkConditions()) this->_bayesNet = _bayesNettemp;
544  }
545  }
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:98
+ 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 137 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().

139  { // insert option for the variation
140  _disturbing = true;
141  Size iter = _iteration;
142 
144 
145  this->_bayesNet = bayesNetinit;
146 
147  if (__checkConditions()) {
148  LazyPropagation< GUM_SCALAR > inf(&bayesNetinit);
149  inf.makeInference();
150 
151  for (auto node : bayesNetinit.nodes()) {
152  auto pottemp = new Potential< GUM_SCALAR >();
153  pottemp->copy(inf.posterior(node));
154  _hashMarginal.insert(node, pottemp);
155  }
156 
157  _bayesNettemp = this->_bayesNet;
158 
159  if (__isPolytree())
160  __PMMx_poly();
161  else
162  __PMMx_multi();
163 
164  bayesNetinit = (this->_bayesNet);
165 
166  while (_hashMarginal.size()) {
167  delete (_hashMarginal.begin().val());
168  _hashMarginal.erase(
169  _hashMarginal.beginSafe()); // safe iterator needed here.
170  }
171 
172  } else {
173  std::cout << this->_bayesNet.toDot() << std::endl;
174  GUM_ERROR(OperationNotAllowed,
175  "BN is not valid cause it does not respect constraint ");
176  }
177 
178  _iteration = iter;
179  _disturbing = false;
180  }
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:48
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
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 64 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().

64  {
65  for (auto node : _bayesNet.nodes())
66  this->generateCPT(_bayesNet.cpt(node).pos(_bayesNet.variable(node)),
67  _bayesNet.cpt(node)); // TODO ASSERT THE LINE
68  }
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 115 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().

116  {
118 
119  // this->_bayesNet = bayesNet;
120  __createTree(this->_nbrNodes);
121  __transformPoly(this->_nbrNodes / 2);
122  _bayesNettemp = this->_bayesNet;
123  __PMMx_poly();
124 
125  this->fillCPT();
127 
128  bayesNet = this->_bayesNet;
129  }
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 663 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().

664  {
665  return _iteration;
666  }
+ 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 82 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().

82  {
83  return _maxArcs;
84  }
+ 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 141 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 72 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().

72  {
73  return _maxModality;
74  }
+ 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 77 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().

77  {
78  return _nbrNodes;
79  }
+ 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 674 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().

674  {
675  return _p;
676  }
+ 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 684 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().

684  {
685  return _q;
686  }
+ 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 694 of file MCBayesNetGenerator_tpl.h.

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

695  {
697  }
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 106 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().

106  {
107  if (maxArcs < _nbrNodes - 1 || maxArcs > (_nbrNodes * (_nbrNodes - 1)) / 2)
108  GUM_ERROR(OperationNotAllowed, " maxArcs value not possible ");
109 
110  _maxArcs = maxArcs;
111  }
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:55
+ 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 153 of file maxInducedWidthMCBayesNetGenerator_tpl.h.

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

153  {
154  if (maxlog10InducedWidth == 0)
155  GUM_ERROR(OperationNotAllowed,
156  "maxInducedWidth must be at least equal "
157  "to 1 to have a connexe graph");
158 
160  }
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:55
+ 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 87 of file IBayesNetGenerator_tpl.h.

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

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

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

704  {
705  _p = p;
706 
707  if (p + _q > 100)
708  GUM_ERROR(
709  OperationNotAllowed,
710  "the sum of the probabilities p and q must be at most equal to 100");
711  }
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:55
+ 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 718 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().

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