ICEACE Model: Closed Economy
1.0.0
Design Documentation of ICEACE Model
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
IceaceModel1.0
Market_Consumption
firm_functions_consumption.c
Go to the documentation of this file.
1
#include "../header.h"
2
#include "../firm_agent_header.h"
3
4
/*
5
* \fn: int firm_consumption_supply()
6
* \brief:
7
*/
8
int
firm_consumption_supply
()
9
{
10
11
if
(
UNIT_GOODS_PRICE
== 0) {
12
return
0;
13
}
14
if
(
INVENTORY
> 0 &&
UNIT_GOODS_PRICE
> 0) {
15
add_sell_message
(
ID
,
UNIT_GOODS_PRICE
,
INVENTORY
);
16
if
(
PRINT_DEBUG_MODE
) {
17
printf(
"Firm Id = %d Sends = %d Goods to Mall with a price = %f\n"
,
ID
,
INVENTORY
,
UNIT_GOODS_PRICE
);
18
}
19
}
20
21
return
0;
/* Returning zero means the agent is not removed */
22
}
23
24
/*
25
* \fn: int firm_consumption_recieve_sales()
26
* \brief:
27
*/
28
int
firm_consumption_receive_sales
()
29
{
30
int
quantity_sold = 0;
31
double
weekly_sales_income = 0;
32
33
START_SOLD_MESSAGE_LOOP
34
quantity_sold +=
sold_message
->
sold_quantities
;
35
FINISH_SOLD_MESSAGE_LOOP
36
weekly_sales_income = quantity_sold *
UNIT_GOODS_PRICE
;
37
/* Updating the inventory. */
38
INVENTORY
-= quantity_sold;
39
if
(
INVENTORY
< 0){
40
if
(
WARNING_MODE
) {
41
printf(
"Warning @firm_consumption_receive_sales(): More than available goods were sold Firm ID = %d, Inventory =%d \n"
,
ID
,
INVENTORY
);
42
}
43
INVENTORY
= 0;
44
}
45
46
/* Updating the sales. */
47
SALES
+= quantity_sold;
48
LIQUIDITY
+= weekly_sales_income;
49
REVENUES
+= weekly_sales_income;
50
51
if
(
PRINT_DEBUG_MODE
) {
52
printf(
"Firm ID = %d Quantity Sold = %d Weekly Revenue = %f\n"
,
ID
, quantity_sold, weekly_sales_income);
53
}
54
55
56
return
0;
/* Returning zero means the agent is not removed */
57
}
58
59
/*
60
* \fn: int firm_consumption_update_market_price()
61
* \brief: The producer firm gets average market price per good.
62
*/
63
int
firm_consumption_update_market_price
()
64
{
65
if
(
PRINT_DEBUG_MODE
) {
66
printf(
"Firm ID = %d checks average goods price at the market\n"
,
ID
);
67
}
68
69
START_GOODS_TRANSACTIONS_SUMMARY_MESSAGE_LOOP
70
AVERAGE_GOODS_PRICE
=
goods_transactions_summary_message
->
avg_price
;
71
FINISH_GOODS_TRANSACTIONS_SUMMARY_MESSAGE_LOOP
72
73
74
return
0;
/* Returning zero means the agent is not removed */
75
}
Generated on Tue Apr 8 2014 13:25:19 for ICEACE Model: Closed Economy by
1.8.3.1