ICEACE Model: Closed Economy  1.0.0
Design Documentation of ICEACE Model
 All Data Structures Files Functions Variables Typedefs Macros Pages
firm_functions_housing.c
Go to the documentation of this file.
1 #include "../header.h"
2 #include "../firm_agent_header.h"
3 #include "../library_header.h"
4 
5 /*
6  * \fn: int firm_housing_enter_market()
7  * \brief: The construction firm enters the market buy number housing inventory
8  * and a stochastically determined price increase.
9  */
11 {
12  double price_difference, price;
13 
14  int i = 1;
15  while (i <= INVENTORY) {
16  price_difference = (((double)random_int(0, 100)) / 100.0) * HOUSING_PRICE_UP_RATE;
17  price = UNIT_HOUSE_PRICE * (1 + price_difference);
18  add_sell_housing_message(ID, price, 1, 0);
19  i++;
20  }
21 
22  if (PRINT_DEBUG_MODE) {
23  printf("Firm ID = %d goes to housing market with %d housing units to sell. \n", ID, INVENTORY);
24  }
25  return 0; /* Returning zero means the agent is not removed */
26 }
27 /*
28  * \fn: int firm_housing_collect_sale_revenues()
29  * \brief: The contructor firm checks its ID from the message board and
30  * updates its inventory, revenue, sales and liquidity when monthly
31  * housing markets is closed.
32  */
34 {
35  int n_sold_units = 0;
36  int total_sold = 0;
37  double sale_unit_price, sales_income;
38 
39 
41  /* The message is filtered via xmml. */
42  n_sold_units = sold_housing_message->quantity_sold;
43  sale_unit_price = sold_housing_message->price_sold;
44 
45  /* Updating inventory. */
46  INVENTORY -= n_sold_units;
47  total_sold += n_sold_units;
48 
49  /* Updating sales. */
50  SALES += n_sold_units;
51 
52  /* Updating revenue and liquidity */
53  sales_income = n_sold_units * sale_unit_price;
54  LIQUIDITY += sales_income;
55  REVENUES += sales_income;
56 
58 
59  if (PRINT_DEBUG_MODE) {
60  printf("Firm ID = %d has sold %d housing units at this round. \n", ID, total_sold);
61  }
62 
63  return 0; /* Returning zero means the agent is not removed */
64 }
65 
66 
67 /*
68  * \fn: int firm_housing_update_market_price()
69  * \brief: The construction firm updated unit housing price based on
70  * recieved average market price.
71  */
73 {
74  double oldprice;
75 
76  oldprice = UNIT_HOUSE_PRICE;
80  DELTA_HOUSING_PRICE = UNIT_HOUSE_PRICE - oldprice;
81  return 0; /* Returning zero means the agent is not removed */
82 }
83