aGrUM  0.14.3
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 61 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 36 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().

37  :
38  _bayesNet() {
39  GUM_CONSTRUCTOR(IBayesNetGenerator);
41 
42  if (maxArcs < nbrNodes - 1 || maxArcs > (nbrNodes * (nbrNodes - 1)) / 2)
43  GUM_ERROR(OperationNotAllowed, " maxArcs value not possible ");
44 
45  if (maxModality < 2)
46  GUM_ERROR(OperationNotAllowed,
47  " maxModality must be at least equal to two ");
48 
49  _maxArcs = maxArcs;
51  }
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:52
+ 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 55 of file IBayesNetGenerator_tpl.h.

55  {
56  GUM_DESTRUCTOR(IBayesNetGenerator);
57  // delete _cptGenerator;
58  }
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 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>
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 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:

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

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:

◆ 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 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:

◆ 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 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)

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:

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

◆ _maxArcs

◆ _maxModality

◆ _nbrNodes


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