aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy > Class Template Reference

Class used to perform Function Graph Operations in the FMDP Framework. More...

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

Collaboration diagram for gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >:

Public Member Functions

Constructors / Destructors
 Regress (const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *vfunction, const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *probDist, const gum::VariableSet *primedVars, const DiscreteVariable *targetVar, const GUM_ELEMENT neutral)
 Default constructor.
 ~Regress ()
 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.
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

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.
const gum::VariableSet_primedVars_
 The set of variables we want to keep at the end.
const DiscreteVariable_targetVar_
 The variable we work on to eleminate.
const GUM_ELEMENT _neutral_
 The function to be performed on the leaves.
Idx _nbVar_
 The total number of variable implied in the operation.
const COMBINEOPERATOR< GUM_ELEMENT > _combine_
 The functions to be performed on the leaves.
const PROJECTOPERATOR< GUM_ELEMENT > _project_
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 given function graph has retrograde variables.
HashTable< NodeId, short int * > _DG2InstantiationNeeded_
short int * _default_
 Just a computationnal trick.

Detailed Description

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
class gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >

Class used to perform Function Graph Operations in the FMDP Framework.

Definition at line 69 of file regress.h.

Constructor & Destructor Documentation

◆ Regress()

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::Regress ( const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * vfunction,
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * probDist,
const gum::VariableSet * primedVars,
const DiscreteVariable * targetVar,
const GUM_ELEMENT neutral )

Default constructor.

Definition at line 65 of file regress_tpl.h.

70 :
72 _DG1InstantiationNeeded_(DG1->realSize(), true, false),
73 _DG2InstantiationNeeded_(DG2->realSize(), true, false) {
76 _nbVar_ = 0;
77 _default_ = nullptr;
80 }
static MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
Class used to perform Function Graph Operations in the FMDP Framework.
Definition regress.h:69
HashTable< NodeId, short int * > _DG2InstantiationNeeded_
Definition regress.h:147
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _DG1_
One of the two function graphs used for the operation.
Definition regress.h:116
const gum::VariableSet * _primedVars_
The set of variables we want to keep at the end.
Definition regress.h:125
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _rd_
The resulting function graph.
Definition regress.h:122
const DiscreteVariable * _targetVar_
The variable we work on to eleminate.
Definition regress.h:128
const GUM_ELEMENT _neutral_
The function to be performed on the leaves.
Definition regress.h:131
short int * _default_
Just a computationnal trick.
Definition regress.h:150
HashTable< NodeId, short int * > _DG1InstantiationNeeded_
Table uses to know if a given node of given function graph has retrograde variables.
Definition regress.h:146
Regress(const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *vfunction, const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > *probDist, const gum::VariableSet *primedVars, const DiscreteVariable *targetVar, const GUM_ELEMENT neutral)
Default constructor.
Definition regress_tpl.h:65
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * _DG2_
The other one.
Definition regress.h:119
const PROJECTOPERATOR< GUM_ELEMENT > _project_
Definition regress.h:138
const COMBINEOPERATOR< GUM_ELEMENT > _combine_
The functions to be performed on the leaves.
Definition regress.h:137
Idx _nbVar_
The total number of variable implied in the operation.
Definition regress.h:134

References Regress(), _combine_, _default_, _DG1_, _DG1InstantiationNeeded_, _DG2_, _DG2InstantiationNeeded_, _nbVar_, _neutral_, _primedVars_, _project_, _rd_, _targetVar_, and gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::getReducedAndOrderedInstance().

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

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

◆ ~Regress()

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::~Regress ( )

Default destructor.

Definition at line 86 of file regress_tpl.h.

86 {
88
89 for (auto instIter = _DG1InstantiationNeeded_.beginSafe();
91 ++instIter)
92 DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
93
94 for (auto instIter = _DG2InstantiationNeeded_.beginSafe();
96 ++instIter)
97 DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
98
99 if (_nbVar_ != 0) DEALLOCATE(_default_, sizeof(short int) * _nbVar_);
100 }
#define DEALLOCATE(x, y)

References Regress(), _default_, _DG1InstantiationNeeded_, _DG2InstantiationNeeded_, _nbVar_, and DEALLOCATE.

Here is the call graph for this function:

Member Function Documentation

◆ _compute_()

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

The main recursion function.

Definition at line 311 of file regress_tpl.h.

