aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy > Class Template Reference

Class used to perform Function Graph Operations. More...

#include <agrum/base/multidim/patterns/multiDimFunctionGraphOperator.h>

Collaboration diagram for gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >:

Public Member Functions

Idx nbCall ()
Idx nbVarRetro ()
Idx sizeVarRetroDomain ()
Constructors / Destructors
 MultiDimFunctionGraphOperator (const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *DG1, const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *DG2)
 Default constructor.
 ~MultiDimFunctionGraphOperator ()
 Default destructor.
Main Method
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * compute ()
 Computes and builds the Function Graph that is the result of the operation.

Private Member Functions

void _establishVarOrder_ ()
 Computes an order for the final Decision graph that will minimize the number of re exploration.
Idx _distance_ (const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *, const DiscreteVariable *, const DiscreteVariable *)
 Heuristic methods to decide which of two retrograde variables should come first.
void _findRetrogradeVariables_ (const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *dg, HashTable< NodeId, short int * > &dgInstNeed)
 Establish for each node in both function graph if it has retrograde variables beneath it.
NodeId _compute_ (O4DGContext &currentSituation, Idx lastInstVarPos)
 The main recursion function.

Private Attributes

Idx _nbCall_
Idx _nbVarRetro_
Idx _sizeVarRetro_
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _DG1_
 One of the two function graphs used for the operation.
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _DG2_
 The other one.
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _rd_
 The resulting function graph.
Idx _nbVar_
 The total number of variable implied in the operation.
const FUNCTOR< GUM_ELEMENT > _function_
 The function to be performed on the leaves.
HashTable< double, NodeId_explorationTable_
 The hashtable used to know if two pair of nodes have already been visited.
HashTable< NodeId, short int * > _DG1InstantiationNeeded_
 Table uses to know if a given node of first function graph has retrograde vrariables.
HashTable< NodeId, short int * > _DG2InstantiationNeeded_
 Table uses to know if a given node of second function graph has retrograde vrariables.
short int * _default_
 Just a comptuationnal trick.

Detailed Description

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
class gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >

Class used to perform Function Graph Operations.

Definition at line 73 of file multiDimFunctionGraphOperator.h.

Constructor & Destructor Documentation

◆ MultiDimFunctionGraphOperator()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::MultiDimFunctionGraphOperator ( const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * DG1,
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * DG2 )

Default constructor.

Definition at line 60 of file multiDimFunctionGraphOperator_tpl.h.

63 :
64 _DG1_(DG1), _DG2_(DG2), _function_(), _DG1InstantiationNeeded_(DG1->realSize(), true, false),
65 _DG2InstantiationNeeded_(DG2->realSize(), true, false) {
68 _nbVar_ = 0;
69 _default_ = nullptr;
70
71 _nbCall_ = 0;
72 _nbVar_ = 0;
74 }
Class used to perform Function Graph Operations.
short int * _default_
Just a comptuationnal trick.
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _DG1_
One of the two function graphs used for the operation.
MultiDimFunctionGraphOperator(const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *DG1, const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *DG2)
Default constructor.
HashTable< NodeId, short int * > _DG1InstantiationNeeded_
Table uses to know if a given node of first function graph has retrograde vrariables.
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _DG2_
The other one.
Idx _nbVar_
The total number of variable implied in the operation.
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _rd_
The resulting function graph.
HashTable< NodeId, short int * > _DG2InstantiationNeeded_
Table uses to know if a given node of second function graph has retrograde vrariables.
const FUNCTOR< GUM_ELEMENT > _function_
The function to be performed on the leaves.
static MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.

References MultiDimFunctionGraphOperator(), _default_, _DG1_, _DG1InstantiationNeeded_, _DG2_, _DG2InstantiationNeeded_, _function_, _nbCall_, _nbVar_, _rd_, _sizeVarRetro_, and gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::getReducedAndOrderedInstance().

Referenced by MultiDimFunctionGraphOperator(), and ~MultiDimFunctionGraphOperator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~MultiDimFunctionGraphOperator()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::~MultiDimFunctionGraphOperator ( )

