aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, FUNCTOR, TerminalNodePolicy >:

Public Member Functions

Idx nbCall ()
Idx nbVarRetro ()
Idx sizeVarRetroDomain ()
Constructors / Destructors
 MultiDimFunctionGraphOperator (const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > *DG1, const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > *DG2)
 Default constructor.
 ~MultiDimFunctionGraphOperator ()
 Default destructor.
Main Method
MultiDimFunctionGraph< GUM_SCALAR, 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_SCALAR, TerminalNodePolicy > *, const DiscreteVariable *, const DiscreteVariable *)
 Heuristic methods to decide which of two retrograde variables should come first.
void _findRetrogradeVariables_ (const MultiDimFunctionGraph< GUM_SCALAR, 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_SCALAR, TerminalNodePolicy > * _DG1_
 One of the two function graphs used for the operation.
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * _DG2_
 The other one.
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * _rd_
 The resulting function graph.
Idx _nbVar_
 The total number of variable implied in the operation.
const FUNCTOR< GUM_SCALAR > _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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
class gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >

Class used to perform Function Graph Operations.

Definition at line 73 of file multiDimFunctionGraphOperator.h.

Constructor & Destructor Documentation

◆ MultiDimFunctionGraphOperator()

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

Default constructor.

Definition at line 59 of file multiDimFunctionGraphOperator_tpl.h.

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

References MultiDimFunctionGraphOperator(), _default_, _DG1_, _DG1InstantiationNeeded_, _DG2_, _DG2InstantiationNeeded_, _function_, _nbCall_, _nbVar_, _rd_, _sizeVarRetro_, and gum::MultiDimFunctionGraph< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::~MultiDimFunctionGraphOperator ( )

Default destructor.

Definition at line 78 of file multiDimFunctionGraphOperator_tpl.h.

79 {
81
82
83 for (auto instIter = _DG1InstantiationNeeded_.beginSafe();
85 ++instIter)
86 SOA_DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
87
88 for (auto instIter = _DG2InstantiationNeeded_.beginSafe();
90 ++instIter)
91 SOA_DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
92
93 if (_nbVar_ != 0) SOA_DEALLOCATE(_default_, sizeof(short int) * _nbVar_);
94 }
#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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
NodeId gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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 332 of file multiDimFunctionGraphOperator_tpl.h.

334 {
335 _nbCall_ += 1;
336
337 NodeId newNode = 0;
338
339
340 // If both current nodes are terminal,
341 // we only have to compute the resulting value
342 if (_DG1_->isTerminalNode(currentSituation.DG1Node())
343 && _DG2_->isTerminalNode(currentSituation.DG2Node())) {
344 // We have to compute new valueand we insert a new node in diagram with
345 // this value, ...
346 return _rd_->manager()->addTerminalNode(
347 _function_(_DG1_->terminalNodeValue(currentSituation.DG1Node()),
348 _DG2_->terminalNodeValue(currentSituation.DG2Node())));
349 }
350
351 // If not,
352 // we'll have to do some exploration
353
354 // First we ensure that we hadn't already visit this pair of node under hte
355 // same circumstances
356
357 short int* dg1NeededVar = _DG1InstantiationNeeded_.exists(currentSituation.DG1Node())
359 : _default_;
361 = _DG1_->isTerminalNode(currentSituation.DG1Node())
362 ? _nbVar_
363 : _rd_->variablesSequence().pos(_DG1_->node(currentSituation.DG1Node())->nodeVar());
364 short int* dg2NeededVar = _DG2InstantiationNeeded_.exists(currentSituation.DG2Node())
366 : _default_;
368 = _DG2_->isTerminalNode(currentSituation.DG2Node())
369 ? _nbVar_
370 : _rd_->variablesSequence().pos(_DG2_->node(currentSituation.DG2Node())->nodeVar());
371
372 short int* instNeeded = static_cast< short int* >(SOA_ALLOCATE(sizeof(short int) * _nbVar_));
373 for (Idx i = 0; i < _nbVar_; i++)
375
377
378 if (_explorationTable_.exists(curSitKey)) {
379 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
381 }
382
383 // ====================================================
384
385 NodeId origDG1 = currentSituation.DG1Node(), origDG2 = currentSituation.DG2Node();
386
388 NodeId leadNodeId = 0;
389 Idx leadVarPos = _rd_->variablesSequence().size();
390 using SetNodeFunction = void (O4DGContext::*)(const NodeId&);
391
393
394 bool sameVar = false;
395
396 if (!_DG1_->isTerminalNode(currentSituation.DG1Node())) {
397 if (currentSituation.varModality(dg1CurrentVarPos) != 0) {
398 currentSituation.setDG1Node(_DG1_->node(currentSituation.DG1Node())
399 ->son(currentSituation.varModality(dg1CurrentVarPos) - 1));
400
403 currentSituation.setDG1Node(origDG1);
404 currentSituation.setDG2Node(origDG2);
405
406 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
407
408 return newNode;
409 }
410
411 leaddg = _DG1_;
412 leadNodeId = currentSituation.DG1Node();
415 }
416
417 if (!_DG2_->isTerminalNode(currentSituation.DG2Node())) {
418 if (currentSituation.varModality(dg2CurrentVarPos) != 0) {
419 currentSituation.setDG2Node(_DG2_->node(currentSituation.DG2Node())
420 ->son(currentSituation.varModality(dg2CurrentVarPos) - 1));
421
424 currentSituation.setDG1Node(origDG1);
425 currentSituation.setDG2Node(origDG2);
426
427 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
428
429 return newNode;
430 }
431
432 if (leadVarPos == dg2CurrentVarPos) { sameVar = true; }
433
435 leaddg = _DG2_;
436 leadNodeId = currentSituation.DG2Node();
439 }
440 }
441
442 // ====================================================
443
444 // Before exploring nodes, we have to ensure that every anticipated
445 // exploration is done
446 for (Idx varPos = lastInstVarPos + 1; varPos < leadVarPos; ++varPos) {
447 if (instNeeded[varPos]) {
448 const DiscreteVariable* curVar = _rd_->variablesSequence().atPos(varPos);
450 = static_cast< NodeId* >(SOA_ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
451
452 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
453 currentSituation.chgVarModality(varPos, modality + 1);
454
456 }
457
458 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
459
461 currentSituation.chgVarModality(varPos, 0);
462 currentSituation.setDG1Node(origDG1);
463 currentSituation.setDG2Node(origDG2);
464
465 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
466
467 return newNode;
468 }
469 }
470
471 // ====================================================
472
473 // If only one of the current node is terminal,
474 // we have to pursue deeper on the other diagram
475 if (sameVar) {
476 // If so - meaning it's the same variable - we have to go
477 // down on both
478 const InternalNode* dg1Node = _DG1_->node(origDG1);
479 const InternalNode* dg2Node = _DG2_->node(origDG2);
480
481 const DiscreteVariable* curVar = dg1Node->nodeVar();
482 Idx varPos = _rd_->variablesSequence().pos(curVar);
483
484 NodeId* sonsIds = static_cast< NodeId* >(SOA_ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
485
486 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
487 currentSituation.chgVarModality(varPos, modality + 1);
488 currentSituation.setDG1Node(dg1Node->son(modality));
489 currentSituation.setDG2Node(dg2Node->son(modality));
490
492 }
493
494 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
495
497 currentSituation.chgVarModality(varPos, 0);
498 currentSituation.setDG1Node(origDG1);
499 currentSituation.setDG2Node(origDG2);
500
501 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
502
503 return newNode;
504 }
505 // ====================================================
506 else {
508
509 const DiscreteVariable* curVar = leaddgNode->nodeVar();
510 NodeId* sonsIds = static_cast< NodeId* >(SOA_ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
511
512 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
513 currentSituation.chgVarModality(leadVarPos, modality + 1);
515
517 }
518
519 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
520
522 currentSituation.chgVarModality(leadVarPos, 0);
523 currentSituation.setDG1Node(origDG1);
524 currentSituation.setDG2Node(origDG2);
525
526 SOA_DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
527
528 return newNode;
529 }
530 }
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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
INLINE Idx gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::_distance_ ( const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * d,
const DiscreteVariable * from,
const DiscreteVariable * to )
private

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