313 {
314 NodeId newNode = 0;
315
316 // If both current nodes are terminal,
317 // we only have to compute the resulting value
318 if (_DG1_->isTerminalNode(currentSituation.DG1Node())
319 && _DG2_->isTerminalNode(currentSituation.DG2Node())) {
320 // We have to compute new valueand we insert a new node in diagram with
321 // this value, ...
323 GUM_ELEMENT tempVal = _combine_(_DG1_->nodeValue(currentSituation.DG1Node()),
324 _DG2_->nodeValue(currentSituation.DG2Node()));
325 for (Idx targetModa = 0; targetModa < _targetVar_->domainSize(); ++targetModa)
327 return _rd_->manager()->addTerminalNode(newVal);
328 }
329
330 // If not,
331 // we'll have to do some exploration
332
333 // First we ensure that we hadn't already visit this pair of node under hte
334 // same circumstances
335 short int* dg1NeededVar = _DG1InstantiationNeeded_.exists(currentSituation.DG1Node())
337 : _default_;
339 = _DG1_->isTerminalNode(currentSituation.DG1Node())
340 ? _nbVar_
341 : _rd_->variablesSequence().pos(_DG1_->node(currentSituation.DG1Node())->nodeVar());
342 short int* dg2NeededVar = _DG2InstantiationNeeded_.exists(currentSituation.DG2Node())
344 : _default_;
346 = _DG2_->isTerminalNode(currentSituation.DG2Node())
347 ? _nbVar_
348 : _rd_->variablesSequence().pos(_DG2_->node(currentSituation.DG2Node())->nodeVar());
349
350 short int* instNeeded = static_cast< short int* >(ALLOCATE(sizeof(short int) * _nbVar_));
351
352 for (Idx i = 0; i < _nbVar_; i++) {
354 }
355
357
358 if (_explorationTable_.exists(curSitKey)) {
359 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
360
362 }
363
364 // ====================================================
365
366 NodeId origDG1 = currentSituation.DG1Node(), origDG2 = currentSituation.DG2Node();
367
369 NodeId leadNodeId = 0;
370 Idx leadVarPos = _rd_->variablesSequence().size();
371 using SetNodeFunction = void (O4DGContext::*)(const NodeId&);
373
374 bool sameVar = false;
375
376 if (!_DG1_->isTerminalNode(currentSituation.DG1Node())) {
377 if (currentSituation.varModality(dg1CurrentVarPos) != 0) {
378 // If var associated to current node has already been instanciated, we
379 // have to jump it
380 currentSituation.setDG1Node(_DG1_->node(currentSituation.DG1Node())
381 ->son(currentSituation.varModality(dg1CurrentVarPos) - 1));
382
385 currentSituation.setDG1Node(origDG1);
386 currentSituation.setDG2Node(origDG2);
387
388 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
389
390 return newNode;
391 }
392
393 leaddg = _DG1_;
394 leadNodeId = currentSituation.DG1Node();
397 }
398
399 if (!_DG2_->isTerminalNode(currentSituation.DG2Node())) {
400 if (currentSituation.varModality(dg2CurrentVarPos) != 0) {
401 // If var associated to current node has already been instanciated, we
402 // have to jump it
403 currentSituation.setDG2Node(_DG2_->node(currentSituation.DG2Node())
404 ->son(currentSituation.varModality(dg2CurrentVarPos) - 1));
405
408 currentSituation.setDG1Node(origDG1);
409 currentSituation.setDG2Node(origDG2);
410
411 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
412
413 return newNode;
414 }
415
416 if (leadVarPos == dg2CurrentVarPos) { sameVar = true; }
417
419 leaddg = _DG2_;
420 leadNodeId = currentSituation.DG2Node();
423 }
424 }
425
426 // ====================================================
427 // Anticipated Exploration
428
429 // Before exploring nodes, we have to ensure that every anticipated
430 // exploration is done
431 for (Idx varPos = lastInstVarPos + 1; varPos < leadVarPos; ++varPos) {
432 if (instNeeded[varPos]) {
433 const DiscreteVariable* curVar = _rd_->variablesSequence().atPos(varPos);
434 NodeId* sonsIds = static_cast< NodeId* >(ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
435
436 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
437 currentSituation.chgVarModality(varPos, modality + 1);
438
440 }
441
442 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
443
445 currentSituation.chgVarModality(varPos, 0);
446 currentSituation.setDG1Node(origDG1);
447 currentSituation.setDG2Node(origDG2);
448
449 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
450
451 return newNode;
452 }
453 }
454
455 // ====================================================
456 // Terminal Exploration
457 if (sameVar && _DG1_->node(origDG1)->nodeVar() == _targetVar_) {
459 for (Idx targetModa = 0; targetModa < _targetVar_->domainSize(); ++targetModa)
461 _combine_(_DG1_->nodeValue(_DG1_->node(origDG1)->son(targetModa)),
462 _DG2_->nodeValue(_DG2_->node(origDG2)->son(targetModa))));
463 newNode = _rd_->manager()->addTerminalNode(newVal);
465 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
466 return newNode;
467 }
468 if (_DG1_->isTerminalNode(origDG1)) {
469 if (_DG2_->node(origDG2)->nodeVar() == _targetVar_) {
471 for (Idx targetModa = 0; targetModa < _targetVar_->domainSize(); ++targetModa)
473 _combine_(_DG1_->nodeValue(origDG1),
474 _DG2_->nodeValue(_DG2_->node(origDG2)->son(targetModa))));
475 newNode = _rd_->manager()->addTerminalNode(newVal);
477 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
478 return newNode;
479 }
480 } else {
481 if (_DG1_->node(origDG1)->nodeVar() == _targetVar_ && _DG2_->isTerminalNode(origDG2)) {
483 for (Idx targetModa = 0; targetModa < _targetVar_->domainSize(); ++targetModa)
485 _combine_(_DG1_->nodeValue(_DG1_->node(origDG1)->son(targetModa)),
486 _DG2_->nodeValue(origDG2)));
487 newNode = _rd_->manager()->addTerminalNode(newVal);
489 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
490 return newNode;
491 }
492 }
493
494 // ====================================================
495 // Normal Exploration
496
497 // If only one of the current node is terminal,
498 // we have to pursue deeper on the other diagram
499 if (sameVar) {
500 // If so - meaning it's the same variable - we have to go
501 // down on both
502 const InternalNode* dg1Node = _DG1_->node(origDG1);
503 const InternalNode* dg2Node = _DG2_->node(origDG2);
504
505 const DiscreteVariable* curVar = dg1Node->nodeVar();
506 Idx varPos = _rd_->variablesSequence().pos(curVar);
507 NodeId* sonsIds = static_cast< NodeId* >(ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
508
509 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
510 currentSituation.chgVarModality(varPos, modality + 1);
511 currentSituation.setDG1Node(dg1Node->son(modality));
512 currentSituation.setDG2Node(dg2Node->son(modality));
513
515 }
516
517 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
518
520 currentSituation.chgVarModality(varPos, 0);
521 currentSituation.setDG1Node(origDG1);
522 currentSituation.setDG2Node(origDG2);
523
524 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
525
526 return newNode;
527 }
528 // ====================================================
529 else {
531
532 const DiscreteVariable* curVar = leaddgNode->nodeVar();
533 NodeId* sonsIds = static_cast< NodeId* >(ALLOCATE(sizeof(NodeId) * curVar->domainSize()));
534
535 for (Idx modality = 0; modality < curVar->domainSize(); modality++) {
536 currentSituation.chgVarModality(leadVarPos, modality + 1);
538
540 }
541
542 newNode = _rd_->manager()->addInternalNode(curVar, sonsIds);
543
545 currentSituation.chgVarModality(leadVarPos, 0);
546 currentSituation.setDG1Node(origDG1);
547 currentSituation.setDG2Node(origDG2);
548
549 DEALLOCATE(instNeeded, sizeof(short int) * _nbVar_);
550
551 return newNode;
552 }
553 }
HashTable< double, NodeId > _explorationTable_
The hashtable used to know if two pair of nodes have already been visited.
Definition regress.h:142
NodeId _compute_(O4DGContext &currentSituation, Idx lastInstVarPos)
The main recursion function.
#define ALLOCATE(x)

