SGSolve
sgsimulationhandler.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 SGSIMULATIONHANDLER_HPP
23 #define SGSIMULATIONHANDLER_HPP
24 
25 #include <QWidget>
26 #include <QMenuBar>
27 #include <QAction>
28 #include <QFormLayout>
29 #include "sg.hpp"
30 #include "sgsimulator.hpp"
31 #include "sgsimulationplot.hpp"
32 #include "qcustomplot.h"
33 
35 
53 class SGSimulationHandler : public QWidget
54 {
55  Q_OBJECT;
56 
57 private:
61 
63  const SGPoint & point;
65  const int state;
66 
71 
73  QLineEdit * simEdit;
75  QLineEdit * iterationEdit;
77  QLineEdit * longRunPayoffEdit;
79  QLineEdit * timeEdit;
83  QTextEdit * textEdit;
85  QTextEdit * transitionTableEdit;
86 
88  QCPBars * stateBars;
90  QCPBars * tupleBars;
92  vector<QCPBars *> actionBars;
93 
95  QCPAxisRect * stateDistrRect;
97  QCPAxisRect * tupleDistrRect;
99  vector<QCPAxisRect *> actionDistrRects;
100 
101 public:
103  SGSimulationHandler(QWidget * parent,
104  const SGSolution_PencilSharpening & _soln,
105  const SGPoint & _point,
106  int _state);
107 
109  virtual ~SGSimulationHandler() {}
110 
111 private slots:
113 
115  void simulate();
116 
117 };
118 
119 #endif
SGSimulationHandler::simEdit
QLineEdit * simEdit
Displays the number of simulations to run.
Definition: sgsimulationhandler.hpp:73
SGSimulationHandler::simulate
void simulate()
Triggers a new simulation.
Definition: sgsimulationhandler.cpp:267
SGSimulationHandler::soln
const SGSolution_PencilSharpening & soln
Constant reference to the associated SGSolution object.
Definition: sgsimulationhandler.hpp:55
SGSimulationHandler::stateBars
QCPBars * stateBars
Bars displaying for the distribution of states.
Definition: sgsimulationhandler.hpp:88
SGSolution_PencilSharpening
Records the progress of SGSolver::solve().
Definition: sgsolution_pencilsharpening.hpp:41
SGSimulationHandler::tupleDistrRect
QCPAxisRect * tupleDistrRect
The QCPAxisRect object associated with the tuple distributions.
Definition: sgsimulationhandler.hpp:97
SGSimulationHandler::longRunPayoffEdit
QLineEdit * longRunPayoffEdit
Displays the average payoffs over the course of the simulation.
Definition: sgsimulationhandler.hpp:77
SGSimulationHandler::tupleBars
QCPBars * tupleBars
Bars displaying the distribution of tuples.
Definition: sgsimulationhandler.hpp:90
SGSimulationHandler::~SGSimulationHandler
virtual ~SGSimulationHandler()
Destructor.
Definition: sgsimulationhandler.hpp:109
SGSimulationHandler::SGSimulationHandler
SGSimulationHandler(QWidget *parent, const SGSolution_PencilSharpening &_soln, const SGPoint &_point, int _state)
Constructor.
Definition: sgsimulationhandler.cpp:24
SGSimulationHandler::stateDistrRect
QCPAxisRect * stateDistrRect
The QCPAxisRect object associated with the state distributions.
Definition: sgsimulationhandler.hpp:95
SGSimulationHandler::actionDistrRects
vector< QCPAxisRect * > actionDistrRects
The QCPAxisRect objects associated with the action distributions.
Definition: sgsimulationhandler.hpp:99
SGSimulationHandler::state
const int state
Initial state for the simulation.
Definition: sgsimulationhandler.hpp:65
SGPoint
A vector in .
Definition: sgpoint.hpp:35
SGSimulationHandler::transitionTableEdit
QTextEdit * transitionTableEdit
Displays the decomposition of extremal equilibria.
Definition: sgsimulationhandler.hpp:85
SGSimulationHandler
Widget for forward simulating an equilibrium.
Definition: sgsimulationhandler.hpp:54
SGSimulationHandler::sim
SGSimulator sim
The associated SGSimulator object.
Definition: sgsimulationhandler.hpp:68
SGSimulationHandler::textEdit
QTextEdit * textEdit
Displays the first 200 periods of the simulation.
Definition: sgsimulationhandler.hpp:83
SGSimulationHandler::actionBars
vector< QCPBars * > actionBars
Bars displaying the distributions of actions in each state.
Definition: sgsimulationhandler.hpp:92
SGSimulator
Class for forward simulating equilibria.
Definition: sgsimulator.hpp:74
SGSimulationHandler::initialTuple
int initialTuple
The initial tuple for the simulation.
Definition: sgsimulationhandler.hpp:70
SGSimulationHandler::iterationEdit
QLineEdit * iterationEdit
Displays the number of periods for which to simulate.
Definition: sgsimulationhandler.hpp:75
SGSimulationPlot
A customized version of QCustomPlot.
Definition: sgsimulationplot.hpp:35
SGSimulationHandler::timeEdit
QLineEdit * timeEdit
Displays the time it took the simulation to run.
Definition: sgsimulationhandler.hpp:79
SGSimulationHandler::point
const SGPoint & point
Discounted payoffs in the simulated equilibrium.
Definition: sgsimulationhandler.hpp:63
SGSimulationHandler::distrPlot
SGSimulationPlot * distrPlot
Displays the distribution of tuples, states, and action profiles.
Definition: sgsimulationhandler.hpp:81