Default destructor.

Definition at line 79 of file multiDimFunctionGraphOperator_tpl.h.

80 {
82
83
84 for (auto instIter = _DG1InstantiationNeeded_.beginSafe();
86 ++instIter)
87 SOA_DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
88
89 for (auto instIter = _DG2InstantiationNeeded_.beginSafe();
91 ++instIter)
92 SOA_DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
93
94 if (_nbVar_ != 0) SOA_DEALLOCATE(_default_, sizeof(short int) * _nbVar_);
95 }
#define SOA_DEALLOCATE(x, y)

References MultiDimFunctionGraphOperator(), _default_, _DG1InstantiationNeeded_, _DG2InstantiationNeeded_, _nbVar_, and SOA_DEALLOCATE.

Here is the call graph for this function:

Member Function Documentation

◆ _compute_()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
NodeId gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_compute_ ( O4DGContext & currentSituation,
Idx lastInstVarPos )
private

The main recursion function.

Main recursion function, called every time we move on a node to determine what we have to do.

Definition at line 333 of file multiDimFunctionGraphOperator_tpl.h.

335 {
336 _nbCall_ += 1;
337
338 NodeId newNode = 0;
339
340
341 // If both current nodes are terminal,
342 // we only have to compute the resulting value
343 if (_DG1_->isTerminalNode(currentSituation.DG1Node())
344 && _DG2_->isTerminalNode(currentSituation.DG2Node())) {
345 // We have to compute new valueand we insert a new node in diagram with
346 // this value, ...
347 return _rd_->manager()->addTerminalNode(
348 _function_(_DG1_->terminalNodeValue(currentSituation.DG1Node()),
349 _DG2_->terminalNodeValue(currentSituation.DG2Node())));
350 }
351
352 // If not,
353 // we'll have to do some exploration
354
355 // First we ensure that we hadn't already visit this pair of node under hte
356 // same circumstances
357
358 short int* dg1NeededVar = _DG1InstantiationNeeded_.exists(currentSituation.DG1Node())
360 : _default_;
362 = _DG1_->isTerminalNode(currentSituation.DG1Node())
363 ? _nbVar_
364 : _rd_->variablesSequence().pos(_DG1_->node(currentSituation.DG1Node())->nodeVar());
365 short int* dg2NeededVar = _DG2InstantiationNeeded_.exists(currentSituation.DG2Node())
367 : _default_;
369 = _DG2_->isTerminalNode(currentSituation.DG2Node())
370 ? _nbVar_
371 : _rd_->variablesSequence().pos(_DG2_->node(currentSituation.DG2Node())->nodeVar());
372
373 short int* instNeeded = static_cast< short int* >(SOA_ALLOCATE(sizeof(short int) * _nbVar_));
374 for (Idx i = 0; i < _nbVar_; i++)
376
378
379 if (_explorationTable_.exists(curSitKey)) {
380 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
382 }
383
384 // ====================================================
385
386 NodeId origDG1 = currentSituation.DG1Node(), origDG2 = currentSituation.DG2Node();
387
389 NodeId leadNodeId = 0;
390 Idx leadVarPos = _rd_->variablesSequence().size();
391 using SetNodeFunction = void (O4DGContext::*)(const NodeId&);
392
394
395 bool sameVar = false;
396
397 if (!_DG1_->isTerminalNode(currentSituation.DG1Node())) {
398 if (currentSituation.varModality(dg1CurrentVarPos) != 0) {
399 currentSituation.setDG1Node(_DG1_->node(currentSituation.DG1Node())
400 ->son(currentSituation.varModality(dg1CurrentVarPos) - 1));
401
404 currentSituation.setDG1Node(origDG1);
405 currentSituation.setDG2Node(origDG2);
406
407 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
408
409 return newNode;
410 }
411
412 leaddg = _DG1_;
413 leadNodeId = currentSituation.DG1Node();
416 }
417
418 if (!_DG2_->isTerminalNode(currentSituation.DG2Node())) {
419 if (currentSituation.varModality(dg2CurrentVarPos) != 0) {
420 currentSituation.setDG2Node(_DG2_->node(currentSituation.DG2Node())
421 ->son(currentSituation.varModality(dg2CurrentVarPos) - 1));
422
425 currentSituation.setDG1Node(origDG1);
426 currentSituation.setDG2Node(origDG2);
427
428 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
429
430 return newNode;
431 }
432
433 if (leadVarPos == dg2CurrentVarPos) { sameVar = true; }
434
436 leaddg = _DG2_;
437 leadNodeId = currentSituation.DG2Node();
440 }
441 }
442
443 // ====================================================
444
445 // Before exploring nodes, we have to ensure that every anticipated
446 // exploration is done
447 for (Idx varPos = lastInstVarPos + 1; varPos < leadVarPos; ++varPos) {
448 if (instNeeded[varPos]) {
449 const DiscreteVariable* curVar = _rd_->variablesSequence().atPos(varPos);
451 = static_cast< NodeId* >(SOA_ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
452
453 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
454 currentSituation.chgVarModality(varPos, modality + 1);
455
457 }
458
459 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
460
462 currentSituation.chgVarModality(varPos, 0);
463 currentSituation.setDG1Node(origDG1);
464 currentSituation.setDG2Node(origDG2);
465
466 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
467
468 return newNode;
469 }
470 }
471
472 // ====================================================
473
474 // If only one of the current node is terminal,
475 // we have to pursue deeper on the other diagram
476 if (sameVar) {
477 // If so - meaning it's the same variable - we have to go
478 // down on both
479 const InternalNode* dg1Node = _DG1_->node(origDG1);
480 const InternalNode* dg2Node = _DG2_->node(origDG2);
481
482 const DiscreteVariable* curVar = dg1Node->nodeVar();
483 Idx varPos = _rd_->variablesSequence().pos(curVar);
484
485 NodeId* sonsIds = static_cast< NodeId* >(SOA_ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
486
487 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
488 currentSituation.chgVarModality(varPos, modality + 1);
489 currentSituation.setDG1Node(dg1Node->son(modality));
490 currentSituation.setDG2Node(dg2Node->son(modality));
491
493 }
494
495 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
496
498 currentSituation.chgVarModality(varPos, 0);
499 currentSituation.setDG1Node(origDG1);
500 currentSituation.setDG2Node(origDG2);
501
502 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
503
504 return newNode;
505 }
506 // ====================================================
507 else {
509
510 const DiscreteVariable* curVar = leaddgNode->nodeVar();
511 NodeId* sonsIds = static_cast< NodeId* >(SOA_ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
512
513 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
514 currentSituation.chgVarModality(leadVarPos, modality + 1);
516
518 }
519
520 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
521
523 currentSituation.chgVarModality(leadVarPos, 0);
524 currentSituation.setDG1Node(origDG1);
525 currentSituation.setDG2Node(origDG2);
526
527 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
528
529 return newNode;
530 }
531 }
HashTable< double, NodeId > _explorationTable_
The hashtable used to know if two pair of nodes have already been visited.
NodeId _compute_(O4DGContext &currentSituation, Idx lastInstVarPos)
The main recursion function.
#define SOA_ALLOCATE(x)

