BCESolve
bcedatastate.hpp
1// This file is part of the BCESolve library for games of incomplete
2// information
3// Copyright (C) 2022 Benjamin A. Brooks
4//
5// BCESolve free software: you can redistribute it and/or modify it
6// under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// BCESolve is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see
17// <http://www.gnu.org/licenses/>.
18//
19// Benjamin A. Brooks
20// ben@benjaminbrooks.net
21// Chicago, IL
22
23#ifndef BCEDATASTATE_HPP
24#define BCEDATASTATE_HPP
25
26#include "bcesolution.hpp"
27#include "bcegame.hpp"
28#include "bceabstractgame.hpp"
29#include "bceenumeration.hpp"
30#include "bceslider.hpp"
31#include "bcelineedit.hpp"
32#include "bcelabel.hpp"
33#include <QtWidgets>
34#include <QMainWindow>
35#include <vector>
36#include <cmath>
37#include <boost/filesystem.hpp>
38
40
51class BCEDataState : public QMainWindow
52{
53 Q_OBJECT;
54
55signals:
56
58
63
77
83 void valueChanged(int val,BCESliderType st,int player);
85
89 void devPlotTitleChange(int player,
90 int aciton,
91 int type,
92 double payoff);
94
97 void devPlotPrChange(int player,double probability);
99
103 void eqmCoordSignal(double xCoord,double yCoord);
105
111 void newStateSignal(int value0,
112 int value1,
113 int state,
114 bool privateVals);
116
121 void sliderLabelsChanged(bool privateVals,int player);
123
128 void objectiveValuesChanged(int player);
130
137 void sendException(QString message);
138
139
140private: // Private Properties. Private Functions near EOF.
142
149 vector<int> actions;
151 vector<int> types;
153 vector<int> values;
155 int state;
163 string guiTitle;
165 bool margS0, margS1;
167
170 vector<bool> margA, margT;
174 vector< vector<double> > equilibriumMatrix;
176 vector< vector<double> > objectiveValues;
178
183 vector< vector<double> > allEqm;
185
190 QVector<BCESlider*> sliderGroup;
192
198 QVector<BCELineEdit*> lineEditGroup;
201
202public:
203
205
211 BCEDataState();
212
214
224 void setSolutionData(const BCESolution &solution, const bool isBoundaryMapped);
225
228
230 const vector<vector<double> >& getMapBWeights() const {
232 }
233
235 const int getNumObjs() const {
237 }
238
240
245 int shareDataProperties(BCESliderType st,int player);
246
248 const int getCurrentEqmIndex() const {
249 return currentEqmIndex;
250 }
251
253
257 const int getCurrentSliderVal(BCESliderType st,int player) const {
258 switch(st) {
259 case Action: return actions[player];
260 break;
261 case Type: return types[player];
262 break;
263 case State: return state;
264 break;
265 }
266 }
267
269
273 const vector< vector<double> >& getEqmMatrix() const {
274 return equilibriumMatrix;
275 }
276
278
282 const vector< vector<double> >& getObjectiveValues() const {
283 return objectiveValues;
284 }
285
287
290 const vector< vector<double> >& getAllEqm() const {
291 return allEqm;
292 }
293
295
299 const BCESolution& getSolution() const {
300 return solutionData;
301 }
302
304 const string getGUITitle() const {
305 return guiTitle;
306 }
307
309 void setConditionOnState(bool conditioned) {
310 conditionedOnState = conditioned;
311 setEqmMatrix();
312 }
313
314public slots:
315
317
321 void setSliderValue(int value,
322 BCESliderType st,
323 int player);
324
326
332 void resetManipulatedData(BCESliderType st,int player);
333
335
340
342
347 void modifyEqmFocus(double x,double y);
348
349private: //functions
350
352
356 void setEqmMatrix();
357
359
363 void setObjectiveVals(int player);
364
366
369 void setAllEqm();
370
372
374 double euclidianDistance(double x1,double x2,double y1,double y2) {
375 return sqrt(pow((y2-y1),2)+pow((x2-x1),2));
376 }
377
379 void setupControlsLayout();
380
381}; // BCEDataState
382
383#endif
int getNumObjectives() const
Returns the number of objectives.
Definition: bceabstractgame.hpp:245
Class for storing and manipulating solution data used by the plot handler.
Definition: bcedatastate.hpp:52
const string getGUITitle() const
Shares file name of currently loaded file with BCEWindow.
Definition: bcedatastate.hpp:304
void sliderLabelsChanged(bool privateVals, int player)
Signals that a slider control has been moved by the user.
string guiTitle
File name of example currently displayed in the GUI.
Definition: bcedatastate.hpp:163
void setupControlsLayout()
Builds the controls layout in the solution tab.
Definition: bcedatastate.cpp:110
bool margS0
If true, GUI displays marginal distribution for player's state.
Definition: bcedatastate.hpp:165
void valueChanged(int val, BCESliderType st, int player)
Signal for a changed slider value.
void modifyEqmFocus(double x, double y)
Changes current equilibrium index for stored BCEData.
Definition: bcedatastate.cpp:255
BCEGame gameData
Currently active BCEGame in the GUI.
Definition: bcedatastate.hpp:161
void equilibriumMatrixChanged()
Signals to the solution tab that equilibriumMatrix has been manipulated.
QVector< BCESlider * > sliderGroup
Vector of Slider Controls.
Definition: bcedatastate.hpp:190
const vector< vector< double > > & getObjectiveValues() const
Shares memory location of objectiveValues with BCEPlotHandler.
Definition: bcedatastate.hpp:282
void setSliderValue(int value, BCESliderType st, int player)
Changes stored slider data.
Definition: bcedatastate.cpp:202
double euclidianDistance(double x1, double x2, double y1, double y2)
Helper function for modifyEqmFocus.
Definition: bcedatastate.hpp:374
const vector< vector< double > > & getEqmMatrix() const
Shares memory location of equilibriumMatrix with BCEPlotHandler.
Definition: bcedatastate.hpp:273
void setAllEqm()
Resets BCE Value Set Plot data.
Definition: bcedatastate.cpp:361
void newStateSignal(int value0, int value1, int state, bool privateVals)
Signals changed state information and type of state (common or private).
void setSolutionData(const BCESolution &solution, const bool isBoundaryMapped)
Loads new data into the GUI.
Definition: bcedatastate.cpp:56
void eqmCoordSignal(double xCoord, double yCoord)
Signals coordinates of the current equilibrium.
const BCESolution & getSolution() const
Shares the current BCESolution by reference.
Definition: bcedatastate.hpp:299
vector< int > actions
A 2 element vector holding the current action for each player.
Definition: bcedatastate.hpp:149
bool isDataLoaded
Notes if data is currently loaded into the GUI.
Definition: bcedatastate.hpp:145
void newDataLoaded()
Signal that new data has been loaded.
const vector< vector< double > > & getMapBWeights() const
Sends map boundary weights to the plot handler.
Definition: bcedatastate.hpp:230
void devPlotPrChange(int player, double probability)
Signals data for changing deviation bar plots' titles.
vector< int > values
A 2 element vector holding the current state for each player.
Definition: bcedatastate.hpp:153
QWidget * controlsLayout
Layout Holding Sliders and Other Data Controls.
Definition: bcedatastate.hpp:227
const vector< vector< double > > & getAllEqm() const
Shares memory location of allEqm with BCEPlotHandler.
Definition: bcedatastate.hpp:290
void setEqmMatrix()
Resets heatmap data.
Definition: bcedatastate.cpp:292
int currentEqmIndex
Index of equilibrium currently displayed in the GUI.
Definition: bcedatastate.hpp:172
bool isPrivateVals
If true, GUI is displaying solution of a private-states game.
Definition: bcedatastate.hpp:157
void objectiveValuesChanged(int player)
Signals to the solution tab that objectiveValues have been manipulated.
vector< bool > margA
If true, GUI displays marginal distribution for player's action/type.
Definition: bcedatastate.hpp:170
BCESolution solutionData
Currently active BCESolution in the GUI.
Definition: bcedatastate.hpp:159
vector< vector< double > > equilibriumMatrix
Data displayed in the GUI's heatmap.
Definition: bcedatastate.hpp:174
int state
Holds the current state of a common-states game.
Definition: bcedatastate.hpp:155
QVector< BCELineEdit * > lineEditGroup
Vector of Line Edits.
Definition: bcedatastate.hpp:198
vector< int > types
A 2 element vector holding the current type for each player.
Definition: bcedatastate.hpp:151
bool conditionedOnState
Tells whether equilibriumMatrix is conditioned on State.
Definition: bcedatastate.hpp:200
const int getCurrentSliderVal(BCESliderType st, int player) const
Returns current integer value of a slider.
Definition: bcedatastate.hpp:257
BCEDataState()
Default constructor.
Definition: bcedatastate.cpp:25
void selectedEqmChanged()
Signal that data for the set of BCE plot has been changed.
vector< vector< double > > allEqm
Data displayed in the GUI's BCE Value Set Plot.
Definition: bcedatastate.hpp:183
void devPlotTitleChange(int player, int aciton, int type, double payoff)
Signals data for changing deviation bar plots' titles.
bool isMapped
Gives if boundary was mapped in the solution object.
Definition: bcedatastate.hpp:147
void setConditionOnState(bool conditioned)
Alters whether data in equilibriumMatrix is conditional on state.
Definition: bcedatastate.hpp:309
vector< vector< double > > objectiveValues
Data displayed in the GUI's bar plots.
Definition: bcedatastate.hpp:176
int shareDataProperties(BCESliderType st, int player)
Shares basic game data (e.g. numActions) with BCEWindow.
Definition: bcedatastate.cpp:45
void sendException(QString message)
Sends an exception message to BCEWindow to be displayed.
const int getCurrentEqmIndex() const
Returns the current eqm index stored in BCEDataState.
Definition: bcedatastate.hpp:248
void setObjectiveVals(int player)
Resets deviation bar plot data.
Definition: bcedatastate.cpp:344
const int getNumObjs() const
Sends the number of objectives to the plot handler.
Definition: bcedatastate.hpp:235
void resetManipulatedData()
Calls all "set" data functions.
Definition: bcedatastate.cpp:248
The base class for games of incomplete information.
Definition: bcegame.hpp:40
Class for storing data produced by BCESolver.
Definition: bcesolution.hpp:64
const vector< vector< double > > & getMapBoundaryWeights() const
Returns the mapBoundary weights.
Definition: bcesolution.hpp:188