Definition at line 223 of file multiDimFunctionGraphOperator_tpl.h.

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

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

Referenced by _establishVarOrder_().

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

◆ _establishVarOrder_()

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

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

Definition at line 131 of file multiDimFunctionGraphOperator_tpl.h.

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

245 {
247 Size tableSize = Size(_nbVar_ * sizeof(short int));
248
249 for (auto varIter = dg->variablesSequence().rbeginSafe();
250 varIter != dg->variablesSequence().rendSafe();
251 --varIter) {
252 Idx varPos = _rd_->variablesSequence().pos(*varIter);
253 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
254 while (nodeIter != nullptr) {
255 short int* instantiationNeeded = static_cast< short int* >(SOA_ALLOCATE(tableSize));
256 dgInstNeed.insert(nodeIter->element(), instantiationNeeded);
257
258 short int* varDescendant = static_cast< short int* >(SOA_ALLOCATE(tableSize));
259 nodesVarDescendant.insert(nodeIter->element(), varDescendant);
260 for (Idx j = 0; j < _nbVar_; j++) {
261 instantiationNeeded[j] = (short int)0;
262 varDescendant[j] = (short int)0;
263 }
264
265 varDescendant[varPos] = (short int)1;
266 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
267 if (!dg->isTerminalNode(dg->node(nodeIter->element())->son(modality))) {
268 short int* sonVarDescendant
269 = nodesVarDescendant[dg->node(nodeIter->element())->son(modality)];
270 for (Idx varIdx = 0; varIdx < _nbVar_; varIdx++) {
273 instantiationNeeded[varIdx] = (short int)1;
274 }
275 }
276 }
277 nodeIter = nodeIter->nextLink();
278 }
279 }
280
281 for (auto varIter = dg->variablesSequence().beginSafe();
282 varIter != dg->variablesSequence().endSafe();
283 ++varIter) {
284 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
285 while (nodeIter != nullptr) {
286 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
287 NodeId sonId = dg->node(nodeIter->element())->son(modality);
288 if (!dg->isTerminalNode(sonId)) {
289 for (Idx varIdx = 0; varIdx < _nbVar_; ++varIdx) {
291 dgInstNeed[sonId][varIdx] = (short int)1;
292 }
293 }
294 }
295 }
296 nodeIter = nodeIter->nextLink();
297 }
298 }
299
301 it != nodesVarDescendant.end();
302 ++it) {
304 }
305 nodesVarDescendant.clear();
306 }
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_SCALAR >::variablesSequence().