References _compute_(), _default_, _DG1_, _DG1InstantiationNeeded_, _DG2_, _DG2InstantiationNeeded_, _explorationTable_, _function_, _nbCall_, _nbVar_, _rd_, gum::O4DGContext::chgVarModality(), gum::O4DGContext::DG1Node(), gum::O4DGContext::DG2Node(), gum::DiscreteVariable::domainSize(), gum::O4DGContext::key(), gum::InternalNode::nodeVar(), gum::O4DGContext::setDG1Node(), gum::O4DGContext::setDG2Node(), SOA_ALLOCATE, SOA_DEALLOCATE, gum::InternalNode::son(), and gum::O4DGContext::varModality().

Referenced by _compute_(), and compute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _distance_()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_distance_ ( const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * d,
const DiscreteVariable * from,
const DiscreteVariable * to )
private

Heuristic methods to decide which of two retrograde variables should come first.

Definition at line 224 of file multiDimFunctionGraphOperator_tpl.h.

227 {
228 Idx posi = d->variablesSequence().pos(from);
229 Idx dist = 1;
230
231 while (d->variablesSequence().atPos(posi) != to) {
232 dist *= (*(d->variablesSequence().atPos(posi))).domainSize();
233 posi++;
234 }
235
236 return dist;
237 }

