82 generatedFunctionGraph->
add(**varIter);
87 std::vector< NodeId > filo;
91 node2MinVar.
insert(generatedFunctionGraph->
root(), 0);
92 filo.push_back(generatedFunctionGraph->
root());
94 while (!filo.empty()) {
95 NodeId currentNodeId = filo.back();
97 Idx cvp = node2MinVar[currentNodeId];
98 const InternalNode* currentNode = generatedFunctionGraph->
node(currentNodeId);
101 Idx nbTensorSons = 0;
116 for (
Idx modality = 0; modality < currentNode->
nodeVar()->domainSize(); modality++) {
117 if (!tensorSons.
list() ||
randomProba() > (1.0 / (1.0 + 3.0 / nbTensorSons))) {
130 filo.push_back(currentNode->
son(modality));
131 node2MinVar.
insert(currentNode->
son(modality), sonVarPos);
135 sonPos = sonPos == nbTensorSons ? nbTensorSons - 1 : sonPos;
149 return generatedFunctionGraph;
154 return !(currentNodeId == 1
166 std::weibull_distribution< double > distribution(
double(span), 1.0);
168 if (randOut > span) randOut = span;
171 return offset + randOut;
Base class for discrete random variable.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Structure used to represent a node internal structure.
const DiscreteVariable * nodeVar() const
Returns the node variable.
NodeId son(Idx modality) const
Returns the son at a given index.
const Link< T > * nextLink() const
Returns next link.
const T & element() const
Returns the element stored in this link.
const Link< T > * list() const
Returns the first link in the chained list.
void addLink(const T &elem)
Adds a link.
~MultiDimFunctionGraphGenerator()
Class destructor.
MultiDimFunctionGraphGenerator(Idx maxVar, Idx minVar, const Sequence< const DiscreteVariable * > &varSeq)
Default constructor.
Idx _generateVarPos_(Idx offset, Idx span)
Generate a variable position.
Idx _nbTotalVar_
The total number of variables.
const Sequence< const DiscreteVariable * > _varSeq_
The variables.
MultiDimFunctionGraph< double > * generate()
Generates a MultiDimFunctionGraph.
bool _createLeaf_(NodeId currentNodeId, HashTable< NodeId, Idx > &node2MinVar)
Creates a leaf.
void clean()
Removes var without nodes in the diagram.
void setRootNode(const NodeId &root)
Sets root node of decision diagram.
NodeId addTerminalNode(const GUM_SCALAR &value)
Adds a value to the MultiDimFunctionGraph.
virtual void reduce()=0
Ensures that every isomorphic subgraphs are merged together.
NodeId addInternalNode(const DiscreteVariable *var)
Inserts a new non terminal node in graph.
void setSon(const NodeId &node, const Idx &modality, const NodeId &sonNode)
Sets nodes son for given modality to designated son node.
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
const NodeId & root() const
Returns the id of the root node from the diagram.
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
const InternalNode * node(NodeId n) const
Returns internalNode structure associated to that nodeId.
const LinkedList< NodeId > * varNodeListe(const DiscreteVariable *var) const
Returns the list of node associated to given variable.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
Safe iterators for Sequence.
The generic class for storing (ordered) sequences of objects.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
std::mt19937 & randomGenerator()
define a random_engine with correct seed
double randomProba()
Returns a random double between 0 and 1 included (i.e.
Headers of gum::MultiDimFunctionGraphGenerator.
gum is the global namespace for all aGrUM entities
priority queues (in which an element cannot appear more than once)
Contains useful methods for random stuff.