References _combine_, _compute_(), _default_, _DG1_, _DG1InstantiationNeeded_, _DG2_, _DG2InstantiationNeeded_, _explorationTable_, _nbVar_, _neutral_, _project_, _rd_, _targetVar_, ALLOCATE, gum::O4DGContext::chgVarModality(), DEALLOCATE, gum::O4DGContext::DG1Node(), gum::O4DGContext::DG2Node(), gum::DiscreteVariable::domainSize(), gum::O4DGContext::key(), gum::InternalNode::nodeVar(), gum::O4DGContext::setDG1Node(), gum::O4DGContext::setDG2Node(), 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:

◆ _establishVarOrder_()

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
void gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_establishVarOrder_ ( )
private

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

Definition at line 142 of file regress_tpl.h.

143 {
144 SequenceIteratorSafe< const DiscreteVariable* > fite = _DG1_->variablesSequence().beginSafe();
145 SequenceIteratorSafe< const DiscreteVariable* > site = _DG2_->variablesSequence().beginSafe();
146
147 while (fite != _DG1_->variablesSequence().endSafe()
148 && site != _DG2_->variablesSequence().endSafe()) {
149 // Test : if var from first order is already in final order
150 // we move onto the next one
151 if (_rd_->variablesSequence().exists(*fite)) {
152 ++fite;
153 continue;
154 }
155
156 // Test : if var from second order is already in final order
157 // we move onto the next one
158 if (_rd_->variablesSequence().exists(*site)) {
159 ++site;
160 continue;
161 }
162
163 // Test : is current var of the first order present in the second order.
164 // if not we add it to final order
165 if (!_DG2_->variablesSequence().exists(*fite) && !_primedVars_->exists(*fite)) {
166 _rd_->add(**fite);
167 ++fite;
168 continue;
169 }
170
171 // Test : is current var of the second order present in the first order.
172 // if not we add it to final order
173 if (!_DG1_->variablesSequence().exists(*site) && !_primedVars_->exists(*site)) {
174 _rd_->add(**site);
175 ++site;
176 continue;
177 }
178
179 // Test : is current var of the second order present in the first order.
180 // if not we add it to final order
181 if (*fite == *site) {
182 _rd_->add(**fite);
183 ++fite;
184 ++site;
185 continue;
186 }
187
188 // Test : if chosing first order var cost less in terms or re exploration,
189 // we chose it
190 _rd_->add(**fite);
191 ++fite;
192 }
193
194 // Whenever an iterator has finished its sequence,
195 // the other may still be in the middle of its one.
196 // Hence, this part ensures that any variables remaining
197 // will be added to the final sequence if needed.
198 if (fite == _DG1_->variablesSequence().endSafe()) {
199 for (; site != _DG2_->variablesSequence().endSafe(); ++site)
200 if (!_rd_->variablesSequence().exists(*site)) _rd_->add(**site);
201 } else {
202 for (; fite != _DG1_->variablesSequence().endSafe(); ++fite)
203 if (!_rd_->variablesSequence().exists(*fite)) _rd_->add(**fite);
204 }
205
206 // Various initialization needed now that we have a bigger picture
207 _nbVar_ = _rd_->variablesSequence().size();
208
209 if (_nbVar_ != 0) {
210 _default_ = static_cast< short int* >(ALLOCATE(sizeof(short int) * _nbVar_));
211 for (Idx i = 0; i < _nbVar_; i++)
212 _default_[i] = (short int)0;
213 }
214 }