References gum::MultiDimImplementation< GUM_ELEMENT >::variablesSequence().

Referenced by _establishVarOrder_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _establishVarOrder_()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
void gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_establishVarOrder_ ( )
private

Computes an order for the final Decision graph that will minimize the number of re exploration.

Definition at line 132 of file multiDimFunctionGraphOperator_tpl.h.

133 {
134 SequenceIteratorSafe< const DiscreteVariable* > fite = _DG1_->variablesSequence().beginSafe();
135 SequenceIteratorSafe< const DiscreteVariable* > site = _DG2_->variablesSequence().beginSafe();
136
137 while (fite != _DG1_->variablesSequence().endSafe()
138 && site != _DG2_->variablesSequence().endSafe()) {
139 // Test : if var from first order is already in final order
140 // we move onto the next one
141 if (_rd_->variablesSequence().exists(*fite)) {
142 ++fite;
143 continue;
144 }
145
146 // Test : if var from second order is already in final order
147 // we move onto the next one
148 if (_rd_->variablesSequence().exists(*site)) {
149 ++site;
150 continue;
151 }
152
153 // Test : is current var of the first order present in the second order.
154 // if not we add it to final order
155 if (!_DG2_->variablesSequence().exists(*fite)) {
156 _rd_->add(**fite);
157 ++fite;
158 continue;
159 }
160
161 // Test : is current var of the second order present in the first order.
162 // if not we add it to final order
163 if (!_DG1_->variablesSequence().exists(*site)) {
164 _rd_->add(**site);
165 ++site;
166 continue;
167 }
168
169 // Test : is current var of the second order present in the first order.
170 // if not we add it to final order
171 if (*fite == *site) {
172 _rd_->add(**fite);
173 ++fite;
174 ++site;
175 continue;
176 }
177
178 // Test : the current tested situation is when two retrograde variables
179 // are detected.
180 // Chosen solution here is to find compute domainSize in between
181 // and chose the one with the smallest
182 _nbVarRetro_++;
183 if (_distance_(_DG1_, *fite, *site) < _distance_(_DG2_, *site, *fite)) {
184 _rd_->add(**fite);
185 _sizeVarRetro_ *= (*fite)->domainSize();
186 ++fite;
187 continue;
188 } else {
189 _rd_->add(**site);
190 _sizeVarRetro_ *= (*site)->domainSize();
191 ++site;
192 continue;
193 }
194 }
195
196 // Whenever an iterator has finished its sequence,
197 // the other may still be in the middle of its one.
198 // Hence, this part ensures that any variables remaining
199 // will be added to the final sequence if needed.
200 if (fite == _DG1_->variablesSequence().endSafe()) {
201 for (; site != _DG2_->variablesSequence().endSafe(); ++site)
202 if (!_rd_->variablesSequence().exists(*site)) _rd_->add(**site);
203 } else {
204 for (; fite != _DG1_->variablesSequence().endSafe(); ++fite)
205 if (!_rd_->variablesSequence().exists(*fite)) _rd_->add(**fite);
206 }
207
208
209 // Various initialization needed now that we have a bigger picture
210 _nbVar_ = _rd_->variablesSequence().size();
211
212 if (_nbVar_ != 0) {
213 _default_ = static_cast< short int* >(SOA_ALLOCATE(sizeof(short int) * _nbVar_));
214 for (Idx i = 0; i < _nbVar_; i++)
215 _default_[i] = (short int)0;
216 }
217 }
Idx _distance_(const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *, const DiscreteVariable *, const DiscreteVariable *)
Heuristic methods to decide which of two retrograde variables should come first.

