aGrUM 2.3.2
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-2025 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-2025 *
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#pragma once
41
42
50
54
55// #define FMDP_VERBOSITY(x) { if (isVerbose()) std::cerr << "[FMDP factory]
56// "<< x << std::endl; }
57
58
59namespace gum {
60
61 /* ****************************************************************************************************
62 * **/
63 /* ** **/
64 /* ** Constructor &
65 * Destructor **/
66 /* ** **/
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_SCALAR >
83
84 // Destructor
85
86 template < typename GUM_SCALAR >
88 GUM_DESTRUCTOR(FMDPFactory);
89 }
90
91 /* ****************************************************************************************************
92 * **/
93 /* ** **/
94 /* ** Getter and
95 * setters **/
96 /* ** **/
97 /* ****************************************************************************************************
98 * **/
99
100
101 // Returns the IBayesNet created by this factory.
102
103 template < typename GUM_SCALAR >
107 "Illegal state to return the factored "
108 "markov decision process: it is not yet "
109 "finished.");
110
111 return _fmdp_;
112 }
113
114 // Returns the current state of the factory.
115
116 template < typename GUM_SCALAR >
118 // This is ok because there is alway at least the state
119 // FMDPfactory_state::NONE in the stack.
120 return _states_.back();
121 }
122
123 // Returns a constant reference on a variable given it's name.
124 // @throw NotFound Raised if no variable matches the name.
125
126 template < typename GUM_SCALAR >
127 INLINE const DiscreteVariable*
128 FMDPFactory< GUM_SCALAR >::variable(const std::string& 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_SCALAR >
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_SCALAR >
164 INLINE void FMDPFactory< GUM_SCALAR >::variableName(const std::string& 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_SCALAR >
178 INLINE void FMDPFactory< GUM_SCALAR >::variableDescription(const std::string& desc) {
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_SCALAR >
191 INLINE void FMDPFactory< GUM_SCALAR >::addModality(const std::string& name) {
193 else {
195 _stringBag_.push_back(name);
196 }
197 }
198
199 // Check if in _stringBag_ there is no other modality with the same name.
200
201 template < typename GUM_SCALAR >
202 INLINE void FMDPFactory< GUM_SCALAR >::_checkModalityInBag_(const std::string& mod) {
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_SCALAR >
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 _varNameMap_.insert(var->name(), var);
223 _varNameMap_.insert(_fmdp_->main2prime(var)->name(), _fmdp_->main2prime(var));
224
225 _resetParts_();
226 _states_.pop_back();
227
228 // VERBOSITY ( " variable " << var->name() << " OK" );
229
230 } else {
231 std::stringstream msg;
232 msg << "Not enough modalities (";
233
234 if (_stringBag_.size() > 2) msg << _stringBag_.size() - 2;
235 else msg << 0;
236
237 msg << ") declared for variable ";
238
239 if (_foo_flag_) msg << _stringBag_[0];
240 else msg << "unknown";
241
242 _resetParts_();
243 _states_.pop_back();
244
246 }
247 }
248
249 /* ****************************************************************************************************
250 * **/
251 /* ** **/
252 /* ** Action declaration methods (FMDPfactory_state::NONE <->
253 * FMDPfactory_state::ACTION) **/
254 /* ** **/
255 /* ****************************************************************************************************
256 * **/
257
258
259 // Tells the factory that we're declaring action
260
261 template < typename GUM_SCALAR >
263 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startActionDeclaration");
264 else {
265 _foo_flag_ = true;
267 }
268
269 // VERBOSITY ( "starting action declaration" );
270 }
271
272 // Tells the factory to add an action
273
274 template < typename GUM_SCALAR >
275 INLINE void FMDPFactory< GUM_SCALAR >::addAction(const std::string& action) {
277 else {
278 _stringBag_.push_back(action);
279 _fmdp_->addAction(_actionIdcpt_++, action);
280 }
281 }
282
283 // Tells the factory that we're out of an action declaration.
284
285 template < typename GUM_SCALAR >
287 if (state() != FMDPfactory_state::ACTION) _illegalStateError_("endActionDeclaration");
288 else {
289 _states_.pop_back();
290 _resetParts_();
291 }
292
293 // VERBOSITY ( "action OK" );
294 }
295
296 /* ****************************************************************************************************
297 * **/
298 /* ** **/
299 /* ** Transition declaration methods **/
300 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::TRANSITION <->
301 * FMDPfactory_state::ACTION) **/
302 /* ** **/
303 /* ****************************************************************************************************
304 * **/
305
306
307 // Tells the factory that we're declaring transition
308
309 template < typename GUM_SCALAR >
312 _illegalStateError_("startTransitionDeclaration");
314
315 // VERBOSITY ( "starting transition declaration" );
317 }
318
319 // Tells the factory to add an action
320
321 template < typename GUM_SCALAR >
322 INLINE void FMDPFactory< GUM_SCALAR >::addTransition(const std::string& var,
323 const MultiDimAdressable* transition) {
325 = reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(transition);
326
328 else if (_foo_flag_)
329 _fmdp_->addTransitionForAction(_fmdp_->actionId(_stringBag_[0]), _varNameMap_[var], t);
330 else _fmdp_->addTransition(_varNameMap_[var], t);
331 }
332
333 // Tells the factory to add a transition table to the current fmdp.
334 // This transition table will be extracted from incorporated
335 // multiDimFunctionGraph.
336
337 template < typename GUM_SCALAR >
338 INLINE void FMDPFactory< GUM_SCALAR >::addTransition(const std::string& var) {
340 else {
342
343 if (_foo_flag_) {
344 this->_FunctionGraph_->setTableName("ACTION :" + _stringBag_[0] + " - VARIABLE : " + var);
345 _fmdp_->addTransitionForAction(_fmdp_->actionId(_stringBag_[0]),
346 _varNameMap_[var],
347 this->_FunctionGraph_);
348 } else {
349 _fmdp_->addTransition(_varNameMap_[var], this->_FunctionGraph_);
350 }
351 }
352 }
353
354 // Tells the factory that we're out of a transition declaration.
355
356 template < typename GUM_SCALAR >
358 if (state() != FMDPfactory_state::TRANSITION) _illegalStateError_("endTransitionDeclaration");
359 else _states_.pop_back();
360
361 // VERBOSITY ( "transition OK" );
362 }
363
364 /* ****************************************************************************************************
365 * **/
366 /* ** **/
367 /* ** Cost declaration methods **/
368 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::COST <->
369 * FMDPfactory_state::ACTION) **/
370 /* ** **/
371 /* ****************************************************************************************************
372 * **/
373
374
375 // Tells the factory that we're declaring cost
376
377 template < typename GUM_SCALAR >
380 _illegalStateError_("startTransitionDeclaration");
381 else _states_.push_back(FMDPfactory_state::COST);
382
383 // VERBOSITY ( "starting Cost declaration" );
385 }
386
387 // Tells the factory to add a cost
388
389 template < typename GUM_SCALAR >
392 = reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(cost);
393
395 else if (_foo_flag_) _fmdp_->addCostForAction(_fmdp_->actionId(_stringBag_[0]), c);
396 else _fmdp_->addCost(c);
397 }
398
399 // Tells the factory to add a cost
400 // This cost table will be extracted from incorporated multiDimFunctionGraph.
401
402 template < typename GUM_SCALAR >
405 else {
407
408 if (_foo_flag_)
409 _fmdp_->addCostForAction(_fmdp_->actionId(_stringBag_[0]), this->_FunctionGraph_);
410 else _fmdp_->addCost(this->_FunctionGraph_);
411 }
412 }
413
414 // Tells the factory that we're out of a cost declaration.
415
416 template < typename GUM_SCALAR >
418 if (state() != FMDPfactory_state::COST) _illegalStateError_("endCostDeclaration");
419 else _states_.pop_back();
420
421 // VERBOSITY ( "Cost OK" );
422 }
423
424 /* ****************************************************************************************************
425 * **/
426 /* ** **/
427 /* ** Reward declaration methods **/
428 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::REWARD <->
429 * FMDPfactory_state::ACTION) **/
430 /* ** **/
431 /* ****************************************************************************************************
432 * **/
433
434
435 // Tells the factory that we're declaring reward
436
437 template < typename GUM_SCALAR >
440 _illegalStateError_("startRewardDeclaration");
441 else _states_.push_back(FMDPfactory_state::REWARD);
442
443 // VERBOSITY ( "starting reward declaration" );
445 }
446
447 // Tells the factory that we're in a reward declaration mode where the global
448 // reward diagram is an operation between simplier dd
449
450 template < typename GUM_SCALAR >
451 INLINE void FMDPFactory< GUM_SCALAR >::setOperationModeOn(std::string operationType) {
452 _foo_flag_ = true;
453 std::string ot(operationType);
454 _stringBag_.push_back(ot);
455 }
456
457 // Tells the factory to add a reward
458
459 template < typename GUM_SCALAR >
462 = reinterpret_cast< const MultiDimImplementation< GUM_SCALAR >* >(reward);
463
465 else _fmdp_->addReward(r);
466 }
467
468 // Tells the factory to add a reward
469 // This reward table will be extracted from incorporated
470 // multiDimFunctionGraph.
471
472 template < typename GUM_SCALAR >
475 else {
477 _FunctionGraph_->setTableName("Reward");
478
479 if (_foo_flag_) _ddBag_.push_back(this->_FunctionGraph_);
480 else _fmdp_->addReward(this->_FunctionGraph_);
481 }
482 }
483
484 // Tells the factory that we're out of a reward declaration.
485
486 template < typename GUM_SCALAR >
488 if (state() != FMDPfactory_state::REWARD) _illegalStateError_("endRewardDeclaration");
489 else {
490 if (_foo_flag_) {
493
494 for (const auto elt: _ddBag_) {
495 temp = res;
496
497 switch (_stringBag_[0][0]) {
498 case '+' : res = add2MultiDimFunctionGraphs(res, elt); break;
499
500 case '-' : res = subtract2MultiDimFunctionGraphs(res, elt); break;
501
502 case '*' : res = multiply2MultiDimFunctionGraphs(res, elt); break;
503
504 case '/' : res = divide2MultiDimFunctionGraphs(res, elt); break;
505
506 default : break;
507 }
508
509 delete elt;
510
511 if (temp != nullptr) delete temp;
512 }
513 reinterpret_cast< MultiDimFunctionGraph< GUM_SCALAR >* >(res)->setTableName("Reward");
514 _fmdp_->addReward(res);
515 }
516
517 _resetParts_();
518 _states_.pop_back();
519 }
520 // VERBOSITY ( "reward OK" );
521 }
522
523 /* ****************************************************************************************************
524 * **/
525 /* ** **/
526 /* ** Discount declaration methods **/
527 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
528 * FMDPfactory_state::ACTION) **/
529 /* ** **/
530 /* ****************************************************************************************************
531 * **/
532
533
534 // Tells the factory that we're declaring discount
535 template < typename GUM_SCALAR >
537 if (state() != FMDPfactory_state::NONE) _illegalStateError_("startDiscountDeclaration");
539
540 // VERBOSITY ( "starting discount declaration" );
541 }
542
543 // Tells the factory to add a discount
544
545 template < typename GUM_SCALAR >
546 INLINE void FMDPFactory< GUM_SCALAR >::addDiscount(float discount) {
548 // else
549 // _fmdp_->setDiscount ( ( GUM_SCALAR ) discount );
550 }
551
552 // Tells the factory that we're out of a discount declaration.
553
554 template < typename GUM_SCALAR >
556 if (state() != FMDPfactory_state::DISCOUNT) _illegalStateError_("endDiscountDeclaration");
557 else _states_.pop_back();
558
559 // VERBOSITY ( "discount OK" );
560 }
561
562 /* ****************************************************************************************************
563 * **/
564 /* ** **/
565 /* ** Discount declaration methods **/
566 /* ** (FMDPfactory_state::NONE <-> FMDPfactory_state::DISCOUNT <->
567 * FMDPfactory_state::ACTION) **/
568 /* ** **/
569 /* ****************************************************************************************************
570 * **/
571
572
573 // Insert in diagram a non terminal node
574
575 template < typename GUM_SCALAR >
576 INLINE NodeId FMDPFactory< GUM_SCALAR >::addInternalNode(std::string name_of_var) {
577 return _FunctionGraph_->manager()->addInternalNode(variable(name_of_var));
578 }
579
580 // Insert in diagram a terminal node
581
582 template < typename GUM_SCALAR >
584 return _FunctionGraph_->manager()->addTerminalNode((GUM_SCALAR)value);
585 }
586
587 // Insert an arc in diagram
588 template < typename GUM_SCALAR >
589 INLINE void FMDPFactory< GUM_SCALAR >::addArc(NodeId from, NodeId to, Idx modality) {
590 _FunctionGraph_->manager()->setSon(from, modality, to);
591 }
592
593 template < typename GUM_SCALAR >
595 _FunctionGraph_->manager()->setRootNode(rootId);
596 }
597
598 /* ****************************************************************************************************
599 * **/
600 /* ** **/
601 /* ** Various Private Methods **/
602 /* ** **/
603 /* ****************************************************************************************************
604 * **/
605
606
607 // Raise an OperationNotAllowed with the message "Illegal state."
608
609 template < typename GUM_SCALAR >
610 INLINE void FMDPFactory< GUM_SCALAR >::_illegalStateError_(const std::string& s) {
611 std::string msg = "Illegal state call (";
612 msg += s;
613 msg += ") in state ";
614
615 switch (state()) {
616 case FMDPfactory_state::NONE : msg += "FMDPfactory_state::NONE"; break;
617
618 case FMDPfactory_state::VARIABLE : msg += "FMDPfactory_state::VARIABLE"; break;
619
620 case FMDPfactory_state::ACTION : msg += "FMDPfactory_state::ACTION"; break;
621
622 case FMDPfactory_state::TRANSITION : msg += "FMDPfactory_state::TRANSITION"; break;
623
624 case FMDPfactory_state::COST : msg += "FMDPfactory_state::COST"; break;
625
626 case FMDPfactory_state::REWARD : msg += "FMDPfactory_state::REWARD"; break;
627
628 case FMDPfactory_state::DISCOUNT : msg += "FMDPfactory_state::DISCOUNT"; break;
629
630 default : msg += "Unknown state";
631 }
632
634 }
635
636 // Reset the different parts used to constructed the IBayesNet.
637
638 template < typename GUM_SCALAR >
640 _foo_flag_ = false;
641 _bar_flag_ = false;
642 _stringBag_.clear();
643 _ddBag_.clear();
644 }
645
646 template < typename GUM_SCALAR >
649 // Recopie des variables principales dans le graphe de décision
650 for (auto varIter = _fmdp_->beginVariables(); varIter != _fmdp_->endVariables(); ++varIter) {
651 _FunctionGraph_->add(**varIter);
652 }
653
654 // Recopie des version primes des variables dans le graphe de décision
655 for (auto varIter = _fmdp_->beginVariables(); varIter != _fmdp_->endVariables(); ++varIter) {
656 _FunctionGraph_->add(*(_fmdp_->main2prime(*varIter)));
657 }
658 }
659
660 template < typename GUM_SCALAR >
662 this->_FunctionGraph_->manager()->reduce();
663 this->_FunctionGraph_->manager()->clean();
664 }
665
666 //~ ==============
667 //~ // Check if a variable with the given name exists, if not raise an
668 // NotFound
669 //~ // exception.
670 //~ ==============
671 //~ template<typename GUM_SCALAR> INLINE
672 //~ void
673 //~ FMDPFactory<GUM_SCALAR>:: _checkVariableName_ ( const std::string& name ) {
674 //~ if ( ! _varNameMap_.exists ( name ) )
675 //~ GUM_ERROR ( NotFound, name )
676 //~ }
677
678
679 // Copy operator is illegal, use only copy constructor.
680
681 template < typename GUM_SCALAR >
684 GUM_ERROR(FatalError, "Illegal!")
685 // For noisy compilers
686 return *this;
687 }
688} /* 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:87
void addCost()
Tells the factory to add a cost table to the current fmdp. This cost table will be extracted from inc...
NodeId addTerminalNode(float value)
Insert in diagram a terminal node.
void setOperationModeOn(std::string operationType)
Tells the factory that we're in a reward declaration mode where the global reward diagram is an opera...
FMDP< GUM_SCALAR > * _fmdp_
The constructed FMDP.
void addArc(NodeId from, NodeId to, Idx modality)
Insert in diagram a non terminal node.
FMDPFactory(FMDP< GUM_SCALAR > *fmdp)
Use this constructor if you want to use an already created factored markov decision process.
FMDPFactory< GUM_SCALAR > & operator=(const FMDPFactory< GUM_SCALAR > &source)
Copy operator is illegal, use only copy constructor.
void endTransitionDeclaration()
Tells the factory that we're out of a transition declaration.
void addTransition(const std::string &var, const MultiDimAdressable *transition)
Tells the factory to add a transition table to the current fmdp.
void addAction(const std::string &action)
Tells the factory to add an action to the current fmdp.
void startVariableDeclaration()
Tells the factory that we're in a variable declaration.
void startDiscountDeclaration()
Tells the factory that we're in a cost declaration.
void _resetParts_()
Reset the different parts used to constructed the FMDP.
~FMDPFactory()
Destructor.
void _initializeFunctionGraph_()
Insert every variables in the function graph.
void variableName(const std::string &name)
Tells the factory the current variable's name.
HashTable< std::string, const DiscreteVariable * > _varNameMap_
Mapping between a declared variable's name and itself.
void addModality(const std::string &name)
Adds a modality to the current variable.
void addReward()
Tells the factory to add a reward table to the current fmdp. This reward table will be extracted from...
void startTransitionDeclaration()
Tells the factory that we're in a transition declaration.
void endVariableDeclaration()
Tells the factory that we're out of a variable declaration.
void startActionDeclaration()
Tells the factory that we're in an action declaration.
bool _bar_flag_
Depending on the context this flag is used for some VERY important reasons.
bool _foo_flag_
Depending on the context this flag is used for some VERY important reasons.
void _checkModalityInBag_(const std::string &mod)
Used in VARIABLE mode Checks if in stringBag there is no other modality with the same name.
void endCostDeclaration()
Tells the factory that we're out of a cost declaration.
void startRewardDeclaration()
Tells the factory that we're in a reward declaration.
void endRewardDeclaration()
Tells the factory that we're out of a cost declaration.
std::vector< const MultiDimImplementation< GUM_SCALAR > * > _ddBag_
Just to keep track of multidim between two start/end calls.
void startCostDeclaration()
Tells the factory that we're in a cost declaration.
void endActionDeclaration()
Tells the factory that we're out of an action declaration.
void endDiscountDeclaration()
Tells the factory that we're out of a cost declaration.
FMDPfactory_state state() const
Returns the current state of the factory.
FMDP< GUM_SCALAR > * fmdp() const
Returns the Factored Markov Decision Process created by this factory.
std::vector< FMDPfactory_state > _states_
State stack.
void variableDescription(const std::string &desc)
Tells the factory the current variable's description.
void setRoot(NodeId rootId)
add an arc in diagram
const DiscreteVariable * variable(const std::string &name) const
Returns a constant reference on a variable given it's name.
void addDiscount(float discount)
Tells the factory to add a cost table to the current fmdp.
NodeId addInternalNode(std::string name_of_var)
Insert in diagram a non terminal node.
MultiDimFunctionGraph< GUM_SCALAR > * _FunctionGraph_
The FunctionGraph we're building at a given time.
std::vector< std::string > _stringBag_
Just to keep track of strings between two start/end calls.
void _finalizeFunctionGraph_()
Insert every variables in the function graph.
void _illegalStateError_(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
Idx _actionIdcpt_
Action Id counter.
This class is used to implement factored decision process.
Definition fmdp.h:73
Exception : fatal (unknown ?) error.
class LabelizedVariable
LabelizedVariable & addLabel(const std::string &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_SCALAR, 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:72
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.