2 #include "../household_agent_header.h"
40 int size, i, quarters_left;
54 if (principal < 0.1) {
60 if (quarters_left == 0){
61 if (principal >= 0.1) {
64 printf(
"Warning @household_credit_update_mortgage_rates(): Mortgage life is over but the debt is not finished! Household = %d, The mortgage = %f\n",
ID, principal);
82 double new_quarterly_interest;
83 double new_quarterly_principal, quarterly_principal;
88 new_quarterly_interest = 0;
89 new_quarterly_principal = 0;
92 for (i = 0; i < size; i++) {
101 quarterly_principal =
MORTGAGES_LIST.array[i].quarterly_principal;
106 d2 = d1 * pow((1 + d1), quarters_left);
107 annuity = 1/d1 - 1/d2;
108 new_quarterly_interest = principal * d1;
109 new_quarterly_principal = (principal / annuity) - new_quarterly_interest;
114 new_quarterly_principal = quarterly_principal;
118 d2 = d1 * pow((1 + d1), quarters_left);
119 annuity = 1/d1 - 1/d2;
122 new_quarterly_interest = principal * d1;
123 new_quarterly_principal = (principal / annuity) - new_quarterly_interest;
127 new_quarterly_interest = principal * rate/4;
128 new_quarterly_principal = principal / quarters_left;
132 d2 = d1 * pow((1 + d1), quarters_left);
133 annuity = 1/d1 - 1/d2;
135 new_quarterly_interest = principal * d1;
136 new_quarterly_principal = principal / annuity - new_quarterly_interest;
139 new_quarterly_interest = principal * rate/4;
140 new_quarterly_principal = quarterly_principal;
145 d2 = d1 * pow((1 + d1), quarters_left);
146 annuity = 1/d1 - 1/d2;
149 new_quarterly_principal = (principal / annuity) - (principal * rate/4);
153 printf(
"Warning @household_housing_buy(): Unexpected mortgage choice = %d \n",
MORTGAGE_CHOICE);
158 MORTGAGES_LIST.array[i].quarterly_interest = new_quarterly_interest;
159 MORTGAGES_LIST.array[i].quarterly_principal = new_quarterly_principal;
204 filename = malloc(100*
sizeof(
char));
206 strcpy(filename,
"./outputs/data/Household_Quarterly.txt");
208 file1 = fopen(filename,
"a");
209 fprintf(file1,
"%d %d %f %f %f %f %f %f %f %f %f\n",
IT_NO,
ID,
TOTAL_ASSETS,
LIQUIDITY,
HOUSING_VALUE,
LABOUR_INCOME,
GOVERNMENT_BENEFITS, CAPITAL_INCOME, MORTGAGES,
HOUSING_PAYMENT,
EQUITY);
226 double general_benefit = 0;
234 double unemployment_benefit = 0;
252 filename = malloc(100*
sizeof(
char));
254 strcpy(filename,
"./outputs/data/Household_Monthly_LastDay.txt");
255 file1 = fopen(filename,
"a");