61 generatedFunctionGraph->
add(**varIter);
67 std::vector< NodeId > filo;
71 node2MinVar.
insert(generatedFunctionGraph->
root(), 0);
72 filo.push_back(generatedFunctionGraph->
root());
74 while (!filo.empty()) {
76 NodeId currentNodeId = filo.back();
78 Idx cvp = node2MinVar[currentNodeId];
80 generatedFunctionGraph->
node(currentNodeId);
83 Idx nbPotentialSons = 0;
104 if (!potentialSons.
list()
106 > (1.0 / (1.0 + 3.0 / nbPotentialSons))) {
112 (
double)std::rand() / (
double)RAND_MAX * 100));
122 filo.push_back(currentNode->
son(modality));
123 node2MinVar.
insert(currentNode->
son(modality), sonVarPos);
127 (
Idx)(((
double)std::rand() / (
double)RAND_MAX) * nbPotentialSons);
128 sonPos = sonPos == nbPotentialSons ? nbPotentialSons - 1 : sonPos;
135 currentNodeId, modality, nicleIter->
element());
144 return generatedFunctionGraph;
149 return !(currentNodeId == 1
163 std::weibull_distribution< double > distribution(
double(span), 1.0);
164 randOut = (
Idx)(distribution(generator) * span / 2);
165 if (randOut > span) randOut = span;
168 return offset + randOut;
Safe iterators for Sequence.
void setSon(const NodeId &node, const Idx &modality, const NodeId &sonNode)
Sets nodes son for given modality to designated son node.
void clean()
Removes var without nodes in the diagram.
void setRootNode(const NodeId &root)
Sets root node of decision diagram.
const InternalNode * node(NodeId n) const
Returns internalNode structure associated to that nodeId.
Class implementing a function graph generator with template type double.
const DiscreteVariable * nodeVar() const
Returns the node variable.
The generic class for storing (ordered) sequences of objects.
NodeId son(Idx modality) const
Returns the son at a given index.
NodeId addInternalNode(const DiscreteVariable *var)
Inserts a new non terminal node in graph.
MultiDimFunctionGraph< double > * generate()
Generates a MultiDimFunctionGraph.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Idx __nbTotalVar
The total number of variables.
const T & element() const
Returns the element stored in this link.
virtual Size domainSize() const =0
bool __createLeaf(NodeId currentNodeId, HashTable< NodeId, Idx > &node2MinVar)
Creates a leaf.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
Structure used to represent a node internal structure.
Link of a chain list allocated using the SmallObjectAllocator.
const Sequence< const DiscreteVariable *> __varSeq
The variables.
const NodeId & root() const
Returns the id of the root node from the diagram.
const LinkedList< NodeId > * varNodeListe(const DiscreteVariable *var) const
Returns the list of node associated to given variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
~MultiDimFunctionGraphGenerator()
Class destructor.
MultiDimFunctionGraphGenerator(Idx maxVar, Idx minVar, const Sequence< const DiscreteVariable * > &varSeq)
Default constructor.
Chain list allocated using the SmallObjectAllocator.
std::default_random_engine getRandomGenerator(unsigned int seed)
define a random_engine with correct seed
const Link< T > * list() const
Returns the first link in the chained list.
NodeId addTerminalNode(const GUM_SCALAR &value)
Adds a value to the MultiDimFunctionGraph.
Size Idx
Type for indexes.
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
const Link< T > * nextLink() const
Returns next link.
virtual void reduce()=0
Ensures that every isomorphic subgraphs are merged together.
Idx __generateVarPos(Idx offset, Idx span)
Generate a variable position.
Size NodeId
Type for node ids.
void addLink(const T &elem)
Adds a link.
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.