References _default_, _DG1_, _DG2_, _distance_(), _nbVar_, _nbVarRetro_, _rd_, _sizeVarRetro_, and SOA_ALLOCATE.

Referenced by compute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _findRetrogradeVariables_()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
void gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_findRetrogradeVariables_ ( const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * dg,
HashTable< NodeId, short int * > & dgInstNeed )
private

Establish for each node in both function graph if it has retrograde variables beneath it.

Definition at line 244 of file multiDimFunctionGraphOperator_tpl.h.

246 {
248 Size tableSize = Size(_nbVar_ * sizeof(short int));
249
250 for (auto varIter = dg->variablesSequence().rbeginSafe();
251 varIter != dg->variablesSequence().rendSafe();
252 --varIter) {
253 Idx varPos = _rd_->variablesSequence().pos(*varIter);
254 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
255 while (nodeIter != nullptr) {
256 short int* instantiationNeeded = static_cast< short int* >(SOA_ALLOCATE(tableSize));
257 dgInstNeed.insert(nodeIter->element(), instantiationNeeded);
258
259 short int* varDescendant = static_cast< short int* >(SOA_ALLOCATE(tableSize));
260 nodesVarDescendant.insert(nodeIter->element(), varDescendant);
261 for (Idx j = 0; j < _nbVar_; j++) {
262 instantiationNeeded[j] = (short int)0;
263 varDescendant[j] = (short int)0;
264 }
265
266 varDescendant[varPos] = (short int)1;
267 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
268 if (!dg->isTerminalNode(dg->node(nodeIter->element())->son(modality))) {
269 short int* sonVarDescendant
270 = nodesVarDescendant[dg->node(nodeIter->element())->son(modality)];
271 for (Idx varIdx = 0; varIdx < _nbVar_; varIdx++) {
274 instantiationNeeded[varIdx] = (short int)1;
275 }
276 }
277 }
278 nodeIter = nodeIter->nextLink();
279 }
280 }
281
282 for (auto varIter = dg->variablesSequence().beginSafe();
283 varIter != dg->variablesSequence().endSafe();
284 ++varIter) {
285 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
286 while (nodeIter != nullptr) {
287 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
288 NodeId sonId = dg->node(nodeIter->element())->son(modality);
289 if (!dg->isTerminalNode(sonId)) {
290 for (Idx varIdx = 0; varIdx < _nbVar_; ++varIdx) {
292 dgInstNeed[sonId][varIdx] = (short int)1;
293 }
294 }
295 }
296 }
297 nodeIter = nodeIter->nextLink();
298 }
299 }
300
302 it != nodesVarDescendant.end();
303 ++it) {
305 }
306 nodesVarDescendant.clear();
307 }
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References _nbVar_, _rd_, gum::HashTable< Key, Val >::begin(), gum::HashTable< Key, Val >::clear(), gum::Link< T >::element(), gum::HashTable< Key, Val >::end(), gum::HashTable< Key, Val >::insert(), gum::Link< T >::nextLink(), SOA_ALLOCATE, SOA_DEALLOCATE, and gum::MultiDimImplementation< GUM_ELEMENT >::variablesSequence().

Referenced by compute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::compute ( )

Computes and builds the Function Graph that is the result of the operation.

Definition at line 103 of file multiDimFunctionGraphOperator_tpl.h.

103 {
107
108 Idx* varInst = nullptr;
109 if (_nbVar_ != 0) {
110 varInst = static_cast< Idx* >(SOA_ALLOCATE(sizeof(Idx) * _nbVar_));
111 for (Idx i = 0; i < _nbVar_; i++)
112 varInst[i] = (Idx)0;
113 }
114
116 conti.setDG1Node(_DG1_->root());
117 conti.setDG2Node(_DG2_->root());
118
119 NodeId root = _compute_(conti, (Idx)0 - 1);
120 _rd_->manager()->setRootNode(root);
121
122 if (_nbVar_ != 0) SOA_DEALLOCATE(varInst, sizeof(Idx) * _nbVar_);
123
124 return _rd_;
125 }
void _establishVarOrder_()
Computes an order for the final Decision graph that will minimize the number of re exploration.
void _findRetrogradeVariables_(const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *dg, HashTable< NodeId, short int * > &dgInstNeed)
Establish for each node in both function graph if it has retrograde variables beneath it.

