SGSolve
sgiteration_pencilsharpening.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 _SGITERATION_HPP
23 #define _SGITERATION_HPP
24 
25 #include "sggame.hpp"
26 #include "sgaction_pencilsharpening.hpp"
27 #include <boost/archive/text_iarchive.hpp>
28 #include <boost/archive/text_oarchive.hpp>
29 #include <boost/serialization/utility.hpp>
30 
31 // Forward declaration of SGApprox
32 class SGApprox;
33 
35 
43 {
44 private:
45  int iteration;
46  int revolution;
51  vector< vector<SGBaseAction> > actions;
55  int bestState;
58  int bestAction;
62  vector<int> actionTuple;
64  vector<SG::Regime> regimeTuple;
67 
68 public:
73 
80  bool storeActions = true);
81 
83  int getIteration() const { return iteration; }
85  int getRevolution() const { return revolution; }
87  int getNumExtremeTuples() const { return numExtremeTuples; }
89  const SGTuple & getPivot() const { return pivot; }
91  const SGPoint & getDirection() const { return direction; }
93  const vector< vector<SGBaseAction> > & getActions() const { return actions; }
95  int getBestState() const { return bestState; }
97  int getBestAction() const { return bestAction; }
99  SG::Regime getRegime() const { return regime; }
101  const vector<int> & getActionTuple() const { return actionTuple; }
103  const vector<SG::Regime> & getRegimeTuple() const { return regimeTuple; }
105  const SGTuple & getThreatTuple() const { return threatTuple; }
106 
109  template<class Archive>
110 
112  void serialize(Archive &ar, const unsigned int version)
113  {
114  ar & iteration;
115  ar & revolution;
116  ar & numExtremeTuples;
117  ar & pivot;
118  ar & direction;
119  ar & actions;
120  ar & bestState;
121  ar & bestAction;
122  ar & regime;
123  ar & actionTuple;
124  ar & regimeTuple;
125  ar & threatTuple;
126  }
127 }; // SGIteration_PencilSharpening
128 
129 #endif
SGIteration_PencilSharpening::revolution
int revolution
Definition: sgiteration_pencilsharpening.hpp:46
SGIteration_PencilSharpening::numExtremeTuples
int numExtremeTuples
Definition: sgiteration_pencilsharpening.hpp:47
SGIteration_PencilSharpening::actionTuple
vector< int > actionTuple
The current action tuple.
Definition: sgiteration_pencilsharpening.hpp:62
SGIteration_PencilSharpening::getDirection
const SGPoint & getDirection() const
Get method for the current direction.
Definition: sgiteration_pencilsharpening.hpp:91
SGIteration_PencilSharpening::getRegime
SG::Regime getRegime() const
Get method for the regime corresponding to the best direction.
Definition: sgiteration_pencilsharpening.hpp:99
SGApprox
Approximation of the equilibrium payoff correspondence.
Definition: sgapprox.hpp:49
SGIteration_PencilSharpening::getPivot
const SGTuple & getPivot() const
Get method for the current pivot.
Definition: sgiteration_pencilsharpening.hpp:89
SGIteration_PencilSharpening::getNumExtremeTuples
int getNumExtremeTuples() const
Get method for the number of extreme tuples.
Definition: sgiteration_pencilsharpening.hpp:87
SGIteration_PencilSharpening::getRevolution
int getRevolution() const
Get method for the revolution.
Definition: sgiteration_pencilsharpening.hpp:85
SGIteration_PencilSharpening::getBestState
int getBestState() const
Get method for the best state.
Definition: sgiteration_pencilsharpening.hpp:95
SGIteration_PencilSharpening::bestAction
int bestAction
The action that generated the best direction.
Definition: sgiteration_pencilsharpening.hpp:58
SGIteration_PencilSharpening::getActions
const vector< vector< SGBaseAction > > & getActions() const
Get method for the actions available at the current iteration.
Definition: sgiteration_pencilsharpening.hpp:93
SGIteration_PencilSharpening::actions
vector< vector< SGBaseAction > > actions
Definition: sgiteration_pencilsharpening.hpp:51
SGIteration_PencilSharpening::getActionTuple
const vector< int > & getActionTuple() const
Get method for the action tuple.
Definition: sgiteration_pencilsharpening.hpp:101
SGIteration_PencilSharpening::iteration
int iteration
Definition: sgiteration_pencilsharpening.hpp:45
SGIteration_PencilSharpening::pivot
SGTuple pivot
Definition: sgiteration_pencilsharpening.hpp:48
SGIteration_PencilSharpening::getRegimeTuple
const vector< SG::Regime > & getRegimeTuple() const
Get method for the regime tuple.
Definition: sgiteration_pencilsharpening.hpp:103
SGIteration_PencilSharpening
Stores data on the behavior of SGApprox::generate()
Definition: sgiteration_pencilsharpening.hpp:43
SGIteration_PencilSharpening::getBestAction
int getBestAction() const
Get method for the best action.
Definition: sgiteration_pencilsharpening.hpp:97
SGIteration_PencilSharpening::getIteration
int getIteration() const
Get method for the iteration.
Definition: sgiteration_pencilsharpening.hpp:83
SGIteration_PencilSharpening::bestState
int bestState
The state that generated the best direction.
Definition: sgiteration_pencilsharpening.hpp:56
SGPoint
A vector in .
Definition: sgpoint.hpp:35
SGIteration_PencilSharpening::getThreatTuple
const SGTuple & getThreatTuple() const
Get method for the current threat tuple.
Definition: sgiteration_pencilsharpening.hpp:105
SGIteration_PencilSharpening::access
friend class boost::serialization::access
Serializes the SGIteration object using boost.
Definition: sgiteration_pencilsharpening.hpp:108
SGIteration_PencilSharpening::threatTuple
SGTuple threatTuple
The current threat tuple.
Definition: sgiteration_pencilsharpening.hpp:66
SGIteration_PencilSharpening::direction
SGPoint direction
Definition: sgiteration_pencilsharpening.hpp:49
SGIteration_PencilSharpening::regimeTuple
vector< SG::Regime > regimeTuple
The states in which IC constraints are not binding.
Definition: sgiteration_pencilsharpening.hpp:64
SGIteration_PencilSharpening::serialize
void serialize(Archive &ar, const unsigned int version)
Serialize the iteration using Boost.
Definition: sgiteration_pencilsharpening.hpp:112
SG::Regime
Regime
Indicates which incentive constraints are binding.
Definition: sgnamespace.hpp:160
SGTuple
Definition: sgtuple.hpp:52
SGIteration_PencilSharpening::regime
SG::Regime regime
True if the best direction was non-binding.
Definition: sgiteration_pencilsharpening.hpp:60
SGIteration_PencilSharpening::SGIteration_PencilSharpening
SGIteration_PencilSharpening()
Default constructor.
Definition: sgiteration_pencilsharpening.hpp:70