References _default_, _DG1_, _DG2_, _nbVar_, _primedVars_, _rd_, and ALLOCATE.

Referenced by compute().

Here is the caller graph for this function:

◆ _findRetrogradeVariables_()

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
void gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, 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 222 of file regress_tpl.h.

224 {
226 Size tableSize = Size(_nbVar_ * sizeof(short int));
227
228 for (auto varIter = dg->variablesSequence().rbeginSafe();
229 varIter != dg->variablesSequence().rendSafe();
230 --varIter) {
231 Idx varPos = _rd_->variablesSequence().pos(*varIter);
232
233 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
234 while (nodeIter != nullptr) {
235 short int* instantiationNeeded = static_cast< short int* >(ALLOCATE(tableSize));
236 dgInstNeed.insert(nodeIter->element(), instantiationNeeded);
237 short int* varDescendant = static_cast< short int* >(ALLOCATE(tableSize));
238 nodesVarDescendant.insert(nodeIter->element(), varDescendant);
239 for (Idx j = 0; j < _nbVar_; j++) {
240 instantiationNeeded[j] = (short int)0;
241 varDescendant[j] = (short int)0;
242 }
243
244
245 varDescendant[varPos] = (short int)1;
246 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
247 if (!dg->isTerminalNode(dg->node(nodeIter->element())->son(modality))) {
248 short int* sonVarDescendant
249 = nodesVarDescendant[dg->node(nodeIter->element())->son(modality)];
250 for (Idx varIdx = 0; varIdx < _nbVar_; varIdx++) {
253 instantiationNeeded[varIdx] = (short int)1;
254 }
255 }
256 }
257 nodeIter = nodeIter->nextLink();
258 }
259 }
260
261 for (auto varIter = dg->variablesSequence().beginSafe();
262 varIter != dg->variablesSequence().endSafe();
263 ++varIter) {
264 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
265 while (nodeIter != nullptr) {
266 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
267 NodeId sonId = dg->node(nodeIter->element())->son(modality);
268 if (!dg->isTerminalNode(sonId)) {
269 for (Idx varIdx = 0; varIdx < _nbVar_; ++varIdx) {
271 dgInstNeed[sonId][varIdx] = (short int)1;
272 }
273 }
274 }
275 }
276 nodeIter = nodeIter->nextLink();
277 }
278 }
279
281 it != nodesVarDescendant.end();
282 ++it) {
283 DEALLOCATE(it.val(), tableSize);
284 }
285
286 nodesVarDescendant.clear();
287 }
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References _nbVar_, _rd_, ALLOCATE, gum::HashTable< Key, Val >::begin(), gum::HashTable< Key, Val >::clear(), DEALLOCATE, gum::Link< T >::element(), gum::HashTable< Key, Val >::end(), gum::HashTable< Key, Val >::insert(), gum::Link< T >::nextLink(), 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 COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::compute ( )

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

