15 char arraydata[100000];
17 while(buffer[(*j)] !=
'{')
19 if(buffer[(*j)] !=
' ')
return -1;
20 else if(buffer[(*j)] ==
'\0')
return -1;
25 while(buffer[(*j)] !=
'}')
28 while(buffer[(*j)] !=
',' && buffer[(*j)] !=
'}')
30 if(buffer[(*j)] ==
'\0')
return -1;
31 arraydata[array_k] = buffer[(*j)];
35 arraydata[array_k] =
'\0';
36 if (arraycount < size) int_static_array[arraycount] = atoi(arraydata);
38 if(buffer[(*j)] !=
'}') (*j)++;
41 if (arraycount > size)
43 fprintf(stderr,
"WARNING: %d 'int' values provided for static array of size %d. Surplus values ignored.\n",
58 char arraydata[100000];
60 while(buffer[(*j)] !=
'{')
62 if(buffer[(*j)] !=
' ')
return -1;
63 else if(buffer[(*j)] ==
'\0')
return -1;
68 while(buffer[(*j)] !=
'}')
71 while(buffer[(*j)] !=
',' && buffer[(*j)] !=
'}')
73 if(buffer[(*j)] ==
'\0')
return -1;
74 arraydata[array_k] = buffer[(*j)];
78 arraydata[array_k] =
'\0';
79 if (arraycount < size) float_static_array[arraycount] = (float)atof(arraydata);
81 if(buffer[(*j)] !=
'}') (*j)++;
84 if (arraycount > size)
86 fprintf(stderr,
"WARNING: %d 'float' values provided for static array of size %d. Surplus values ignored.\n",
101 char arraydata[100000];
103 while(buffer[(*j)] !=
'{')
105 if(buffer[(*j)] !=
' ')
return -1;
106 else if(buffer[(*j)] ==
'\0')
return -1;
111 while(buffer[(*j)] !=
'}')
114 while(buffer[(*j)] !=
',' && buffer[(*j)] !=
'}')
116 if(buffer[(*j)] ==
'\0')
return -1;
117 arraydata[array_k] = buffer[(*j)];
121 arraydata[array_k] =
'\0';
122 if (arraycount < size) double_static_array[arraycount] = atof(arraydata);
124 if(buffer[(*j)] !=
'}') (*j)++;
127 if (arraycount > size)
129 fprintf(stderr,
"WARNING: %d 'double' values provided for static array of size %d. Surplus values ignored.\n",
144 while(buffer[(*j)] ==
' ')
149 for(arraycount = 0; arraycount < size; arraycount++)
151 char_static_array[arraycount] = buffer[(*j)];
166 char arraydata[100000];
168 while(buffer[(*j)] !=
'{')
170 if(buffer[(*j)] !=
' ')
return -1;
171 else if(buffer[(*j)] ==
'\0')
return -1;
176 while(buffer[(*j)] !=
'}')
179 while(buffer[(*j)] !=
',' && buffer[(*j)] !=
'}')
181 if(buffer[(*j)] ==
'\0')
return -1;
182 arraydata[array_k] = buffer[(*j)];
186 arraydata[array_k] =
'\0';
187 add_int(int_dynamic_array, atoi(arraydata));
189 if(buffer[(*j)] !=
'}') (*j)++;
203 char arraydata[100000];
205 while(buffer[(*j)] !=
'{')
207 if(buffer[(*j)] !=
' ')
return -1;
208 else if(buffer[(*j)] ==
'\0')
return -1;
213 while(buffer[(*j)] !=
'}')
216 while(buffer[(*j)] !=
',' && buffer[(*j)] !=
'}')
218 if(buffer[(*j)] ==
'\0')
return -1;
219 arraydata[array_k] = buffer[(*j)];
223 arraydata[array_k] =
'\0';
224 add_float(float_dynamic_array, (
float)atof(arraydata));
226 if(buffer[(*j)] !=
'}') (*j)++;
240 char arraydata[100000];
242 while(buffer[(*j)] !=
'{')
244 if(buffer[(*j)] !=
' ')
return -1;
245 else if(buffer[(*j)] ==
'\0')
return -1;
250 while(buffer[(*j)] !=
'}')
253 while(buffer[(*j)] !=
',' && buffer[(*j)] !=
'}')
255 if(buffer[(*j)] ==
'\0')
return -1;
256 arraydata[array_k] = buffer[(*j)];
260 arraydata[array_k] =
'\0';
261 add_double(double_dynamic_array, atof(arraydata));
263 if(buffer[(*j)] !=
'}') (*j)++;
275 if(*j > buffer_size)
return -1;
277 while(buffer[(*j)] ==
' ')
282 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
',' && buffer[(*j)] !=
'}')
284 add_char(char_dynamic_array, buffer[(*j)]);
298 char arraydata[100000];
301 while(buffer[(*j)] !=
'{')
303 if(buffer[(*j)] !=
' ')
return -1;
304 else if(buffer[(*j)] ==
'\0')
return -1;
309 (*temp_datatype).quantity = 0;
311 while(buffer[*j] !=
',')
313 if(buffer[(*j)] ==
'\0')
return -1;
314 arraydata[array_k] = buffer[*j];
318 arraydata[array_k] =
'\0';
319 (*temp_datatype).quantity = atoi(arraydata);
321 (*temp_datatype).avg_price = 0.0;
323 while(buffer[*j] !=
'}')
325 if(buffer[(*j)] ==
'\0')
return -1;
326 arraydata[array_k] = buffer[*j];
330 arraydata[array_k] =
'\0';
331 (*temp_datatype).avg_price = atof(arraydata);
345 while(buffer[(*j)] !=
'{')
347 if(buffer[(*j)] !=
' ')
return -1;
348 else if(buffer[(*j)] ==
'\0')
return -1;
353 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
355 if(buffer[(*j)] ==
'{')
358 rc =
read_transaction(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
359 if(rc != 0) { printf(
"Error: reading variable 'transaction' of type '\n");
return -1; }
363 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
376 while(buffer[(*j)] !=
'{')
378 if(buffer[(*j)] !=
' ')
return -1;
379 else if(buffer[(*j)] ==
'\0')
return -1;
384 for(arraycount = 0; arraycount < size; arraycount++)
386 rc =
read_transaction(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
387 if(rc != 0) { printf(
"Error: reading variable 'transaction' of type '\n");
return -1; }
388 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
401 char arraydata[100000];
404 while(buffer[(*j)] !=
'{')
406 if(buffer[(*j)] !=
' ')
return -1;
407 else if(buffer[(*j)] ==
'\0')
return -1;
412 (*temp_datatype).id = 0;
414 while(buffer[*j] !=
',')
416 if(buffer[(*j)] ==
'\0')
return -1;
417 arraydata[array_k] = buffer[*j];
421 arraydata[array_k] =
'\0';
422 (*temp_datatype).id = atoi(arraydata);
424 (*temp_datatype).budget = 0.0;
426 while(buffer[*j] !=
'}')
428 if(buffer[(*j)] ==
'\0')
return -1;
429 arraydata[array_k] = buffer[*j];
433 arraydata[array_k] =
'\0';
434 (*temp_datatype).budget = atof(arraydata);
448 while(buffer[(*j)] !=
'{')
450 if(buffer[(*j)] !=
' ')
return -1;
451 else if(buffer[(*j)] ==
'\0')
return -1;
456 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
458 if(buffer[(*j)] ==
'{')
461 rc =
read_buyer(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
462 if(rc != 0) { printf(
"Error: reading variable 'buyer' of type '\n");
return -1; }
466 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
479 while(buffer[(*j)] !=
'{')
481 if(buffer[(*j)] !=
' ')
return -1;
482 else if(buffer[(*j)] ==
'\0')
return -1;
487 for(arraycount = 0; arraycount < size; arraycount++)
489 rc =
read_buyer(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
490 if(rc != 0) { printf(
"Error: reading variable 'buyer' of type '\n");
return -1; }
491 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
504 char arraydata[100000];
507 while(buffer[(*j)] !=
'{')
509 if(buffer[(*j)] !=
' ')
return -1;
510 else if(buffer[(*j)] ==
'\0')
return -1;
515 (*temp_datatype).id = 0;
517 while(buffer[*j] !=
',')
519 if(buffer[(*j)] ==
'\0')
return -1;
520 arraydata[array_k] = buffer[*j];
524 arraydata[array_k] =
'\0';
525 (*temp_datatype).id = atoi(arraydata);
527 (*temp_datatype).price = 0.0;
529 while(buffer[*j] !=
',')
531 if(buffer[(*j)] ==
'\0')
return -1;
532 arraydata[array_k] = buffer[*j];
536 arraydata[array_k] =
'\0';
537 (*temp_datatype).price = atof(arraydata);
539 (*temp_datatype).inventory = 0;
541 while(buffer[*j] !=
',')
543 if(buffer[(*j)] ==
'\0')
return -1;
544 arraydata[array_k] = buffer[*j];
548 arraydata[array_k] =
'\0';
549 (*temp_datatype).inventory = atoi(arraydata);
551 (*temp_datatype).inv_price = 0.0;
553 while(buffer[*j] !=
'}')
555 if(buffer[(*j)] ==
'\0')
return -1;
556 arraydata[array_k] = buffer[*j];
560 arraydata[array_k] =
'\0';
561 (*temp_datatype).inv_price = atof(arraydata);
577 while(buffer[(*j)] !=
'{')
579 if(buffer[(*j)] !=
' ')
return -1;
580 else if(buffer[(*j)] ==
'\0')
return -1;
585 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
587 if(buffer[(*j)] ==
'{')
589 add_seller(temp_datatype_array, 0, 0.0, 0, 0.0);
590 rc =
read_seller(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
591 if(rc != 0) { printf(
"Error: reading variable 'seller' of type '\n");
return -1; }
595 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
608 while(buffer[(*j)] !=
'{')
610 if(buffer[(*j)] !=
' ')
return -1;
611 else if(buffer[(*j)] ==
'\0')
return -1;
616 for(arraycount = 0; arraycount < size; arraycount++)
618 rc =
read_seller(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
619 if(rc != 0) { printf(
"Error: reading variable 'seller' of type '\n");
return -1; }
620 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
633 char arraydata[100000];
636 while(buffer[(*j)] !=
'{')
638 if(buffer[(*j)] !=
' ')
return -1;
639 else if(buffer[(*j)] ==
'\0')
return -1;
644 (*temp_datatype).id = 0;
646 while(buffer[*j] !=
',')
648 if(buffer[(*j)] ==
'\0')
return -1;
649 arraydata[array_k] = buffer[*j];
653 arraydata[array_k] =
'\0';
654 (*temp_datatype).id = atoi(arraydata);
656 (*temp_datatype).wage = 0.0;
658 while(buffer[*j] !=
'}')
660 if(buffer[(*j)] ==
'\0')
return -1;
661 arraydata[array_k] = buffer[*j];
665 arraydata[array_k] =
'\0';
666 (*temp_datatype).wage = atof(arraydata);
680 while(buffer[(*j)] !=
'{')
682 if(buffer[(*j)] !=
' ')
return -1;
683 else if(buffer[(*j)] ==
'\0')
return -1;
688 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
690 if(buffer[(*j)] ==
'{')
693 rc =
read_vacancy(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
694 if(rc != 0) { printf(
"Error: reading variable 'vacancy' of type '\n");
return -1; }
698 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
711 while(buffer[(*j)] !=
'{')
713 if(buffer[(*j)] !=
' ')
return -1;
714 else if(buffer[(*j)] ==
'\0')
return -1;
719 for(arraycount = 0; arraycount < size; arraycount++)
721 rc =
read_vacancy(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
722 if(rc != 0) { printf(
"Error: reading variable 'vacancy' of type '\n");
return -1; }
723 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
736 char arraydata[100000];
739 while(buffer[(*j)] !=
'{')
741 if(buffer[(*j)] !=
' ')
return -1;
742 else if(buffer[(*j)] ==
'\0')
return -1;
747 (*temp_datatype).id = 0;
749 while(buffer[*j] !=
',')
751 if(buffer[(*j)] ==
'\0')
return -1;
752 arraydata[array_k] = buffer[*j];
756 arraydata[array_k] =
'\0';
757 (*temp_datatype).id = atoi(arraydata);
759 (*temp_datatype).wage = 0.0;
761 while(buffer[*j] !=
'}')
763 if(buffer[(*j)] ==
'\0')
return -1;
764 arraydata[array_k] = buffer[*j];
768 arraydata[array_k] =
'\0';
769 (*temp_datatype).wage = atof(arraydata);
783 while(buffer[(*j)] !=
'{')
785 if(buffer[(*j)] !=
' ')
return -1;
786 else if(buffer[(*j)] ==
'\0')
return -1;
791 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
793 if(buffer[(*j)] ==
'{')
796 rc =
read_employee(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
797 if(rc != 0) { printf(
"Error: reading variable 'employee' of type '\n");
return -1; }
801 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
814 while(buffer[(*j)] !=
'{')
816 if(buffer[(*j)] !=
' ')
return -1;
817 else if(buffer[(*j)] ==
'\0')
return -1;
822 for(arraycount = 0; arraycount < size; arraycount++)
824 rc =
read_employee(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
825 if(rc != 0) { printf(
"Error: reading variable 'employee' of type '\n");
return -1; }
826 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
839 char arraydata[100000];
842 while(buffer[(*j)] !=
'{')
844 if(buffer[(*j)] !=
' ')
return -1;
845 else if(buffer[(*j)] ==
'\0')
return -1;
850 (*temp_datatype).bank_id = 0;
852 while(buffer[*j] !=
',')
854 if(buffer[(*j)] ==
'\0')
return -1;
855 arraydata[array_k] = buffer[*j];
859 arraydata[array_k] =
'\0';
860 (*temp_datatype).bank_id = atoi(arraydata);
862 (*temp_datatype).principal = 0.0;
864 while(buffer[*j] !=
',')
866 if(buffer[(*j)] ==
'\0')
return -1;
867 arraydata[array_k] = buffer[*j];
871 arraydata[array_k] =
'\0';
872 (*temp_datatype).principal = atof(arraydata);
874 (*temp_datatype).quarters_left = 0;
876 while(buffer[*j] !=
',')
878 if(buffer[(*j)] ==
'\0')
return -1;
879 arraydata[array_k] = buffer[*j];
883 arraydata[array_k] =
'\0';
884 (*temp_datatype).quarters_left = atoi(arraydata);
886 (*temp_datatype).quarterly_interest = 0.0;
888 while(buffer[*j] !=
',')
890 if(buffer[(*j)] ==
'\0')
return -1;
891 arraydata[array_k] = buffer[*j];
895 arraydata[array_k] =
'\0';
896 (*temp_datatype).quarterly_interest = atof(arraydata);
898 (*temp_datatype).quarterly_principal = 0.0;
900 while(buffer[*j] !=
',')
902 if(buffer[(*j)] ==
'\0')
return -1;
903 arraydata[array_k] = buffer[*j];
907 arraydata[array_k] =
'\0';
908 (*temp_datatype).quarterly_principal = atof(arraydata);
910 (*temp_datatype).interestrate = 0.0;
912 while(buffer[*j] !=
',')
914 if(buffer[(*j)] ==
'\0')
return -1;
915 arraydata[array_k] = buffer[*j];
919 arraydata[array_k] =
'\0';
920 (*temp_datatype).interestrate = atof(arraydata);
922 (*temp_datatype).mtype = 0;
924 while(buffer[*j] !=
'}')
926 if(buffer[(*j)] ==
'\0')
return -1;
927 arraydata[array_k] = buffer[*j];
931 arraydata[array_k] =
'\0';
932 (*temp_datatype).mtype = atoi(arraydata);
951 while(buffer[(*j)] !=
'{')
953 if(buffer[(*j)] !=
' ')
return -1;
954 else if(buffer[(*j)] ==
'\0')
return -1;
959 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
961 if(buffer[(*j)] ==
'{')
963 add_mortgage(temp_datatype_array, 0, 0.0, 0, 0.0, 0.0, 0.0, 0);
964 rc =
read_mortgage(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
965 if(rc != 0) { printf(
"Error: reading variable 'mortgage' of type '\n");
return -1; }
969 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
982 while(buffer[(*j)] !=
'{')
984 if(buffer[(*j)] !=
' ')
return -1;
985 else if(buffer[(*j)] ==
'\0')
return -1;
990 for(arraycount = 0; arraycount < size; arraycount++)
992 rc =
read_mortgage(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
993 if(rc != 0) { printf(
"Error: reading variable 'mortgage' of type '\n");
return -1; }
994 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
1007 char arraydata[100000];
1010 while(buffer[(*j)] !=
'{')
1012 if(buffer[(*j)] !=
' ')
return -1;
1013 else if(buffer[(*j)] ==
'\0')
return -1;
1018 (*temp_datatype).bank_id = 0;
1020 while(buffer[*j] !=
',')
1022 if(buffer[(*j)] ==
'\0')
return -1;
1023 arraydata[array_k] = buffer[*j];
1027 arraydata[array_k] =
'\0';
1028 (*temp_datatype).bank_id = atoi(arraydata);
1030 (*temp_datatype).amount = 0.0;
1032 while(buffer[*j] !=
',')
1034 if(buffer[(*j)] ==
'\0')
return -1;
1035 arraydata[array_k] = buffer[*j];
1039 arraydata[array_k] =
'\0';
1040 (*temp_datatype).amount = atof(arraydata);
1042 (*temp_datatype).to_be_paid = 0.0;
1044 while(buffer[*j] !=
'}')
1046 if(buffer[(*j)] ==
'\0')
return -1;
1047 arraydata[array_k] = buffer[*j];
1051 arraydata[array_k] =
'\0';
1052 (*temp_datatype).to_be_paid = atof(arraydata);
1067 while(buffer[(*j)] !=
'{')
1069 if(buffer[(*j)] !=
' ')
return -1;
1070 else if(buffer[(*j)] ==
'\0')
return -1;
1075 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
1077 if(buffer[(*j)] ==
'{')
1079 add_loan(temp_datatype_array, 0, 0.0, 0.0);
1080 rc =
read_loan(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
1081 if(rc != 0) { printf(
"Error: reading variable 'loan' of type '\n");
return -1; }
1085 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
1098 while(buffer[(*j)] !=
'{')
1100 if(buffer[(*j)] !=
' ')
return -1;
1101 else if(buffer[(*j)] ==
'\0')
return -1;
1106 for(arraycount = 0; arraycount < size; arraycount++)
1108 rc =
read_loan(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
1109 if(rc != 0) { printf(
"Error: reading variable 'loan' of type '\n");
return -1; }
1110 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
1123 char arraydata[100000];
1126 while(buffer[(*j)] !=
'{')
1128 if(buffer[(*j)] !=
' ')
return -1;
1129 else if(buffer[(*j)] ==
'\0')
return -1;
1134 (*temp_datatype).buyer_id = 0;
1136 while(buffer[*j] !=
',')
1138 if(buffer[(*j)] ==
'\0')
return -1;
1139 arraydata[array_k] = buffer[*j];
1143 arraydata[array_k] =
'\0';
1144 (*temp_datatype).buyer_id = atoi(arraydata);
1146 (*temp_datatype).bank_id = 0;
1148 while(buffer[*j] !=
',')
1150 if(buffer[(*j)] ==
'\0')
return -1;
1151 arraydata[array_k] = buffer[*j];
1155 arraydata[array_k] =
'\0';
1156 (*temp_datatype).bank_id = atoi(arraydata);
1158 (*temp_datatype).liquidity = 0.0;
1160 while(buffer[*j] !=
',')
1162 if(buffer[(*j)] ==
'\0')
return -1;
1163 arraydata[array_k] = buffer[*j];
1167 arraydata[array_k] =
'\0';
1168 (*temp_datatype).liquidity = atof(arraydata);
1170 (*temp_datatype).quarterly_income = 0.0;
1172 while(buffer[*j] !=
',')
1174 if(buffer[(*j)] ==
'\0')
return -1;
1175 arraydata[array_k] = buffer[*j];
1179 arraydata[array_k] =
'\0';
1180 (*temp_datatype).quarterly_income = atof(arraydata);
1182 (*temp_datatype).quarterly_mortgage_paid = 0.0;
1184 while(buffer[*j] !=
',')
1186 if(buffer[(*j)] ==
'\0')
return -1;
1187 arraydata[array_k] = buffer[*j];
1191 arraydata[array_k] =
'\0';
1192 (*temp_datatype).quarterly_mortgage_paid = atof(arraydata);
1194 (*temp_datatype).choice = 0;
1196 while(buffer[*j] !=
'}')
1198 if(buffer[(*j)] ==
'\0')
return -1;
1199 arraydata[array_k] = buffer[*j];
1203 arraydata[array_k] =
'\0';
1204 (*temp_datatype).choice = atoi(arraydata);
1222 while(buffer[(*j)] !=
'{')
1224 if(buffer[(*j)] !=
' ')
return -1;
1225 else if(buffer[(*j)] ==
'\0')
return -1;
1230 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
1232 if(buffer[(*j)] ==
'{')
1234 add_hbuyer(temp_datatype_array, 0, 0, 0.0, 0.0, 0.0, 0);
1235 rc =
read_hbuyer(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
1236 if(rc != 0) { printf(
"Error: reading variable 'hbuyer' of type '\n");
return -1; }
1240 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
1253 while(buffer[(*j)] !=
'{')
1255 if(buffer[(*j)] !=
' ')
return -1;
1256 else if(buffer[(*j)] ==
'\0')
return -1;
1261 for(arraycount = 0; arraycount < size; arraycount++)
1263 rc =
read_hbuyer(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
1264 if(rc != 0) { printf(
"Error: reading variable 'hbuyer' of type '\n");
return -1; }
1265 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
1278 char arraydata[100000];
1281 while(buffer[(*j)] !=
'{')
1283 if(buffer[(*j)] !=
' ')
return -1;
1284 else if(buffer[(*j)] ==
'\0')
return -1;
1289 (*temp_datatype).seller_id = 0;
1291 while(buffer[*j] !=
',')
1293 if(buffer[(*j)] ==
'\0')
return -1;
1294 arraydata[array_k] = buffer[*j];
1298 arraydata[array_k] =
'\0';
1299 (*temp_datatype).seller_id = atoi(arraydata);
1301 (*temp_datatype).price = 0.0;
1303 while(buffer[*j] !=
',')
1305 if(buffer[(*j)] ==
'\0')
return -1;
1306 arraydata[array_k] = buffer[*j];
1310 arraydata[array_k] =
'\0';
1311 (*temp_datatype).price = atof(arraydata);
1313 (*temp_datatype).quantity = 0;
1315 while(buffer[*j] !=
',')
1317 if(buffer[(*j)] ==
'\0')
return -1;
1318 arraydata[array_k] = buffer[*j];
1322 arraydata[array_k] =
'\0';
1323 (*temp_datatype).quantity = atoi(arraydata);
1325 (*temp_datatype).type = 0;
1327 while(buffer[*j] !=
'}')
1329 if(buffer[(*j)] ==
'\0')
return -1;
1330 arraydata[array_k] = buffer[*j];
1334 arraydata[array_k] =
'\0';
1335 (*temp_datatype).type = atoi(arraydata);
1351 while(buffer[(*j)] !=
'{')
1353 if(buffer[(*j)] !=
' ')
return -1;
1354 else if(buffer[(*j)] ==
'\0')
return -1;
1359 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
1361 if(buffer[(*j)] ==
'{')
1364 rc =
read_hseller(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
1365 if(rc != 0) { printf(
"Error: reading variable 'hseller' of type '\n");
return -1; }
1369 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
1382 while(buffer[(*j)] !=
'{')
1384 if(buffer[(*j)] !=
' ')
return -1;
1385 else if(buffer[(*j)] ==
'\0')
return -1;
1390 for(arraycount = 0; arraycount < size; arraycount++)
1392 rc =
read_hseller(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
1393 if(rc != 0) { printf(
"Error: reading variable 'hseller' of type '\n");
return -1; }
1394 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
1407 char arraydata[100000];
1410 while(buffer[(*j)] !=
'{')
1412 if(buffer[(*j)] !=
' ')
return -1;
1413 else if(buffer[(*j)] ==
'\0')
return -1;
1418 (*temp_datatype).id = 0;
1420 while(buffer[*j] !=
',')
1422 if(buffer[(*j)] ==
'\0')
return -1;
1423 arraydata[array_k] = buffer[*j];
1427 arraydata[array_k] =
'\0';
1428 (*temp_datatype).id = atoi(arraydata);
1430 (*temp_datatype).equity = 0.0;
1432 while(buffer[*j] !=
',')
1434 if(buffer[(*j)] ==
'\0')
return -1;
1435 arraydata[array_k] = buffer[*j];
1439 arraydata[array_k] =
'\0';
1440 (*temp_datatype).equity = atof(arraydata);
1442 (*temp_datatype).risky_assets = 0.0;
1444 while(buffer[*j] !=
',')
1446 if(buffer[(*j)] ==
'\0')
return -1;
1447 arraydata[array_k] = buffer[*j];
1451 arraydata[array_k] =
'\0';
1452 (*temp_datatype).risky_assets = atof(arraydata);
1454 (*temp_datatype).amount_mortgaged = 0.0;
1456 while(buffer[*j] !=
'}')
1458 if(buffer[(*j)] ==
'\0')
return -1;
1459 arraydata[array_k] = buffer[*j];
1463 arraydata[array_k] =
'\0';
1464 (*temp_datatype).amount_mortgaged = atof(arraydata);
1480 while(buffer[(*j)] !=
'{')
1482 if(buffer[(*j)] !=
' ')
return -1;
1483 else if(buffer[(*j)] ==
'\0')
return -1;
1488 while(buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'}')
1490 if(buffer[(*j)] ==
'{')
1492 add_hbank(temp_datatype_array, 0, 0.0, 0.0, 0.0);
1493 rc =
read_hbank(buffer, buffer_size, j, &(*temp_datatype_array).array[arraycount]);
1494 if(rc != 0) { printf(
"Error: reading variable 'hbank' of type '\n");
return -1; }
1498 while(buffer[(*j)] !=
'}' && buffer[(*j)] !=
'\0' && buffer[(*j)] !=
'{') { (*j)++; }
1511 while(buffer[(*j)] !=
'{')
1513 if(buffer[(*j)] !=
' ')
return -1;
1514 else if(buffer[(*j)] ==
'\0')
return -1;
1519 for(arraycount = 0; arraycount < size; arraycount++)
1521 rc =
read_hbank(buffer, buffer_size, j, &temp_datatype_array[arraycount]);
1522 if(rc != 0) { printf(
"Error: reading variable 'hbank' of type '\n");
return -1; }
1523 if(arraycount < (size-1))
while(buffer[(*j)] !=
'{') { (*j)++; }
1536 char buffer[100000];
1538 int in_environment = 0;
1539 int in_resume_mode = 0;
1540 int in_print_debug_mode = 0;
1541 int in_warning_mode = 0;
1542 int in_data_collection_mode = 0;
1543 int in_collect_household_data = 0;
1544 int in_collect_firm_data = 0;
1545 int in_ratio_liquidity = 0;
1546 int in_consumption_adjustment_speed = 0;
1547 int in_wealth_effect = 0;
1548 int in_turnover_probability = 0;
1549 int in_production_markup = 0;
1550 int in_price_markup = 0;
1551 int in_firm_memory_persistance = 0;
1552 int in_ratio_fiscal_policy = 0;
1553 int in_ratio_capitalist_households = 0;
1554 int in_inflation_target = 0;
1555 int in_firms_minimum_equity_ratio = 0;
1556 int in_firm_startup_leverage = 0;
1557 int in_household_startup_leverage = 0;
1558 int in_car_buffer_threshold = 0;
1559 int in_housing_market_entrance_prob = 0;
1560 int in_fire_sale_threshold = 0;
1561 int in_household_budget_constraint = 0;
1562 int in_capital_adequecy_ratio = 0;
1563 int in_housing_price_up_rate = 0;
1564 int in_housing_price_down_rate = 0;
1565 int in_household_mortgage_writeoff_high = 0;
1566 int in_household_mortgage_writeoff_low = 0;
1572 if((file = fopen(location,
"r"))==NULL)
1574 printf(
"Error: cannot open import xml file '%s'\n", location);
1577 printf(
"Reading environment data from: %s\n", location);
1579 while(c != (
char)EOF)
1582 c = (char)fgetc(file);
1585 buffer[index] =
'\0';
1586 if(strcmp(buffer,
"environment") == 0) in_environment = 1;
1587 if(strcmp(buffer,
"/environment") == 0) in_environment = 0;
1588 if(strcmp(buffer,
"resume_mode") == 0) in_resume_mode = 1;
1589 if(strcmp(buffer,
"/resume_mode") == 0) in_resume_mode = 0;
1590 if(strcmp(buffer,
"print_debug_mode") == 0) in_print_debug_mode = 1;
1591 if(strcmp(buffer,
"/print_debug_mode") == 0) in_print_debug_mode = 0;
1592 if(strcmp(buffer,
"warning_mode") == 0) in_warning_mode = 1;
1593 if(strcmp(buffer,
"/warning_mode") == 0) in_warning_mode = 0;
1594 if(strcmp(buffer,
"data_collection_mode") == 0) in_data_collection_mode = 1;
1595 if(strcmp(buffer,
"/data_collection_mode") == 0) in_data_collection_mode = 0;
1596 if(strcmp(buffer,
"collect_household_data") == 0) in_collect_household_data = 1;
1597 if(strcmp(buffer,
"/collect_household_data") == 0) in_collect_household_data = 0;
1598 if(strcmp(buffer,
"collect_firm_data") == 0) in_collect_firm_data = 1;
1599 if(strcmp(buffer,
"/collect_firm_data") == 0) in_collect_firm_data = 0;
1600 if(strcmp(buffer,
"ratio_liquidity") == 0) in_ratio_liquidity = 1;
1601 if(strcmp(buffer,
"/ratio_liquidity") == 0) in_ratio_liquidity = 0;
1602 if(strcmp(buffer,
"consumption_adjustment_speed") == 0) in_consumption_adjustment_speed = 1;
1603 if(strcmp(buffer,
"/consumption_adjustment_speed") == 0) in_consumption_adjustment_speed = 0;
1604 if(strcmp(buffer,
"wealth_effect") == 0) in_wealth_effect = 1;
1605 if(strcmp(buffer,
"/wealth_effect") == 0) in_wealth_effect = 0;
1606 if(strcmp(buffer,
"turnover_probability") == 0) in_turnover_probability = 1;
1607 if(strcmp(buffer,
"/turnover_probability") == 0) in_turnover_probability = 0;
1608 if(strcmp(buffer,
"production_markup") == 0) in_production_markup = 1;
1609 if(strcmp(buffer,
"/production_markup") == 0) in_production_markup = 0;
1610 if(strcmp(buffer,
"price_markup") == 0) in_price_markup = 1;
1611 if(strcmp(buffer,
"/price_markup") == 0) in_price_markup = 0;
1612 if(strcmp(buffer,
"firm_memory_persistance") == 0) in_firm_memory_persistance = 1;
1613 if(strcmp(buffer,
"/firm_memory_persistance") == 0) in_firm_memory_persistance = 0;
1614 if(strcmp(buffer,
"ratio_fiscal_policy") == 0) in_ratio_fiscal_policy = 1;
1615 if(strcmp(buffer,
"/ratio_fiscal_policy") == 0) in_ratio_fiscal_policy = 0;
1616 if(strcmp(buffer,
"ratio_capitalist_households") == 0) in_ratio_capitalist_households = 1;
1617 if(strcmp(buffer,
"/ratio_capitalist_households") == 0) in_ratio_capitalist_households = 0;
1618 if(strcmp(buffer,
"inflation_target") == 0) in_inflation_target = 1;
1619 if(strcmp(buffer,
"/inflation_target") == 0) in_inflation_target = 0;
1620 if(strcmp(buffer,
"firms_minimum_equity_ratio") == 0) in_firms_minimum_equity_ratio = 1;
1621 if(strcmp(buffer,
"/firms_minimum_equity_ratio") == 0) in_firms_minimum_equity_ratio = 0;
1622 if(strcmp(buffer,
"firm_startup_leverage") == 0) in_firm_startup_leverage = 1;
1623 if(strcmp(buffer,
"/firm_startup_leverage") == 0) in_firm_startup_leverage = 0;
1624 if(strcmp(buffer,
"household_startup_leverage") == 0) in_household_startup_leverage = 1;
1625 if(strcmp(buffer,
"/household_startup_leverage") == 0) in_household_startup_leverage = 0;
1626 if(strcmp(buffer,
"car_buffer_threshold") == 0) in_car_buffer_threshold = 1;
1627 if(strcmp(buffer,
"/car_buffer_threshold") == 0) in_car_buffer_threshold = 0;
1628 if(strcmp(buffer,
"housing_market_entrance_prob") == 0) in_housing_market_entrance_prob = 1;
1629 if(strcmp(buffer,
"/housing_market_entrance_prob") == 0) in_housing_market_entrance_prob = 0;
1630 if(strcmp(buffer,
"fire_sale_threshold") == 0) in_fire_sale_threshold = 1;
1631 if(strcmp(buffer,
"/fire_sale_threshold") == 0) in_fire_sale_threshold = 0;
1632 if(strcmp(buffer,
"household_budget_constraint") == 0) in_household_budget_constraint = 1;
1633 if(strcmp(buffer,
"/household_budget_constraint") == 0) in_household_budget_constraint = 0;
1634 if(strcmp(buffer,
"capital_adequecy_ratio") == 0) in_capital_adequecy_ratio = 1;
1635 if(strcmp(buffer,
"/capital_adequecy_ratio") == 0) in_capital_adequecy_ratio = 0;
1636 if(strcmp(buffer,
"housing_price_up_rate") == 0) in_housing_price_up_rate = 1;
1637 if(strcmp(buffer,
"/housing_price_up_rate") == 0) in_housing_price_up_rate = 0;
1638 if(strcmp(buffer,
"housing_price_down_rate") == 0) in_housing_price_down_rate = 1;
1639 if(strcmp(buffer,
"/housing_price_down_rate") == 0) in_housing_price_down_rate = 0;
1640 if(strcmp(buffer,
"household_mortgage_writeoff_high") == 0) in_household_mortgage_writeoff_high = 1;
1641 if(strcmp(buffer,
"/household_mortgage_writeoff_high") == 0) in_household_mortgage_writeoff_high = 0;
1642 if(strcmp(buffer,
"household_mortgage_writeoff_low") == 0) in_household_mortgage_writeoff_low = 1;
1643 if(strcmp(buffer,
"/household_mortgage_writeoff_low") == 0) in_household_mortgage_writeoff_low = 0;
1646 buffer[index] =
'\0';
1650 buffer[index] =
'\0';
1651 if(in_environment == 1)
1684 buffer[index] =
'\0';
1689 if(index < 999) index++;
1699 double cloud_data[],
1700 int partition_method,
1702 int number_partitions,
1708 char buffer[100000];
1709 char agentname[10000];
1714 int FLAME_in_xagent = 0;
1715 int FLAME_in_name = 0;
1716 int in_firm_agent = 0;
1717 int in_household_agent = 0;
1718 int in_equityfund_agent = 0;
1719 int in_bank_agent = 0;
1720 int in_government_agent = 0;
1721 int in_centralbank_agent = 0;
1722 int in_jpoffice_agent = 0;
1723 int in_mall_agent = 0;
1724 int in_reagency_agent = 0;
1728 int in_isconstructor = 0;
1729 int in_day_of_month_to_act = 0;
1730 int in_isinsolvent = 0;
1732 int in_day_of_week_to_act = 0;
1733 int in_average_goods_price = 0;
1734 int in_employees = 0;
1736 int in_wage_offer = 0;
1737 int in_average_wage = 0;
1738 int in_no_employees = 0;
1739 int in_vacancies = 0;
1740 int in_employees_needed = 0;
1741 int in_day_of_month_wages_paid = 0;
1742 int in_labour_productivity = 0;
1743 int in_capital_productivity = 0;
1744 int in_capital_goods = 0;
1745 int in_capital_goods_price = 0;
1746 int in_production_current = 0;
1747 int in_expected_sales = 0;
1748 int in_production_plan = 0;
1749 int in_unit_goods_price = 0;
1750 int in_unit_cost = 0;
1751 int in_day_of_month_production_completed = 0;
1752 int in_unit_house_price = 0;
1753 int in_projects = 0;
1754 int in_loans_interest_rate = 0;
1756 int in_inventory = 0;
1758 int in_revenues = 0;
1759 int in_total_assets = 0;
1760 int in_operating_costs = 0;
1761 int in_labour_costs = 0;
1762 int in_total_interest_payments = 0;
1763 int in_dividends_paid = 0;
1764 int in_dividends_to_be_paid = 0;
1765 int in_retained_earnings = 0;
1766 int in_net_earnings = 0;
1769 int in_liquidity = 0;
1770 int in_isliquidshort = 0;
1772 int in_hasinvestment = 0;
1773 int in_isilliquid = 0;
1774 int in_planned_investment_costs = 0;
1775 int in_liquidity_need = 0;
1776 int in_loan_list = 0;
1777 int in_labour_tax_rate = 0;
1778 int in_delta_housing_price = 0;
1779 int in_weekly_consumption_budget = 0;
1780 int in_mall_budget = 0;
1781 int in_quarterly_price_change = 0;
1782 int in_my_employer_id = 0;
1784 int in_ismanager = 0;
1785 int in_government_benefits = 0;
1786 int in_day_of_month_wage_recieved = 0;
1787 int in_mortgages_interest_rate = 0;
1788 int in_mortgages_list = 0;
1789 int in_mortgages = 0;
1790 int in_housing_payment = 0;
1791 int in_housing_price = 0;
1792 int in_housing_units = 0;
1793 int in_n_shares = 0;
1794 int in_capital_income = 0;
1795 int in_previous_wages = 0;
1796 int in_previous_benefits = 0;
1797 int in_labour_income = 0;
1798 int in_housing_value = 0;
1799 int in_expected_housing_payment = 0;
1800 int in_hmarket_role = 0;
1801 int in_equity_ratio = 0;
1802 int in_minimum_equity_ratio = 0;
1803 int in_mortgage_costs = 0;
1804 int in_delta_housing_value = 0;
1805 int in_mortgage_choice = 0;
1806 int in_share_firms = 0;
1807 int in_share_construction_firms = 0;
1808 int in_share_banks = 0;
1809 int in_dividends_recieved = 0;
1810 int in_dividends_retained = 0;
1811 int in_firm_investment = 0;
1812 int in_capital_tax_rate = 0;
1814 int in_loans_start = 0;
1815 int in_deposits = 0;
1816 int in_centralbank_debt = 0;
1817 int in_total_writeoffs = 0;
1818 int in_interest_rate = 0;
1819 int in_interests_accrued = 0;
1820 int in_interests_paid = 0;
1821 int in_total_dividends = 0;
1822 int in_total_costs = 0;
1823 int in_unemployment_rate = 0;
1824 int in_population_size = 0;
1825 int in_labour_tax_income = 0;
1826 int in_capital_tax_income = 0;
1827 int in_gov_general_benefit_rate = 0;
1828 int in_gov_unemployment_rate = 0;
1829 int in_general_benefits = 0;
1830 int in_unemployment_benefits = 0;
1831 int in_earnings = 0;
1832 int in_centralbank_income = 0;
1833 int in_expenditures = 0;
1834 int in_inflation_rate = 0;
1835 int in_consumption_goods_prices = 0;
1837 int in_weekly_price_averages = 0;
1838 int in_loans_banks = 0;
1839 int in_loans_government = 0;
1840 int in_fiat_money = 0;
1841 int in_liquidity_banks = 0;
1842 int in_liquidity_government = 0;
1843 int in_liquidity_equityfund = 0;
1845 int in_goods_transactions = 0;
1846 int in_housing_transactions = 0;
1861 double posx=0.0, posy=0.0, posz=0.0;
1867 if(j == 0 && rc == 0) {}
1869 agentname[0] =
'\0';
1873 if((file = fopen(location,
"r"))==NULL)
1875 printf(
"Error: cannot open import xml file '%s'\n", location);
1878 printf(
"Reading agent data from: %s\n", location);
1880 while(c != (
char)EOF)
1883 c = (char)fgetc(file);
1886 buffer[index] =
'\0';
1887 if(strcmp(buffer,
"itno") == 0) in_itno = 1;
1888 if(strcmp(buffer,
"/itno") == 0) in_itno = 0;
1889 if(strcmp(buffer,
"xagent") == 0)
1891 FLAME_in_xagent = 1;
1892 agentname[0] =
'\0';
1894 if(strcmp(buffer,
"/xagent") == 0)
1896 if(strcmp(agentname,
"firm") == 0)
1898 if(current_firm_agent == NULL) { printf(
"Memory error reading firm agent\n"); exit(0); }
1912 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
1913 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
1914 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
1915 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
1916 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
1917 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
1921 if(partition_method == geometric)
1935 else if (partition_method == other)
1937 if (agent_count % number_partitions == 0)
1945 else if(strcmp(agentname,
"household") == 0)
1947 if(current_household_agent == NULL) { printf(
"Memory error reading household agent\n"); exit(0); }
1961 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
1962 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
1963 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
1964 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
1965 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
1966 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
1970 if(partition_method == geometric)
1984 else if (partition_method == other)
1986 if (agent_count % number_partitions == 0)
1994 else if(strcmp(agentname,
"equityfund") == 0)
1996 if(current_equityfund_agent == NULL) { printf(
"Memory error reading equityfund agent\n"); exit(0); }
2010 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
2011 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
2012 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
2013 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
2014 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
2015 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
2019 if(partition_method == geometric)
2033 else if (partition_method == other)
2035 if (agent_count % number_partitions == 0)
2043 else if(strcmp(agentname,
"bank") == 0)
2045 if(current_bank_agent == NULL) { printf(
"Memory error reading bank agent\n"); exit(0); }
2059 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
2060 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
2061 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
2062 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
2063 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
2064 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
2068 if(partition_method == geometric)
2082 else if (partition_method == other)
2084 if (agent_count % number_partitions == 0)
2092 else if(strcmp(agentname,
"government") == 0)
2094 if(current_government_agent == NULL) { printf(
"Memory error reading government agent\n"); exit(0); }
2108 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
2109 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
2110 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
2111 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
2112 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
2113 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
2117 if(partition_method == geometric)
2131 else if (partition_method == other)
2133 if (agent_count % number_partitions == 0)
2141 else if(strcmp(agentname,
"centralbank") == 0)
2143 if(current_centralbank_agent == NULL) { printf(
"Memory error reading centralbank agent\n"); exit(0); }
2157 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
2158 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
2159 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
2160 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
2161 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
2162 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
2166 if(partition_method == geometric)
2180 else if (partition_method == other)
2182 if (agent_count % number_partitions == 0)
2190 else if(strcmp(agentname,
"jpoffice") == 0)
2192 if(current_jpoffice_agent == NULL) { printf(
"Memory error reading jpoffice agent\n"); exit(0); }
2206 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
2207 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
2208 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
2209 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
2210 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
2211 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
2215 if(partition_method == geometric)
2229 else if (partition_method == other)
2231 if (agent_count % number_partitions == 0)
2239 else if(strcmp(agentname,
"mall") == 0)
2241 if(current_mall_agent == NULL) { printf(
"Memory error reading mall agent\n"); exit(0); }
2255 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
2256 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
2257 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
2258 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
2259 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
2260 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
2264 if(partition_method == geometric)
2278 else if (partition_method == other)
2280 if (agent_count % number_partitions == 0)
2288 else if(strcmp(agentname,
"reagency") == 0)
2290 if(current_reagency_agent == NULL) { printf(
"Memory error reading reagency agent\n"); exit(0); }
2304 if ( posx < cloud_data[0] ) cloud_data[0] = posx;
2305 if ( posx > cloud_data[1] ) cloud_data[1] = posx;
2306 if ( posy < cloud_data[2] ) cloud_data[2] = posy;
2307 if ( posy > cloud_data[3] ) cloud_data[3] = posy;
2308 if ( posz < cloud_data[2] ) cloud_data[4] = posz;
2309 if ( posz > cloud_data[3] ) cloud_data[5] = posz;
2313 if(partition_method == geometric)
2327 else if (partition_method == other)
2329 if (agent_count % number_partitions == 0)
2339 printf(
"Warning: agent name undefined - '%s'\n", agentname);
2342 agentname[0] =
'\0';
2343 FLAME_in_xagent = 0;
2345 in_household_agent = 0;
2346 in_equityfund_agent = 0;
2348 in_government_agent = 0;
2349 in_centralbank_agent = 0;
2350 in_jpoffice_agent = 0;
2352 in_reagency_agent = 0;
2355 if(strcmp(buffer,
"name") == 0) FLAME_in_name = 1;
2356 if(strcmp(buffer,
"/name") == 0) FLAME_in_name = 0;
2357 if(strcmp(buffer,
"id") == 0) { in_id = 1; }
2358 if(strcmp(buffer,
"/id") == 0) { in_id = 0; }
2359 if(strcmp(buffer,
"bank_id") == 0) { in_bank_id = 1; }
2360 if(strcmp(buffer,
"/bank_id") == 0) { in_bank_id = 0; }
2361 if(strcmp(buffer,
"isconstructor") == 0) { in_isconstructor = 1; }
2362 if(strcmp(buffer,
"/isconstructor") == 0) { in_isconstructor = 0; }
2363 if(strcmp(buffer,
"day_of_month_to_act") == 0) { in_day_of_month_to_act = 1; }
2364 if(strcmp(buffer,
"/day_of_month_to_act") == 0) { in_day_of_month_to_act = 0; }
2365 if(strcmp(buffer,
"isinsolvent") == 0) { in_isinsolvent = 1; }
2366 if(strcmp(buffer,
"/isinsolvent") == 0) { in_isinsolvent = 0; }
2367 if(strcmp(buffer,
"it_no") == 0) { in_it_no = 1; }
2368 if(strcmp(buffer,
"/it_no") == 0) { in_it_no = 0; }
2369 if(strcmp(buffer,
"day_of_week_to_act") == 0) { in_day_of_week_to_act = 1; }
2370 if(strcmp(buffer,
"/day_of_week_to_act") == 0) { in_day_of_week_to_act = 0; }
2371 if(strcmp(buffer,
"average_goods_price") == 0) { in_average_goods_price = 1; }
2372 if(strcmp(buffer,
"/average_goods_price") == 0) { in_average_goods_price = 0; }
2373 if(strcmp(buffer,
"employees") == 0) { in_employees = 1; }
2374 if(strcmp(buffer,
"/employees") == 0) { in_employees = 0; }
2375 if(strcmp(buffer,
"manager") == 0) { in_manager = 1; }
2376 if(strcmp(buffer,
"/manager") == 0) { in_manager = 0; }
2377 if(strcmp(buffer,
"wage_offer") == 0) { in_wage_offer = 1; }
2378 if(strcmp(buffer,
"/wage_offer") == 0) { in_wage_offer = 0; }
2379 if(strcmp(buffer,
"average_wage") == 0) { in_average_wage = 1; }
2380 if(strcmp(buffer,
"/average_wage") == 0) { in_average_wage = 0; }
2381 if(strcmp(buffer,
"no_employees") == 0) { in_no_employees = 1; }
2382 if(strcmp(buffer,
"/no_employees") == 0) { in_no_employees = 0; }
2383 if(strcmp(buffer,
"vacancies") == 0) { in_vacancies = 1; }
2384 if(strcmp(buffer,
"/vacancies") == 0) { in_vacancies = 0; }
2385 if(strcmp(buffer,
"employees_needed") == 0) { in_employees_needed = 1; }
2386 if(strcmp(buffer,
"/employees_needed") == 0) { in_employees_needed = 0; }
2387 if(strcmp(buffer,
"day_of_month_wages_paid") == 0) { in_day_of_month_wages_paid = 1; }
2388 if(strcmp(buffer,
"/day_of_month_wages_paid") == 0) { in_day_of_month_wages_paid = 0; }
2389 if(strcmp(buffer,
"labour_productivity") == 0) { in_labour_productivity = 1; }
2390 if(strcmp(buffer,
"/labour_productivity") == 0) { in_labour_productivity = 0; }
2391 if(strcmp(buffer,
"capital_productivity") == 0) { in_capital_productivity = 1; }
2392 if(strcmp(buffer,
"/capital_productivity") == 0) { in_capital_productivity = 0; }
2393 if(strcmp(buffer,
"capital_goods") == 0) { in_capital_goods = 1; }
2394 if(strcmp(buffer,
"/capital_goods") == 0) { in_capital_goods = 0; }
2395 if(strcmp(buffer,
"capital_goods_price") == 0) { in_capital_goods_price = 1; }
2396 if(strcmp(buffer,
"/capital_goods_price") == 0) { in_capital_goods_price = 0; }
2397 if(strcmp(buffer,
"production_current") == 0) { in_production_current = 1; }
2398 if(strcmp(buffer,
"/production_current") == 0) { in_production_current = 0; }
2399 if(strcmp(buffer,
"expected_sales") == 0) { in_expected_sales = 1; }
2400 if(strcmp(buffer,
"/expected_sales") == 0) { in_expected_sales = 0; }
2401 if(strcmp(buffer,
"production_plan") == 0) { in_production_plan = 1; }
2402 if(strcmp(buffer,
"/production_plan") == 0) { in_production_plan = 0; }
2403 if(strcmp(buffer,
"unit_goods_price") == 0) { in_unit_goods_price = 1; }
2404 if(strcmp(buffer,
"/unit_goods_price") == 0) { in_unit_goods_price = 0; }
2405 if(strcmp(buffer,
"unit_cost") == 0) { in_unit_cost = 1; }
2406 if(strcmp(buffer,
"/unit_cost") == 0) { in_unit_cost = 0; }
2407 if(strcmp(buffer,
"day_of_month_production_completed") == 0) { in_day_of_month_production_completed = 1; }
2408 if(strcmp(buffer,
"/day_of_month_production_completed") == 0) { in_day_of_month_production_completed = 0; }
2409 if(strcmp(buffer,
"unit_house_price") == 0) { in_unit_house_price = 1; }
2410 if(strcmp(buffer,
"/unit_house_price") == 0) { in_unit_house_price = 0; }
2411 if(strcmp(buffer,
"projects") == 0) { in_projects = 1; }
2412 if(strcmp(buffer,
"/projects") == 0) { in_projects = 0; }
2413 if(strcmp(buffer,
"loans_interest_rate") == 0) { in_loans_interest_rate = 1; }
2414 if(strcmp(buffer,
"/loans_interest_rate") == 0) { in_loans_interest_rate = 0; }
2415 if(strcmp(buffer,
"debt") == 0) { in_debt = 1; }
2416 if(strcmp(buffer,
"/debt") == 0) { in_debt = 0; }
2417 if(strcmp(buffer,
"inventory") == 0) { in_inventory = 1; }
2418 if(strcmp(buffer,
"/inventory") == 0) { in_inventory = 0; }
2419 if(strcmp(buffer,
"sales") == 0) { in_sales = 1; }
2420 if(strcmp(buffer,
"/sales") == 0) { in_sales = 0; }
2421 if(strcmp(buffer,
"revenues") == 0) { in_revenues = 1; }
2422 if(strcmp(buffer,
"/revenues") == 0) { in_revenues = 0; }
2423 if(strcmp(buffer,
"total_assets") == 0) { in_total_assets = 1; }
2424 if(strcmp(buffer,
"/total_assets") == 0) { in_total_assets = 0; }
2425 if(strcmp(buffer,
"operating_costs") == 0) { in_operating_costs = 1; }
2426 if(strcmp(buffer,
"/operating_costs") == 0) { in_operating_costs = 0; }
2427 if(strcmp(buffer,
"labour_costs") == 0) { in_labour_costs = 1; }
2428 if(strcmp(buffer,
"/labour_costs") == 0) { in_labour_costs = 0; }
2429 if(strcmp(buffer,
"total_interest_payments") == 0) { in_total_interest_payments = 1; }
2430 if(strcmp(buffer,
"/total_interest_payments") == 0) { in_total_interest_payments = 0; }
2431 if(strcmp(buffer,
"dividends_paid") == 0) { in_dividends_paid = 1; }
2432 if(strcmp(buffer,
"/dividends_paid") == 0) { in_dividends_paid = 0; }
2433 if(strcmp(buffer,
"dividends_to_be_paid") == 0) { in_dividends_to_be_paid = 1; }
2434 if(strcmp(buffer,
"/dividends_to_be_paid") == 0) { in_dividends_to_be_paid = 0; }
2435 if(strcmp(buffer,
"retained_earnings") == 0) { in_retained_earnings = 1; }
2436 if(strcmp(buffer,
"/retained_earnings") == 0) { in_retained_earnings = 0; }
2437 if(strcmp(buffer,
"net_earnings") == 0) { in_net_earnings = 1; }
2438 if(strcmp(buffer,
"/net_earnings") == 0) { in_net_earnings = 0; }
2439 if(strcmp(buffer,
"ebit") == 0) { in_ebit = 1; }
2440 if(strcmp(buffer,
"/ebit") == 0) { in_ebit = 0; }
2441 if(strcmp(buffer,
"equity") == 0) { in_equity = 1; }
2442 if(strcmp(buffer,
"/equity") == 0) { in_equity = 0; }
2443 if(strcmp(buffer,
"liquidity") == 0) { in_liquidity = 1; }
2444 if(strcmp(buffer,
"/liquidity") == 0) { in_liquidity = 0; }
2445 if(strcmp(buffer,
"isliquidshort") == 0) { in_isliquidshort = 1; }
2446 if(strcmp(buffer,
"/isliquidshort") == 0) { in_isliquidshort = 0; }
2447 if(strcmp(buffer,
"hasloan") == 0) { in_hasloan = 1; }
2448 if(strcmp(buffer,
"/hasloan") == 0) { in_hasloan = 0; }
2449 if(strcmp(buffer,
"hasinvestment") == 0) { in_hasinvestment = 1; }
2450 if(strcmp(buffer,
"/hasinvestment") == 0) { in_hasinvestment = 0; }
2451 if(strcmp(buffer,
"isilliquid") == 0) { in_isilliquid = 1; }
2452 if(strcmp(buffer,
"/isilliquid") == 0) { in_isilliquid = 0; }
2453 if(strcmp(buffer,
"planned_investment_costs") == 0) { in_planned_investment_costs = 1; }
2454 if(strcmp(buffer,
"/planned_investment_costs") == 0) { in_planned_investment_costs = 0; }
2455 if(strcmp(buffer,
"liquidity_need") == 0) { in_liquidity_need = 1; }
2456 if(strcmp(buffer,
"/liquidity_need") == 0) { in_liquidity_need = 0; }
2457 if(strcmp(buffer,
"loan_list") == 0) { in_loan_list = 1; }
2458 if(strcmp(buffer,
"/loan_list") == 0) { in_loan_list = 0; }
2459 if(strcmp(buffer,
"labour_tax_rate") == 0) { in_labour_tax_rate = 1; }
2460 if(strcmp(buffer,
"/labour_tax_rate") == 0) { in_labour_tax_rate = 0; }
2461 if(strcmp(buffer,
"delta_housing_price") == 0) { in_delta_housing_price = 1; }
2462 if(strcmp(buffer,
"/delta_housing_price") == 0) { in_delta_housing_price = 0; }
2463 if(strcmp(buffer,
"weekly_consumption_budget") == 0) { in_weekly_consumption_budget = 1; }
2464 if(strcmp(buffer,
"/weekly_consumption_budget") == 0) { in_weekly_consumption_budget = 0; }
2465 if(strcmp(buffer,
"mall_budget") == 0) { in_mall_budget = 1; }
2466 if(strcmp(buffer,
"/mall_budget") == 0) { in_mall_budget = 0; }
2467 if(strcmp(buffer,
"quarterly_price_change") == 0) { in_quarterly_price_change = 1; }
2468 if(strcmp(buffer,
"/quarterly_price_change") == 0) { in_quarterly_price_change = 0; }
2469 if(strcmp(buffer,
"my_employer_id") == 0) { in_my_employer_id = 1; }
2470 if(strcmp(buffer,
"/my_employer_id") == 0) { in_my_employer_id = 0; }
2471 if(strcmp(buffer,
"wage") == 0) { in_wage = 1; }
2472 if(strcmp(buffer,
"/wage") == 0) { in_wage = 0; }
2473 if(strcmp(buffer,
"ismanager") == 0) { in_ismanager = 1; }
2474 if(strcmp(buffer,
"/ismanager") == 0) { in_ismanager = 0; }
2475 if(strcmp(buffer,
"government_benefits") == 0) { in_government_benefits = 1; }
2476 if(strcmp(buffer,
"/government_benefits") == 0) { in_government_benefits = 0; }
2477 if(strcmp(buffer,
"day_of_month_wage_recieved") == 0) { in_day_of_month_wage_recieved = 1; }
2478 if(strcmp(buffer,
"/day_of_month_wage_recieved") == 0) { in_day_of_month_wage_recieved = 0; }
2479 if(strcmp(buffer,
"mortgages_interest_rate") == 0) { in_mortgages_interest_rate = 1; }
2480 if(strcmp(buffer,
"/mortgages_interest_rate") == 0) { in_mortgages_interest_rate = 0; }
2481 if(strcmp(buffer,
"mortgages_list") == 0) { in_mortgages_list = 1; }
2482 if(strcmp(buffer,
"/mortgages_list") == 0) { in_mortgages_list = 0; }
2483 if(strcmp(buffer,
"mortgages") == 0) { in_mortgages = 1; }
2484 if(strcmp(buffer,
"/mortgages") == 0) { in_mortgages = 0; }
2485 if(strcmp(buffer,
"housing_payment") == 0) { in_housing_payment = 1; }
2486 if(strcmp(buffer,
"/housing_payment") == 0) { in_housing_payment = 0; }
2487 if(strcmp(buffer,
"housing_price") == 0) { in_housing_price = 1; }
2488 if(strcmp(buffer,
"/housing_price") == 0) { in_housing_price = 0; }
2489 if(strcmp(buffer,
"housing_units") == 0) { in_housing_units = 1; }
2490 if(strcmp(buffer,
"/housing_units") == 0) { in_housing_units = 0; }
2491 if(strcmp(buffer,
"n_shares") == 0) { in_n_shares = 1; }
2492 if(strcmp(buffer,
"/n_shares") == 0) { in_n_shares = 0; }
2493 if(strcmp(buffer,
"capital_income") == 0) { in_capital_income = 1; }
2494 if(strcmp(buffer,
"/capital_income") == 0) { in_capital_income = 0; }
2495 if(strcmp(buffer,
"previous_wages") == 0) { in_previous_wages = 1; }
2496 if(strcmp(buffer,
"/previous_wages") == 0) { in_previous_wages = 0; }
2497 if(strcmp(buffer,
"previous_benefits") == 0) { in_previous_benefits = 1; }
2498 if(strcmp(buffer,
"/previous_benefits") == 0) { in_previous_benefits = 0; }
2499 if(strcmp(buffer,
"labour_income") == 0) { in_labour_income = 1; }
2500 if(strcmp(buffer,
"/labour_income") == 0) { in_labour_income = 0; }
2501 if(strcmp(buffer,
"housing_value") == 0) { in_housing_value = 1; }
2502 if(strcmp(buffer,
"/housing_value") == 0) { in_housing_value = 0; }
2503 if(strcmp(buffer,
"expected_housing_payment") == 0) { in_expected_housing_payment = 1; }
2504 if(strcmp(buffer,
"/expected_housing_payment") == 0) { in_expected_housing_payment = 0; }
2505 if(strcmp(buffer,
"hmarket_role") == 0) { in_hmarket_role = 1; }
2506 if(strcmp(buffer,
"/hmarket_role") == 0) { in_hmarket_role = 0; }
2507 if(strcmp(buffer,
"equity_ratio") == 0) { in_equity_ratio = 1; }
2508 if(strcmp(buffer,
"/equity_ratio") == 0) { in_equity_ratio = 0; }
2509 if(strcmp(buffer,
"minimum_equity_ratio") == 0) { in_minimum_equity_ratio = 1; }
2510 if(strcmp(buffer,
"/minimum_equity_ratio") == 0) { in_minimum_equity_ratio = 0; }
2511 if(strcmp(buffer,
"mortgage_costs") == 0) { in_mortgage_costs = 1; }
2512 if(strcmp(buffer,
"/mortgage_costs") == 0) { in_mortgage_costs = 0; }
2513 if(strcmp(buffer,
"delta_housing_value") == 0) { in_delta_housing_value = 1; }
2514 if(strcmp(buffer,
"/delta_housing_value") == 0) { in_delta_housing_value = 0; }
2515 if(strcmp(buffer,
"mortgage_choice") == 0) { in_mortgage_choice = 1; }
2516 if(strcmp(buffer,
"/mortgage_choice") == 0) { in_mortgage_choice = 0; }
2517 if(strcmp(buffer,
"share_firms") == 0) { in_share_firms = 1; }
2518 if(strcmp(buffer,
"/share_firms") == 0) { in_share_firms = 0; }
2519 if(strcmp(buffer,
"share_construction_firms") == 0) { in_share_construction_firms = 1; }
2520 if(strcmp(buffer,
"/share_construction_firms") == 0) { in_share_construction_firms = 0; }
2521 if(strcmp(buffer,
"share_banks") == 0) { in_share_banks = 1; }
2522 if(strcmp(buffer,
"/share_banks") == 0) { in_share_banks = 0; }
2523 if(strcmp(buffer,
"dividends_recieved") == 0) { in_dividends_recieved = 1; }
2524 if(strcmp(buffer,
"/dividends_recieved") == 0) { in_dividends_recieved = 0; }
2525 if(strcmp(buffer,
"dividends_retained") == 0) { in_dividends_retained = 1; }
2526 if(strcmp(buffer,
"/dividends_retained") == 0) { in_dividends_retained = 0; }
2527 if(strcmp(buffer,
"firm_investment") == 0) { in_firm_investment = 1; }
2528 if(strcmp(buffer,
"/firm_investment") == 0) { in_firm_investment = 0; }
2529 if(strcmp(buffer,
"capital_tax_rate") == 0) { in_capital_tax_rate = 1; }
2530 if(strcmp(buffer,
"/capital_tax_rate") == 0) { in_capital_tax_rate = 0; }
2531 if(strcmp(buffer,
"loans") == 0) { in_loans = 1; }
2532 if(strcmp(buffer,
"/loans") == 0) { in_loans = 0; }
2533 if(strcmp(buffer,
"loans_start") == 0) { in_loans_start = 1; }
2534 if(strcmp(buffer,
"/loans_start") == 0) { in_loans_start = 0; }
2535 if(strcmp(buffer,
"deposits") == 0) { in_deposits = 1; }
2536 if(strcmp(buffer,
"/deposits") == 0) { in_deposits = 0; }
2537 if(strcmp(buffer,
"centralbank_debt") == 0) { in_centralbank_debt = 1; }
2538 if(strcmp(buffer,
"/centralbank_debt") == 0) { in_centralbank_debt = 0; }
2539 if(strcmp(buffer,
"total_writeoffs") == 0) { in_total_writeoffs = 1; }
2540 if(strcmp(buffer,
"/total_writeoffs") == 0) { in_total_writeoffs = 0; }
2541 if(strcmp(buffer,
"interest_rate") == 0) { in_interest_rate = 1; }
2542 if(strcmp(buffer,
"/interest_rate") == 0) { in_interest_rate = 0; }
2543 if(strcmp(buffer,
"interests_accrued") == 0) { in_interests_accrued = 1; }
2544 if(strcmp(buffer,
"/interests_accrued") == 0) { in_interests_accrued = 0; }
2545 if(strcmp(buffer,
"interests_paid") == 0) { in_interests_paid = 1; }
2546 if(strcmp(buffer,
"/interests_paid") == 0) { in_interests_paid = 0; }
2547 if(strcmp(buffer,
"total_dividends") == 0) { in_total_dividends = 1; }
2548 if(strcmp(buffer,
"/total_dividends") == 0) { in_total_dividends = 0; }
2549 if(strcmp(buffer,
"total_costs") == 0) { in_total_costs = 1; }
2550 if(strcmp(buffer,
"/total_costs") == 0) { in_total_costs = 0; }
2551 if(strcmp(buffer,
"unemployment_rate") == 0) { in_unemployment_rate = 1; }
2552 if(strcmp(buffer,
"/unemployment_rate") == 0) { in_unemployment_rate = 0; }
2553 if(strcmp(buffer,
"population_size") == 0) { in_population_size = 1; }
2554 if(strcmp(buffer,
"/population_size") == 0) { in_population_size = 0; }
2555 if(strcmp(buffer,
"labour_tax_income") == 0) { in_labour_tax_income = 1; }
2556 if(strcmp(buffer,
"/labour_tax_income") == 0) { in_labour_tax_income = 0; }
2557 if(strcmp(buffer,
"capital_tax_income") == 0) { in_capital_tax_income = 1; }
2558 if(strcmp(buffer,
"/capital_tax_income") == 0) { in_capital_tax_income = 0; }
2559 if(strcmp(buffer,
"gov_general_benefit_rate") == 0) { in_gov_general_benefit_rate = 1; }
2560 if(strcmp(buffer,
"/gov_general_benefit_rate") == 0) { in_gov_general_benefit_rate = 0; }
2561 if(strcmp(buffer,
"gov_unemployment_rate") == 0) { in_gov_unemployment_rate = 1; }
2562 if(strcmp(buffer,
"/gov_unemployment_rate") == 0) { in_gov_unemployment_rate = 0; }
2563 if(strcmp(buffer,
"general_benefits") == 0) { in_general_benefits = 1; }
2564 if(strcmp(buffer,
"/general_benefits") == 0) { in_general_benefits = 0; }
2565 if(strcmp(buffer,
"unemployment_benefits") == 0) { in_unemployment_benefits = 1; }
2566 if(strcmp(buffer,
"/unemployment_benefits") == 0) { in_unemployment_benefits = 0; }
2567 if(strcmp(buffer,
"earnings") == 0) { in_earnings = 1; }
2568 if(strcmp(buffer,
"/earnings") == 0) { in_earnings = 0; }
2569 if(strcmp(buffer,
"centralbank_income") == 0) { in_centralbank_income = 1; }
2570 if(strcmp(buffer,
"/centralbank_income") == 0) { in_centralbank_income = 0; }
2571 if(strcmp(buffer,
"expenditures") == 0) { in_expenditures = 1; }
2572 if(strcmp(buffer,
"/expenditures") == 0) { in_expenditures = 0; }
2573 if(strcmp(buffer,
"inflation_rate") == 0) { in_inflation_rate = 1; }
2574 if(strcmp(buffer,
"/inflation_rate") == 0) { in_inflation_rate = 0; }
2575 if(strcmp(buffer,
"consumption_goods_prices") == 0) { in_consumption_goods_prices = 1; }
2576 if(strcmp(buffer,
"/consumption_goods_prices") == 0) { in_consumption_goods_prices = 0; }
2577 if(strcmp(buffer,
"goods") == 0) { in_goods = 1; }
2578 if(strcmp(buffer,
"/goods") == 0) { in_goods = 0; }
2579 if(strcmp(buffer,
"weekly_price_averages") == 0) { in_weekly_price_averages = 1; }
2580 if(strcmp(buffer,
"/weekly_price_averages") == 0) { in_weekly_price_averages = 0; }
2581 if(strcmp(buffer,
"loans_banks") == 0) { in_loans_banks = 1; }
2582 if(strcmp(buffer,
"/loans_banks") == 0) { in_loans_banks = 0; }
2583 if(strcmp(buffer,
"loans_government") == 0) { in_loans_government = 1; }
2584 if(strcmp(buffer,
"/loans_government") == 0) { in_loans_government = 0; }
2585 if(strcmp(buffer,
"fiat_money") == 0) { in_fiat_money = 1; }
2586 if(strcmp(buffer,
"/fiat_money") == 0) { in_fiat_money = 0; }
2587 if(strcmp(buffer,
"liquidity_banks") == 0) { in_liquidity_banks = 1; }
2588 if(strcmp(buffer,
"/liquidity_banks") == 0) { in_liquidity_banks = 0; }
2589 if(strcmp(buffer,
"liquidity_government") == 0) { in_liquidity_government = 1; }
2590 if(strcmp(buffer,
"/liquidity_government") == 0) { in_liquidity_government = 0; }
2591 if(strcmp(buffer,
"liquidity_equityfund") == 0) { in_liquidity_equityfund = 1; }
2592 if(strcmp(buffer,
"/liquidity_equityfund") == 0) { in_liquidity_equityfund = 0; }
2593 if(strcmp(buffer,
"houses") == 0) { in_houses = 1; }
2594 if(strcmp(buffer,
"/houses") == 0) { in_houses = 0; }
2595 if(strcmp(buffer,
"goods_transactions") == 0) { in_goods_transactions = 1; }
2596 if(strcmp(buffer,
"/goods_transactions") == 0) { in_goods_transactions = 0; }
2597 if(strcmp(buffer,
"housing_transactions") == 0) { in_housing_transactions = 1; }
2598 if(strcmp(buffer,
"/housing_transactions") == 0) { in_housing_transactions = 0; }
2601 buffer[index] =
'\0';
2605 buffer[index] =
'\0';
2607 if(in_itno && FLAME_in_xagent == 0) *itno = atoi(buffer);
2608 if(FLAME_in_xagent == 1)
2610 if(FLAME_in_name == 1)
2612 strcpy(agentname, buffer);
2614 if(strcmp(agentname,
"firm") == 0)
2619 else if(strcmp(agentname,
"household") == 0)
2622 in_household_agent = 1;
2624 else if(strcmp(agentname,
"equityfund") == 0)
2627 in_equityfund_agent = 1;
2629 else if(strcmp(agentname,
"bank") == 0)
2634 else if(strcmp(agentname,
"government") == 0)
2637 in_government_agent = 1;
2639 else if(strcmp(agentname,
"centralbank") == 0)
2642 in_centralbank_agent = 1;
2644 else if(strcmp(agentname,
"jpoffice") == 0)
2647 in_jpoffice_agent = 1;
2649 else if(strcmp(agentname,
"mall") == 0)
2654 else if(strcmp(agentname,
"reagency") == 0)
2657 in_reagency_agent = 1;
2661 printf(
"Warning: agent name undefined - '%s'\n", agentname);
2665 else if(in_firm_agent == 1)
2667 if(in_id) { current_firm_agent->
id = atoi(buffer); }
2668 if(in_bank_id) { current_firm_agent->
bank_id = atoi(buffer); }
2669 if(in_isconstructor) { current_firm_agent->
isconstructor = atoi(buffer); }
2671 if(in_isinsolvent) { current_firm_agent->
isinsolvent = atoi(buffer); }
2672 if(in_it_no) { current_firm_agent->
it_no = atoi(buffer); }
2675 if(in_employees) { j = 0;
2677 if(rc != 0) { printf(
"Error: reading 'firm' agent variable 'employees' of type 'int_array'\n"); exit(0); } }
2678 if(in_manager) { current_firm_agent->
manager = atoi(buffer); }
2679 if(in_wage_offer) { current_firm_agent->
wage_offer = atof(buffer); }
2680 if(in_average_wage) { current_firm_agent->
average_wage = atof(buffer); }
2681 if(in_no_employees) { current_firm_agent->
no_employees = atoi(buffer); }
2682 if(in_vacancies) { current_firm_agent->
vacancies = atoi(buffer); }
2683 if(in_employees_needed) { current_firm_agent->
employees_needed = atoi(buffer); }
2687 if(in_capital_goods) { current_firm_agent->
capital_goods = atoi(buffer); }
2690 if(in_expected_sales) { current_firm_agent->
expected_sales = atoi(buffer); }
2691 if(in_production_plan) { current_firm_agent->
production_plan = atoi(buffer); }
2692 if(in_unit_goods_price) { current_firm_agent->
unit_goods_price = atof(buffer); }
2693 if(in_unit_cost) { current_firm_agent->
unit_cost = atof(buffer); }
2695 if(in_unit_house_price) { current_firm_agent->
unit_house_price = atof(buffer); }
2696 if(in_projects) { j = 0;
2698 if(rc != 0) { printf(
"Error: reading 'firm' agent variable 'projects' of type 'int'\n"); exit(0); } }
2700 if(in_debt) { current_firm_agent->
debt = atof(buffer); }
2701 if(in_inventory) { current_firm_agent->
inventory = atoi(buffer); }
2702 if(in_sales) { current_firm_agent->
sales = atoi(buffer); }
2703 if(in_revenues) { current_firm_agent->
revenues = atof(buffer); }
2704 if(in_total_assets) { current_firm_agent->
total_assets = atof(buffer); }
2705 if(in_operating_costs) { current_firm_agent->
operating_costs = atof(buffer); }
2706 if(in_labour_costs) { current_firm_agent->
labour_costs = atof(buffer); }
2708 if(in_dividends_paid) { current_firm_agent->
dividends_paid = atof(buffer); }
2710 if(in_retained_earnings) { current_firm_agent->
retained_earnings = atof(buffer); }
2711 if(in_net_earnings) { current_firm_agent->
net_earnings = atof(buffer); }
2712 if(in_ebit) { current_firm_agent->
ebit = atof(buffer); }
2713 if(in_equity) { current_firm_agent->
equity = atof(buffer); }
2714 if(in_liquidity) { current_firm_agent->
liquidity = atof(buffer); }
2715 if(in_isliquidshort) { current_firm_agent->
isliquidshort = atoi(buffer); }
2716 if(in_hasloan) { current_firm_agent->
hasloan = atoi(buffer); }
2717 if(in_hasinvestment) { current_firm_agent->
hasinvestment = atoi(buffer); }
2718 if(in_isilliquid) { current_firm_agent->
isilliquid = atoi(buffer); }
2720 if(in_liquidity_need) { current_firm_agent->
liquidity_need = atof(buffer); }
2721 if(in_loan_list) { j = 0;
2723 if(rc != 0) { printf(
"Error: reading 'firm' agent variable 'loan_list' of type 'loan'\n"); exit(0); } }
2724 if(in_labour_tax_rate) { current_firm_agent->
labour_tax_rate = atof(buffer); }
2726 }
else if(in_household_agent == 1)
2728 if(in_id) { current_household_agent->
id = atoi(buffer); }
2729 if(in_bank_id) { current_household_agent->
bank_id = atoi(buffer); }
2730 if(in_it_no) { current_household_agent->
it_no = atoi(buffer); }
2731 if(in_day_of_week_to_act) { current_household_agent->
day_of_week_to_act = atoi(buffer); }
2733 if(in_mall_budget) { current_household_agent->
mall_budget = atof(buffer); }
2735 if(in_my_employer_id) { current_household_agent->
my_employer_id = atoi(buffer); }
2736 if(in_wage) { current_household_agent->
wage = atof(buffer); }
2737 if(in_ismanager) { current_household_agent->
ismanager = atoi(buffer); }
2738 if(in_government_benefits) { current_household_agent->
government_benefits = atof(buffer); }
2739 if(in_day_of_month_to_act) { current_household_agent->
day_of_month_to_act = atoi(buffer); }
2742 if(in_labour_tax_rate) { current_household_agent->
labour_tax_rate = atof(buffer); }
2743 if(in_mortgages_list) { j = 0;
2745 if(rc != 0) { printf(
"Error: reading 'household' agent variable 'mortgages_list' of type 'mortgage_array'\n"); exit(0); } }
2746 if(in_mortgages) { current_household_agent->
mortgages = atof(buffer); }
2747 if(in_housing_payment) { current_household_agent->
housing_payment = atof(buffer); }
2748 if(in_equity) { current_household_agent->
equity = atof(buffer); }
2749 if(in_housing_price) { current_household_agent->
housing_price = atof(buffer); }
2750 if(in_housing_units) { current_household_agent->
housing_units = atoi(buffer); }
2751 if(in_n_shares) { current_household_agent->
n_shares = atoi(buffer); }
2752 if(in_liquidity) { current_household_agent->
liquidity = atof(buffer); }
2753 if(in_capital_income) { current_household_agent->
capital_income = atof(buffer); }
2754 if(in_previous_wages) { j = 0;
2756 if(rc != 0) { printf(
"Error: reading 'household' agent variable 'previous_wages' of type 'double'\n"); exit(0); } }
2757 if(in_previous_benefits) { j = 0;
2759 if(rc != 0) { printf(
"Error: reading 'household' agent variable 'previous_benefits' of type 'double'\n"); exit(0); } }
2760 if(in_labour_income) { current_household_agent->
labour_income = atof(buffer); }
2761 if(in_total_assets) { current_household_agent->
total_assets = atof(buffer); }
2762 if(in_housing_value) { current_household_agent->
housing_value = atof(buffer); }
2764 if(in_hmarket_role) { current_household_agent->
hmarket_role = atoi(buffer); }
2765 if(in_equity_ratio) { current_household_agent->
equity_ratio = atof(buffer); }
2767 if(in_mortgage_costs) { j = 0;
2769 if(rc != 0) { printf(
"Error: reading 'household' agent variable 'mortgage_costs' of type 'double'\n"); exit(0); } }
2770 if(in_delta_housing_value) { current_household_agent->
delta_housing_value = atof(buffer); }
2771 if(in_mortgage_choice) { current_household_agent->
mortgage_choice = atoi(buffer); }
2772 }
else if(in_equityfund_agent == 1)
2774 if(in_id) { current_equityfund_agent->
id = atoi(buffer); }
2775 if(in_it_no) { current_equityfund_agent->
it_no = atoi(buffer); }
2776 if(in_day_of_month_to_act) { current_equityfund_agent->
day_of_month_to_act = atoi(buffer); }
2778 if(in_share_firms) { current_equityfund_agent->
share_firms = atof(buffer); }
2780 if(in_share_banks) { current_equityfund_agent->
share_banks = atof(buffer); }
2781 if(in_equity) { current_equityfund_agent->
equity = atof(buffer); }
2782 if(in_liquidity) { current_equityfund_agent->
liquidity = atof(buffer); }
2783 if(in_n_shares) { current_equityfund_agent->
n_shares = atoi(buffer); }
2784 if(in_dividends_recieved) { current_equityfund_agent->
dividends_recieved = atof(buffer); }
2785 if(in_dividends_retained) { current_equityfund_agent->
dividends_retained = atof(buffer); }
2786 if(in_dividends_paid) { current_equityfund_agent->
dividends_paid = atof(buffer); }
2787 if(in_firm_investment) { current_equityfund_agent->
firm_investment = atof(buffer); }
2788 if(in_capital_tax_rate) { current_equityfund_agent->
capital_tax_rate = atof(buffer); }
2789 }
else if(in_bank_agent == 1)
2791 if(in_id) { current_bank_agent->
id = atoi(buffer); }
2794 if(in_it_no) { current_bank_agent->
it_no = atoi(buffer); }
2795 if(in_total_assets) { current_bank_agent->
total_assets = atof(buffer); }
2796 if(in_loans) { current_bank_agent->
loans = atof(buffer); }
2797 if(in_loans_start) { current_bank_agent->
loans_start = atof(buffer); }
2798 if(in_mortgages) { current_bank_agent->
mortgages = atof(buffer); }
2799 if(in_deposits) { current_bank_agent->
deposits = atof(buffer); }
2800 if(in_centralbank_debt) { current_bank_agent->
centralbank_debt = atof(buffer); }
2801 if(in_equity) { current_bank_agent->
equity = atof(buffer); }
2802 if(in_liquidity) { current_bank_agent->
liquidity = atof(buffer); }
2803 if(in_revenues) { current_bank_agent->
revenues = atof(buffer); }
2804 if(in_total_writeoffs) { current_bank_agent->
total_writeoffs = atof(buffer); }
2805 if(in_interest_rate) { current_bank_agent->
interest_rate = atof(buffer); }
2806 if(in_interests_accrued) { current_bank_agent->
interests_accrued = atof(buffer); }
2807 if(in_interests_paid) { current_bank_agent->
interests_paid = atof(buffer); }
2808 if(in_dividends_paid) { current_bank_agent->
dividends_paid = atof(buffer); }
2809 if(in_total_dividends) { current_bank_agent->
total_dividends = atof(buffer); }
2810 if(in_retained_earnings) { current_bank_agent->
retained_earnings = atof(buffer); }
2811 if(in_net_earnings) { current_bank_agent->
net_earnings = atof(buffer); }
2812 if(in_total_costs) { current_bank_agent->
total_costs = atof(buffer); }
2813 }
else if(in_government_agent == 1)
2815 if(in_id) { current_government_agent->
id = atoi(buffer); }
2816 if(in_it_no) { current_government_agent->
it_no = atoi(buffer); }
2817 if(in_average_wage) { current_government_agent->
average_wage = atof(buffer); }
2818 if(in_unemployment_rate) { current_government_agent->
unemployment_rate = atof(buffer); }
2819 if(in_population_size) { current_government_agent->
population_size = atoi(buffer); }
2820 if(in_debt) { current_government_agent->
debt = atof(buffer); }
2821 if(in_equity) { current_government_agent->
equity = atof(buffer); }
2822 if(in_liquidity) { current_government_agent->
liquidity = atof(buffer); }
2823 if(in_day_of_month_to_act) { current_government_agent->
day_of_month_to_act = atoi(buffer); }
2825 if(in_capital_tax_rate) { current_government_agent->
capital_tax_rate = atof(buffer); }
2826 if(in_labour_tax_rate) { current_government_agent->
labour_tax_rate = atof(buffer); }
2827 if(in_labour_tax_income) { current_government_agent->
labour_tax_income = atof(buffer); }
2828 if(in_capital_tax_income) { current_government_agent->
capital_tax_income = atof(buffer); }
2831 if(in_general_benefits) { current_government_agent->
general_benefits = atof(buffer); }
2833 if(in_earnings) { current_government_agent->
earnings = atof(buffer); }
2834 if(in_centralbank_income) { current_government_agent->
centralbank_income = atof(buffer); }
2835 if(in_expenditures) { current_government_agent->
expenditures = atof(buffer); }
2836 }
else if(in_centralbank_agent == 1)
2838 if(in_id) { current_centralbank_agent->
id = atoi(buffer); }
2839 if(in_day_of_month_to_act) { current_centralbank_agent->
day_of_month_to_act = atoi(buffer); }
2840 if(in_unemployment_rate) { current_centralbank_agent->
unemployment_rate = atof(buffer); }
2841 if(in_inflation_rate) { current_centralbank_agent->
inflation_rate = atof(buffer); }
2842 if(in_consumption_goods_prices) { j = 0;
2844 if(rc != 0) { printf(
"Error: reading 'centralbank' agent variable 'consumption_goods_prices' of type 'double'\n"); exit(0); } }
2845 if(in_it_no) { current_centralbank_agent->
it_no = atoi(buffer); }
2846 if(in_day_of_week_to_act) { current_centralbank_agent->
day_of_week_to_act = atoi(buffer); }
2847 if(in_goods) { j = 0;
2849 if(rc != 0) { printf(
"Error: reading 'centralbank' agent variable 'goods' of type 'transaction'\n"); exit(0); } }
2850 if(in_weekly_price_averages) { j = 0;
2852 if(rc != 0) { printf(
"Error: reading 'centralbank' agent variable 'weekly_price_averages' of type 'double'\n"); exit(0); } }
2854 if(in_interest_rate) { current_centralbank_agent->
interest_rate = atof(buffer); }
2855 if(in_liquidity) { current_centralbank_agent->
liquidity = atof(buffer); }
2856 if(in_loans_banks) { current_centralbank_agent->
loans_banks = atof(buffer); }
2857 if(in_loans_government) { current_centralbank_agent->
loans_government = atof(buffer); }
2858 if(in_fiat_money) { current_centralbank_agent->
fiat_money = atof(buffer); }
2859 if(in_equity) { current_centralbank_agent->
equity = atof(buffer); }
2860 if(in_liquidity_banks) { current_centralbank_agent->
liquidity_banks = atof(buffer); }
2861 if(in_liquidity_government) { current_centralbank_agent->
liquidity_government = atof(buffer); }
2862 if(in_liquidity_equityfund) { current_centralbank_agent->
liquidity_equityfund = atof(buffer); }
2863 if(in_total_assets) { current_centralbank_agent->
total_assets = atof(buffer); }
2864 if(in_total_writeoffs) { current_centralbank_agent->
total_writeoffs = atof(buffer); }
2865 if(in_interests_accrued) { current_centralbank_agent->
interests_accrued = atof(buffer); }
2866 if(in_revenues) { current_centralbank_agent->
revenues = atof(buffer); }
2867 if(in_net_earnings) { current_centralbank_agent->
net_earnings = atof(buffer); }
2868 if(in_total_costs) { current_centralbank_agent->
total_costs = atof(buffer); }
2869 if(in_houses) { j = 0;
2871 if(rc != 0) { printf(
"Error: reading 'centralbank' agent variable 'houses' of type 'transaction'\n"); exit(0); } }
2872 }
else if(in_jpoffice_agent == 1)
2874 if(in_id) { current_jpoffice_agent->
id = atoi(buffer); }
2875 if(in_it_no) { current_jpoffice_agent->
it_no = atoi(buffer); }
2876 if(in_day_of_month_to_act) { current_jpoffice_agent->
day_of_month_to_act = atoi(buffer); }
2877 }
else if(in_mall_agent == 1)
2879 if(in_id) { current_mall_agent->
id = atoi(buffer); }
2880 if(in_it_no) { current_mall_agent->
it_no = atoi(buffer); }
2882 if(in_goods_transactions) { j = 0;
2884 if(rc != 0) { printf(
"Error: reading 'mall' agent variable 'goods_transactions' of type 'transaction'\n"); exit(0); } }
2885 }
else if(in_reagency_agent == 1)
2887 if(in_id) { current_reagency_agent->
id = atoi(buffer); }
2888 if(in_day_of_month_to_act) { current_reagency_agent->
day_of_month_to_act = atoi(buffer); }
2889 if(in_it_no) { current_reagency_agent->
it_no = atoi(buffer); }
2891 if(in_housing_transactions) { j = 0;
2893 if(rc != 0) { printf(
"Error: reading 'reagency' agent variable 'housing_transactions' of type 'transaction'\n"); exit(0); } }
2897 buffer[index] =
'\0';
2902 if(index < 99999) index++;
2905 printf(
"Error: agent reading buffer too small\n");
2906 printf(
"%s\n", buffer);
2928 buffer = (
char *)malloc( (strlen(location) + strlen(
"dummy.temp") + 1) *
sizeof(char));
2929 strcpy(buffer, location);
2930 strcat(buffer,
"dummy.temp");
2932 if((file = fopen(buffer,
"w")) == NULL)
return 0;
2953 int partition_method,
int flag)
2959 char buffer[100000];
2960 char FLAME_location[10000];
2961 char FLAME_format[10000];
2962 char FLAME_type[10000];
2966 int agent_count = 0;
2967 int number_partitions = 0;
2974 cloud_data[0] =
SPINF;
2975 cloud_data[1] = -
SPINF;
2976 cloud_data[2] =
SPINF;
2977 cloud_data[3] = -
SPINF;
2978 cloud_data[4] =
SPINF;
2979 cloud_data[5] = -
SPINF;
2993 int FLAME_in_imports = 0;
2994 int FLAME_in_import = 0;
2995 int FLAME_in_outputs = 0;
2996 int FLAME_in_output = 0;
2997 int FLAME_in_location = 0;
2998 int FLAME_in_format = 0;
2999 int FLAME_in_type = 0;
3000 int FLAME_in_time = 0;
3001 int FLAME_in_period = 0;
3002 int FLAME_in_phase = 0;
3003 int FLAME_in_name = 0;
3037 if((file = fopen(filename,
"r"))==NULL)
3039 printf(
"Error: opening initial states '%s'\n", filename);
3050 if(partition_method==geometric) printf(
"xml: Geometric partitioning\n");
3051 else if(partition_method==other) printf(
"xml: Round-robin partitioning\n");
3052 else printf(
"xml: Error - invalid partitioning method\n");
3061 printf(
"Reading initial data file: %s\n", filename);
3066 c = (char)fgetc(file);
3074 if(strcmp(buffer,
"states") == 0) reading = 1;
3075 if(strcmp(buffer,
"/states") == 0) reading = 0;
3076 if(strcmp(buffer,
"itno") == 0) in_itno = 1;
3077 if(strcmp(buffer,
"/itno") == 0) in_itno = 0;
3078 if(strcmp(buffer,
"imports") == 0) FLAME_in_imports = 1;
3079 if(strcmp(buffer,
"/imports") == 0) FLAME_in_imports = 0;
3080 if(strcmp(buffer,
"import") == 0)
3083 strcpy(FLAME_location, filelocation);
3084 FLAME_format[0] =
'\0';
3085 FLAME_type[0] =
'\0';
3087 FLAME_in_import = 1;
3089 if(strcmp(buffer,
"/import") == 0)
3091 if(strcmp(
"agent", FLAME_type) == 0 || strcmp(
"environment", FLAME_type) == 0)
3093 if(strcmp(
"xml", FLAME_format) == 0)
3095 if(strcmp(
"agent", FLAME_type) == 0)
readAgentXML(FLAME_location, cloud_data, partition_method, flag, number_partitions, agent_count, itno);
3100 printf(
"Error: import format '%s' is unsupported\n", FLAME_format);
3106 printf(
"Error: import type '%s' is not agent or environment\n", FLAME_type);
3110 FLAME_in_import = 0;
3112 if(strcmp(buffer,
"location") == 0) FLAME_in_location = 1;
3113 if(strcmp(buffer,
"/location") == 0) FLAME_in_location = 0;
3114 if(strcmp(buffer,
"format") == 0) FLAME_in_format = 1;
3115 if(strcmp(buffer,
"/format") == 0) FLAME_in_format = 0;
3116 if(strcmp(buffer,
"type") == 0) FLAME_in_type = 1;
3117 if(strcmp(buffer,
"/type") == 0) FLAME_in_type = 0;
3118 if(strcmp(buffer,
"outputs") == 0) FLAME_in_outputs = 1;
3119 if(strcmp(buffer,
"/outputs") == 0) FLAME_in_outputs = 0;
3120 if(strcmp(buffer,
"output") == 0)
3122 if(FLAME_in_outputs == 1)
3126 FLAME_in_output = 1;
3129 if(strcmp(buffer,
"/output") == 0)
3131 if(FLAME_in_outputs == 1)
3133 if(current_FLAME_output->
type == -1)
3135 printf(
"Error: an output type has not been set\n");
3138 if(current_FLAME_output->
format == -1)
3140 printf(
"Error: an output format has not been set\n");
3143 if(current_FLAME_output->
location == NULL)
3145 printf(
"Error: an output location has not been set\n");
3149 if(current_FLAME_output->
type == 0)
3154 printf(
"Error: location directory '%s' does not exist\n", current_FLAME_output->
location);
3159 if(current_FLAME_output->
period < 1)
3161 printf(
"Error: output period is less than 1: '%d'\n", current_FLAME_output->
period);
3165 if(current_FLAME_output->
phase >= current_FLAME_output->
period)
3167 printf(
"Error: output phase is more or equal to period: '%d'\n", current_FLAME_output->
phase);
3171 FLAME_in_output = 0;
3174 if(strcmp(buffer,
"time") == 0) FLAME_in_time = 1;
3175 if(strcmp(buffer,
"/time") == 0) FLAME_in_time = 0;
3176 if(strcmp(buffer,
"period") == 0) FLAME_in_period = 1;
3177 if(strcmp(buffer,
"/period") == 0) FLAME_in_period = 0;
3178 if(strcmp(buffer,
"phase") == 0) FLAME_in_phase = 1;
3179 if(strcmp(buffer,
"/phase") == 0) FLAME_in_phase = 0;
3180 if(strcmp(buffer,
"name") == 0) FLAME_in_name = 1;
3181 if(strcmp(buffer,
"/name") == 0) FLAME_in_name = 0;
3195 if(in_itno) *itno = atoi(buffer);
3196 if(FLAME_in_imports == 1)
3198 if(FLAME_in_import == 1)
3200 if(FLAME_in_location == 1) strcat(FLAME_location, buffer);
3201 if(FLAME_in_format == 1) strcpy(FLAME_format, buffer);
3202 if(FLAME_in_type == 1) strcpy(FLAME_type, buffer);
3205 if(FLAME_in_outputs == 1)
3207 if(FLAME_in_output == 1)
3209 if(FLAME_in_type == 1)
3211 if(strcmp(
"snapshot", buffer) == 0) current_FLAME_output->
type = 0;
3212 else if(strcmp(
"agent", buffer) != 0)
3214 printf(
"Error: output type is not 'snapshot' or an 'agent': '%s'\n", buffer);
3218 if(FLAME_in_name == 1)
3220 if(strcmp(
"firm", buffer) == 0) current_FLAME_output->
type = 1;
3221 else if(strcmp(
"household", buffer) == 0) current_FLAME_output->
type = 2;
3222 else if(strcmp(
"equityfund", buffer) == 0) current_FLAME_output->
type = 3;
3223 else if(strcmp(
"bank", buffer) == 0) current_FLAME_output->
type = 4;
3224 else if(strcmp(
"government", buffer) == 0) current_FLAME_output->
type = 5;
3225 else if(strcmp(
"centralbank", buffer) == 0) current_FLAME_output->
type = 6;
3226 else if(strcmp(
"jpoffice", buffer) == 0) current_FLAME_output->
type = 7;
3227 else if(strcmp(
"mall", buffer) == 0) current_FLAME_output->
type = 8;
3228 else if(strcmp(
"reagency", buffer) == 0) current_FLAME_output->
type = 9;
3231 printf(
"Error: output name is not an agent name: '%s'\n", buffer);
3235 if(FLAME_in_format == 1)
3237 if(strcmp(
"xml", buffer) == 0) current_FLAME_output->
format = 0;
3240 printf(
"Error: output format is unsupported: '%s'\n", buffer);
3244 if(FLAME_in_location == 1)
3246 current_FLAME_output->
location = (
char *)malloc( (strlen(filelocation) + strlen(buffer) + 1) *
sizeof(char));
3247 strcpy(current_FLAME_output->
location, filelocation);
3248 strcat(current_FLAME_output->
location, buffer);
3250 if(FLAME_in_time == 1)
3252 if(FLAME_in_period == 1) current_FLAME_output->
period = atoi(buffer);
3253 if(FLAME_in_phase == 1) current_FLAME_output->
phase = atoi(buffer);
3261 else if(in_tag == 1)
3279 readAgentXML(filename, cloud_data, partition_method, flag, number_partitions, agent_count, itno);
3285 current_FLAME_output->
type = 0;
3286 current_FLAME_output->
format = 0;
3287 current_FLAME_output->
location = (
char *)malloc( (strlen(filelocation) + 1) *
sizeof(char));
3288 strcpy(current_FLAME_output->
location, filelocation);
3289 current_FLAME_output->
period = 1;
3290 current_FLAME_output->
phase = 0;
3294 for(current_FLAME_output =
FLAME_outputs; current_FLAME_output != NULL; current_FLAME_output = current_FLAME_output->
next)
3296 printf(
"output: type='");
3297 if(current_FLAME_output->
type == 0) printf(
"snapshot");
3298 else if(current_FLAME_output->
type == 1) printf(
"agent' name='firm");
3299 else if(current_FLAME_output->
type == 2) printf(
"agent' name='household");
3300 else if(current_FLAME_output->
type == 3) printf(
"agent' name='equityfund");
3301 else if(current_FLAME_output->
type == 4) printf(
"agent' name='bank");
3302 else if(current_FLAME_output->
type == 5) printf(
"agent' name='government");
3303 else if(current_FLAME_output->
type == 6) printf(
"agent' name='centralbank");
3304 else if(current_FLAME_output->
type == 7) printf(
"agent' name='jpoffice");
3305 else if(current_FLAME_output->
type == 8) printf(
"agent' name='mall");
3306 else if(current_FLAME_output->
type == 9) printf(
"agent' name='reagency");
3307 else printf(
"undefined");
3308 printf(
"' format='");
3309 if(current_FLAME_output->
format == 0) printf(
"xml");
3310 else printf(
"undefined");
3311 printf(
"' location='%s'", current_FLAME_output->
location);
3312 printf(
" period='%d' phase='%d'\n", current_FLAME_output->
period, current_FLAME_output->
phase);
3316 if ( partition_method == geometric ) {
3317 if ( cloud_data[0] == cloud_data[1] ) {
3318 cloud_data[0] = -
SPINF;
3319 cloud_data[1] =
SPINF;
3321 if ( cloud_data[2] == cloud_data[3] ) {
3322 cloud_data[2] = -
SPINF;
3323 cloud_data[3] =
SPINF;
3325 if ( cloud_data[4] == cloud_data[5] ) {
3326 cloud_data[4] = -
SPINF;
3327 cloud_data[5] =
SPINF;
3341 for(i=0; i<size; i++)
3343 sprintf(data,
"%i", temp[i]);
3345 if(i < size-1) fputs(
", ", file);
3359 for(i=0; i<size; i++)
3361 sprintf(data,
"%f", temp[i]);
3363 if(i < size-1) fputs(
", ", file);
3377 for(i=0; i<size; i++)
3379 sprintf(data,
"%f", temp[i]);
3381 if(i < size-1) fputs(
", ", file);
3395 for(i=0; i<size; i++)
3397 sprintf(data,
"%c", temp[i]);
3413 for(i=0; i<(*temp).size; i++)
3415 sprintf(data,
"%i", (*temp).array[i]);
3417 if(i < ((*temp).size-1)) fputs(
", ", file);
3431 for(i=0; i<(*temp).size; i++)
3433 sprintf(data,
"%f", (*temp).array[i]);
3435 if(i < ((*temp).size-1)) fputs(
", ", file);
3449 for(i=0; i<(*temp).size; i++)
3451 sprintf(data,
"%f", (*temp).array[i]);
3453 if(i < ((*temp).size-1)) fputs(
", ", file);
3466 for(i=0; i<(*temp).size; i++)
3468 sprintf(data,
"%c", (*temp).array[i]);
3481 sprintf(data,
"%i", (*temp_datatype).quantity);
3483 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).avg_price);
3493 for(i = 0; i < size; i++)
3497 if(i < size - 1) fputs(
", ", file);
3507 for(i = 0; i < (*temp_datatype).size; i++)
3511 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3524 sprintf(data,
"%i", (*temp_datatype).id);
3526 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).budget);
3536 for(i = 0; i < size; i++)
3540 if(i < size - 1) fputs(
", ", file);
3550 for(i = 0; i < (*temp_datatype).size; i++)
3554 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3567 sprintf(data,
"%i", (*temp_datatype).id);
3569 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).price);
3571 fputs(
", ", file); sprintf(data,
"%i", (*temp_datatype).inventory);
3573 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).inv_price);
3583 for(i = 0; i < size; i++)
3587 if(i < size - 1) fputs(
", ", file);
3597 for(i = 0; i < (*temp_datatype).size; i++)
3601 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3614 sprintf(data,
"%i", (*temp_datatype).id);
3616 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).wage);
3626 for(i = 0; i < size; i++)
3630 if(i < size - 1) fputs(
", ", file);
3640 for(i = 0; i < (*temp_datatype).size; i++)
3644 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3657 sprintf(data,
"%i", (*temp_datatype).id);
3659 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).wage);
3669 for(i = 0; i < size; i++)
3673 if(i < size - 1) fputs(
", ", file);
3683 for(i = 0; i < (*temp_datatype).size; i++)
3687 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3700 sprintf(data,
"%i", (*temp_datatype).bank_id);
3702 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).principal);
3704 fputs(
", ", file); sprintf(data,
"%i", (*temp_datatype).quarters_left);
3706 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).quarterly_interest);
3708 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).quarterly_principal);
3710 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).interestrate);
3712 fputs(
", ", file); sprintf(data,
"%i", (*temp_datatype).mtype);
3722 for(i = 0; i < size; i++)
3726 if(i < size - 1) fputs(
", ", file);
3736 for(i = 0; i < (*temp_datatype).size; i++)
3740 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3753 sprintf(data,
"%i", (*temp_datatype).bank_id);
3755 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).amount);
3757 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).to_be_paid);
3767 for(i = 0; i < size; i++)
3771 if(i < size - 1) fputs(
", ", file);
3781 for(i = 0; i < (*temp_datatype).size; i++)
3783 write_loan(file, &(*temp_datatype).array[i]);
3785 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3798 sprintf(data,
"%i", (*temp_datatype).buyer_id);
3800 fputs(
", ", file); sprintf(data,
"%i", (*temp_datatype).bank_id);
3802 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).liquidity);
3804 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).quarterly_income);
3806 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).quarterly_mortgage_paid);
3808 fputs(
", ", file); sprintf(data,
"%i", (*temp_datatype).choice);
3818 for(i = 0; i < size; i++)
3822 if(i < size - 1) fputs(
", ", file);
3832 for(i = 0; i < (*temp_datatype).size; i++)
3836 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3849 sprintf(data,
"%i", (*temp_datatype).seller_id);
3851 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).price);
3853 fputs(
", ", file); sprintf(data,
"%i", (*temp_datatype).quantity);
3855 fputs(
", ", file); sprintf(data,
"%i", (*temp_datatype).type);
3865 for(i = 0; i < size; i++)
3869 if(i < size - 1) fputs(
", ", file);
3879 for(i = 0; i < (*temp_datatype).size; i++)
3883 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3896 sprintf(data,
"%i", (*temp_datatype).id);
3898 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).equity);
3900 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).risky_assets);
3902 fputs(
", ", file); sprintf(data,
"%f", (*temp_datatype).amount_mortgaged);
3912 for(i = 0; i < size; i++)
3916 if(i < size - 1) fputs(
", ", file);
3926 for(i = 0; i < (*temp_datatype).size; i++)
3930 if(i < (*temp_datatype).size - 1) fputs(
", ", file);
3940 fputs(
"<xagent>\n" , file);
3941 fputs(
"<name>firm</name>\n", file);
3942 fputs(
"<id>", file);
3943 sprintf(data,
"%i", current->
id);
3945 fputs(
"</id>\n", file);
3946 fputs(
"<bank_id>", file);
3947 sprintf(data,
"%i", current->
bank_id);
3949 fputs(
"</bank_id>\n", file);
3950 fputs(
"<isconstructor>", file);
3953 fputs(
"</isconstructor>\n", file);
3954 fputs(
"<day_of_month_to_act>", file);
3957 fputs(
"</day_of_month_to_act>\n", file);
3958 fputs(
"<isinsolvent>", file);
3961 fputs(
"</isinsolvent>\n", file);
3962 fputs(
"<it_no>", file);
3963 sprintf(data,
"%i", current->
it_no);
3965 fputs(
"</it_no>\n", file);
3966 fputs(
"<day_of_week_to_act>", file);
3969 fputs(
"</day_of_week_to_act>\n", file);
3970 fputs(
"<average_goods_price>", file);
3973 fputs(
"</average_goods_price>\n", file);
3974 fputs(
"<employees>", file);
3976 fputs(
"</employees>\n", file);
3977 fputs(
"<manager>", file);
3978 sprintf(data,
"%i", current->
manager);
3980 fputs(
"</manager>\n", file);
3981 fputs(
"<wage_offer>", file);
3984 fputs(
"</wage_offer>\n", file);
3985 fputs(
"<average_wage>", file);
3988 fputs(
"</average_wage>\n", file);
3989 fputs(
"<no_employees>", file);
3992 fputs(
"</no_employees>\n", file);
3993 fputs(
"<vacancies>", file);
3994 sprintf(data,
"%i", current->
vacancies);
3996 fputs(
"</vacancies>\n", file);
3997 fputs(
"<employees_needed>", file);
4000 fputs(
"</employees_needed>\n", file);
4001 fputs(
"<day_of_month_wages_paid>", file);
4004 fputs(
"</day_of_month_wages_paid>\n", file);
4005 fputs(
"<labour_productivity>", file);
4008 fputs(
"</labour_productivity>\n", file);
4009 fputs(
"<capital_productivity>", file);
4012 fputs(
"</capital_productivity>\n", file);
4013 fputs(
"<capital_goods>", file);
4016 fputs(
"</capital_goods>\n", file);
4017 fputs(
"<capital_goods_price>", file);
4020 fputs(
"</capital_goods_price>\n", file);
4021 fputs(
"<production_current>", file);
4024 fputs(
"</production_current>\n", file);
4025 fputs(
"<expected_sales>", file);
4028 fputs(
"</expected_sales>\n", file);
4029 fputs(
"<production_plan>", file);
4032 fputs(
"</production_plan>\n", file);
4033 fputs(
"<unit_goods_price>", file);
4036 fputs(
"</unit_goods_price>\n", file);
4037 fputs(
"<unit_cost>", file);
4038 sprintf(data,
"%f", current->
unit_cost);
4040 fputs(
"</unit_cost>\n", file);
4041 fputs(
"<day_of_month_production_completed>", file);
4044 fputs(
"</day_of_month_production_completed>\n", file);
4045 fputs(
"<unit_house_price>", file);
4048 fputs(
"</unit_house_price>\n", file);
4049 fputs(
"<projects>", file);
4051 fputs(
"</projects>\n", file);
4052 fputs(
"<loans_interest_rate>", file);
4055 fputs(
"</loans_interest_rate>\n", file);
4056 fputs(
"<debt>", file);
4057 sprintf(data,
"%f", current->
debt);
4059 fputs(
"</debt>\n", file);
4060 fputs(
"<inventory>", file);
4061 sprintf(data,
"%i", current->
inventory);
4063 fputs(
"</inventory>\n", file);
4064 fputs(
"<sales>", file);
4065 sprintf(data,
"%i", current->
sales);
4067 fputs(
"</sales>\n", file);
4068 fputs(
"<revenues>", file);
4069 sprintf(data,
"%f", current->
revenues);
4071 fputs(
"</revenues>\n", file);
4072 fputs(
"<total_assets>", file);
4075 fputs(
"</total_assets>\n", file);
4076 fputs(
"<operating_costs>", file);
4079 fputs(
"</operating_costs>\n", file);
4080 fputs(
"<labour_costs>", file);
4083 fputs(
"</labour_costs>\n", file);
4084 fputs(
"<total_interest_payments>", file);
4087 fputs(
"</total_interest_payments>\n", file);
4088 fputs(
"<dividends_paid>", file);
4091 fputs(
"</dividends_paid>\n", file);
4092 fputs(
"<dividends_to_be_paid>", file);
4095 fputs(
"</dividends_to_be_paid>\n", file);
4096 fputs(
"<retained_earnings>", file);
4099 fputs(
"</retained_earnings>\n", file);
4100 fputs(
"<net_earnings>", file);
4103 fputs(
"</net_earnings>\n", file);
4104 fputs(
"<ebit>", file);
4105 sprintf(data,
"%f", current->
ebit);
4107 fputs(
"</ebit>\n", file);
4108 fputs(
"<equity>", file);
4109 sprintf(data,
"%f", current->
equity);
4111 fputs(
"</equity>\n", file);
4112 fputs(
"<liquidity>", file);
4113 sprintf(data,
"%f", current->
liquidity);
4115 fputs(
"</liquidity>\n", file);
4116 fputs(
"<isliquidshort>", file);
4119 fputs(
"</isliquidshort>\n", file);
4120 fputs(
"<hasloan>", file);
4121 sprintf(data,
"%i", current->
hasloan);
4123 fputs(
"</hasloan>\n", file);
4124 fputs(
"<hasinvestment>", file);
4127 fputs(
"</hasinvestment>\n", file);
4128 fputs(
"<isilliquid>", file);
4131 fputs(
"</isilliquid>\n", file);
4132 fputs(
"<planned_investment_costs>", file);
4135 fputs(
"</planned_investment_costs>\n", file);
4136 fputs(
"<liquidity_need>", file);
4139 fputs(
"</liquidity_need>\n", file);
4140 fputs(
"<loan_list>", file);
4142 fputs(
"</loan_list>\n", file);
4143 fputs(
"<labour_tax_rate>", file);
4146 fputs(
"</labour_tax_rate>\n", file);
4147 fputs(
"<delta_housing_price>", file);
4150 fputs(
"</delta_housing_price>\n", file);
4152 fputs(
"</xagent>\n", file);
4158 fputs(
"<xagent>\n" , file);
4159 fputs(
"<name>household</name>\n", file);
4160 fputs(
"<id>", file);
4161 sprintf(data,
"%i", current->
id);
4163 fputs(
"</id>\n", file);
4164 fputs(
"<bank_id>", file);
4165 sprintf(data,
"%i", current->
bank_id);
4167 fputs(
"</bank_id>\n", file);
4168 fputs(
"<it_no>", file);
4169 sprintf(data,
"%i", current->
it_no);
4171 fputs(
"</it_no>\n", file);
4172 fputs(
"<day_of_week_to_act>", file);
4175 fputs(
"</day_of_week_to_act>\n", file);
4176 fputs(
"<weekly_consumption_budget>", file);
4179 fputs(
"</weekly_consumption_budget>\n", file);
4180 fputs(
"<mall_budget>", file);
4183 fputs(
"</mall_budget>\n", file);
4184 fputs(
"<quarterly_price_change>", file);
4187 fputs(
"</quarterly_price_change>\n", file);
4188 fputs(
"<my_employer_id>", file);
4191 fputs(
"</my_employer_id>\n", file);
4192 fputs(
"<wage>", file);
4193 sprintf(data,
"%f", current->
wage);
4195 fputs(
"</wage>\n", file);
4196 fputs(
"<ismanager>", file);
4197 sprintf(data,
"%i", current->
ismanager);
4199 fputs(
"</ismanager>\n", file);
4200 fputs(
"<government_benefits>", file);
4203 fputs(
"</government_benefits>\n", file);
4204 fputs(
"<day_of_month_to_act>", file);
4207 fputs(
"</day_of_month_to_act>\n", file);
4208 fputs(
"<day_of_month_wage_recieved>", file);
4211 fputs(
"</day_of_month_wage_recieved>\n", file);
4212 fputs(
"<mortgages_interest_rate>", file);
4215 fputs(
"</mortgages_interest_rate>\n", file);
4216 fputs(
"<labour_tax_rate>", file);
4219 fputs(
"</labour_tax_rate>\n", file);
4220 fputs(
"<mortgages_list>", file);
4222 fputs(
"</mortgages_list>\n", file);
4223 fputs(
"<mortgages>", file);
4224 sprintf(data,
"%f", current->
mortgages);
4226 fputs(
"</mortgages>\n", file);
4227 fputs(
"<housing_payment>", file);
4230 fputs(
"</housing_payment>\n", file);
4231 fputs(
"<equity>", file);
4232 sprintf(data,
"%f", current->
equity);
4234 fputs(
"</equity>\n", file);
4235 fputs(
"<housing_price>", file);
4238 fputs(
"</housing_price>\n", file);
4239 fputs(
"<housing_units>", file);
4242 fputs(
"</housing_units>\n", file);
4243 fputs(
"<n_shares>", file);
4244 sprintf(data,
"%i", current->
n_shares);
4246 fputs(
"</n_shares>\n", file);
4247 fputs(
"<liquidity>", file);
4248 sprintf(data,
"%f", current->
liquidity);
4250 fputs(
"</liquidity>\n", file);
4251 fputs(
"<capital_income>", file);
4254 fputs(
"</capital_income>\n", file);
4255 fputs(
"<previous_wages>", file);
4257 fputs(
"</previous_wages>\n", file);
4258 fputs(
"<previous_benefits>", file);
4260 fputs(
"</previous_benefits>\n", file);
4261 fputs(
"<labour_income>", file);
4264 fputs(
"</labour_income>\n", file);
4265 fputs(
"<total_assets>", file);
4268 fputs(
"</total_assets>\n", file);
4269 fputs(
"<housing_value>", file);
4272 fputs(
"</housing_value>\n", file);
4273 fputs(
"<expected_housing_payment>", file);
4276 fputs(
"</expected_housing_payment>\n", file);
4277 fputs(
"<hmarket_role>", file);
4280 fputs(
"</hmarket_role>\n", file);
4281 fputs(
"<equity_ratio>", file);
4284 fputs(
"</equity_ratio>\n", file);
4285 fputs(
"<minimum_equity_ratio>", file);
4288 fputs(
"</minimum_equity_ratio>\n", file);
4289 fputs(
"<mortgage_costs>", file);
4291 fputs(
"</mortgage_costs>\n", file);
4292 fputs(
"<delta_housing_value>", file);
4295 fputs(
"</delta_housing_value>\n", file);
4296 fputs(
"<mortgage_choice>", file);
4299 fputs(
"</mortgage_choice>\n", file);
4301 fputs(
"</xagent>\n", file);
4307 fputs(
"<xagent>\n" , file);
4308 fputs(
"<name>equityfund</name>\n", file);
4309 fputs(
"<id>", file);
4310 sprintf(data,
"%i", current->
id);
4312 fputs(
"</id>\n", file);
4313 fputs(
"<it_no>", file);
4314 sprintf(data,
"%i", current->
it_no);
4316 fputs(
"</it_no>\n", file);
4317 fputs(
"<day_of_month_to_act>", file);
4320 fputs(
"</day_of_month_to_act>\n", file);
4321 fputs(
"<day_of_month_wages_paid>", file);
4324 fputs(
"</day_of_month_wages_paid>\n", file);
4325 fputs(
"<share_firms>", file);
4328 fputs(
"</share_firms>\n", file);
4329 fputs(
"<share_construction_firms>", file);
4332 fputs(
"</share_construction_firms>\n", file);
4333 fputs(
"<share_banks>", file);
4336 fputs(
"</share_banks>\n", file);
4337 fputs(
"<equity>", file);
4338 sprintf(data,
"%f", current->
equity);
4340 fputs(
"</equity>\n", file);
4341 fputs(
"<liquidity>", file);
4342 sprintf(data,
"%f", current->
liquidity);
4344 fputs(
"</liquidity>\n", file);
4345 fputs(
"<n_shares>", file);
4346 sprintf(data,
"%i", current->
n_shares);
4348 fputs(
"</n_shares>\n", file);
4349 fputs(
"<dividends_recieved>", file);
4352 fputs(
"</dividends_recieved>\n", file);
4353 fputs(
"<dividends_retained>", file);
4356 fputs(
"</dividends_retained>\n", file);
4357 fputs(
"<dividends_paid>", file);
4360 fputs(
"</dividends_paid>\n", file);
4361 fputs(
"<firm_investment>", file);
4364 fputs(
"</firm_investment>\n", file);
4365 fputs(
"<capital_tax_rate>", file);
4368 fputs(
"</capital_tax_rate>\n", file);
4370 fputs(
"</xagent>\n", file);
4376 fputs(
"<xagent>\n" , file);
4377 fputs(
"<name>bank</name>\n", file);
4378 fputs(
"<id>", file);
4379 sprintf(data,
"%i", current->
id);
4381 fputs(
"</id>\n", file);
4382 fputs(
"<day_of_month_to_act>", file);
4385 fputs(
"</day_of_month_to_act>\n", file);
4386 fputs(
"<day_of_week_to_act>", file);
4389 fputs(
"</day_of_week_to_act>\n", file);
4390 fputs(
"<it_no>", file);
4391 sprintf(data,
"%i", current->
it_no);
4393 fputs(
"</it_no>\n", file);
4394 fputs(
"<total_assets>", file);
4397 fputs(
"</total_assets>\n", file);
4398 fputs(
"<loans>", file);
4399 sprintf(data,
"%f", current->
loans);
4401 fputs(
"</loans>\n", file);
4402 fputs(
"<loans_start>", file);
4405 fputs(
"</loans_start>\n", file);
4406 fputs(
"<mortgages>", file);
4407 sprintf(data,
"%f", current->
mortgages);
4409 fputs(
"</mortgages>\n", file);
4410 fputs(
"<deposits>", file);
4411 sprintf(data,
"%f", current->
deposits);
4413 fputs(
"</deposits>\n", file);
4414 fputs(
"<centralbank_debt>", file);
4417 fputs(
"</centralbank_debt>\n", file);
4418 fputs(
"<equity>", file);
4419 sprintf(data,
"%f", current->
equity);
4421 fputs(
"</equity>\n", file);
4422 fputs(
"<liquidity>", file);
4423 sprintf(data,
"%f", current->
liquidity);
4425 fputs(
"</liquidity>\n", file);
4426 fputs(
"<revenues>", file);
4427 sprintf(data,
"%f", current->
revenues);
4429 fputs(
"</revenues>\n", file);
4430 fputs(
"<total_writeoffs>", file);
4433 fputs(
"</total_writeoffs>\n", file);
4434 fputs(
"<interest_rate>", file);
4437 fputs(
"</interest_rate>\n", file);
4438 fputs(
"<interests_accrued>", file);
4441 fputs(
"</interests_accrued>\n", file);
4442 fputs(
"<interests_paid>", file);
4445 fputs(
"</interests_paid>\n", file);
4446 fputs(
"<dividends_paid>", file);
4449 fputs(
"</dividends_paid>\n", file);
4450 fputs(
"<total_dividends>", file);
4453 fputs(
"</total_dividends>\n", file);
4454 fputs(
"<retained_earnings>", file);
4457 fputs(
"</retained_earnings>\n", file);
4458 fputs(
"<net_earnings>", file);
4461 fputs(
"</net_earnings>\n", file);
4462 fputs(
"<total_costs>", file);
4465 fputs(
"</total_costs>\n", file);
4467 fputs(
"</xagent>\n", file);
4473 fputs(
"<xagent>\n" , file);
4474 fputs(
"<name>government</name>\n", file);
4475 fputs(
"<id>", file);
4476 sprintf(data,
"%i", current->
id);
4478 fputs(
"</id>\n", file);
4479 fputs(
"<it_no>", file);
4480 sprintf(data,
"%i", current->
it_no);
4482 fputs(
"</it_no>\n", file);
4483 fputs(
"<average_wage>", file);
4486 fputs(
"</average_wage>\n", file);
4487 fputs(
"<unemployment_rate>", file);
4490 fputs(
"</unemployment_rate>\n", file);
4491 fputs(
"<population_size>", file);
4494 fputs(
"</population_size>\n", file);
4495 fputs(
"<debt>", file);
4496 sprintf(data,
"%f", current->
debt);
4498 fputs(
"</debt>\n", file);
4499 fputs(
"<equity>", file);
4500 sprintf(data,
"%f", current->
equity);
4502 fputs(
"</equity>\n", file);
4503 fputs(
"<liquidity>", file);
4504 sprintf(data,
"%f", current->
liquidity);
4506 fputs(
"</liquidity>\n", file);
4507 fputs(
"<day_of_month_to_act>", file);
4510 fputs(
"</day_of_month_to_act>\n", file);
4511 fputs(
"<day_of_month_wages_paid>", file);
4514 fputs(
"</day_of_month_wages_paid>\n", file);
4515 fputs(
"<capital_tax_rate>", file);
4518 fputs(
"</capital_tax_rate>\n", file);
4519 fputs(
"<labour_tax_rate>", file);
4522 fputs(
"</labour_tax_rate>\n", file);
4523 fputs(
"<labour_tax_income>", file);
4526 fputs(
"</labour_tax_income>\n", file);
4527 fputs(
"<capital_tax_income>", file);
4530 fputs(
"</capital_tax_income>\n", file);
4531 fputs(
"<gov_general_benefit_rate>", file);
4534 fputs(
"</gov_general_benefit_rate>\n", file);
4535 fputs(
"<gov_unemployment_rate>", file);
4538 fputs(
"</gov_unemployment_rate>\n", file);
4539 fputs(
"<general_benefits>", file);
4542 fputs(
"</general_benefits>\n", file);
4543 fputs(
"<unemployment_benefits>", file);
4546 fputs(
"</unemployment_benefits>\n", file);
4547 fputs(
"<earnings>", file);
4548 sprintf(data,
"%f", current->
earnings);
4550 fputs(
"</earnings>\n", file);
4551 fputs(
"<centralbank_income>", file);
4554 fputs(
"</centralbank_income>\n", file);
4555 fputs(
"<expenditures>", file);
4558 fputs(
"</expenditures>\n", file);
4560 fputs(
"</xagent>\n", file);
4566 fputs(
"<xagent>\n" , file);
4567 fputs(
"<name>centralbank</name>\n", file);
4568 fputs(
"<id>", file);
4569 sprintf(data,
"%i", current->
id);
4571 fputs(
"</id>\n", file);
4572 fputs(
"<day_of_month_to_act>", file);
4575 fputs(
"</day_of_month_to_act>\n", file);
4576 fputs(
"<unemployment_rate>", file);
4579 fputs(
"</unemployment_rate>\n", file);
4580 fputs(
"<inflation_rate>", file);
4583 fputs(
"</inflation_rate>\n", file);
4584 fputs(
"<consumption_goods_prices>", file);
4586 fputs(
"</consumption_goods_prices>\n", file);
4587 fputs(
"<it_no>", file);
4588 sprintf(data,
"%i", current->
it_no);
4590 fputs(
"</it_no>\n", file);
4591 fputs(
"<day_of_week_to_act>", file);
4594 fputs(
"</day_of_week_to_act>\n", file);
4595 fputs(
"<goods>", file);
4597 fputs(
"</goods>\n", file);
4598 fputs(
"<weekly_price_averages>", file);
4600 fputs(
"</weekly_price_averages>\n", file);
4601 fputs(
"<day_of_month_wages_paid>", file);
4604 fputs(
"</day_of_month_wages_paid>\n", file);
4605 fputs(
"<interest_rate>", file);
4608 fputs(
"</interest_rate>\n", file);
4609 fputs(
"<liquidity>", file);
4610 sprintf(data,
"%f", current->
liquidity);
4612 fputs(
"</liquidity>\n", file);
4613 fputs(
"<loans_banks>", file);
4616 fputs(
"</loans_banks>\n", file);
4617 fputs(
"<loans_government>", file);
4620 fputs(
"</loans_government>\n", file);
4621 fputs(
"<fiat_money>", file);
4624 fputs(
"</fiat_money>\n", file);
4625 fputs(
"<equity>", file);
4626 sprintf(data,
"%f", current->
equity);
4628 fputs(
"</equity>\n", file);
4629 fputs(
"<liquidity_banks>", file);
4632 fputs(
"</liquidity_banks>\n", file);
4633 fputs(
"<liquidity_government>", file);
4636 fputs(
"</liquidity_government>\n", file);
4637 fputs(
"<liquidity_equityfund>", file);
4640 fputs(
"</liquidity_equityfund>\n", file);
4641 fputs(
"<total_assets>", file);
4644 fputs(
"</total_assets>\n", file);
4645 fputs(
"<total_writeoffs>", file);
4648 fputs(
"</total_writeoffs>\n", file);
4649 fputs(
"<interests_accrued>", file);
4652 fputs(
"</interests_accrued>\n", file);
4653 fputs(
"<revenues>", file);
4654 sprintf(data,
"%f", current->
revenues);
4656 fputs(
"</revenues>\n", file);
4657 fputs(
"<net_earnings>", file);
4660 fputs(
"</net_earnings>\n", file);
4661 fputs(
"<total_costs>", file);
4664 fputs(
"</total_costs>\n", file);
4665 fputs(
"<houses>", file);
4667 fputs(
"</houses>\n", file);
4669 fputs(
"</xagent>\n", file);
4675 fputs(
"<xagent>\n" , file);
4676 fputs(
"<name>jpoffice</name>\n", file);
4677 fputs(
"<id>", file);
4678 sprintf(data,
"%i", current->
id);
4680 fputs(
"</id>\n", file);
4681 fputs(
"<it_no>", file);
4682 sprintf(data,
"%i", current->
it_no);
4684 fputs(
"</it_no>\n", file);
4685 fputs(
"<day_of_month_to_act>", file);
4688 fputs(
"</day_of_month_to_act>\n", file);
4690 fputs(
"</xagent>\n", file);
4696 fputs(
"<xagent>\n" , file);
4697 fputs(
"<name>mall</name>\n", file);
4698 fputs(
"<id>", file);
4699 sprintf(data,
"%i", current->
id);
4701 fputs(
"</id>\n", file);
4702 fputs(
"<it_no>", file);
4703 sprintf(data,
"%i", current->
it_no);
4705 fputs(
"</it_no>\n", file);
4706 fputs(
"<day_of_week_to_act>", file);
4709 fputs(
"</day_of_week_to_act>\n", file);
4710 fputs(
"<goods_transactions>", file);
4712 fputs(
"</goods_transactions>\n", file);
4714 fputs(
"</xagent>\n", file);
4720 fputs(
"<xagent>\n" , file);
4721 fputs(
"<name>reagency</name>\n", file);
4722 fputs(
"<id>", file);
4723 sprintf(data,
"%i", current->
id);
4725 fputs(
"</id>\n", file);
4726 fputs(
"<day_of_month_to_act>", file);
4729 fputs(
"</day_of_month_to_act>\n", file);
4730 fputs(
"<it_no>", file);
4731 sprintf(data,
"%i", current->
it_no);
4733 fputs(
"</it_no>\n", file);
4734 fputs(
"<mortgages_interest_rate>", file);
4737 fputs(
"</mortgages_interest_rate>\n", file);
4738 fputs(
"<housing_transactions>", file);
4740 fputs(
"</housing_transactions>\n", file);
4742 fputs(
"</xagent>\n", file);
4752 sprintf(data,
"%s%i.xml", location, iteration_number);
4754 if((file = fopen(data,
"w"))==NULL)
4756 printf(
"Error: cannot open file '%s' for writing\n", data);
4761 fputs(
"<states>\n", file);
4764 fputs(
"<itno>", file);
4765 sprintf(data,
"%i", iteration_number);
4767 fputs(
"</itno>\n", file);
4768 fputs(
"<environment>\n" , file);
4769 fputs(
"<resume_mode>", file);
4772 fputs(
"</resume_mode>\n", file);
4773 fputs(
"<print_debug_mode>", file);
4776 fputs(
"</print_debug_mode>\n", file);
4777 fputs(
"<warning_mode>", file);
4780 fputs(
"</warning_mode>\n", file);
4781 fputs(
"<data_collection_mode>", file);
4784 fputs(
"</data_collection_mode>\n", file);
4785 fputs(
"<collect_household_data>", file);
4788 fputs(
"</collect_household_data>\n", file);
4789 fputs(
"<collect_firm_data>", file);
4792 fputs(
"</collect_firm_data>\n", file);
4793 fputs(
"<ratio_liquidity>", file);
4796 fputs(
"</ratio_liquidity>\n", file);
4797 fputs(
"<consumption_adjustment_speed>", file);
4800 fputs(
"</consumption_adjustment_speed>\n", file);
4801 fputs(
"<wealth_effect>", file);
4804 fputs(
"</wealth_effect>\n", file);
4805 fputs(
"<turnover_probability>", file);
4808 fputs(
"</turnover_probability>\n", file);
4809 fputs(
"<production_markup>", file);
4812 fputs(
"</production_markup>\n", file);
4813 fputs(
"<price_markup>", file);
4816 fputs(
"</price_markup>\n", file);
4817 fputs(
"<firm_memory_persistance>", file);
4820 fputs(
"</firm_memory_persistance>\n", file);
4821 fputs(
"<ratio_fiscal_policy>", file);
4824 fputs(
"</ratio_fiscal_policy>\n", file);
4825 fputs(
"<ratio_capitalist_households>", file);
4828 fputs(
"</ratio_capitalist_households>\n", file);
4829 fputs(
"<inflation_target>", file);
4832 fputs(
"</inflation_target>\n", file);
4833 fputs(
"<firms_minimum_equity_ratio>", file);
4836 fputs(
"</firms_minimum_equity_ratio>\n", file);
4837 fputs(
"<firm_startup_leverage>", file);
4840 fputs(
"</firm_startup_leverage>\n", file);
4841 fputs(
"<household_startup_leverage>", file);
4844 fputs(
"</household_startup_leverage>\n", file);
4845 fputs(
"<car_buffer_threshold>", file);
4848 fputs(
"</car_buffer_threshold>\n", file);
4849 fputs(
"<housing_market_entrance_prob>", file);
4852 fputs(
"</housing_market_entrance_prob>\n", file);
4853 fputs(
"<fire_sale_threshold>", file);
4856 fputs(
"</fire_sale_threshold>\n", file);
4857 fputs(
"<household_budget_constraint>", file);
4860 fputs(
"</household_budget_constraint>\n", file);
4861 fputs(
"<capital_adequecy_ratio>", file);
4864 fputs(
"</capital_adequecy_ratio>\n", file);
4865 fputs(
"<housing_price_up_rate>", file);
4868 fputs(
"</housing_price_up_rate>\n", file);
4869 fputs(
"<housing_price_down_rate>", file);
4872 fputs(
"</housing_price_down_rate>\n", file);
4873 fputs(
"<household_mortgage_writeoff_high>", file);
4876 fputs(
"</household_mortgage_writeoff_high>\n", file);
4877 fputs(
"<household_mortgage_writeoff_low>", file);
4880 fputs(
"</household_mortgage_writeoff_low>\n", file);
4881 fputs(
"</environment>\n" , file);
4984 fputs(
"</states>\n" , file);
4998 int output_types[1000];
4999 int output_type_size = 0;
5002 for(current_FLAME_output =
FLAME_outputs; current_FLAME_output != NULL; current_FLAME_output = current_FLAME_output->
next)
5005 if(iteration_number%current_FLAME_output->
period == current_FLAME_output->
phase)
5008 if(current_FLAME_output->
flag == 0)
5011 if(current_FLAME_output->
type == 0)
5014 output_types[0] = 0;
5017 current_FLAME_output->
flag = 1;
5018 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5020 if(strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5022 current_FLAME_output2->
flag = 1;
5026 if(current_FLAME_output->
type == 1)
5029 output_type_size = 0;
5030 output_types[0] = 1;
5032 current_FLAME_output->
flag = 1;
5033 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5035 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5037 output_types[++output_type_size] = current_FLAME_output2->
type;
5039 current_FLAME_output2->
flag = 1;
5044 }
if(current_FLAME_output->
type == 2)
5047 output_type_size = 0;
5048 output_types[0] = 2;
5050 current_FLAME_output->
flag = 1;
5051 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5053 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5055 output_types[++output_type_size] = current_FLAME_output2->
type;
5057 current_FLAME_output2->
flag = 1;
5062 }
if(current_FLAME_output->
type == 3)
5065 output_type_size = 0;
5066 output_types[0] = 3;
5068 current_FLAME_output->
flag = 1;
5069 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5071 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5073 output_types[++output_type_size] = current_FLAME_output2->
type;
5075 current_FLAME_output2->
flag = 1;
5080 }
if(current_FLAME_output->
type == 4)
5083 output_type_size = 0;
5084 output_types[0] = 4;
5086 current_FLAME_output->
flag = 1;
5087 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5089 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5091 output_types[++output_type_size] = current_FLAME_output2->
type;
5093 current_FLAME_output2->
flag = 1;
5098 }
if(current_FLAME_output->
type == 5)
5101 output_type_size = 0;
5102 output_types[0] = 5;
5104 current_FLAME_output->
flag = 1;
5105 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5107 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5109 output_types[++output_type_size] = current_FLAME_output2->
type;
5111 current_FLAME_output2->
flag = 1;
5116 }
if(current_FLAME_output->
type == 6)
5119 output_type_size = 0;
5120 output_types[0] = 6;
5122 current_FLAME_output->
flag = 1;
5123 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5125 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5127 output_types[++output_type_size] = current_FLAME_output2->
type;
5129 current_FLAME_output2->
flag = 1;
5134 }
if(current_FLAME_output->
type == 7)
5137 output_type_size = 0;
5138 output_types[0] = 7;
5140 current_FLAME_output->
flag = 1;
5141 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5143 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5145 output_types[++output_type_size] = current_FLAME_output2->
type;
5147 current_FLAME_output2->
flag = 1;
5152 }
if(current_FLAME_output->
type == 8)
5155 output_type_size = 0;
5156 output_types[0] = 8;
5158 current_FLAME_output->
flag = 1;
5159 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5161 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5163 output_types[++output_type_size] = current_FLAME_output2->
type;
5165 current_FLAME_output2->
flag = 1;
5170 }
if(current_FLAME_output->
type == 9)
5173 output_type_size = 0;
5174 output_types[0] = 9;
5176 current_FLAME_output->
flag = 1;
5177 for(current_FLAME_output2 =
FLAME_outputs; current_FLAME_output2 != NULL; current_FLAME_output2 = current_FLAME_output2->
next)
5179 if(current_FLAME_output2->
flag == 0 && strcmp(current_FLAME_output->
location, current_FLAME_output2->
location) == 0)
5181 output_types[++output_type_size] = current_FLAME_output2->
type;
5183 current_FLAME_output2->
flag = 1;
5193 for(current_FLAME_output =
FLAME_outputs; current_FLAME_output != NULL; current_FLAME_output = current_FLAME_output->
next)
5195 current_FLAME_output->
flag = 0;