aGrUM  0.15.1
gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator > Class Template Referenceabstract

Class for generating bayesian networks. More...

#include <agrum/BN/generator/IBayesNetGenerator.h>

+ Inheritance diagram for gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >:

Public Member Functions

Constructors / Destructor
 IBayesNetGenerator (Size nbrNodes, Size maxArcs, Size maxModality)
 constructor. More...
 
virtual ~IBayesNetGenerator ()
 Destructor. More...
 
BN generation methods
virtual void generateBN (BayesNet< GUM_SCALAR > &bayesNet)=0
 Virtual function that Generates a bayesian networks. More...
 
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 _nbrNodes
 
Size _maxArcs
 
Size _maxModality
 
BayesNet< GUM_SCALAR > _bayesNet
 

Detailed Description

template<typename GUM_SCALAR, template< typename > class ICPTGenerator>
class gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >

Class for generating bayesian networks.

This class is the abstract class for randomly generating a bayesian network given three parameters: the number of nodes the wanted maximum number of arcs and the maximum number of modality for each node.

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 63 of file IBayesNetGenerator.h.

Constructor & Destructor Documentation

◆ IBayesNetGenerator()

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

constructor.

Use by default the SimpleCPTGenerator for generating the BNs CPT.

Parameters
nbrNodesThe number of nodes in the generated BN.
maxArcsThe number of maximum number of arcs imposed on the generator
maxModalityEach DRV has from 2 to maxModality modalities
Exceptions
OperationNotAllowedif the number of maximum arcs does not allow the generation of a connexe graph maxArcs < nbrNodes -1, is too big maxArcs > nbrNodes *(nbrNodes -1) /2 and if the maximum of modality is lower than 2.

Definition at line 39 of file IBayesNetGenerator_tpl.h.

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

40  :
41  _bayesNet() {
42  GUM_CONSTRUCTOR(IBayesNetGenerator);
44 
45  if (maxArcs < nbrNodes - 1 || maxArcs > (nbrNodes * (nbrNodes - 1)) / 2)
46  GUM_ERROR(OperationNotAllowed, " maxArcs value not possible ");
47 
48  if (maxModality < 2)
49  GUM_ERROR(OperationNotAllowed,
50  " maxModality must be at least equal to two ");
51 
52  _maxArcs = maxArcs;
54  }
IBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality)
constructor.
Size nbrNodes() const
Return a constant reference to the number of nodes imposed on the IBayesNetGenerator.
BayesNet< GUM_SCALAR > _bayesNet
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
+ Here is the call graph for this function:

◆ ~IBayesNetGenerator()

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
INLINE gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::~IBayesNetGenerator ( )
virtual

Destructor.

Definition at line 58 of file IBayesNetGenerator_tpl.h.

58  {
59  GUM_DESTRUCTOR(IBayesNetGenerator);
60  // delete _cptGenerator;
61  }
IBayesNetGenerator(Size nbrNodes, Size maxArcs, Size maxModality)
constructor.

Member Function Documentation

◆ fillCPT()

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

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>
virtual void gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::generateBN ( BayesNet< GUM_SCALAR > &  bayesNet)
pure virtual

Virtual function that Generates a bayesian networks.

Parameters
bayesNetBayesian Network to be completed after initialisation
Returns
null but modify inputed empty Bayesian Network

Implemented in gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >, and gum::SimpleBayesNetGenerator< GUM_SCALAR, ICPTGenerator >.

◆ maxArcs()

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

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:

◆ maxModality()

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

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

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:

◆ setMaxArcs()

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

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:

◆ setMaxModality()

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

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)

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:

Member Data Documentation

◆ _bayesNet

template<typename GUM_SCALAR , template< typename > class ICPTGenerator>
BayesNet< GUM_SCALAR > gum::IBayesNetGenerator< GUM_SCALAR, ICPTGenerator >::_bayesNet
protected

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().

◆ _maxArcs

◆ _maxModality

◆ _nbrNodes


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