ICEACE Model: Closed Economy  1.0.0
Design Documentation of ICEACE Model
 All Data Structures Files Functions Variables Typedefs Macros Pages
jpoffice_functions_top.c
Go to the documentation of this file.
1 #include "header.h"
3 #include "./library_header.h"
4 
5 /*
6  * \fn: int jpoffice_init_employment()
7  * \brief:
8  */
10 {
11  /* Initialize */
12 
13  /* Allocate firms and household arrays. */
14  int_array household_list;
15  int_array regular_firm_list;
16  int_array constructor_firm_list;
17 
18  int firm_type, firm_id, household_id;
19  int nhouseholds, nrfirms, ncfirms;
20  int constructor_firm_size, employment_size;
21  int nemployed = 0;
22  int i,j;
23 
24  /* initialize arrays */
25  init_int_array(&household_list);
26  init_int_array(&regular_firm_list);
27  init_int_array(&constructor_firm_list);
28 
29 
30  /* Collect household IDs */
33  add_int(&household_list, household_id);
35 
36  nhouseholds = household_list.size;
37  if (nhouseholds == 0 ) {
38  if (WARNING_MODE) {
39  printf("Warning @jpoffice_init_employment(): No household is detected at initiliazation.\n");
40  }
41  free_int_array(&household_list);
42  free_int_array(&regular_firm_list);
43  free_int_array(&constructor_firm_list);
44  return 0;
45  }
46 
47  /* Collect firm IDs */
51  if (firm_type == 0) {
52  add_int(&regular_firm_list, firm_id);
53  } else {
54  add_int(&constructor_firm_list, firm_id);
55  }
57 
58  nrfirms = regular_firm_list.size;
59  ncfirms = constructor_firm_list.size;
60 
61  /* employment ratio is 0.9
62  * number of employees at construction sector is 7.5% of population.
63  * These 2 values should be added to jpoffice memory for parameterization!!
64  */
65  constructor_firm_size = (int) (nhouseholds * 0.075 / ncfirms);
66  employment_size = (int) (nhouseholds * 0.95);
67 
68  if (PRINT_DEBUG_MODE) {
69  printf("nRFirms: %d nCFirms: %d, nHH: %d\n", nrfirms, ncfirms, nhouseholds);
70  printf("nCFirm Size: %d, nEmployment: %d\n", constructor_firm_size, employment_size);
71  }
72 
73  /* Each constructor is assigned one employee */
74  for (i = 0; i < ncfirms; i++) {
75  if (nemployed > employment_size) {
76  if (WARNING_MODE) {
77  printf("Warning @jpoffice_init_employment(): There are more constructor firms then employable number of households.\n");
78  }
79  free_int_array(&household_list);
80  free_int_array(&regular_firm_list);
81  free_int_array(&constructor_firm_list);
82  return 0;
83  }
84  firm_id = constructor_firm_list.array[i];
85  household_id = household_list.array[0];
86  /* The employee is a manager. */
87  add_jpoffice_household_employer_message(household_id, firm_id, 1);
88  add_jpoffice_firm_employee_message(firm_id, household_id, 1);
89  remove_int(&household_list, 0);
90  nemployed++;
91  }
92 
93  /* Each regular firm is assigned one employee */
94  for (i = 0; i < nrfirms; i++) {
95  if (nemployed > employment_size) {
96  if (WARNING_MODE) {
97  printf("Warning @jpoffice_init_employment(): There are more firms then employable number of households.\n");
98  }
99  free_int_array(&household_list);
100  free_int_array(&regular_firm_list);
101  free_int_array(&constructor_firm_list);
102  return 0;
103  }
104  firm_id = regular_firm_list.array[i];
105  household_id = household_list.array[0];
106  /* The employee is a manager. */
107  add_jpoffice_household_employer_message(household_id, firm_id, 1);
108  add_jpoffice_firm_employee_message(firm_id, household_id, 1);
109  remove_int(&household_list, 0);
110  nemployed++;
111  }
112 
113  /* Each constructor is assigned additional constant employees */
114  for (i = 0; i < ncfirms; i++) {
115  firm_id = constructor_firm_list.array[0];
116  for (j = 1; j < constructor_firm_size; j++) {
117  if (nemployed > employment_size) {
118  if (WARNING_MODE) {
119  printf("Warning @jpoffice_init_employment(): Household shortage is observed at assigning additional labour to constructor firms.\n");
120  }
121  free_int_array(&household_list);
122  free_int_array(&regular_firm_list);
123  free_int_array(&constructor_firm_list);
124  return 0;
125  }
126  household_id = household_list.array[0];
127  add_jpoffice_household_employer_message(household_id, firm_id,0);
128  add_jpoffice_firm_employee_message(firm_id, household_id, 0);
129  remove_int(&household_list, 0);
130  nemployed++;
131  }
132  remove_int(&constructor_firm_list, 0);
133  }
134 
135  /* Rest of households are assigned to firms randomly.
136  * If a normal or a scale-free distribution for firm size to be opted,
137  * it should be implemented hereby.
138  */
139  do {
140  if (nemployed > employment_size){
141  break;
142  }
143  j = nrfirms - 1;
144  i = random_int(0, j);
145  firm_id = regular_firm_list.array[i];
146  household_id = household_list.array[0];
147  add_jpoffice_household_employer_message(household_id, firm_id,0);
148  add_jpoffice_firm_employee_message(firm_id, household_id, 0);
149  remove_int(&household_list, 0);
150  nemployed++;
151  } while (1);
152 
153  if (PRINT_DEBUG_MODE) {
154  printf("Number of total employement %d\n", nemployed);
155  }
156 
157  /* Finish */
158  free_int_array(&household_list);
159  free_int_array(&regular_firm_list);
160  free_int_array(&constructor_firm_list);
161 
162  return 0; /* Returning zero means the agent is not removed */
163 }
164 
165 /*
166  * \fn: int jpoffice_iterate()
167  * \brief:
168  */
170 {
171  IT_NO++;
172  return 0; /* Returning zero means the agent is not removed */
173 }
174