ICEACE Model: Closed Economy
1.0.0
Design Documentation of ICEACE Model
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
IceaceModel1.0
centralbank_functions_top.c
Go to the documentation of this file.
1
#include "
header.h
"
2
#include "
centralbank_agent_header.h
"
3
4
5
/*
6
* \fn: int centralbank_init_balancesheet()
7
* \brief:
8
*/
9
int
centralbank_init_balancesheet
()
10
{
11
double
amount;
12
13
LOANS_BANKS
= 0;
14
START_BANK_CENTRALBANK_INIT_DEBT_MESSAGE_LOOP
15
LOANS_BANKS
+=
bank_centralbank_init_debt_message
->
amount
;
16
FINISH_BANK_CENTRALBANK_INIT_DEBT_MESSAGE_LOOP
17
18
19
20
LIQUIDITY_BANKS
= 0;
21
START_BANK_CENTRALBANK_INIT_DEPOSIT_MESSAGE_LOOP
22
amount =
bank_centralbank_init_deposit_message
->
amount
;
23
LIQUIDITY_BANKS += amount;
24
FINISH_BANK_CENTRALBANK_INIT_DEPOSIT_MESSAGE_LOOP
25
26
START_GOV_CENTRALBANK_INIT_DEPOSIT_MESSAGE_LOOP
27
amount =
gov_centralbank_init_deposit_message
->
amount
;
28
LIQUIDITY_GOVERNMENT
= amount;
29
FINISH_GOV_CENTRALBANK_INIT_DEPOSIT_MESSAGE_LOOP
30
31
32
START_FUND_CENTRALBANK_INIT_DEPOSIT_MESSAGE_LOOP
33
amount =
fund_centralbank_init_deposit_message
->
amount
;
34
LIQUIDITY_EQUITYFUND
= amount;
35
FINISH_FUND_CENTRALBANK_INIT_DEPOSIT_MESSAGE_LOOP
36
/* Equity Fund liquidity is disregarded. */
37
LIQUIDITY_EQUITYFUND
= 0;
38
39
LIQUIDITY
= 0;
40
EQUITY
= 0;
41
LOANS_GOVERNMENT
= 0;
42
TOTAL_WRITEOFFS
= 0;
43
44
double
loans, deposits, liabilities;
45
loans = LOANS_BANKS +
LOANS_GOVERNMENT
;
46
deposits = LIQUIDITY_BANKS +
LIQUIDITY_GOVERNMENT
+
LIQUIDITY_EQUITYFUND
;
47
/* Fiat money in this case equal to firms total loans minus private sector deposits. */
48
FIAT_MONEY
= loans - deposits;
49
if
(
FIAT_MONEY
< 0) {
50
LIQUIDITY
= -1 *
FIAT_MONEY
;
51
FIAT_MONEY
= 0;
52
53
}
54
liabilities =
FIAT_MONEY
+ deposits;
55
TOTAL_ASSETS
= loans +
LIQUIDITY
;
56
EQUITY
=
TOTAL_ASSETS
- liabilities;
57
58
return
0;
/* Returning zero means the agent is not removed */
59
}
60
61
/*
62
* \fn: int centralbank_iterate()
63
* \brief:
64
*/
65
int
centralbank_iterate
()
66
{
67
if
(
DATA_COLLECTION_MODE
) {
68
if
(
IT_NO
== 0) {
69
char
* filename;
70
FILE * file1;
71
72
/* @/fn: centralbank_do_balance_sheet() */
73
filename = malloc(100*
sizeof
(
char
));
74
filename[0]=0;
75
strcpy(filename,
"./outputs/data/CentralBank_snapshot.txt"
);
76
file1 = fopen(filename,
"w"
);
77
fprintf(file1,
"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
,
"IT_NO"
,
"INTEREST_RATE"
,
"INFLATION_RATE"
,
"REVENUES"
,
"TOTAL_COSTS"
,
"NET_EARNINGS"
,
"TOTAL_ASSETS"
,
"LIQUIDITY"
,
"LOANS_BANKS"
,
"LOANS_GOVERNMENT"
,
"EQUITY"
,
"FIAT_MONEY"
,
"LIQUIDITY_BANKS"
,
"LIQUIDITY_GOVERNMENT"
,
"LIQUIDITY_EQUITYFUND"
);
78
//fprintf(file1,"%d %f %f %f %f %f %f %f %f %f %f %f %f %f\n",IT_NO, INTEREST_RATE, INFLATION_RATE, REVENUES, TOTAL_COSTS, NET_EARNINGS, TOTAL_ASSETS, LIQUIDITY, LOANS_BANKS, LOANS_GOVERNMENT, EQUITY,FIAT_MONEY, LIQUIDITY_BANKS, LIQUIDITY_GOVERNMENT, LIQUIDITY_EQUITYFUND);
79
fclose(file1);
80
free(filename);
81
}
82
83
if
(
IT_NO
== 0) {
84
char
* filename;
85
FILE * file1;
86
87
/* @/fn: () */
88
filename = malloc(40*
sizeof
(
char
));
89
filename[0]=0;
90
strcpy(filename,
"./outputs/data/BankruptcyInspection.txt"
);
91
file1 = fopen(filename,
"w"
);
92
fprintf(file1,
"%s %s %s %s %s %s\n"
,
"IT"
,
"ID"
,
"Agent"
,
"Writeoff_Type"
,
"Bank"
,
"Amount"
);
93
fclose(file1);
94
free(filename);
95
}
96
}
97
98
IT_NO
++;
99
return
0;
/* Returning zero means the agent is not removed */
100
}
101
102
103
/*
104
* \fn: int centralbank_update_deposits()
105
* \brief:
106
*/
107
int
centralbank_update_deposits
()
108
{
109
double
pre, post, delta_deposits;
110
111
pre =
LIQUIDITY_BANKS
+
LIQUIDITY_EQUITYFUND
+
LIQUIDITY_GOVERNMENT
;
112
113
114
LIQUIDITY_BANKS
= 0;
115
START_BANK_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
116
LIQUIDITY_BANKS
+=
bank_centralbank_update_deposit_message
->
amount
;
117
FINISH_BANK_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
118
119
LIQUIDITY_GOVERNMENT = 0;
120
START_GOV_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
121
LIQUIDITY_GOVERNMENT =
gov_centralbank_update_deposit_message
->
amount
;
122
FINISH_GOV_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
123
124
LIQUIDITY_EQUITYFUND
= 0;
125
START_FUND_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
126
LIQUIDITY_EQUITYFUND =
fund_centralbank_update_deposit_message
->
amount
;
127
FINISH_FUND_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
128
129
130
post = LIQUIDITY_BANKS + LIQUIDITY_EQUITYFUND +
LIQUIDITY_GOVERNMENT
;
131
132
delta_deposits = post - pre;
133
134
LIQUIDITY
+= delta_deposits;
135
136
/* This is where Central Bank prints banknotes. */
137
if
(
LIQUIDITY
< 0) {
138
FIAT_MONEY
-=
LIQUIDITY
;
139
LIQUIDITY
= 0;
140
}
141
142
143
return
0;
/* Returning zero means the agent is not removed */
144
}
145
Generated on Tue Apr 8 2014 13:25:17 for ICEACE Model: Closed Economy by
1.8.3.1