Definition at line 109 of file regress_tpl.h.

109 {
113
114 Idx* varInst = nullptr;
115 if (_nbVar_ != 0) {
116 varInst = static_cast< Idx* >(ALLOCATE(sizeof(Idx) * _nbVar_));
117 for (Idx i = 0; i < _nbVar_; i++)
118 varInst[i] = (Idx)0;
119 }
120
122 conti.setDG1Node(_DG1_->root());
123 conti.setDG2Node(_DG2_->root());
124
125 NodeId root = _compute_(conti, (Idx)0 - 1);
126 _rd_->manager()->setRootNode(root);
127
128 if (_nbVar_ != 0) DEALLOCATE(varInst, sizeof(Idx) * _nbVar_);
129
130 _rd_->erase(*_targetVar_);
131
132 return _rd_;
133 }
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_, _targetVar_, ALLOCATE, DEALLOCATE, gum::O4DGContext::setDG1Node(), and gum::O4DGContext::setDG2Node().

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

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

Member Data Documentation

◆ _combine_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const COMBINEOPERATOR< GUM_ELEMENT > gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_combine_
private

The functions to be performed on the leaves.

Definition at line 137 of file regress.h.

Referenced by Regress(), and _compute_().

◆ _default_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
short int* gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_default_
private

Just a computationnal trick.

Definition at line 150 of file regress.h.

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

◆ _DG1_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >* gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_DG1_
private

One of the two function graphs used for the operation.

Definition at line 116 of file regress.h.

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

◆ _DG1InstantiationNeeded_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_DG1InstantiationNeeded_
private

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

Definition at line 146 of file regress.h.

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

◆ _DG2_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >* gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_DG2_
private

The other one.

Definition at line 119 of file regress.h.

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

◆ _DG2InstantiationNeeded_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_DG2InstantiationNeeded_
private

Definition at line 147 of file regress.h.

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

◆ _explorationTable_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< double, NodeId > gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_explorationTable_
private

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

Definition at line 142 of file regress.h.

Referenced by _compute_().

◆ _nbVar_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_nbVar_
private

The total number of variable implied in the operation.

Definition at line 134 of file regress.h.

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

◆ _neutral_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const GUM_ELEMENT gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_neutral_
private

The function to be performed on the leaves.

Definition at line 131 of file regress.h.

Referenced by Regress(), and _compute_().

◆ _primedVars_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const gum::VariableSet* gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_primedVars_
private

The set of variables we want to keep at the end.

Definition at line 125 of file regress.h.

Referenced by Regress(), and _establishVarOrder_().

◆ _project_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const PROJECTOPERATOR< GUM_ELEMENT > gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_project_
private

Definition at line 138 of file regress.h.

Referenced by Regress(), and _compute_().

◆ _rd_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >* gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_rd_
private

The resulting function graph.

Definition at line 122 of file regress.h.

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

◆ _targetVar_

template<typename GUM_ELEMENT, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const DiscreteVariable* gum::Regress< GUM_ELEMENT, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_targetVar_
private

The variable we work on to eleminate.

Definition at line 128 of file regress.h.

Referenced by Regress(), _compute_(), and compute().


The documentation for this class was generated from the following files:
  • agrum/base/multidim/utils/FunctionGraphUtilities/operators/regress.h
  • agrum/base/multidim/utils/FunctionGraphUtilities/operators/regress_tpl.h