aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
fmdpFactory_tpl.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41#pragma once
42
43
51
55
56// #define FMDP_VERBOSITY(x) { if (isVerbose()) std::cerr << "[FMDP factory]
57// "<< x << std::endl; }
58
59
60namespace gum {
61
62 /* ****************************************************************************************************
63 * **/
64 /* ** **/
65 /* ** Constructor &
66 * Destructor **/
67 /* ** **/
68 /* ****************************************************************************************************
69 * **/
70
71 // Default constructor.
72 // @param fmdp A pointer over the Factored Markov Decision Process filled by
73 // this factory.
74
75 template < typename GUM_ELEMENT >
83
84 // Destructor
85
86 template < typename GUM_ELEMENT >
90
91 /* ****************************************************************************************************
92 * **/
93 /* ** **/
94 /* ** Getter and
95 * setters **/
96 /* ** **/
97 /* ****************************************************************************************************
98 * **/
99
100 // Returns the IBayesNet created by this factory.
101
102 template < typename GUM_ELEMENT >
106 "Illegal state to return the factored "
107 "markov decision process: it is not yet "
108 "finished.");
109
110 return _fmdp_;
111 }
112
113 // Returns the current state of the factory.
114
115 template < typename GUM_ELEMENT >
117 // This is ok because there is alway at least the state
118 // FMDPfactory_state::NONE in the stack.
119 return _states_.back();
120 }
121
122 // Returns a constant reference on a variable given it's name.
123 // @throw NotFound Raised if no variable matches the name.
124
125 template < typename GUM_ELEMENT >
126 const DiscreteVariable* FMDPFactory< GUM_ELEMENT >::variable(std::string_view name) const {
127 for (const auto& elt: _varNameMap_)
128 if (elt.first.compare(name) == 0) return elt.second;
129
130 GUM_ERROR(NotFound, name)
131
132 return nullptr;
133 }
134
135 /* ****************************************************************************************************
136 * **/
137 /* ** **/
138 /* ** Variable declaration methods (FMDPfactory_state::NONE <->
139 * FMDPfactory_state::VARIABLE) **/
140 /* ** **/
141 /* ****************************************************************************************************
142 * **/
143
144 // Tells the factory that we're in a variable declaration.
145
146 template < typename GUM_ELEMENT >
148 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startVariableDeclaration");
149 else {
151 _stringBag_.push_back("name");
152 _stringBag_.push_back("desc");
153 }
154
155 // VERBOSITY ( " starting variable" );
156 }
157
158 // Tells the factory the current variable's name.
159
160 template < typename GUM_ELEMENT >
161 void FMDPFactory< GUM_ELEMENT >::variableName(std::string_view name) {
162 if (state() != FMDPfactory_state::VARIABLE) _illegalStateError_("variableName");
163 else {
164 if (_varNameMap_.exists(name)) GUM_ERROR(DuplicateElement, "Name already used: " << name)
165
166 _foo_flag_ = true;
167 _stringBag_[0] = name;
168 // VERBOSITY ( " -- variable " << name );
169 }
170 }
171
172 // Tells the factory the current variable's description.
173
174 template < typename GUM_ELEMENT >
176 if (state() != FMDPfactory_state::VARIABLE) _illegalStateError_("variableDescription");
177 else {
178 _bar_flag_ = true;
179 _stringBag_[1] = desc;
180 }
181 }
182
183 // Adds a modality to the current variable.
184 // @throw DuplicateElement If the current variable already has a modality
185 // with the same name.
186
187 template < typename GUM_ELEMENT >
188 void FMDPFactory< GUM_ELEMENT >::addModality(std::string_view name) {
190 else {
192 _stringBag_.emplace_back(name);
193 }
194 }
195
196 // Check if in _stringBag_ there is no other modality with the same name.
197
198 template < typename GUM_ELEMENT >
200 for (size_t i = 2; i < _stringBag_.size(); ++i)
201 if (mod == _stringBag_[i])
202 GUM_ERROR(DuplicateElement, "Modality" << mod << " already exists.")
203 }
204
205 // Tells the factory that we're out of a variable declaration.
206
207 template < typename GUM_ELEMENT >
209 if (state() != FMDPfactory_state::VARIABLE) _illegalStateError_("endVariableDeclaration");
210 else if (_foo_flag_ && (_stringBag_.size() > 3)) {
212 = new LabelizedVariable(_stringBag_[0], (_bar_flag_) ? _stringBag_[1] : "", 0);
213
214 for (size_t i = 2; i < _stringBag_.size(); ++i) {
215 var->addLabel(_stringBag_[i]);
216 }
217
218 _fmdp_->addVariable(var);
219 _fmdp_->setDeleteVariablesOnDestruction(true);
220 _varNameMap_.insert(var->name(), var);
221 _varNameMap_.insert(_fmdp_->main2prime(var)->name(), _fmdp_->main2prime(var));
222
223 _resetParts_();
224 _states_.pop_back();
225
226 // VERBOSITY ( " variable " << var->name() << " OK" );
227
228 } else {
229 const size_t nModa = _stringBag_.size() > 2 ? _stringBag_.size() - 2 : size_t{0};
230 const std::string varName = _foo_flag_ ? _stringBag_[0] : "unknown";
231
232 _resetParts_();
233 _states_.pop_back();
234
236 std::format("Not enough modalities ({}) declared for variable {}", nModa, varName))
237 }
238 }
239
240 /* ****************************************************************************************************
241 * **/
242 /* ** **/
243 /* ** Action declaration methods (FMDPfactory_state::NONE <->
244 * FMDPfactory_state::ACTION) **/
245 /* ** **/
246 /* ****************************************************************************************************
247 * **/
248
249 // Tells the factory that we're declaring action
250
251 template < typename GUM_ELEMENT >
253 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startActionDeclaration");
254 else {
255 _foo_flag_ = true;
257 }
258
259 // VERBOSITY ( "starting action declaration" );
260 }
261
262 // Tells the factory to add an action
263
264 template < typename GUM_ELEMENT >
265 void FMDPFactory< GUM_ELEMENT >::addAction(std::string_view action) {
267 else {
268 _stringBag_.emplace_back(action);
269 _fmdp_->addAction(_actionIdcpt_++, std::string(action));
270 }
271 }
272
273 // Tells the factory that we're out of an action declaration.
274
275 template < typename GUM_ELEMENT >
277 if (state() != FMDPfactory_state::ACTION) _illegalStateError_("endActionDeclaration");
278 else {
279 _states_.pop_back();
280 _resetParts_();
281 }
282
283 // VERBOSITY ( "action OK" );
284 }
285
286 /* ****************************************************************************************************
287 * **/
288 /* ** **/
289 /* ** Transition declaration methods **/
290 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::TRANSITION <->
291 * FMDPfactory_state::ACTION) **/
292 /* ** **/
293 /* ****************************************************************************************************
294 * **/
295
296 // Tells the factory that we're declaring transition
297
298 template < typename GUM_ELEMENT >
301 _illegalStateError_("startTransitionDeclaration");
303
304 // VERBOSITY ( "starting transition declaration" );
306 }
307
308 // Tells the factory to add an action
309
310 template < typename GUM_ELEMENT >
312 const MultiDimAdressable* transition) {
314 = static_cast< const MultiDimImplementation< GUM_ELEMENT >* >(transition);
315
317 else if (_foo_flag_)
318 _fmdp_->addTransitionForAction(_fmdp_->actionId(_stringBag_[0]), variable(var), t);
319 else _fmdp_->addTransition(variable(var), t);
320 }
321
322 // Tells the factory to add a transition table to the current fmdp.
323 // This transition table will be extracted from incorporated
324 // multiDimFunctionGraph.
325
326 template < typename GUM_ELEMENT >
327 void FMDPFactory< GUM_ELEMENT >::addTransition(std::string_view var) {
329 else {
331
332 if (_foo_flag_) {
333 this->_FunctionGraph_->setTableName("ACTION :" + _stringBag_[0]
334 + " - VARIABLE : " + std::string(var));
335 _fmdp_->addTransitionForAction(_fmdp_->actionId(_stringBag_[0]),
336 variable(var),
337 this->_FunctionGraph_);
338 } else {
339 _fmdp_->addTransition(variable(var), this->_FunctionGraph_);
340 }
341 }
342 }
343
344 // Tells the factory that we're out of a transition declaration.
345
346 template < typename GUM_ELEMENT >
348 if (state() != FMDPfactory_state::TRANSITION) _illegalStateError_("endTransitionDeclaration");
349 else _states_.pop_back();
350
351 // VERBOSITY ( "transition OK" );
352 }
353
354 /* ****************************************************************************************************
355 * **/
356 /* ** **/
357 /* ** Cost declaration methods **/
358 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::COST <->
359 * FMDPfactory_state::ACTION) **/
360 /* ** **/
361 /* ****************************************************************************************************
362 * **/
363
364 // Tells the factory that we're declaring cost
365
366 template < typename GUM_ELEMENT >
369 _illegalStateError_("startTransitionDeclaration");
370 else _states_.push_back(FMDPfactory_state::COST);
371
372 // VERBOSITY ( "starting Cost declaration" );
374 }
375
376 // Tells the factory to add a cost
377
378 template < typename GUM_ELEMENT >
381 = static_cast< const MultiDimImplementation< GUM_ELEMENT >* >(cost);
382
384 else if (_foo_flag_) _fmdp_->addCostForAction(_fmdp_->actionId(_stringBag_[0]), c);
385 else _fmdp_->addCost(c);
386 }
387
388 // Tells the factory to add a cost
389 // This cost table will be extracted from incorporated multiDimFunctionGraph.
390
391 template < typename GUM_ELEMENT >
394 else {
396
397 if (_foo_flag_)
398 _fmdp_->addCostForAction(_fmdp_->actionId(_stringBag_[0]), this->_FunctionGraph_);
399 else _fmdp_->addCost(this->_FunctionGraph_);
400 }
401 }
402
403 // Tells the factory that we're out of a cost declaration.
404
405 template < typename GUM_ELEMENT >
407 if (state() != FMDPfactory_state::COST) _illegalStateError_("endCostDeclaration");
408 else _states_.pop_back();
409
410 // VERBOSITY ( "Cost OK" );
411 }
412
413 /* ****************************************************************************************************
414 * **/
415 /* ** **/
416 /* ** Reward declaration methods **/
417 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::REWARD <->
418 * FMDPfactory_state::ACTION) **/
419 /* ** **/
420 /* ****************************************************************************************************
421 * **/
422
423 // Tells the factory that we're declaring reward
424
425 template < typename GUM_ELEMENT >
428 _illegalStateError_("startRewardDeclaration");
429 else _states_.push_back(FMDPfactory_state::REWARD);
430
431 // VERBOSITY ( "starting reward declaration" );
433 }
434
435 // Tells the factory that we're in a reward declaration mode where the global
436 // reward diagram is an operation between simplier dd
437
438 template < typename GUM_ELEMENT >
439 void FMDPFactory< GUM_ELEMENT >::setOperationModeOn(std::string_view operationType) {
440 _foo_flag_ = true;
441 _stringBag_.push_back(std::string{operationType});
442 }
443
444 // Tells the factory to add a reward
445
446 template < typename GUM_ELEMENT >
449 = static_cast< const MultiDimImplementation< GUM_ELEMENT >* >(reward);
450
452 else _fmdp_->addReward(r);
453 }
454
455 // Tells the factory to add a reward
456 // This reward table will be extracted from incorporated
457 // multiDimFunctionGraph.
458
459 template < typename GUM_ELEMENT >
462 else {
464 _FunctionGraph_->setTableName("Reward");
465
466 if (_foo_flag_) _ddBag_.push_back(this->_FunctionGraph_);
467 else _fmdp_->addReward(this->_FunctionGraph_);
468 }
469 }
470
471 // Tells the factory that we're out of a reward declaration.
472
473 template < typename GUM_ELEMENT >
475 if (state() != FMDPfactory_state::REWARD) _illegalStateError_("endRewardDeclaration");
476 else {
477 if (_foo_flag_) {
479
480 for (const auto elt: _ddBag_) {
481 if (res == nullptr) {
482 res = const_cast< MultiDimImplementation< GUM_ELEMENT >* >(elt);
483 continue;
484 }
486
487 switch (_stringBag_[0][0]) {
488 case '+' : res = add2MultiDimFunctionGraphs(res, elt); break;
489
490 case '-' : res = subtract2MultiDimFunctionGraphs(res, elt); break;
491
492 case '*' : res = multiply2MultiDimFunctionGraphs(res, elt); break;
493
494 case '/' : res = divide2MultiDimFunctionGraphs(res, elt); break;
495
496 default : break;
497 }
498
499 delete elt;
500 delete temp;
501 }
502
503 if (res != nullptr) {
504 static_cast< MultiDimFunctionGraph< GUM_ELEMENT >* >(res)->setTableName("Reward");
505 _fmdp_->addReward(res);
506 }
507 }
508
509 _resetParts_();
510 _states_.pop_back();
511 }
512 // VERBOSITY ( "reward OK" );
513 }
514
515 /* ****************************************************************************************************
516 * **/
517 /* ** **/
518 /* ** Discount declaration methods **/
519 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
520 * FMDPfactory_state::ACTION) **/
521 /* ** **/
522 /* ****************************************************************************************************
523 * **/
524
525 // Tells the factory that we're declaring discount
526 template < typename GUM_ELEMENT >
528 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startDiscountDeclaration");
530
531 // VERBOSITY ( "starting discount declaration" );
532 }
533
534 // Tells the factory to add a discount
535
536 template < typename GUM_ELEMENT >
539 else _fmdp_->setDiscount((GUM_ELEMENT)discount);
540 }
541
542 // Tells the factory that we're out of a discount declaration.
543
544 template < typename GUM_ELEMENT >
546 if (state() != FMDPfactory_state::DISCOUNT) _illegalStateError_("endDiscountDeclaration");
547 else _states_.pop_back();
548
549 // VERBOSITY ( "discount OK" );
550 }
551
552 /* ****************************************************************************************************
553 * **/
554 /* ** **/
555 /* ** Discount declaration methods **/
556 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
557 * FMDPfactory_state::ACTION) **/
558 /* ** **/
559 /* ****************************************************************************************************
560 * **/
561
562 // Insert in diagram a non terminal node
563
564 template < typename GUM_ELEMENT >
566 return _FunctionGraph_->manager()->addInternalNode(variable(name_of_var));
567 }
568
569 // Insert in diagram a terminal node
570
571 template < typename GUM_ELEMENT >
573 return _FunctionGraph_->manager()->addTerminalNode((GUM_ELEMENT)value);
574 }
575
576 // Insert an arc in diagram
577 template < typename GUM_ELEMENT >
579 _FunctionGraph_->manager()->setSon(from, modality, to);
580 }
581
582 template < typename GUM_ELEMENT >
584 _FunctionGraph_->manager()->setRootNode(rootId);
585 }
586
587 /* ****************************************************************************************************
588 * **/
589 /* ** **/
590 /* ** Various Private Methods **/
591 /* ** **/
592 /* ****************************************************************************************************
593 * **/
594
595 // Raise an OperationNotAllowed with the message "Illegal state."
596
597 template < typename GUM_ELEMENT >
599 std::string msg = "Illegal state call (";
600 msg += s;
601 msg += ") in state ";
602
603 switch (state()) {
604 case FMDPfactory_state::NONE : msg += "FMDPfactory_state::NONE"; break;
605
606 case FMDPfactory_state::VARIABLE : msg += "FMDPfactory_state::VARIABLE"; break;
607
608 case FMDPfactory_state::ACTION : msg += "FMDPfactory_state::ACTION"; break;
609
610 case FMDPfactory_state::TRANSITION : msg += "FMDPfactory_state::TRANSITION"; break;
611
612 case FMDPfactory_state::COST : msg += "FMDPfactory_state::COST"; break;
613
614 case FMDPfactory_state::REWARD : msg += "FMDPfactory_state::REWARD"; break;
615
616 case FMDPfactory_state::DISCOUNT : msg += "FMDPfactory_state::DISCOUNT"; break;
617
618 default : msg += "Unknown state";
619 }
620
622 }
623
624 // Reset the different parts used to constructed the IBayesNet.
625
626 template < typename GUM_ELEMENT >
628 _foo_flag_ = false;
629 _bar_flag_ = false;
630 _stringBag_.clear();
631 _ddBag_.clear();
632 }
633
634 template < typename GUM_ELEMENT >
637 // Recopie des variables principales dans le graphe de décision
638 for (auto varIter = _fmdp_->beginVariables(); varIter != _fmdp_->endVariables(); ++varIter) {
639 _FunctionGraph_->add(**varIter);
640 }
641
642 // Recopie des version primes des variables dans le graphe de décision
643 for (auto varIter = _fmdp_->beginVariables(); varIter != _fmdp_->endVariables(); ++varIter) {
644 _FunctionGraph_->add(*(_fmdp_->main2prime(*varIter)));
645 }
646 }
647
648 template < typename GUM_ELEMENT >
650 this->_FunctionGraph_->manager()->reduce();
651 this->_FunctionGraph_->manager()->clean();
652 }
653
654 //~ ==============
655 //~ // Check if a variable with the given name exists, if not raise an
656 // NotFound
657 //~ // exception.
658 //~ ==============
659 //~ template<typename GUM_ELEMENT> INLINE
660 //~ void
661 //~ FMDPFactory<GUM_ELEMENT>:: _checkVariableName_ ( const std::string& name ) {
662 //~ if ( ! _varNameMap_.exists ( name ) )
663 //~ GUM_ERROR ( NotFound, name )
664 //~ }
665
666
667 // Copy operator is illegal, use only copy constructor.
668
669 template < typename GUM_ELEMENT >
672 GUM_ERROR(FatalError, "Illegal!")
673 // For noisy compilers
674 return *this;
675 }
676} /* namespace gum */
Base class for discrete random variable.
Exception : a similar element already exists.
A factory class to ease Factored Markov Decision Process construction.
Definition fmdpFactory.h:89
void variableName(std::string_view name) override
Tells the factory the current variable's name.
void addModality(std::string_view name) override
Adds a modality to the current variable.
void endVariableDeclaration() override
Tells the factory that we're out of a variable declaration.
NodeId addInternalNode(std::string_view name_of_var) override
Insert in diagram a non terminal node.
const DiscreteVariable * variable(std::string_view name) const override
Returns a constant reference on a variable given it's name.
void endTransitionDeclaration() override
Tells the factory that we're out of a transition declaration.
void endDiscountDeclaration() override
Tells the factory that we're out of a cost declaration.
~FMDPFactory() override
Destructor.
std::vector< FMDPfactory_state > _states_
State stack.
FMDPFactory< GUM_ELEMENT > & operator=(const FMDPFactory< GUM_ELEMENT > &source)
Copy operator is illegal, use only copy constructor.
void startActionDeclaration() override
Tells the factory that we're in an action declaration.
void addCost() override
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from inc...
void _resetParts_()
Reset the different parts used to constructed the FMDP.
HashTable< std::string, const DiscreteVariable * > _varNameMap_
Mapping between a declared variable's name and itself.
FMDP< GUM_ELEMENT > * _fmdp_
The constructed FMDP.
void addTransition(std::string_view var, const MultiDimAdressable *transition) override
Tells the factory to add a transition table to the current fmdp.
void _finalizeFunctionGraph_()
Insert every variables in the function graph.
void addArc(NodeId from, NodeId to, Idx modality) override
Insert in diagram a non terminal node.
void addReward() override
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from...
void endActionDeclaration() override
Tells the factory that we're out of an action declaration.
bool _foo_flag_
Depending on the context this flag is used for some VERY important reasons.
void _initializeFunctionGraph_()
Insert every variables in the function graph.
void setRoot(NodeId rootId) override
add an arc in diagram
void addDiscount(float discount) override
Tells the factory to add a cost table to the current fmdp.
MultiDimFunctionGraph< GUM_ELEMENT > * _FunctionGraph_
The FunctionGraph we're building at a given time.
void _checkModalityInBag_(std::string_view mod)
Used in VARIABLE mode Checks if in stringBag there is no other modality with the same name.
void endRewardDeclaration() override
Tells the factory that we're out of a cost declaration.
void startVariableDeclaration() override
Tells the factory that we're in a variable declaration.
FMDP< GUM_ELEMENT > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
void startDiscountDeclaration() override
Tells the factory that we're in a cost declaration.
void startCostDeclaration() override
Tells the factory that we're in a cost declaration.
FMDPFactory(FMDP< GUM_ELEMENT > *fmdp)
Use this constructor if you want to use an already created factored markov decision process.
FMDPfactory_state state() const override
Returns the current state of the factory.
NodeId addTerminalNode(float value) override
Insert in diagram a terminal node.
bool _bar_flag_
Depending on the context this flag is used for some VERY important reasons.
void endCostDeclaration() override
Tells the factory that we're out of a cost declaration.
std::vector< std::string > _stringBag_
Just to keep track of strings between two start/end calls.
Idx _actionIdcpt_
Action Id counter.
void variableDescription(std::string_view desc) override
Tells the factory the current variable's description.
std::vector< const MultiDimImplementation< GUM_ELEMENT > * > _ddBag_
Just to keep track of multidim between two start/end calls.
void startRewardDeclaration() override
Tells the factory that we're in a reward declaration.
void _illegalStateError_(std::string_view s)
Raise an OperationNotAllowed with the message "Illegal state.".
void startTransitionDeclaration() override
Tells the factory that we're in a transition declaration.
void addAction(std::string_view action) override
Tells the factory to add an action to the current fmdp.
void setOperationModeOn(std::string_view operationType) override
Tells the factory that we're in a reward declaration mode where the global reward diagram is an opera...
This class is used to implement factored decision process.
Definition fmdp.h:75
Exception : fatal (unknown ?) error.
class LabelizedVariable
LabelizedVariable & addLabel(std::string_view aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
LabelizedVariable()
(protected) Default constructor
Abstract base class for all multi dimensionnal addressable.
Class implementingting a function graph.
static MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.
<agrum/base/multidim/multiDimImplementation.h>
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
Headers of the FMDPFactory class.
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.
MultiDimFunctionGraph< T > * divide2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for dividing two multiDimArrays
MultiDimFunctionGraph< T > * multiply2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for multiplying two multiDimArrays
MultiDimFunctionGraph< T > * subtract2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for subtracting two multiDimArrays
MultiDimFunctionGraph< T > * add2MultiDimFunctionGraphs(const MultiDimFunctionGraph< T > *t1, const MultiDimFunctionGraph< T > *t2)
a specialized function for summing two multiDimArrays
Headers of gum::MultiDimImplementation.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
FMDPfactory_state
The enumeration of states in which the factory can be in.
Header of the Tensor class.