@@ -24,48 +24,66 @@ function initialise_model(parameters::Dict{String, Any}, initial_conditions::Dic
24
24
properties = BeforeIT. init_properties (parameters, T; typeInt = typeInt, typeFloat = typeFloat)
25
25
26
26
# firms
27
- firms = BeforeIT. init_firms (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
27
+ firms, _ = BeforeIT. init_firms (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
28
28
29
29
# workers, and update firms vacancies
30
- workers_act, workers_inact, V_i_new = BeforeIT. init_workers (parameters, initial_conditions, firms; typeInt = typeInt, typeFloat = typeFloat)
30
+ workers_act, workers_inact, V_i_new, _, _ = BeforeIT. init_workers (parameters, initial_conditions, firms; typeInt = typeInt, typeFloat = typeFloat)
31
31
firms. V_i = V_i_new
32
32
33
33
# bank
34
- bank = BeforeIT. init_bank (parameters, initial_conditions, firms; typeInt = typeInt, typeFloat = typeFloat)
34
+ bank, _ = BeforeIT. init_bank (parameters, initial_conditions, firms; typeInt = typeInt, typeFloat = typeFloat)
35
35
36
36
# central bank
37
- central_bank = BeforeIT. init_central_bank (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
37
+ central_bank, _ = BeforeIT. init_central_bank (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
38
38
39
39
# government
40
- government = BeforeIT. init_government (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
40
+ government, _ = BeforeIT. init_government (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
41
41
42
42
# rest of the world
43
- rotw = BeforeIT. init_rotw (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
43
+ rotw, _ = BeforeIT. init_rotw (parameters, initial_conditions; typeInt = typeInt, typeFloat = typeFloat)
44
44
45
45
# aggregates
46
- agg = BeforeIT. init_aggregates (parameters, initial_conditions, T; typeInt = typeInt, typeFloat = typeFloat)
47
-
48
- # obtain total income by summing contributions from firm owners, workers and bank owner
49
-
50
- tot_Y_h = sum (firms. Y_h) + sum (workers_act. Y_h) + sum (workers_inact. Y_h) + bank. Y_h
51
-
52
- # uptade K_h and D_h in all agent types
53
- firms. K_h .= firms. K_h / tot_Y_h
54
- firms. D_h .= firms. D_h / tot_Y_h
55
- workers_act. K_h .= workers_act. K_h / tot_Y_h
56
- workers_act. D_h .= workers_act. D_h / tot_Y_h
57
- workers_inact. K_h .= workers_inact. K_h / tot_Y_h
58
- workers_inact. D_h .= workers_inact. D_h / tot_Y_h
59
- bank. K_h = bank. K_h / tot_Y_h
60
- bank. D_h = bank. D_h / tot_Y_h
61
-
62
- # get total deposits and update bank balance sheet
63
- tot_D_h = sum (firms. D_h) + sum (workers_act. D_h) + sum (workers_inact. D_h) + bank. D_h
64
- bank. D_k += tot_D_h
46
+ agg, _ = BeforeIT. init_aggregates (parameters, initial_conditions, T; typeInt = typeInt, typeFloat = typeFloat)
65
47
66
48
# model
67
49
model = Model (workers_act, workers_inact, firms, bank, central_bank, government, rotw, agg, properties)
68
50
51
+ # update the model with global quantities (total income, total deposits) obtained from all the agents
52
+ update_variables_with_totals! (model)
53
+
69
54
return model
70
55
71
56
end
57
+
58
+ """
59
+ update_variables_with_totals!(model::Model)
60
+
61
+ Update the variables in the given `model` with some global quantities obtained from all agents.
62
+ This is the last step in the initialization process and it must be performed after all agents have been initialized.
63
+
64
+ # Arguments
65
+ - `model::Model`: The model object to update.
66
+
67
+ # Returns
68
+ - Nothing
69
+
70
+ """
71
+ function update_variables_with_totals! (model:: Model )
72
+
73
+ # obtain total income by summing contributions from firm owners, workers and bank owner
74
+ tot_Y_h = sum (model. firms. Y_h) + sum (model. w_act. Y_h) + sum (model. w_inact. Y_h) + model. bank. Y_h
75
+
76
+ # uptade K_h and D_h in all agent types using total income
77
+ model. firms. K_h .= model. firms. K_h / tot_Y_h
78
+ model. firms. D_h .= model. firms. D_h / tot_Y_h
79
+ model. w_act. K_h .= model. w_act. K_h / tot_Y_h
80
+ model. w_act. D_h .= model. w_act. D_h / tot_Y_h
81
+ model. w_inact. K_h .= model. w_inact. K_h / tot_Y_h
82
+ model. w_inact. D_h .= model. w_inact. D_h / tot_Y_h
83
+ model. bank. K_h = model. bank. K_h / tot_Y_h
84
+ model. bank. D_h = model. bank. D_h / tot_Y_h
85
+
86
+ # get total deposits and update bank balance sheet
87
+ tot_D_h = sum (model. firms. D_h) + sum (model. w_act. D_h) + sum (model. w_inact. D_h) + model. bank. D_h
88
+ model. bank. D_k += tot_D_h
89
+ end
0 commit comments