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
firm_functions_top.c
Go to the documentation of this file.
1
#include "
header.h
"
2
#include "
firm_agent_header.h
"
3
#include <math.h>
4
5
/*
6
* \fn: int firm_init_post_id()
7
* \brief:
8
*/
9
int
firm_init_post_id
()
10
{
11
add_firm_jpoffice_id_message
(
ID
,
ISCONSTRUCTOR
);
12
13
/*** Balancesheet Verification. */
14
if
(
DATA_COLLECTION_MODE
) {
15
char
* filename;
16
FILE * file1;
17
filename = malloc(100*
sizeof
(
char
));
18
filename[0]=0;
19
strcpy(filename,
"./outputs/data/Firm_ID_Liquidity_Loan.txt"
);
20
file1 = fopen(filename,
"w"
);
21
//fprintf(file1,"%d %f %f\n",ID, LIQUIDITY, DEBT);
22
fclose(file1);
23
free(filename);
24
}
25
26
27
return
0;
/* Returning zero means the agent is not removed */
28
}
29
30
/*
31
* \fn: int firm_init_employment()
32
* \brief:
33
*/
34
int
firm_init_employment
()
35
{
36
int
new_employee, position;
37
38
START_JPOFFICE_FIRM_EMPLOYEE_MESSAGE_LOOP
39
new_employee =
jpoffice_firm_employee_message
->
employee_id
;
40
position =
jpoffice_firm_employee_message
->
position
;
41
if
(position > 0) {
42
MANAGER
= new_employee;
43
}
44
add_int
(&
EMPLOYEES
, new_employee);
45
FINISH_JPOFFICE_FIRM_EMPLOYEE_MESSAGE_LOOP
46
47
48
CAPITAL_GOODS_PRICE
= 100 *
UNIT_GOODS_PRICE
;
49
50
51
NO_EMPLOYEES
=
EMPLOYEES
.size;
52
EMPLOYEES_NEEDED
=
NO_EMPLOYEES
;
53
LABOUR_COSTS
=
NO_EMPLOYEES
*
WAGE_OFFER
;
54
DEBT
= (
NO_EMPLOYEES
* WAGE_OFFER * 0.2) /
LOANS_INTEREST_RATE
;
55
TOTAL_INTEREST_PAYMENTS
=
DEBT
* (
LOANS_INTEREST_RATE
/ 4);
56
OPERATING_COSTS
=
LABOUR_COSTS
+
TOTAL_INTEREST_PAYMENTS
;
57
EQUITY
=
DEBT
/
FIRM_STARTUP_LEVERAGE
;
58
TOTAL_ASSETS
=
DEBT
+
EQUITY
;
59
LOAN_LIST
[0].amount =
DEBT
;
60
61
/* The value is used to set a large (inf) number for regular firms.*/
62
CAPITAL_PRODUCTIVITY
= (double) 999999;
63
64
if
(
ISCONSTRUCTOR
) {
65
66
PRODUCTION_CURRENT
= (int) (
NO_EMPLOYEES
*
LABOUR_PRODUCTIVITY
/ 12);
67
INVENTORY
=
PRODUCTION_CURRENT
;
68
SALES
= 2;
69
REVENUES
=
SALES
*
UNIT_HOUSE_PRICE
;
70
CAPITAL_GOODS
= ceil((
TOTAL_ASSETS
- UNIT_HOUSE_PRICE *
INVENTORY
-
LIQUIDITY
)/CAPITAL_GOODS_PRICE);
71
CAPITAL_PRODUCTIVITY
=
LABOUR_PRODUCTIVITY
*
NO_EMPLOYEES
/ (0.7 *
CAPITAL_GOODS
);
72
73
}
else
{
74
75
PRODUCTION_CURRENT
= (int) (
NO_EMPLOYEES
*
LABOUR_PRODUCTIVITY
);
76
INVENTORY
= (int) (
PRODUCTION_CURRENT
/ 10);
77
SALES
=
PRODUCTION_CURRENT
;
78
REVENUES
=
SALES
*
UNIT_GOODS_PRICE
;
79
CAPITAL_GOODS
= ceil((
TOTAL_ASSETS
- UNIT_GOODS_PRICE *
INVENTORY
-
LIQUIDITY
)/CAPITAL_GOODS_PRICE);
80
}
81
82
EBIT
=
REVENUES
-
LABOUR_COSTS
;
83
NET_EARNINGS
=
EBIT
-
TOTAL_INTEREST_PAYMENTS
;
84
LIQUIDITY
+=
NET_EARNINGS
;
85
86
if
(
PRINT_DEBUG_MODE
) {
87
printf(
"Firm %d --> Size = %d \n"
,
ID
,
NO_EMPLOYEES
);
88
}
89
90
return
0;
/* Returning zero means the agent is not removed */
91
}
92
93
/*
94
* \fn: int firm_init_balancesheet()
95
* \brief:
96
*/
97
int
firm_init_balancesheet
()
98
{
99
/*The firms are initiliazed loans only with their preferred banks.
100
*/
101
add_firm_bank_init_loans_message
(
BANK_ID
,
LOAN_LIST
[0].amount);
102
103
add_firm_bank_init_deposit_message
(
BANK_ID
,
LIQUIDITY
);
104
105
/*** Balancesheet Verification. */
106
if
(
DATA_COLLECTION_MODE
) {
107
char
* filename;
108
FILE * file1;
109
filename = malloc(100*
sizeof
(
char
));
110
filename[0]=0;
111
strcpy(filename,
"./outputs/data/Firm_ID_Liquidity_Loan.txt"
);
112
file1 = fopen(filename,
"a"
);
113
fprintf(file1,
"%d %f %f\n"
,
ID
,
LIQUIDITY
,
DEBT
);
114
fclose(file1);
115
free(filename);
116
117
}
118
119
120
return
0;
/* Returning zero means the agent is not removed */
121
}
122
123
/*
124
* \fn: int firm_iterate()
125
* \brief:
126
*/
127
int
firm_iterate
()
128
{
129
if
(
DATA_COLLECTION_MODE
&&
COLLECT_FIRM_DATA
) {
130
131
if
(
IT_NO
== 0)
132
{
133
134
char
* filename;
135
FILE * file1;
136
filename = malloc(140*
sizeof
(
char
));
137
138
if
(
ISCONSTRUCTOR
) {
139
/* @\fn: firm_production_construction_plan() */
140
filename[0]=0;
141
strcpy(filename,
"./outputs/data/Constructor_Firm_Monthly.txt"
);
142
file1 = fopen(filename,
"w"
);
143
fprintf(file1,
"%s %s %s %s %s %s %s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"WAGE_OFFER"
,
"NO_EMPLOYEES"
,
"EMPLOYEES_NEEDED"
,
"SALES"
,
"INVENTORY"
,
"PRODUCTION_CURRENT"
,
"PRODUCTION_PLAN"
,
"UNIT_HOUSE_PRICE"
);
144
fclose(file1);
145
146
147
/* @\fn: firm_credit_compute_income_statement() */
148
filename[0]=0;
149
strcpy(filename,
"./outputs/data/Constructor_Firm_Quarterly_IncomeStatement.txt"
);
150
file1 = fopen(filename,
"w"
);
151
fprintf(file1,
"%s %s %s %s %s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"REVENUES"
,
"OPERATING_COSTS"
,
"LABOUR_COSTS"
,
"TOTAL_INTEREST_PAYMENTS"
,
"EBIT"
,
"NET_EARNINGS"
);
152
fclose(file1);
153
154
155
/* @\fn: firm_credit_pay_dividends() */
156
filename[0]=0;
157
strcpy(filename,
"./outputs/data/Constructor_Firm_Quarterly_Dividends.txt"
);
158
file1 = fopen(filename,
"w"
);
159
fprintf(file1,
"%s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"DIVIDENDS_PAID"
,
"DIVIDENDS_TO_BE_PAID"
);
160
fclose(file1);
161
162
/* @\fn: firm_credit_do_balance_sheet() */
163
filename[0]=0;
164
strcpy(filename,
"./outputs/data/Constructor_Firm_Quarterly_BalanceSheet.txt"
);
165
file1 = fopen(filename,
"w"
);
166
fprintf(file1,
"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"ISLIQUIDSHORT"
,
"HASLOAN"
,
"HASINVESTMENT"
,
"LIQUIDITY_NEED"
,
"ISINSOLVENT"
,
"ISILLIQUID"
,
"TOTAL_ASSETS"
,
"LIQUIDITY"
,
"INVENTORY"
,
"UNIT_HOUSE_PRICE"
,
"CAPITAL_GOODS_PRICE"
,
"CAPITAL_GOODS"
,
"DEBT"
,
"EQUITY"
);
167
fclose(file1);
168
}
169
else
170
{
171
/* @\fn: firm_production_plan() */
172
filename[0]=0;
173
strcpy(filename,
"./outputs/data/Firm_Monthly.txt"
);
174
file1 = fopen(filename,
"w"
);
175
fprintf(file1,
"%s %s %s %s %s %s %s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"WAGE_OFFER"
,
"NO_EMPLOYEES"
,
"EMPLOYEES_NEEDED"
,
"SALES"
,
"INVENTORY"
,
"PRODUCTION_CURRENT"
,
"PRODUCTION_PLAN"
,
"UNIT_GOODS_PRICE"
);
176
fclose(file1);
177
178
179
/* @\fn: firm_credit_compute_income_statement() */
180
filename[0]=0;
181
strcpy(filename,
"./outputs/data/Firm_Quarterly_IncomeStatement.txt"
);
182
file1 = fopen(filename,
"w"
);
183
fprintf(file1,
"%s %s %s %s %s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"REVENUES"
,
"OPERATING_COSTS"
,
"LABOUR_COSTS"
,
"TOTAL_INTEREST_PAYMENTS"
,
"EBIT"
,
"NET_EARNINGS"
);
184
fclose(file1);
185
186
187
/* @\fn: firm_credit_pay_dividends() */
188
filename[0]=0;
189
strcpy(filename,
"./outputs/data/Firm_Quarterly_Dividends.txt"
);
190
file1 = fopen(filename,
"w"
);
191
fprintf(file1,
"%s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"DIVIDENDS_PAID"
,
"DIVIDENDS_TO_BE_PAID"
);
192
fclose(file1);
193
194
/* @\fn: firm_credit_do_balance_sheet() */
195
filename[0]=0;
196
strcpy(filename,
"./outputs/data/Firm_Quarterly_BalanceSheet.txt"
);
197
file1 = fopen(filename,
"w"
);
198
fprintf(file1,
"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
,
"IT_NO"
,
"ID"
,
"ISLIQUIDSHORT"
,
"HASLOAN"
,
"HASINVESTMENT"
,
"LIQUIDITY_NEED"
,
"ISINSOLVENT"
,
"ISILLIQUID"
,
"TOTAL_ASSETS"
,
"LIQUIDITY"
,
"INVENTORY"
,
"UNIT_GOODS_PRICE"
,
"CAPITAL_GOODS_PRICE"
,
"CAPITAL_GOODS"
,
"DEBT"
,
"EQUITY"
);
199
fclose(file1);
200
}
201
free(filename);
202
}
203
}
204
205
206
IT_NO
++;
207
return
0;
/* Returning zero means the agent is not removed */
208
}
209
210
/*
211
* \fn: int firm_update_bank_account()
212
* \brief: puts money to deposit account of its prefered bak. */
213
int
firm_update_bank_account
()
214
{
215
if
(
LIQUIDITY
> 0) {
216
add_firm_bank_update_deposit_message
(
BANK_ID
,
LIQUIDITY
);
217
}
218
219
if
(
PRINT_DEBUG_MODE
) {
220
printf(
"Firm ID = %d a liquidity amount = %f has deposited to bank.\n"
,
ID
,
LIQUIDITY
);
221
}
222
223
return
0;
/* Returning zero means the agent is not removed */
224
}
Generated on Tue Apr 8 2014 13:25:17 for ICEACE Model: Closed Economy by
1.8.3.1