aGrUM  0.21.0
a C++ library for (probabilistic) graphical models
IDecisionStrategy.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Headers of the Decision Strategy interface.
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
27  * GONZALES(@AMU)
28  */
29 
30 
31 // =========================================================================
32 #ifndef GUM_SDYNA_DECISION_STRATEGY_H
33 #define GUM_SDYNA_DECISION_STRATEGY_H
34 // =========================================================================
35 #include <agrum/tools/core/types.h>
36 // =========================================================================
37 #include <agrum/FMDP/planning/actionSet.h>
38 // =========================================================================
39 #include <agrum/tools/variables/discreteVariable.h>
40 // =========================================================================
41 
42 namespace gum {
43 
44  /**
45  * @class IDecisionStrategy IDecisionStrategy.h
46  * <agrum/FMDP/SDyna/IDecisionStrategy.h>
47  * @brief Interface for manipulating decision center
48  * @ingroup fmdp_group
49  *
50  */
52  // ###################################################################
53  /// @name Constructor & destructor.
54  // ###################################################################
55  /// @{
56  public:
57  // ==========================================================================
58  /// Destructor (virtual and empty since it's an interface)
59  // ==========================================================================
60  virtual ~IDecisionStrategy() {}
61 
62  /// @}
63 
64  // ###################################################################
65  /// @name Initialization
66  // ###################################################################
67  /// @{
68  public:
69  // ==========================================================================
70  /// Initializes the learner
71  // ==========================================================================
72  virtual void initialize(const FMDP< double >* fmdp) {
73  optPol_ = nullptr;
74  if (allActions_.size() == 0)
75  for (auto actionIter = fmdp->beginActions(); actionIter != fmdp->endActions(); ++actionIter)
76  allActions_ += *actionIter;
77  }
78  /// @}
79 
80 
81  // ###################################################################
82  /// @name Incremental methods
83  // ###################################################################
84  /// @{
85  public:
86  virtual void checkState(const Instantiation& newState, Idx actionId) = 0;
87 
88  void
89  setOptimalStrategy(const MultiDimFunctionGraph< ActionSet, SetTerminalNodePolicy >* optPol) {
90  optPol_ = const_cast< MultiDimFunctionGraph< ActionSet, SetTerminalNodePolicy >* >(optPol);
91  }
92 
94  return (optPol_ && optPol_->realSize() != 0) ? optPol_->get(curState) : allActions_;
95  }
96 
97  protected:
98  ///
100 
101  ///
103 
104  /// @}
105  };
106 } // namespace gum
107 #endif // GUM_SDYNA_DECISION_STRATEGY_H
virtual void initialize(const FMDP< double > *fmdp)
Initializes the learner.
virtual ActionSet stateOptimalPolicy(const Instantiation &curState)
<agrum/FMDP/SDyna/IDecisionStrategy.h>
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual void checkState(const Instantiation &newState, Idx actionId)=0
const MultiDimFunctionGraph< ActionSet, SetTerminalNodePolicy > * optPol_
virtual ~IDecisionStrategy()
Destructor (virtual and empty since it&#39;s an interface)
void setOptimalStrategy(const MultiDimFunctionGraph< ActionSet, SetTerminalNodePolicy > *optPol)