ICEACE Model: Closed Economy  1.0.0
Design Documentation of ICEACE Model
 All Data Structures Files Functions Variables Typedefs Macros Pages
household_functions_consumption.c
Go to the documentation of this file.
1 #include "../header.h"
2 #include "../household_agent_header.h"
3 
4 /*
5  * \fn: int household_consumption_compute_budget()
6  * \brief: Household computes its regular weekly budget
7  * and its monthly consumption limit. The incomes and costs are based on
8  * a 3 months long history.
9  */
11 {
12  double disposable_income;
13  double budget;
14 
16 
17  disposable_income = LABOUR_INCOME + CAPITAL_INCOME - HOUSING_PAYMENT;
18 
19 
20  budget = disposable_income;
21  budget += CONSUMPTION_ADJUSTMENT_SPEED * (LIQUIDITY - RATIO_LIQUIDITY * disposable_income);
23 
24  if (budget < 0) {
26  } else {
27  WEEKLY_CONSUMPTION_BUDGET = budget / 12;
28  }
29 
30  MALL_BUDGET = 0;
31 
32 
33  return 0; /* Returning zero means the agent is not removed */
34 }
35 
36 /*
37  * \fn: int household_consumption_demand()
38  * \brief: The function computes actual amount of money to be spent at the mall.
39  */
41 {
43 
44  if (LIQUIDITY <= 0 ) {
45  if (PRINT_DEBUG_MODE){
46  printf("Household ID = %d has no money to go to the mall!\n", ID);
47  }
48  return 0;
49  }
50 
51  /* Below case may occur when liquidty of an household is taken down by housing expenditures, etc.
52  */
53  if (MALL_BUDGET > LIQUIDITY) {
55  if (LIQUIDITY > 0) {
57  }
58  } else {
59  if (MALL_BUDGET > 0) {
61  }
62  }
63 
64  if (PRINT_DEBUG_MODE) {
65  if (ID > 50 && ID < 60) {
66  printf("Household ID = %d goes to market with a budget = %f \n", ID, MALL_BUDGET);
67  }
68  }
69 
70  return 0; /* Returning zero means the agent is not removed */
71 }
72 
73 /*
74  * \fn: int household_consumption_recieve_goods()
75  * \brief: Household updates its post-mall planned consumption and liquidity.
76  */
78 {
79  double money_spent;
80  double total_money_spent, money_to_spend;
81  int bought, quantity_bought;
82 
83  if (PRINT_DEBUG_MODE) {
84  if (ID > 50 && ID < 60) {
85  printf("Household ID = %d waiting to receive goods from the mall. \n", ID);
86  }
87  }
88 
89  money_to_spend = MALL_BUDGET;
90  total_money_spent = 0;
91  quantity_bought = 0;
93  money_spent = bought_message->money_spent;
95  if (money_spent > 0 && bought > 0) {
96  total_money_spent += money_spent;
97  quantity_bought += bought;
98  }
100 
101  MALL_BUDGET -= total_money_spent;
102  LIQUIDITY -= total_money_spent;
103 
104  if (PRINT_DEBUG_MODE) {
105  if (ID > 50 && ID < 60) {
106  printf("Household ID = %d bought %d goods \n", ID, quantity_bought);
107  }
108  }
109 
111  char * filename;
112  FILE * file1;
113  filename = malloc(100*sizeof(char));
114  filename[0]=0;
115  strcpy(filename, "./outputs/data/Household_Weekly.txt");
116 
117  file1 = fopen(filename,"a");
118  fprintf(file1,"%d %d %f %f %f %f %d\n",IT_NO, ID, LIQUIDITY, WEEKLY_CONSUMPTION_BUDGET, money_to_spend, total_money_spent, quantity_bought);
119  fclose(file1);
120  free(filename);
121  }
122 
123  return 0; /* Returning zero means the agent is not removed */
124 }
125 
126 /*
127  * \fn: int household_consumption_trace_cpi()
128  * \brief: Household traces monthly cpi.
129  */
131 {
132  // MONTHLY_PRICE_INDEX_PRE = MONTHLY_PRICE_INDEX;
133 
137 
138  return 0; /* Returning zero means the agent is not removed */
139 }