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
Market_Labour
firm_functions_labour.c
Go to the documentation of this file.
1
#include "../header.h"
2
#include "../firm_agent_header.h"
3
#include "../library_header.h"
4
5
/*
6
* \fn: int firm_labour_workforce_needed()
7
* \brief: A firm computes required number of employees to fulfill production
8
* requirements.
9
*/
10
int
firm_labour_workforce_needed
()
11
{
12
/* Making sure that at least one employee per firm is hired. */
13
if
(
NO_EMPLOYEES
< 1) {
14
EMPLOYEES_NEEDED
= 1;
15
}
16
17
VACANCIES
=
EMPLOYEES_NEEDED
-
NO_EMPLOYEES
;
18
19
if
(
PRINT_DEBUG_MODE
) {
20
printf(
"Firm %d is at Labour Market VACANCIES is %d\n"
,
ID
,
VACANCIES
);
21
for
(
int
i = 0; i<
EMPLOYEES
.size; i++) {
22
printf(
" %d "
,
EMPLOYEES
.array[i]);
23
}
24
printf(
"\n Manageger = %d\n"
,
MANAGER
);
25
}
26
27
return
0;
/* Returning zero means the agent is not removed */
28
}
29
30
/*
31
* \fn: int firm_labour_fire()
32
* \brief: A firm picks a number of employees to be fired. And sends out a
33
* notification message.
34
*/
35
int
firm_labour_fire
()
36
{
37
/* Algorithm:
38
Determine number of employees to be fired.
39
Make a deterministic sampling. Pick the ones with higher indices.
40
Send out fired message.
41
*/
42
43
int
size;
44
size =
EMPLOYEES
.size;
45
if
(size < 2) {
46
NO_EMPLOYEES
= size;
47
VACANCIES
= 0;
48
return
0;
49
}
50
51
int
employer, position, i;
52
int
n_to_fire, fired;
53
54
n_to_fire = size -
EMPLOYEES_NEEDED
;
55
56
/* Keep at least one employee at the firm. */
57
if
(n_to_fire >= size) {
58
n_to_fire = size - 1;
59
}
60
61
i = 0;
62
fired = 0;
63
while
(fired < n_to_fire) {
64
if
(i == size){
break
;}
65
i++;
66
position =
EMPLOYEES
.size - 1;
67
employer =
EMPLOYEES
.array[position];
68
if
(employer ==
MANAGER
){
continue
;}
69
add_fired_message
(
EMPLOYEES
.array[position]);
70
remove_int
(&
EMPLOYEES
, position);
71
fired++;
72
73
}
74
75
NO_EMPLOYEES
= size;
76
VACANCIES
= 0;
77
78
return
0;
/* Returning zero means the agent is not removed */
79
}
80
81
/*
82
* \fn: int firm_labour_job_announcement_stage1()
83
* \brief: a firm announces a number of vacancies.
84
* a vacancy message holds firm id and wage to be paid.
85
*/
86
int
firm_labour_job_announcement_stage1
()
87
{
88
if
(
WAGE_OFFER
<=
AVERAGE_WAGE
) {
89
WAGE_OFFER
= 1.01 *
AVERAGE_WAGE
;
90
}
91
92
for
(
int
i = 0; i <
VACANCIES
; i++) {
93
add_vacancy_stage1_message
(
ID
,
WAGE_OFFER
);
94
}
95
96
return
0;
/* Returning zero means the agent is not removed */
97
}
98
99
/*
100
* \fn: int firm_labour_job_offer()
101
* \brief: the firm recieves job application messages. Messages are sorted
102
* by employee ids. Applicants with lower indices (employee ids) are hired.
103
* This leads to a type of deterministic sampling. An employee applies to a
104
* post one at a time.
105
*/
106
int
firm_labour_job_offer_stage1
()
107
{
108
int
n_hired, new_employee;
109
110
/* Recieve job application messages. */
111
n_hired = 0;
112
113
START_JOB_MATCH_STAGE1_MESSAGE_LOOP
114
new_employee =
job_match_stage1_message
->
employee_id
;
115
add_int
(&
EMPLOYEES
, new_employee);
116
n_hired +=1;
117
FINISH_JOB_MATCH_STAGE1_MESSAGE_LOOP
118
119
/* It is possible that fewer than needed applications were recieved. */
120
VACANCIES
-= n_hired;
121
NO_EMPLOYEES
=
EMPLOYEES
.size;
122
123
return
0;
/* Returning zero means the agent is not removed */
124
}
125
126
/*
127
* \fn: int firm_labour_update()
128
* \brief: the firm recieves job resignation message.
129
* Labour force status is updated. Messages addressed to this agent
130
* is filtered before hand.
131
*/
132
int
firm_labour_update
()
133
{
134
int
id_resigned, n_resigned, index, i;
135
136
n_resigned = 0;
137
/* Recieve job resignation messages addressed to the firm. */
138
START_JOB_CHANGE_MESSAGE_LOOP
139
id_resigned =
job_change_message
->
employee_id
;
140
n_resigned++;
141
index =
EMPLOYEES
.size - 1;
142
for
(i=0; i<
EMPLOYEES
.size; i++) {
143
if
(
EMPLOYEES
.array[i] == id_resigned) {
144
index = i;
145
break
;
146
}
147
}
148
remove_int
(&
EMPLOYEES
, index);
149
FINISH_JOB_CHANGE_MESSAGE_LOOP
150
151
NO_EMPLOYEES
=
EMPLOYEES
.size;
152
VACANCIES
+= n_resigned;
153
154
return
0;
/* Returning zero means the agent is not removed */
155
}
156
157
/*
158
* \fn: int firm_labour_job_announcement_stage2()
159
* \brief: a firm announces a number of unfilled or resigned vacancies.
160
* a vacancy message holds firm id and wage to be paid. The behaviour is
161
* activated only when there are still vacancies.
162
*/
163
int
firm_labour_job_announcement_stage2
()
164
{
165
for
(
int
i = 0; i <
VACANCIES
; i++) {
166
add_vacancy_stage2_message
(
ID
,
WAGE_OFFER
);
167
}
168
169
170
return
0;
/* Returning zero means the agent is not removed */
171
}
172
173
/*
174
* \fn: int firm_labour_job_offer_stage2()
175
* \brief: the firm recieves job application messages in the second round.
176
* Messages are sorted by employee ids. Applicants with lower indices
177
* (employee ids) are hired.
178
* This leads to a type of deterministic sampling. An employee applies to a
179
* post one at a time.
180
*/
181
int
firm_labour_job_offer_stage2
()
182
{
183
int
n_hired, candidate;
184
185
/* Recieve job application messages. */
186
n_hired = 0;
187
188
189
START_JOB_MATCH_STAGE2_MESSAGE_LOOP
190
candidate =
job_match_stage2_message
->
employee_id
;
191
add_int
(&
EMPLOYEES
, candidate);
192
n_hired++;
193
FINISH_JOB_MATCH_STAGE2_MESSAGE_LOOP
194
195
196
VACANCIES
-= n_hired;
197
NO_EMPLOYEES
=
EMPLOYEES
.size;
198
199
if
(
PRINT_DEBUG_MODE
){
200
printf(
"Firm ID = %d is at the end of Labour Market Stage 2: Number of Employees =%d, Vacancies = %d \n"
,
ID
,
NO_EMPLOYEES
, VACANCIES);
201
}
202
return
0;
/* Returning zero means the agent is not removed */
203
}
204
205
206
207
/*
208
* \fn: int firm_labour_pay_wages()
209
* \brief: a firm pays wages and taxes on wages.
210
*/
211
int
firm_labour_pay_wages
()
212
{
213
double
payrolls;
214
double
labour_tax = 0;
215
216
add_firm_household_wage_payment_message
(
ID
,
WAGE_OFFER
);
217
218
payrolls = (double)(
WAGE_OFFER
*
NO_EMPLOYEES
);
219
labour_tax = payrolls *
LABOUR_TAX_RATE
;
220
add_labour_tax_message
(labour_tax);
221
LIQUIDITY
-= payrolls;
222
LABOUR_COSTS
+= payrolls;
223
224
225
return
0;
/* Returning zero means the agent is not removed */
226
}
227
228
229
/*
230
* \fn: int firm_labour_trace_wages()
231
* \brief: The firm traces wages in the market and update.
232
*/
233
int
firm_labour_trace_wages
(){
234
int
unemployed = 0;
235
double
total_wages = 0;
236
int
total = 0;
237
int
id;
238
START_EMPLOYMENT_STATUS_MESSAGE_LOOP
239
id
=
employment_status_message
->
employer_id
;
240
if
(
id
== 0) {
241
unemployed++;
242
}
243
else
{
244
total_wages +=
employment_status_message
->
wage
;
245
}
246
total++;
247
FINISH_EMPLOYMENT_STATUS_MESSAGE_LOOP
248
if
(total == 0 || unemployed == total) {
249
250
}
else
{
251
AVERAGE_WAGE
= total_wages / (total - unemployed);
252
}
253
254
return
0;
/* Returning zero means the agent is not removed */
255
}
Generated on Tue Apr 8 2014 13:25:19 for ICEACE Model: Closed Economy by
1.8.3.1