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

Public Member Functions

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

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.
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_SCALAR _neutral_
 The function to be performed on the leaves.
Idx _nbVar_
 The total number of variable implied in the operation.
const COMBINEOPERATOR< GUM_SCALAR > _combine_
 The functions to be performed on the leaves.
const PROJECTOPERATOR< GUM_SCALAR > _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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
class gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
INLINE gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::Regress ( const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * vfunction,
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * probDist,
const gum::VariableSet * primedVars,
const DiscreteVariable * targetVar,
const GUM_SCALAR neutral )

Default constructor.

Definition at line 64 of file regress_tpl.h.

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

References Regress(), _combine_, _default_, _DG1_, _DG1InstantiationNeeded_, _DG2_, _DG2InstantiationNeeded_, _nbVar_, _neutral_, _primedVars_, _project_, _rd_, _targetVar_, and gum::MultiDimFunctionGraph< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
INLINE gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::~Regress ( )

Default destructor.

Definition at line 85 of file regress_tpl.h.

85 {
87
88 for (auto instIter = _DG1InstantiationNeeded_.beginSafe();
90 ++instIter)
91 DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
92
93 for (auto instIter = _DG2InstantiationNeeded_.beginSafe();
95 ++instIter)
96 DEALLOCATE(instIter.val(), sizeof(short int) * _nbVar_);
97
98 if (_nbVar_ != 0) DEALLOCATE(_default_, sizeof(short int) * _nbVar_);
99 }
#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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
INLINE NodeId gum::Regress< GUM_SCALAR, 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_SCALAR 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
INLINE void gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_establishVarOrder_ ( )
private

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

Definition at line 141 of file regress_tpl.h.

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

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

Referenced by compute().

Here is the caller graph for this function:

◆ _findRetrogradeVariables_()

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

223 {
225 Size tableSize = Size(_nbVar_ * sizeof(short int));
226
227 for (auto varIter = dg->variablesSequence().rbeginSafe();
228 varIter != dg->variablesSequence().rendSafe();
229 --varIter) {
230 Idx varPos = _rd_->variablesSequence().pos(*varIter);
231
232 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
233 while (nodeIter != nullptr) {
234 short int* instantiationNeeded = static_cast< short int* >(ALLOCATE(tableSize));
235 dgInstNeed.insert(nodeIter->element(), instantiationNeeded);
236 short int* varDescendant = static_cast< short int* >(ALLOCATE(tableSize));
237 nodesVarDescendant.insert(nodeIter->element(), varDescendant);
238 for (Idx j = 0; j < _nbVar_; j++) {
239 instantiationNeeded[j] = (short int)0;
240 varDescendant[j] = (short int)0;
241 }
242
243
244 varDescendant[varPos] = (short int)1;
245 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
246 if (!dg->isTerminalNode(dg->node(nodeIter->element())->son(modality))) {
247 short int* sonVarDescendant
248 = nodesVarDescendant[dg->node(nodeIter->element())->son(modality)];
249 for (Idx varIdx = 0; varIdx < _nbVar_; varIdx++) {
252 instantiationNeeded[varIdx] = (short int)1;
253 }
254 }
255 }
256 nodeIter = nodeIter->nextLink();
257 }
258 }
259
260 for (auto varIter = dg->variablesSequence().beginSafe();
261 varIter != dg->variablesSequence().endSafe();
262 ++varIter) {
263 const Link< NodeId >* nodeIter = dg->varNodeListe(*varIter)->list();
264 while (nodeIter != nullptr) {
265 for (Idx modality = 0; modality < dg->node(nodeIter->element())->nbSons(); ++modality) {
266 NodeId sonId = dg->node(nodeIter->element())->son(modality);
267 if (!dg->isTerminalNode(sonId)) {
268 for (Idx varIdx = 0; varIdx < _nbVar_; ++varIdx) {
270 dgInstNeed[sonId][varIdx] = (short int)1;
271 }
272 }
273 }
274 }
275 nodeIter = nodeIter->nextLink();
276 }
277 }
278
280 it != nodesVarDescendant.end();
281 ++it) {
282 DEALLOCATE(it.val(), tableSize);
283 }
284
285 nodesVarDescendant.clear();
286 }
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_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 COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy>
INLINE MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::compute ( )

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

Definition at line 108 of file regress_tpl.h.

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

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

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

Member Data Documentation

◆ _combine_

template<typename GUM_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const COMBINEOPERATOR< GUM_SCALAR > gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
short int* gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< NodeId, short int* > gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_DG2InstantiationNeeded_
private

Definition at line 147 of file regress.h.

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

◆ _explorationTable_

template<typename GUM_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
HashTable< double, NodeId > gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
Idx gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const GUM_SCALAR gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const gum::VariableSet* gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const PROJECTOPERATOR< GUM_SCALAR > gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::_project_
private

Definition at line 138 of file regress.h.

Referenced by Regress(), and _compute_().

◆ _rd_

template<typename GUM_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >* gum::Regress< GUM_SCALAR, 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_SCALAR, template< typename > class COMBINEOPERATOR, template< typename > class PROJECTOPERATOR, template< typename > class TerminalNodePolicy = ExactTerminalNodePolicy>
const DiscreteVariable* gum::Regress< GUM_SCALAR, 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