References _compute_(), _DG1_, _DG1InstantiationNeeded_, _DG2_, _DG2InstantiationNeeded_, _establishVarOrder_(), _findRetrogradeVariables_(), _nbVar_, _rd_, gum::O4DGContext::setDG1Node(), gum::O4DGContext::setDG2Node(), SOA_ALLOCATE, and SOA_DEALLOCATE.

Referenced by gum::MDDOperatorStrategy< GUM_ELEMENT >::argmaximize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nbCall()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::nbCall ( )

Definition at line 536 of file multiDimFunctionGraphOperator_tpl.h.

536 {
537 return _nbCall_;
538 }

References _nbCall_.

◆ nbVarRetro()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::nbVarRetro ( )

Definition at line 543 of file multiDimFunctionGraphOperator_tpl.h.

543 {
544 return _nbVarRetro_;
545 }

References _nbVarRetro_.

◆ sizeVarRetroDomain()

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::sizeVarRetroDomain ( )

Definition at line 550 of file multiDimFunctionGraphOperator_tpl.h.

551 {
552 return _sizeVarRetro_;
553 }

References _sizeVarRetro_.

Member Data Documentation

◆ _default_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
short int* gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_default_
private

Just a comptuationnal trick.

Definition at line 162 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), ~MultiDimFunctionGraphOperator(), _compute_(), and _establishVarOrder_().

◆ _DG1_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >* gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_DG1_
private

One of the two function graphs used for the operation.

Definition at line 135 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), _compute_(), _establishVarOrder_(), and compute().

◆ _DG1InstantiationNeeded_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_DG1InstantiationNeeded_
private

Table uses to know if a given node of first function graph has retrograde vrariables.

Definition at line 155 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), ~MultiDimFunctionGraphOperator(), _compute_(), and compute().

◆ _DG2_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >* gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_DG2_
private

The other one.

Definition at line 138 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), _compute_(), _establishVarOrder_(), and compute().

◆ _DG2InstantiationNeeded_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_DG2InstantiationNeeded_
private

Table uses to know if a given node of second function graph has retrograde vrariables.

Definition at line 159 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), ~MultiDimFunctionGraphOperator(), _compute_(), and compute().

◆ _explorationTable_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< double, NodeId > gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_explorationTable_
private

The hashtable used to know if two pair of nodes have already been visited.

Definition at line 151 of file multiDimFunctionGraphOperator.h.

Referenced by _compute_().

◆ _function_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const FUNCTOR< GUM_ELEMENT > gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_function_
private

The function to be performed on the leaves.

Definition at line 147 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), and _compute_().

◆ _nbCall_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_nbCall_
private

◆ _nbVar_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_nbVar_
private

The total number of variable implied in the operation.

Definition at line 144 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), ~MultiDimFunctionGraphOperator(), _compute_(), _establishVarOrder_(), _findRetrogradeVariables_(), and compute().

◆ _nbVarRetro_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_nbVarRetro_
private

Definition at line 112 of file multiDimFunctionGraphOperator.h.

Referenced by _establishVarOrder_(), and nbVarRetro().

◆ _rd_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >* gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_rd_
private

The resulting function graph.

Definition at line 141 of file multiDimFunctionGraphOperator.h.

Referenced by MultiDimFunctionGraphOperator(), _compute_(), _establishVarOrder_(), _findRetrogradeVariables_(), and compute().

◆ _sizeVarRetro_

template<typename GUM_ELEMENT, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_ELEMENT, FUNCTOR, TerminalNodePolicy >::_sizeVarRetro_
private

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