aGrUM 3.1.1
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
72 // Default constructor.
73 // @param fmdp A pointer over the Factored Markov Decision Process filled by
74 // this factory.
75
76 template < typename GUM_ELEMENT >
84
85 // Destructor
86
87 template < typename GUM_ELEMENT >
91
92 /* ****************************************************************************************************
93 * **/
94 /* ** **/
95 /* ** Getter and
96 * setters **/
97 /* ** **/
98 /* ****************************************************************************************************
99 * **/
100
101
102 // Returns the IBayesNet created by this factory.
103
104 template < typename GUM_ELEMENT >
108 "Illegal state to return the factored "
109 "markov decision process: it is not yet "
110 "finished.");
111
112 return _fmdp_;
113 }
114
115 // Returns the current state of the factory.
116
117 template < typename GUM_ELEMENT >
119 // This is ok because there is alway at least the state
120 // FMDPfactory_state::NONE in the stack.
121 return _states_.back();
122 }
123
124 // Returns a constant reference on a variable given it's name.
125 // @throw NotFound Raised if no variable matches the name.
126
127 template < typename GUM_ELEMENT >
128 const DiscreteVariable* FMDPFactory< GUM_ELEMENT >::variable(std::string_view name) const {
129 for (const auto& elt: _varNameMap_)
130 if (elt.first.compare(name) == 0) return elt.second;
131
132 GUM_ERROR(NotFound, name)
133
134 return nullptr;
135 }
136
137 /* ****************************************************************************************************
138 * **/
139 /* ** **/
140 /* ** Variable declaration methods (FMDPfactory_state::NONE <->
141 * FMDPfactory_state::VARIABLE) **/
142 /* ** **/
143 /* ****************************************************************************************************
144 * **/
145
146
147 // Tells the factory that we're in a variable declaration.
148
149 template < typename GUM_ELEMENT >
151 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startVariableDeclaration");
152 else {
154 _stringBag_.push_back("name");
155 _stringBag_.push_back("desc");
156 }
157
158 // VERBOSITY ( " starting variable" );
159 }
160
161 // Tells the factory the current variable's name.
162
163 template < typename GUM_ELEMENT >
164 void FMDPFactory< GUM_ELEMENT >::variableName(std::string_view name) {
165 if (state() != FMDPfactory_state::VARIABLE) _illegalStateError_("variableName");
166 else {
167 if (_varNameMap_.exists(name)) GUM_ERROR(DuplicateElement, "Name already used: " << name)
168
169 _foo_flag_ = true;
170 _stringBag_[0] = name;
171 // VERBOSITY ( " -- variable " << name );
172 }
173 }
174
175 // Tells the factory the current variable's description.
176
177 template < typename GUM_ELEMENT >
179 if (state() != FMDPfactory_state::VARIABLE) _illegalStateError_("variableDescription");
180 else {
181 _bar_flag_ = true;
182 _stringBag_[1] = desc;
183 }
184 }
185
186 // Adds a modality to the current variable.
187 // @throw DuplicateElement If the current variable already has a modality
188 // with the same name.
189
190 template < typename GUM_ELEMENT >
191 void FMDPFactory< GUM_ELEMENT >::addModality(std::string_view name) {
193 else {
195 _stringBag_.emplace_back(name);
196 }
197 }
198
199 // Check if in _stringBag_ there is no other modality with the same name.
200
201 template < typename GUM_ELEMENT >
203 for (size_t i = 2; i < _stringBag_.size(); ++i)
204 if (mod == _stringBag_[i])
205 GUM_ERROR(DuplicateElement, "Modality" << mod << " already exists.")
206 }
207
208 // Tells the factory that we're out of a variable declaration.
209
210 template < typename GUM_ELEMENT >
212 if (state() != FMDPfactory_state::VARIABLE) _illegalStateError_("endVariableDeclaration");
213 else if (_foo_flag_ && (_stringBag_.size() > 3)) {
215 = new LabelizedVariable(_stringBag_[0], (_bar_flag_) ? _stringBag_[1] : "", 0);
216
217 for (size_t i = 2; i < _stringBag_.size(); ++i) {
218 var->addLabel(_stringBag_[i]);
219 }
220
221 _fmdp_->addVariable(var);
222 _fmdp_->setDeleteVariablesOnDestruction(true);
223 _varNameMap_.insert(var->name(), var);
224 _varNameMap_.insert(_fmdp_->main2prime(var)->name(), _fmdp_->main2prime(var));
225
226 _resetParts_();
227 _states_.pop_back();
228
229 // VERBOSITY ( " variable " << var->name() << " OK" );
230
231 } else {
232 const size_t nModa = _stringBag_.size() > 2 ? _stringBag_.size() - 2 : size_t{0};
233 const std::string varName = _foo_flag_ ? _stringBag_[0] : "unknown";
234
235 _resetParts_();
236 _states_.pop_back();
237
239 std::format("Not enough modalities ({}) declared for variable {}", nModa, varName))
240 }
241 }
242
243 /* ****************************************************************************************************
244 * **/
245 /* ** **/
246 /* ** Action declaration methods (FMDPfactory_state::NONE <->
247 * FMDPfactory_state::ACTION) **/
248 /* ** **/
249 /* ****************************************************************************************************
250 * **/
251
252
253 // Tells the factory that we're declaring action
254
255 template < typename GUM_ELEMENT >
257 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startActionDeclaration");
258 else {
259 _foo_flag_ = true;
261 }
262
263 // VERBOSITY ( "starting action declaration" );
264 }
265
266 // Tells the factory to add an action
267
268 template < typename GUM_ELEMENT >
269 void FMDPFactory< GUM_ELEMENT >::addAction(std::string_view action) {
271 else {
272 _stringBag_.emplace_back(action);
273 _fmdp_->addAction(_actionIdcpt_++, std::string(action));
274 }
275 }
276
277 // Tells the factory that we're out of an action declaration.
278
279 template < typename GUM_ELEMENT >
281 if (state() != FMDPfactory_state::ACTION) _illegalStateError_("endActionDeclaration");
282 else {
283 _states_.pop_back();
284 _resetParts_();
285 }
286
287 // VERBOSITY ( "action OK" );
288 }
289
290 /* ****************************************************************************************************
291 * **/
292 /* ** **/
293 /* ** Transition declaration methods **/
294 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::TRANSITION <->
295 * FMDPfactory_state::ACTION) **/
296 /* ** **/
297 /* ****************************************************************************************************
298 * **/
299
300
301 // Tells the factory that we're declaring transition
302
303 template < typename GUM_ELEMENT >
306 _illegalStateError_("startTransitionDeclaration");
308
309 // VERBOSITY ( "starting transition declaration" );
311 }
312
313 // Tells the factory to add an action
314
315 template < typename GUM_ELEMENT >
317 const MultiDimAdressable* transition) {
319 = static_cast< const MultiDimImplementation< GUM_ELEMENT >* >(transition);
320
322 else if (_foo_flag_)
323 _fmdp_->addTransitionForAction(_fmdp_->actionId(_stringBag_[0]), variable(var), t);
324 else _fmdp_->addTransition(variable(var), t);
325 }
326
327 // Tells the factory to add a transition table to the current fmdp.
328 // This transition table will be extracted from incorporated
329 // multiDimFunctionGraph.
330
331 template < typename GUM_ELEMENT >
332 void FMDPFactory< GUM_ELEMENT >::addTransition(std::string_view var) {
334 else {
336
337 if (_foo_flag_) {
338 this->_FunctionGraph_->setTableName("ACTION :" + _stringBag_[0]
339 + " - VARIABLE : " + std::string(var));
340 _fmdp_->addTransitionForAction(_fmdp_->actionId(_stringBag_[0]),
341 variable(var),
342 this->_FunctionGraph_);
343 } else {
344 _fmdp_->addTransition(variable(var), this->_FunctionGraph_);
345 }
346 }
347 }
348
349 // Tells the factory that we're out of a transition declaration.
350
351 template < typename GUM_ELEMENT >
353 if (state() != FMDPfactory_state::TRANSITION) _illegalStateError_("endTransitionDeclaration");
354 else _states_.pop_back();
355
356 // VERBOSITY ( "transition OK" );
357 }
358
359 /* ****************************************************************************************************
360 * **/
361 /* ** **/
362 /* ** Cost declaration methods **/
363 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::COST <->
364 * FMDPfactory_state::ACTION) **/
365 /* ** **/
366 /* ****************************************************************************************************
367 * **/
368
369
370 // Tells the factory that we're declaring cost
371
372 template < typename GUM_ELEMENT >
375 _illegalStateError_("startTransitionDeclaration");
376 else _states_.push_back(FMDPfactory_state::COST);
377
378 // VERBOSITY ( "starting Cost declaration" );
380 }
381
382 // Tells the factory to add a cost
383
384 template < typename GUM_ELEMENT >
387 = static_cast< const MultiDimImplementation< GUM_ELEMENT >* >(cost);
388
390 else if (_foo_flag_) _fmdp_->addCostForAction(_fmdp_->actionId(_stringBag_[0]), c);
391 else _fmdp_->addCost(c);
392 }
393
394 // Tells the factory to add a cost
395 // This cost table will be extracted from incorporated multiDimFunctionGraph.
396
397 template < typename GUM_ELEMENT >
400 else {
402
403 if (_foo_flag_)
404 _fmdp_->addCostForAction(_fmdp_->actionId(_stringBag_[0]), this->_FunctionGraph_);
405 else _fmdp_->addCost(this->_FunctionGraph_);
406 }
407 }
408
409 // Tells the factory that we're out of a cost declaration.
410
411 template < typename GUM_ELEMENT >
413 if (state() != FMDPfactory_state::COST) _illegalStateError_("endCostDeclaration");
414 else _states_.pop_back();
415
416 // VERBOSITY ( "Cost OK" );
417 }
418
419 /* ****************************************************************************************************
420 * **/
421 /* ** **/
422 /* ** Reward declaration methods **/
423 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::REWARD <->
424 * FMDPfactory_state::ACTION) **/
425 /* ** **/
426 /* ****************************************************************************************************
427 * **/
428
429
430 // Tells the factory that we're declaring reward
431
432 template < typename GUM_ELEMENT >
435 _illegalStateError_("startRewardDeclaration");
436 else _states_.push_back(FMDPfactory_state::REWARD);
437
438 // VERBOSITY ( "starting reward declaration" );
440 }
441
442 // Tells the factory that we're in a reward declaration mode where the global
443 // reward diagram is an operation between simplier dd
444
445 template < typename GUM_ELEMENT >
446 void FMDPFactory< GUM_ELEMENT >::setOperationModeOn(std::string_view operationType) {
447 _foo_flag_ = true;
448 _stringBag_.push_back(std::string{operationType});
449 }
450
451 // Tells the factory to add a reward
452
453 template < typename GUM_ELEMENT >
456 = static_cast< const MultiDimImplementation< GUM_ELEMENT >* >(reward);
457
459 else _fmdp_->addReward(r);
460 }
461
462 // Tells the factory to add a reward
463 // This reward table will be extracted from incorporated
464 // multiDimFunctionGraph.
465
466 template < typename GUM_ELEMENT >
469 else {
471 _FunctionGraph_->setTableName("Reward");
472
473 if (_foo_flag_) _ddBag_.push_back(this->_FunctionGraph_);
474 else _fmdp_->addReward(this->_FunctionGraph_);
475 }
476 }
477
478 // Tells the factory that we're out of a reward declaration.
479
480 template < typename GUM_ELEMENT >
482 if (state() != FMDPfactory_state::REWARD) _illegalStateError_("endRewardDeclaration");
483 else {
484 if (_foo_flag_) {
486
487 for (const auto elt: _ddBag_) {
488 if (res == nullptr) {
489 res = const_cast< MultiDimImplementation< GUM_ELEMENT >* >(elt);
490 continue;
491 }
493
494 switch (_stringBag_[0][0]) {
495 case '+' : res = add2MultiDimFunctionGraphs(res, elt); break;
496
497 case '-' : res = subtract2MultiDimFunctionGraphs(res, elt); break;
498
499 case '*' : res = multiply2MultiDimFunctionGraphs(res, elt); break;
500
501 case '/' : res = divide2MultiDimFunctionGraphs(res, elt); break;
502
503 default : break;
504 }
505
506 delete elt;
507 delete temp;
508 }
509
510 if (res != nullptr) {
511 static_cast< MultiDimFunctionGraph< GUM_ELEMENT >* >(res)->setTableName("Reward");
512 _fmdp_->addReward(res);
513 }
514 }
515
516 _resetParts_();
517 _states_.pop_back();
518 }
519 // VERBOSITY ( "reward OK" );
520 }
521
522 /* ****************************************************************************************************
523 * **/
524 /* ** **/
525 /* ** Discount declaration methods **/
526 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
527 * FMDPfactory_state::ACTION) **/
528 /* ** **/
529 /* ****************************************************************************************************
530 * **/
531
532
533 // Tells the factory that we're declaring discount
534 template < typename GUM_ELEMENT >
536 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startDiscountDeclaration");
538
539 // VERBOSITY ( "starting discount declaration" );
540 }
541
542 // Tells the factory to add a discount
543
544 template < typename GUM_ELEMENT >
547 else _fmdp_->setDiscount((GUM_ELEMENT)discount);
548 }
549
550 // Tells the factory that we're out of a discount declaration.
551
552 template < typename GUM_ELEMENT >
554 if (state() != FMDPfactory_state::DISCOUNT) _illegalStateError_("endDiscountDeclaration");
555 else _states_.pop_back();
556
557 // VERBOSITY ( "discount OK" );
558 }
559
560 /* ****************************************************************************************************
561 * **/
562 /* ** **/
563 /* ** Discount declaration methods **/
564 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
565 * FMDPfactory_state::ACTION) **/
566 /* ** **/
567 /* ****************************************************************************************************
568 * **/
569
570
571 // Insert in diagram a non terminal node
572
573 template < typename GUM_ELEMENT >
575 return _FunctionGraph_->manager()->addInternalNode(variable(name_of_var));
576 }
577
578 // Insert in diagram a terminal node
579
580 template < typename GUM_ELEMENT >
582 return _FunctionGraph_->manager()->addTerminalNode((GUM_ELEMENT)value);
583 }
584
585 // Insert an arc in diagram
586 template < typename GUM_ELEMENT >
588 _FunctionGraph_->manager()->setSon(from, modality, to);
589 }
590
591 template < typename GUM_ELEMENT >
593 _FunctionGraph_->manager()->setRootNode(rootId);
594 }
595
596 /* ****************************************************************************************************
597 * **/
598 /* ** **/
599 /* ** Various Private Methods **/
600 /* ** **/
601 /* ****************************************************************************************************
602 * **/
603
604
605 // Raise an OperationNotAllowed with the message "Illegal state."
606
607 template < typename GUM_ELEMENT >
609 std::string msg = "Illegal state call (";
610 msg += s;
611 msg += ") in state ";
612
613 switch (state()) {
614 case FMDPfactory_state::NONE : msg += "FMDPfactory_state::NONE"; break;
615
616 case FMDPfactory_state::VARIABLE : msg += "FMDPfactory_state::VARIABLE"; break;
617
618 case FMDPfactory_state::ACTION : msg += "FMDPfactory_state::ACTION"; break;
619
620 case FMDPfactory_state::TRANSITION : msg += "FMDPfactory_state::TRANSITION"; break;
621
622 case FMDPfactory_state::COST : msg += "FMDPfactory_state::COST"; break;
623
624 case FMDPfactory_state::REWARD : msg += "FMDPfactory_state::REWARD"; break;
625
626 case FMDPfactory_state::DISCOUNT : msg += "FMDPfactory_state::DISCOUNT"; break;
627
628 default : msg += "Unknown state";
629 }
630
632 }
633
634 // Reset the different parts used to constructed the IBayesNet.
635
636 template < typename GUM_ELEMENT >
638 _foo_flag_ = false;
639 _bar_flag_ = false;
640 _stringBag_.clear();
641 _ddBag_.clear();
642 }
643
644 template < typename GUM_ELEMENT >
647 // Recopie des variables principales dans le graphe de décision
648 for (auto varIter = _fmdp_->beginVariables(); varIter != _fmdp_->endVariables(); ++varIter) {
649 _FunctionGraph_->add(**varIter);
650 }
651
652 // Recopie des version primes des variables dans le graphe de décision
653 for (auto varIter = _fmdp_->beginVariables(); varIter != _fmdp_->endVariables(); ++varIter) {
654 _FunctionGraph_->add(*(_fmdp_->main2prime(*varIter)));
655 }
656 }
657
658 template < typename GUM_ELEMENT >
660 this->_FunctionGraph_->manager()->reduce();
661 this->_FunctionGraph_->manager()->clean();
662 }
663
664 //~ ==============
665 //~ // Check if a variable with the given name exists, if not raise an
666 // NotFound
667 //~ // exception.
668 //~ ==============
669 //~ template<typename GUM_ELEMENT> INLINE
670 //~ void
671 //~ FMDPFactory<GUM_ELEMENT>:: _checkVariableName_ ( const std::string& name ) {
672 //~ if ( ! _varNameMap_.exists ( name ) )
673 //~ GUM_ERROR ( NotFound, name )
674 //~ }
675
676
677 // Copy operator is illegal, use only copy constructor.
678
679 template < typename GUM_ELEMENT >
682 GUM_ERROR(FatalError, "Illegal!")
683 // For noisy compilers
684 return *this;
685 }
686} /* 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)
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.