From 7fff430a9e1933bd864fb9ad3724315c43f1e33f Mon Sep 17 00:00:00 2001 From: Aldo Date: Thu, 23 May 2024 16:50:54 +0200 Subject: [PATCH] refactor: remove Standard from standard agent structs --- src/model_init/abstract.jl | 1 - src/model_init/agents.jl | 32 ++++++++++++++++---------------- src/model_init/init.jl | 16 ++++++++-------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/model_init/abstract.jl b/src/model_init/abstract.jl index b918370..a3ec1c6 100644 --- a/src/model_init/abstract.jl +++ b/src/model_init/abstract.jl @@ -3,7 +3,6 @@ export AbstractBank, AbstractFirms, AbstractGovernment, AbstractRestOfTheWorld, - AbstractRestOfTheWorld, AbstractWorkers, @worker, @firm, diff --git a/src/model_init/agents.jl b/src/model_init/agents.jl index 3f2590f..af6c9b0 100644 --- a/src/model_init/agents.jl +++ b/src/model_init/agents.jl @@ -1,10 +1,10 @@ -export StandardWorkers, - StandardFirms, - StandardBank, - StandardCentralBank, - StandardGovernment, - StandardRestOfTheWorld, - StandardAggregates, +export Workers, + Firms, + Bank, + CentralBank, + Government, + RestOfTheWorld, + Aggregates, Model include("abstract.jl") """ @@ -24,7 +24,7 @@ For all fields the entry at index `i` corresponds to the `i`th worker. - `C_h`: Realised consumption - `I_h`: Realised investment """ -struct StandardWorkers{T <: AbstractVector, I <: AbstractVector} <: AbstractWorkers +struct Workers{T <: AbstractVector, I <: AbstractVector} <: AbstractWorkers @worker T I end @@ -82,7 +82,7 @@ For all fields the entry at index `i` corresponds to the `i`th firm. - `K_h`: Capital stock - `D_h`: Deposits of the owner of the firms """ -mutable struct StandardFirms{T <: AbstractVector, I <: AbstractVector} <: AbstractFirms +mutable struct Firms{T <: AbstractVector, I <: AbstractVector} <: AbstractFirms @firm T I end @@ -106,7 +106,7 @@ This is a Bank type. It represents the bank of the model. - `D_h`: Deposits """ -mutable struct StandardBank{P} <: AbstractBank +mutable struct Bank{P} <: AbstractBank @bank P end @@ -124,7 +124,7 @@ This is a CentralBank type. It represents the central bank of the model. - `xi_gamma`: Weight placed on economic - `E_CB`: Central bank equity """ -mutable struct StandardCentralBank{T} <: AbstractCentralBank +mutable struct CentralBank{T} <: AbstractCentralBank @centralBank T end @@ -145,7 +145,7 @@ This is a Government type. It represents the government of the model. - `C_j`: Realised government consumption - `P_j`: Price inflation of government goods <- ?? """ -mutable struct StandardGovernment{T} <: AbstractGovernment +mutable struct Government{T} <: AbstractGovernment @government T end @@ -180,7 +180,7 @@ This is a RestOfTheWorld type. It represents the rest of the world of the model. - `P_m [vector]`: Price of imports per sector - `P_l`: Price inflation of exports <- ?? """ -mutable struct StandardRestOfTheWorld{T} <: AbstractRestOfTheWorld +mutable struct RestOfTheWorld{T} <: AbstractRestOfTheWorld @restOfTheWorld T end @@ -205,7 +205,7 @@ Note that `t` is an integer, while the rest are floats or vectors of floats. - `t`: Time index """ -mutable struct StandardAggregates{T, I} +mutable struct Aggregates{T, I} @aggregates T I end @@ -229,8 +229,8 @@ mutable struct Model bank::AbstractBank cb::AbstractCentralBank gov::AbstractGovernment - rotw::StandardRestOfTheWorld - agg::StandardAggregates + rotw::AbstractRestOfTheWorld + agg::Aggregates prop::Any end diff --git a/src/model_init/init.jl b/src/model_init/init.jl index 578b51c..8e6dae1 100644 --- a/src/model_init/init.jl +++ b/src/model_init/init.jl @@ -293,7 +293,7 @@ function initialise_model(parameters, initial_conditions, T, typeInt = Int64, ty N_d_i = zeros(typeInt, I) Pi_e_i = zeros(typeFloat, I) - firms = StandardFirms( + firms = Firms( G_i, alpha_bar_i, beta_i, @@ -346,7 +346,7 @@ function initialise_model(parameters, initial_conditions, T, typeInt = Int64, ty C_h = zeros(typeFloat, length(ids)) I_h = zeros(typeFloat, length(ids)) # active workers (both employed and unemployed) - workers_act = StandardWorkers(Y_h[1:H_W], D_h[1:H_W], K_h[1:H_W], w_h[1:H_W], O_h[1:H_W], C_d_h, I_d_h, C_h, I_h) + workers_act = Workers(Y_h[1:H_W], D_h[1:H_W], K_h[1:H_W], w_h[1:H_W], O_h[1:H_W], C_d_h, I_d_h, C_h, I_h) # inactive workers ids = Vector{typeInt}((I + H_W + 1):(I + H_W + H_inact)) @@ -356,7 +356,7 @@ function initialise_model(parameters, initial_conditions, T, typeInt = Int64, ty I_d_h = zeros(typeFloat, length(ids)) C_h = zeros(typeFloat, length(ids)) I_h = zeros(typeFloat, length(ids)) - workers_inact = StandardWorkers( + workers_inact = Workers( Y_h[(H_W + 1):(H_W + H_inact)], D_h[(H_W + 1):(H_W + H_inact)], K_h[(H_W + 1):(H_W + H_inact)], @@ -377,10 +377,10 @@ function initialise_model(parameters, initial_conditions, T, typeInt = Int64, ty K_h = K_h[H_W + H_inact + I + 1] D_h = D_h[H_W + H_inact + I + 1] Pi_e_k = typeFloat(0.0) - bank = StandardBank(E_k, Pi_k, Pi_e_k, D_k, r, Y_h_k, C_d_h, I_d_h, C_h, I_h, K_h, D_h) + bank = Bank(E_k, Pi_k, Pi_e_k, D_k, r, Y_h_k, C_d_h, I_d_h, C_h, I_h, K_h, D_h) id = typeInt(I + H_W + H_inact + 2) - central_bank = StandardCentralBank(r_bar, r_G, rho, r_star, pi_star, xi_pi, xi_gamma, E_CB) + central_bank = CentralBank(r_bar, r_G, rho, r_star, pi_star, xi_pi, xi_gamma, E_CB) id = typeInt(I + H_W + H_inact + 3) C_d_j = Vector{typeFloat}(zeros(J)) @@ -388,7 +388,7 @@ function initialise_model(parameters, initial_conditions, T, typeInt = Int64, ty P_j = zero(typeFloat) Y_G = zero(typeFloat) government = - StandardGovernment(alpha_G, beta_G, sigma_G, Y_G, C_G[T_prime], L_G, sb_inact, sb_other, C_d_j, C_j, P_j) + Government(alpha_G, beta_G, sigma_G, Y_G, C_G[T_prime], L_G, sb_inact, sb_other, C_d_j, C_j, P_j) id = typeInt(I + H_W + H_inact + 4) C_d_l = Vector{typeFloat}(zeros(L)) @@ -398,7 +398,7 @@ function initialise_model(parameters, initial_conditions, T, typeInt = Int64, ty Q_m = Vector{typeFloat}(zeros(G)) Q_d_m = Vector{typeFloat}(zeros(G)) P_m = Vector{typeFloat}(zeros(G)) - rotw = StandardRestOfTheWorld( + rotw = RestOfTheWorld( alpha_E, beta_E, sigma_E, @@ -435,7 +435,7 @@ function initialise_model(parameters, initial_conditions, T, typeInt = Int64, ty epsilon_Y_EA = zero(typeFloat) epsilon_E = zero(typeFloat) epsilon_I = zero(typeFloat) - agg = StandardAggregates( + agg = Aggregates( Y, pi_, P_bar,