-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdomain.h
More file actions
248 lines (194 loc) · 6.69 KB
/
domain.h
File metadata and controls
248 lines (194 loc) · 6.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#ifndef DOMAIN_H
#define DOMAIN_H
//#include "mainwindow.h"
//#include "behaviour.h"
// #include "account.h"
#include <iostream>
#include <map>
#include <QObject>
#include <QVector>
#include <QtCharts/QLineSeries>
#include <QSettings>
#include <QMap>
// NEXT: This class should contain the main driver code to trigger its
// components in response to a clock maintained by MainWindow. Also, allow
// clock tick frequency to be set as a global option so we can put time
// durations on the x-axes of the charts. Suggested default: one tick per week.
QT_CHARTS_USE_NAMESPACE
/*
class Account;
class Government;
class Worker;
class Firm;
class Bank;
*/
// Only potentially conditional parameters are listed here
enum class ParamType {
procurement,
emp_rate,
prop_con,
inc_tax_rate,
inc_thresh,
sales_tax_rate,
firm_creation_prob,
recoup,
dedns,
unemp_ben_rate,
active_pop,
distrib,
prop_inv,
boe_int,
bus_int,
loan_prob,
};
const static QMap<ParamType,QString> parameterKeys
{
{ParamType::procurement, "govt-procurement"},
{ParamType::emp_rate, "employment-rate"},
{ParamType::prop_con, "propensity-to-consume"},
{ParamType::inc_tax_rate, "income-tax-rate"},
{ParamType::inc_thresh, "income-threshold"},
{ParamType::sales_tax_rate, "sales-tax-rate"},
{ParamType::firm_creation_prob, "firm-creation-prob"},
{ParamType::dedns, "pre-tax-dedns-rate"},
{ParamType::unemp_ben_rate, "unempl-benefit-rate"},
{ParamType::active_pop, "active-population-rate"},
{ParamType::distrib, "reserve-rate"},
{ParamType::prop_inv, "prop-invest"},
{ParamType::boe_int, "boe-interest"},
{ParamType::bus_int, "bus-interest"},
{ParamType::loan_prob, "loan-prob"},
{ParamType::recoup, "capex-recoup-periods"},
};
class Domain : public QObject
{
Q_OBJECT
public:
static Domain *createDomain(const QString &name, const QString ¤cy, const QString ¤cyAbbrev);
// List of all domains. When a new domain is created it is automatically
// added to this list.
static QList<Domain*> domains;
// Get the domain having the given name, returning a pointer to it, and
// set it as current. Requires loadAllDomains() to have been called
// (which loads all the Domains into QList<Domain*> domains).
static Domain *getDomain(const QString &name);
static Domain *currentDomain;
/*
inline static Domain *getDefaultDomain() {
return defaultDomain;
}
*/
void initialise();
Firm *createFirm(bool state_supported = false);
Firm *selectRandomFirm(Firm *exclude = nullptr);
Bank *getCentral_bank() const;
const QString &getName() const;
int getPopulation();
int getPopSize(); // max available population size
// int getActivePop(); // target size of economically active population
// int getGovExpRate(); // government expenditure (currency units per period)
int getStdWage(); // standard wage (currency units per employee per period)
int getPropCon(); // propensity to consume (%)
int getIncTaxRate(); // income tax rate (%)
int getSalesTaxRate(); // sales tax rate (%)
int getFCP(); // firm creaton probability (%)
int getUBR(); // unemployment benefit rate (% of std wage)
int getPropInv(); // propensity to invest
int getReserve(); // funds kept in reserve for next period (%)
// ------------------------------------------------------------------------
// Properties
// ------------------------------------------------------------------------
enum class Property
{
current_period,
pop_size, // although constant, we treat this as a property
// as it's sometimes useful to show it on a graph
gov_exp,
bens_paid,
gov_exp_plus,
gov_recpts,
deficit,
deficit_pc,
gov_bal,
num_firms,
num_emps,
pc_emps,
num_unemps,
pc_unemps,
pc_active,
num_gov_emps,
num_hired,
num_fired,
prod_bal,
wages,
consumption,
bonuses,
dedns,
inc_tax,
sales_tax,
dom_bal,
amount_owed,
bus_size,
hundred,
zero,
procurement,
productivity,
rel_productivity,
unbudgeted,
investment,
gdp,
profit,
num_properties
};
Property getProperty(int); // return the property with the given value
QList<Property> prop_list; // to simplify iterations
double scale(Property p);
double gini();
// This gives us a set of pointers to line series, ordered by the Properties
// they are associated with. E.g., when iterating, the series for bens_paid
// will be encountered before the series for gov_recpts. Order is
// significant as it allows us to store values and use them in later
// composite properties (e,g, deficit).
QMap<Property, QLineSeries*> series;
QMap<Property, bool> scalable;
int _num_properties = static_cast<int>(Property::num_properties);
int min_val[static_cast<int>(Property::num_properties)];
int max_val[static_cast<int>(Property::num_properties)];
int sum[static_cast<int>(Property::num_properties)];
// Retrieve the current (periodic) value associated with a given Property
double getPropertyVal(Property p);
private:
// A domain should create its own (anonymous) behaviour, including currency
// and currency abbreviation
Domain(const QString &name, const QString ¤cy, const QString ¤cyAbbrev);
QString _name;
QString _currency;
QString _abbrev;
// This class is invoked (directly or indirectly) from MainWindow so it
// cannot itself the MainWindow object
// MainWindow *_mainwindow;
int _population;
// One of these is redundant!
Bank *_centralBank;
Bank *_bank;
Government *_gov;
QVector<Firm*> firms;
QVector<Worker*> workers;
double _gini;
// Constants
QString _notes; // This isn't used at present
int _startups;
double _scale;
double _std_wage;
// See getPropertyValue
int _num_firms, _num_emps, _num_unemps, _num_gov_emps, _num_hired,
_num_fired, _pop_size;
double _exp, _bens, _rcpts, _gov_bal, _prod_bal, _wages, _consumption,
_bonuses, _dedns, _inc_tax, _sales_tax, _dom_bal, _loan_prob,
_amount_owed, _deficit, _pc_active, _bus_size, _proc_exp,
_productivity, _rel_productivity, _investment, _gdp, _profit;
public slots:
void iterate(int _period, bool visible = false);
signals:
};
#endif // DOMAIN_H