35 # define IBNG IBayesNetGenerator 37 # define IBNG IBayesNetGenerator< GUM_SCALAR, ICPTGenerator > 40 template <
typename GUM_SCALAR >
44 for (
auto node : bayesNet.
nodes())
53 template <
typename GUM_SCALAR,
65 IBNG(nbrNodes, maxArcs, maxModality),
66 _bayesNettemp(), _hashMarginal() {
70 "the sum of the probabilities p and q must be at most equal to 100");
80 template <
typename GUM_SCALAR,
91 (
Size)(bayesNet.sizeArcs() * 1.1),
100 template <
typename GUM_SCALAR,
101 template <
typename >
103 template <
typename >
104 class ICPTDisturber >
110 template <
typename GUM_SCALAR,
111 template <
typename >
113 template <
typename >
114 class ICPTDisturber >
132 template <
typename GUM_SCALAR,
133 template <
typename >
135 template <
typename >
136 class ICPTDisturber >
151 for (
auto node : bayesNetinit.
nodes()) {
173 std::cout << this->
_bayesNet.toDot() << std::endl;
175 "BN is not valid cause it does not respect constraint ");
182 template <
typename GUM_SCALAR,
183 template <
typename >
185 template <
typename >
186 class ICPTDisturber >
195 template <
typename GUM_SCALAR,
196 template <
typename >
198 template <
typename >
199 class ICPTDisturber >
241 template <
typename GUM_SCALAR,
242 template <
typename >
244 template <
typename >
245 class ICPTDisturber >
290 template <
typename GUM_SCALAR,
291 template <
typename >
293 template <
typename >
294 class ICPTDisturber >
308 template <
typename GUM_SCALAR,
309 template <
typename >
311 template <
typename >
312 class ICPTDisturber >
331 for (
auto node : __dag.
parents(j)) {
342 for (
auto node : __dag.
children(j)) {
355 template <
typename GUM_SCALAR,
356 template <
typename >
358 template <
typename >
359 class ICPTDisturber >
369 template <
typename GUM_SCALAR,
370 template <
typename >
372 template <
typename >
373 class ICPTDisturber >
383 template <
typename GUM_SCALAR,
384 template <
typename >
386 template <
typename >
387 class ICPTDisturber >
397 this->disturbAugmCPT(j, this->
_bayesNet, potj, (GUM_SCALAR)0.5);
402 template <
typename GUM_SCALAR,
403 template <
typename >
405 template <
typename >
406 class ICPTDisturber >
419 this->disturbReducCPT(j, this->
_bayesNet, potj, marg);
429 template <
typename GUM_SCALAR,
430 template <
typename >
432 template <
typename >
433 class ICPTDisturber >
443 template <
typename GUM_SCALAR,
444 template <
typename >
446 template <
typename >
447 class ICPTDisturber >
453 if (this->
_bayesNet.parents(temp).size()) {
455 auto it = this->
_bayesNet.parents(j).begin();
463 }
else if (this->
_bayesNet.children(temp).size()) {
465 auto it = this->
_bayesNet.children(i).begin();
478 template <
typename GUM_SCALAR,
479 template <
typename >
481 template <
typename >
482 class ICPTDisturber >
488 std::stringstream strBuff;
489 strBuff <<
"n_" << n++;
492 Size maxNodes = BNSize - 1;
497 maxNodes = maxNodes - SubG;
503 template <
typename GUM_SCALAR,
504 template <
typename >
506 template <
typename >
507 class ICPTDisturber >
511 std::stringstream strBuff;
512 strBuff <<
"n_" << n++;
515 Size maxNodes = BNSize - 1;
520 maxNodes = maxNodes - SubG;
529 template <
typename GUM_SCALAR,
530 template <
typename >
532 template <
typename >
533 class ICPTDisturber >
547 template <
typename GUM_SCALAR,
548 template <
typename >
550 template <
typename >
551 class ICPTDisturber >
558 template <
typename GUM_SCALAR,
559 template <
typename >
561 template <
typename >
562 class ICPTDisturber >
573 for (
auto par : __dag.
parents(i)) {
577 for (
auto chi : __dag.
children(i)) {
585 template <
typename GUM_SCALAR,
586 template <
typename >
588 template <
typename >
589 class ICPTDisturber >
599 for (
auto par : __dag.
parents(i)) {
603 for (
auto chi : __dag.
children(i)) {
611 template <
typename GUM_SCALAR,
612 template <
typename >
614 template <
typename >
615 class ICPTDisturber >
626 for (
auto node : __dag.
children(tail)) {
634 template <
typename GUM_SCALAR,
635 template <
typename >
637 template <
typename >
638 class ICPTDisturber >
648 for (
auto node : __dag.
children(tail)) {
657 template <
typename GUM_SCALAR,
658 template <
typename >
660 template <
typename >
661 class ICPTDisturber >
668 template <
typename GUM_SCALAR,
669 template <
typename >
671 template <
typename >
672 class ICPTDisturber >
678 template <
typename GUM_SCALAR,
679 template <
typename >
681 template <
typename >
682 class ICPTDisturber >
688 template <
typename GUM_SCALAR,
689 template <
typename >
691 template <
typename >
692 class ICPTDisturber >
698 template <
typename GUM_SCALAR,
699 template <
typename >
701 template <
typename >
702 class ICPTDisturber >
710 "the sum of the probabilities p and q must be at most equal to 100");
712 template <
typename GUM_SCALAR,
713 template <
typename >
715 template <
typename >
716 class ICPTDisturber >
724 "the sum of the probabilities p and q must be at most equal to 100");
aGrUM's Potential is a multi-dimensional array with tensor operators.
Class representing a Bayesian Network.
MCBayesNetGenerator(Size nbrNodes, Size maxArcs, Idx maxModality=2, Size iteration=5000, Idx p=30, Idx q=40)
Constructor.
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...
const DiscreteVariable & variable(NodeId id) const final
Returns a gum::DiscreteVariable given its gum::NodeId in the gum::BayesNet.
Idx q() const
Return a constant reference to the probabilité imposed on the Markov Chain BayesNetGenerator.
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
<agrum/BN/generator/MCayesNetGenerator.h>
void fillCPT()
function that insert random values in the CPT of each nodes according to the CPTGenerator.
gum::Size getMaxModality(gum::BayesNet< GUM_SCALAR > &bayesNet)
bool __connect(NodeId i, NodeId j)
The function that verify if node i and j are connected.
void setQ(Idx q)
Modifies the value of the probability q imposed on the BayesNetGenerator.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void copy(const MultiDimContainer< GUM_SCALAR > &src)
Removes all variables in this MultiDimContainer and copy the content of src, variables 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.
virtual void makeInference() final
perform the heavy computations needed to compute the targets' posteriors
virtual Size domainSize() const =0
void setP(Idx p)
Modifies the value of the probability p imposed on the BayesNetGenerator.
~MCBayesNetGenerator() override
Destructor.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
BayesNet< GUM_SCALAR > _bayesNet
BayesNet< GUM_SCALAR > _bayesNettemp
void __transformPoly(Idx nbiter)
The function that randomly change the simple tree into a polytree.
const NodeGraphPart & nodes() const
Returns a constant reference to the dag of this Bayes Net.
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
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...
NodeId __createPartTree(Size BNSize, Idx &n)
The internal function used by __createTree that randomly generate a simple tree.
void setIteration(Size iteration)
Modifies the value of the number of iterations impose on the BayesNetGenerator.
void disturbBN(BayesNet< GUM_SCALAR > &bayesNetinit, Size iteration=0)
Change randomly the topology of a specific bayesian networks.
void __chooseNodes(NodeId &i, NodeId &j)
The function that randomly choose two nodes of the graph.
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
virtual const Potential< GUM_SCALAR > & posterior(NodeId node) final
Computes and returns the posterior of a node.
void __AR()
The function will remove and add a random arc changing the topology of the graph but asserting its co...
<agrum/BN/inference/lazyPropagation.h>
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 crea...
void generateBN(BayesNet< GUM_SCALAR > &bayesNet) override
Generates a random bayesian network.
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 Idx
Type for indexes.
void __AorR()
The function will add or remove a random arc in the graph using the functions __insertArc and __remov...
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...
bool __directedPath(NodeId tail, NodeId head)
The function that verify if there is a oriented path from node i to node j.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __createTree(Size BNSize)
The function that randomly generate a simple tree.
Idx p() const
Return a constant reference to the probabilité p imposed on the Markov Chain BayesNetGenerator.
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
Size NodeId
Type for node ids.
void insert(const Key &k)
Inserts a new element into the set.
#define GUM_ERROR(type, msg)
HashTable< NodeId, Potential< GUM_SCALAR > *> _hashMarginal