SGSolve
sgpolicy.hpp
1 // This file is part of the SGSolve library for stochastic games
2 // Copyright (C) 2019 Benjamin A. Brooks
3 //
4 // SGSolve free software: you can redistribute it and/or modify it
5 // under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // SGSolve is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see
16 // <http://www.gnu.org/licenses/>.
17 //
18 // Benjamin A. Brooks
19 // ben@benjaminbrooks.net
20 // Chicago, IL
21 
22 #ifndef _SGPOLICY_HPP
23 #define _SGPOLICY_HPP
24 
25 #include "sgaction_maxminmax.hpp"
26 
28 typedef list<SGAction_MaxMinMax>::const_iterator SGActionIter;
29 
31 
33 class SGPolicy
34 {
35 private:
36  SGActionIter action;
43 public:
45  SGPolicy(const SGActionIter & _action,
46  const SG::Regime _regime,
47  const int _bindingPlayer = -1,
48  const int _bindingPoint = -1):
49  action(_action),
50  regime(_regime),
51  bindingPlayer(_bindingPlayer),
52  bindingPoint(_bindingPoint)
53  {}
54 
56  const SGActionIter & getAction() const
57  { return action; }
59  const SG::Regime & getRegime() const
60  { return regime; }
62  const int getBindingPlayer() const
63  { return bindingPlayer; }
65  const int getBindingPoint() const
66  { return bindingPoint; }
67 
69  std::string hash() const;
70 
72  bool isEqual(const SGActionIter & _action,
73  const SG::Regime & _regime,
74  const int _bindingPlayer=-1,
75  const int _bindingPoint=-1) const
76  {
77  return (_action != action
78  || _regime != regime
79  || (regime == SG::Binding &&
80  (bindingPlayer != _bindingPlayer
81  || bindingPoint != _bindingPoint)));
82  }
83 
84  friend bool operator< (const SGPolicy &, const SGPolicy &);
85  friend ostream& operator<<(ostream& out, const SGPolicy &);
86 
87 }; // SGPolicy
88 
89 
90 #endif
SGPolicy
A policy for the max-min-max algorithm.
Definition: sgpolicy.hpp:34
SGPolicy::getRegime
const SG::Regime & getRegime() const
Regime get method.
Definition: sgpolicy.hpp:59
SGPolicy::hash
std::string hash() const
Returns a unique identifying string for the policy.
Definition: sgpolicy.cpp:25
SGPolicy::SGPolicy
SGPolicy(const SGActionIter &_action, const SG::Regime _regime, const int _bindingPlayer=-1, const int _bindingPoint=-1)
Constructor.
Definition: sgpolicy.hpp:45
SGPolicy::isEqual
bool isEqual(const SGActionIter &_action, const SG::Regime &_regime, const int _bindingPlayer=-1, const int _bindingPoint=-1) const
Tests equality of two policies.
Definition: sgpolicy.hpp:72
SGPolicy::getBindingPlayer
const int getBindingPlayer() const
Binding player get method.
Definition: sgpolicy.hpp:62
SGPolicy::bindingPoint
int bindingPoint
Definition: sgpolicy.hpp:40
SGPolicy::getBindingPoint
const int getBindingPoint() const
Binding point get method.
Definition: sgpolicy.hpp:65
SGPolicy::getAction
const SGActionIter & getAction() const
Action get method.
Definition: sgpolicy.hpp:56
SGPolicy::regime
SG::Regime regime
Definition: sgpolicy.hpp:37
SG::Regime
Regime
Indicates which incentive constraints are binding.
Definition: sgnamespace.hpp:160
SGPolicy::bindingPlayer
int bindingPlayer
Definition: sgpolicy.hpp:38
SGPolicy::action
SGActionIter action
Definition: sgpolicy.hpp:36