Referenced by compute().

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

◆ compute()

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

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

Definition at line 102 of file multiDimFunctionGraphOperator_tpl.h.

102 {
106
107 Idx* varInst = nullptr;
108 if (_nbVar_ != 0) {
109 varInst = static_cast< Idx* >(SOA_ALLOCATE(sizeof(Idx) * _nbVar_));
110 for (Idx i = 0; i < _nbVar_; i++)
111 varInst[i] = (Idx)0;
112 }
113
115 conti.setDG1Node(_DG1_->root());
116 conti.setDG2Node(_DG2_->root());
117
118 NodeId root = _compute_(conti, (Idx)0 - 1);
119 _rd_->manager()->setRootNode(root);
120
121 if (_nbVar_ != 0) SOA_DEALLOCATE(varInst, sizeof(Idx) * _nbVar_);
122
123 return _rd_;
124 }
void _establishVarOrder_()
Computes an order for the final Decision graph that will minimize the number of re exploration.
void _findRetrogradeVariables_(const MultiDimFunctionGraph< GUM_SCALAR, 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_SCALAR >::argmaximize().

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

◆ nbCall()

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

Definition at line 535 of file multiDimFunctionGraphOperator_tpl.h.

535 {
536 return _nbCall_;
537 }

References _nbCall_.

◆ nbVarRetro()

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

Definition at line 543 of file multiDimFunctionGraphOperator_tpl.h.

543 {
544 return _nbVarRetro_;
545 }

References _nbVarRetro_.

◆ sizeVarRetroDomain()

template<typename GUM_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy>
INLINE Idx gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
short int* gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< double, NodeId > gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const FUNCTOR< GUM_SCALAR > gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::_nbCall_
private

◆ _nbVar_

template<typename GUM_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::_nbVarRetro_
private

Definition at line 112 of file multiDimFunctionGraphOperator.h.

Referenced by _establishVarOrder_(), and nbVarRetro().

◆ _rd_

template<typename GUM_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* gum::MultiDimFunctionGraphOperator< GUM_SCALAR, 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_SCALAR, template< typename > class FUNCTOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::_sizeVarRetro_
private

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