From f814c15e4eb58ce17b7f5033e445f2a3cb5b6c50 Mon Sep 17 00:00:00 2001 From: Tortar Date: Sat, 26 Oct 2024 21:54:30 +0200 Subject: [PATCH 1/6] Improve speed of simulations --- src/markets/search_and_matching.jl | 99 +++++++++++++++--------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/src/markets/search_and_matching.jl b/src/markets/search_and_matching.jl index 6a88d23..f87339c 100644 --- a/src/markets/search_and_matching.jl +++ b/src/markets/search_and_matching.jl @@ -196,22 +196,22 @@ function update_aggregate_variables!( gov.P_j = sum(P_j_g) rotw.P_l = sum(P_l_g) - P_CF_i[I_i .> 0] .= P_CF_i[I_i .> 0] ./ I_i[I_i .> 0] - P_bar_i[DM_i .> 0] .= P_bar_i[DM_i .> 0] ./ DM_i[DM_i .> 0] + P_CF_i[I_i .> 0] .= @view(P_CF_i[I_i .> 0]) ./ @view(I_i[I_i .> 0]) + P_bar_i[DM_i .> 0] .= @view(P_bar_i[DM_i .> 0]) ./ @view(DM_i[DM_i .> 0]) agg.P_bar_h = sum(C_h) / agg.P_bar_h agg.P_bar_CF_h = sum(I_h) / agg.P_bar_CF_h gov.P_j = gov.C_j / gov.P_j rotw.P_l = rotw.C_l / rotw.P_l - w_act.C_h .= C_h[1:H_W] - w_inact.C_h .= C_h[(H_W + 1):(H_W + H_inact)] - firms.C_h .= C_h[(H_W + H_inact + 1):(H_W + H_inact + I)] + w_act.C_h .= @view(C_h[1:H_W]) + w_inact.C_h .= @view(C_h[(H_W + 1):(H_W + H_inact)]) + firms.C_h .= @view(C_h[(H_W + H_inact + 1):(H_W + H_inact + I)]) bank.C_h = C_h[H] - w_act.I_h .= I_h[1:H_W] - w_inact.I_h .= I_h[(H_W + 1):(H_W + H_inact)] - firms.I_h .= I_h[(H_W + H_inact + 1):(H_W + H_inact + I)] + w_act.I_h .= @view(I_h[1:H_W]) + w_inact.I_h .= @view(I_h[(H_W + 1):(H_W + H_inact)]) + firms.I_h .= @view(I_h[(H_W + H_inact + 1):(H_W + H_inact + I)]) bank.I_h = I_h[H] rotw.Q_d_m .= Q_d_m @@ -345,8 +345,8 @@ function perform_firms_market!( ############################## ######## FIRMS MARKET ######## ############################## - - DM_d_ig = a_sg[g, firms.G_i] .* firms.DM_d_i + b_CF_g[g] .* firms.I_d_i + + DM_d_ig = @view(a_sg[g, firms.G_i]) .* firms.DM_d_i + b_CF_g[g] .* firms.I_d_i DM_nominal_ig = zeros(size(DM_d_ig)) # firms that have demand for good "g" participate as buyers @@ -354,7 +354,7 @@ function perform_firms_market!( # remove firms that have no stock of good "g" #F_g[S_fg[F_g] .<= 0] .= [] - to_delete = findall(S_fg[F_g] .<= 0) + to_delete = findall(@view(S_fg[F_g]) .<= 0) deleteat!(F_g, to_delete) # continue exchanges until either demand or supply terminates @@ -362,10 +362,10 @@ function perform_firms_market!( while length(I_g) != 0 && length(F_g) != 0 # price probability of being selected - pr_price_f = pos(exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) + pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) # size probability of being selected - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) # total probabilities of being selected pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) @@ -384,20 +384,21 @@ function perform_firms_market!( # selected firm has sufficient stock if S_fg[f] > DM_d_ig[i] S_fg[f] -= DM_d_ig[i] - DM_nominal_ig[i] += DM_d_ig[i] .* P_f[f] + DM_nominal_ig[i] += DM_d_ig[i] .* @view(P_f[f]) DM_d_ig[i] = 0 else DM_d_ig[i] -= S_fg[f] - DM_nominal_ig[i] += S_fg[f] .* P_f[f] + DM_nominal_ig[i] += @view(S_fg[f]) .* @view(P_f[f]) S_fg[f] = 0 F_g = deleteat!(F_g, e) if isempty(F_g) break end - pr_price_f = pos(exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + + pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) end end @@ -410,12 +411,12 @@ function perform_firms_market!( I_g = findall(DM_d_ig_ .> 0) F_g = findall(G_f .== g) - to_delete = findall((S_fg_[F_g] .<= 0.0) .|| (S_f[F_g] .<= 0.0)) + to_delete = findall((@view(S_fg_[F_g]) .<= 0.0) .|| (@view(S_f[F_g]) .<= 0.0)) deleteat!(F_g, to_delete) while !isempty(I_g) && !isempty(F_g) - pr_price_f = pos(exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) # I_g = I_g[randperm(length(I_g))] @@ -438,8 +439,8 @@ function perform_firms_market!( if isempty(F_g) break end - pr_price_f = pos(exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) end end @@ -447,18 +448,18 @@ function perform_firms_market!( end end - DM_i_g[g, :] .= a_sg[g, firms.G_i] .* firms.DM_d_i .- pos(DM_d_ig .- b_CF_g[g] .* firms.I_d_i) + DM_i_g[g, :] .= @view(a_sg[g, firms.G_i]) .* firms.DM_d_i .- pos(DM_d_ig .- b_CF_g[g] .* firms.I_d_i) I_i_g[g, :] .= pos(b_CF_g[g] .* firms.I_d_i .- DM_d_ig) P_bar_i_g[g, :] .= pos( - DM_nominal_ig .* (a_sg[g, firms.G_i] .* firms.DM_d_i .- pos(DM_d_ig .- b_CF_g[g] .* firms.I_d_i)) ./ - (a_sg[g, firms.G_i] .* firms.DM_d_i .+ b_CF_g[g] .* firms.I_d_i .- DM_d_ig), + DM_nominal_ig .* (@view(a_sg[g, firms.G_i]) .* firms.DM_d_i .- pos(DM_d_ig .- b_CF_g[g] .* firms.I_d_i)) ./ + (@view(a_sg[g, firms.G_i]) .* firms.DM_d_i .+ b_CF_g[g] .* firms.I_d_i .- DM_d_ig), ) P_CF_i_g[g, :] .= pos( DM_nominal_ig .* pos(b_CF_g[g] .* firms.I_d_i .- DM_d_ig) ./ - (a_sg[g, firms.G_i] .* firms.DM_d_i .+ b_CF_g[g] .* firms.I_d_i .- DM_d_ig), + (@view(a_sg[g, firms.G_i]) .* firms.DM_d_i .+ b_CF_g[g] .* firms.I_d_i .- DM_d_ig), ) end @@ -508,13 +509,13 @@ function perform_retail_market!( C_real_hg = zeros(size(C_d_hg)) H_g = findall(C_d_hg .> 0.0) - to_delete = findall(S_fg[F_g] .<= 0) + to_delete = findall(@view(S_fg[F_g]) .<= 0) deleteat!(F_g, to_delete) while !isempty(H_g) && !isempty(F_g) - pr_price_f = pos(exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) shuffle!(H_g) @@ -536,8 +537,8 @@ function perform_retail_market!( if isempty(F_g) break end - pr_price_f = pos(exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) end end @@ -548,10 +549,10 @@ function perform_retail_market!( C_d_hg_ = copy(C_d_hg) H_g = findall(C_d_hg_ .> 0) F_g = findall(G_f .== g) - F_g = F_g[(S_fg_[F_g] .> 0) .& (S_f[F_g] .> 0)] + F_g = F_g[(@view(S_fg_[F_g]) .> 0) .& (@view(S_f[F_g]) .> 0)] while !isempty(H_g) && !isempty(F_g) - pr_price_f = pos(exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) H_g = shuffle(H_g) @@ -572,9 +573,9 @@ function perform_retail_market!( if isempty(F_g) break end - pr_price_f = max.(0, exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* P_f[F_g]))) + pr_price_f = max.(0, exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) pr_price_f[isnan.(pr_price_f)] .= 0.0 - pr_size_f = S_f[F_g] ./ sum(S_f[F_g]) + pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) end @@ -583,27 +584,27 @@ function perform_retail_market!( end end - Q_d_i_g[g, :] .= S_f[1:I] .- S_fg[1:I] - Q_d_m_g[g, :] .= S_f[(I + 1):end] .- S_fg[(I + 1):end] + Q_d_i_g[g, :] .= @view(S_f[1:I]) .- @view(S_fg[1:I]) + Q_d_m_g[g, :] .= @view(S_f[(I + 1):end]) .- @view(S_fg[(I + 1):end]) - C_h_g[g, :] .= b_HH_g[g] .* C_d_h .- pos(C_d_hg[1:H] .- b_CFH_g[g] .* I_d_h) - I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- view(C_d_hg, 1:H)) #I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- C_d_hg[1:H]) + C_h_g[g, :] .= b_HH_g[g] .* C_d_h .- pos(@view(C_d_hg[1:H]) .- b_CFH_g[g] .* I_d_h) + I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H])) #I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- C_d_hg[1:H]) - C_j_g[g] = sum(c_G_g[g] .* gov.C_d_j) - sum(C_d_hg[(H + L + 1):(H + L + J)]) - C_l_g[g] = sum(c_E_g[g] .* rotw.C_d_l) - sum(C_d_hg[(H + 1):(H + L)]) + C_j_g[g] = sum(c_G_g[g] .* gov.C_d_j) - sum(@view(C_d_hg[(H + L + 1):(H + L + J)])) + C_l_g[g] = sum(c_E_g[g] .* rotw.C_d_l) - sum(@view(C_d_hg[(H + 1):(H + L)])) - a = sum(C_real_hg[1:H]) - b = sum(C_d_h .* b_HH_g[g] .- pos(view(C_d_hg, 1:H) .- b_CFH_g[g] .* I_d_h)) # b = sum(C_d_h .* b_HH_g[g] .- pos(C_d_hg[1:H] .- b_CFH_g[g] .* I_d_h)) # OLD - c = sum((C_d_h .* b_HH_g[g] .+ b_CFH_g[g] .* I_d_h .- C_d_hg[1:H])) + a = sum(@view(C_real_hg[1:H])) + b = sum(C_d_h .* b_HH_g[g] .- pos(@view(C_d_hg[1:H]) .- b_CFH_g[g] .* I_d_h)) # b = sum(C_d_h .* b_HH_g[g] .- pos(C_d_hg[1:H] .- b_CFH_g[g] .* I_d_h)) # OLD + c = sum((C_d_h .* b_HH_g[g] .+ b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H]))) P_bar_h_g[g] = pos(a * b / c) P_bar_CF_h_g[g] = pos( - sum(C_real_hg[1:H]) * sum(pos(b_CFH_g[g] .* I_d_h .- C_d_hg[1:H])) / - sum((C_d_h .* b_HH_g[g] .+ b_CFH_g[g] .* I_d_h .- C_d_hg[1:H])), + sum(@view(C_real_hg[1:H])) * sum(pos(b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H]))) / + sum((C_d_h .* b_HH_g[g] .+ b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H]))), ) - P_j_g[g] = sum(C_real_hg[(H + L + 1):(H + L + J)]) - P_l_g[g] = sum(C_real_hg[(H + 1):(H + L)]) + P_j_g[g] = sum(@view(C_real_hg[(H + L + 1):(H + L + J)])) + P_l_g[g] = sum(@view(C_real_hg[(H + 1):(H + L)])) end From 121a2bdb5ac7009ebeeee6ab1f5b9cc97a54b5ba Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Sun, 27 Oct 2024 20:19:51 +0100 Subject: [PATCH 2/6] Some more improvements --- src/markets/search_and_matching.jl | 31 ++++++++---------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/markets/search_and_matching.jl b/src/markets/search_and_matching.jl index f87339c..8f8f513 100644 --- a/src/markets/search_and_matching.jl +++ b/src/markets/search_and_matching.jl @@ -366,10 +366,9 @@ function perform_firms_market!( # size probability of being selected pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) - # total probabilities of being selected + # total probabilities of being selected pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) - #pr_cum_f = [0; cumsum(pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)] # select buyers at random shuffle!(I_g) @@ -378,7 +377,6 @@ function perform_firms_market!( # select a random firm according to the probabilities e = wsample(1:length(F_g), pr_cum_f_) - #e = randf(pr_cum_f) f = F_g[e] # selected firm has sufficient stock @@ -386,17 +384,12 @@ function perform_firms_market!( S_fg[f] -= DM_d_ig[i] DM_nominal_ig[i] += DM_d_ig[i] .* @view(P_f[f]) DM_d_ig[i] = 0 - else DM_d_ig[i] -= S_fg[f] DM_nominal_ig[i] += @view(S_fg[f]) .* @view(P_f[f]) S_fg[f] = 0 - F_g = deleteat!(F_g, e) - - if isempty(F_g) - break - end - + deleteat!(F_g, e) + isempty(F_g) && break pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) @@ -405,7 +398,6 @@ function perform_firms_market!( I_g = findall(DM_d_ig .> 0) end - if !isempty(I_g) DM_d_ig_ = copy(DM_d_ig) I_g = findall(DM_d_ig_ .> 0) @@ -419,7 +411,6 @@ function perform_firms_market!( pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) - # I_g = I_g[randperm(length(I_g))] shuffle!(I_g) for j in eachindex(I_g) i = I_g[j] @@ -436,9 +427,7 @@ function perform_firms_market!( S_fg[f] -= S_fg_[f] S_fg_[f] = 0 deleteat!(F_g, e) - if isempty(F_g) - break - end + isempty(F_g) && break pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) @@ -533,10 +522,8 @@ function perform_retail_market!( C_d_hg[h] -= S_fg[f] * P_f[f] C_real_hg[h] += S_fg[f] S_fg[f] = 0 - F_g = F_g[setdiff(1:end, e)] - if isempty(F_g) - break - end + deleteat!(F_g, e) + isempty(F_g) && break pr_price_f = pos(exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) pr_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f) @@ -569,10 +556,8 @@ function perform_retail_market!( C_d_hg_[h] -= S_fg_[f] * P_f[f] S_fg[f] -= S_fg_[f] S_fg_[f] = 0 - F_g = deleteat!(F_g, e) - if isempty(F_g) - break - end + deleteat!(F_g, e) + isempty(F_g) && break pr_price_f = max.(0, exp.(-2 .* @view(P_f[F_g])) ./ sum(exp.(-2 .* @view(P_f[F_g])))) pr_price_f[isnan.(pr_price_f)] .= 0.0 pr_size_f = @view(S_f[F_g]) ./ sum(@view(S_f[F_g])) From 249c2335780446e0cec651c8d428a0a66b5a3370 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Thu, 31 Oct 2024 02:58:25 +0100 Subject: [PATCH 3/6] Update search_and_matching_credit.jl --- src/markets/search_and_matching_credit.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/markets/search_and_matching_credit.jl b/src/markets/search_and_matching_credit.jl index f58e443..0dcda9a 100644 --- a/src/markets/search_and_matching_credit.jl +++ b/src/markets/search_and_matching_credit.jl @@ -24,7 +24,7 @@ function search_and_matching_credit(firms::AbstractFirms, model) shuffle!(I_FG) for f in eachindex(I_FG) i = I_FG[f] - DL_i[i] = max(0, min(min(DL_d_i[i], zeta_LTV * K_e_i[i] - L_e_i[i]), E_k / zeta - sum(L_e_i .+ DL_i))) + DL_i[i] = max(0, min(min(DL_d_i[i], zeta_LTV * K_e_i[i] - L_e_i[i]), E_k / zeta - (sum(L_e_i) + sum(DL_i)))) end return DL_i end From ecb159f5d9a34d163d7be99cd614b900e8184cc9 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:40:09 +0100 Subject: [PATCH 4/6] Update search_and_matching.jl --- src/markets/search_and_matching.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/markets/search_and_matching.jl b/src/markets/search_and_matching.jl index 8f8f513..f90284e 100644 --- a/src/markets/search_and_matching.jl +++ b/src/markets/search_and_matching.jl @@ -573,13 +573,13 @@ function perform_retail_market!( Q_d_m_g[g, :] .= @view(S_f[(I + 1):end]) .- @view(S_fg[(I + 1):end]) C_h_g[g, :] .= b_HH_g[g] .* C_d_h .- pos(@view(C_d_hg[1:H]) .- b_CFH_g[g] .* I_d_h) - I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H])) #I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- C_d_hg[1:H]) + I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H])) - C_j_g[g] = sum(c_G_g[g] .* gov.C_d_j) - sum(@view(C_d_hg[(H + L + 1):(H + L + J)])) - C_l_g[g] = sum(c_E_g[g] .* rotw.C_d_l) - sum(@view(C_d_hg[(H + 1):(H + L)])) + C_j_g[g] = dot(c_G_g[g], gov.C_d_j) - sum(@view(C_d_hg[(H + L + 1):(H + L + J)])) + C_l_g[g] = dot(c_E_g[g], rotw.C_d_l) - sum(@view(C_d_hg[(H + 1):(H + L)])) a = sum(@view(C_real_hg[1:H])) - b = sum(C_d_h .* b_HH_g[g] .- pos(@view(C_d_hg[1:H]) .- b_CFH_g[g] .* I_d_h)) # b = sum(C_d_h .* b_HH_g[g] .- pos(C_d_hg[1:H] .- b_CFH_g[g] .* I_d_h)) # OLD + b = sum(C_d_h .* b_HH_g[g] .- pos(@view(C_d_hg[1:H]) .- b_CFH_g[g] .* I_d_h)) c = sum((C_d_h .* b_HH_g[g] .+ b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H]))) P_bar_h_g[g] = pos(a * b / c) From 70bd3c84c70830accd1aa7b1f35975c2d18a5d3c Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:41:31 +0100 Subject: [PATCH 5/6] Update BeforeIT.jl --- src/BeforeIT.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BeforeIT.jl b/src/BeforeIT.jl index b973393..c7ff7aa 100644 --- a/src/BeforeIT.jl +++ b/src/BeforeIT.jl @@ -1,5 +1,6 @@ module BeforeIT +using LinearAlgebra using Random using StatsBase import Base: length From 7b613a19e4b2ea993fd56cf9966ebfc7b5578190 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:45:31 +0100 Subject: [PATCH 6/6] Update search_and_matching.jl --- src/markets/search_and_matching.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/markets/search_and_matching.jl b/src/markets/search_and_matching.jl index f90284e..61b335e 100644 --- a/src/markets/search_and_matching.jl +++ b/src/markets/search_and_matching.jl @@ -575,8 +575,8 @@ function perform_retail_market!( C_h_g[g, :] .= b_HH_g[g] .* C_d_h .- pos(@view(C_d_hg[1:H]) .- b_CFH_g[g] .* I_d_h) I_h_g[g, :] .= pos(b_CFH_g[g] .* I_d_h .- @view(C_d_hg[1:H])) - C_j_g[g] = dot(c_G_g[g], gov.C_d_j) - sum(@view(C_d_hg[(H + L + 1):(H + L + J)])) - C_l_g[g] = dot(c_E_g[g], rotw.C_d_l) - sum(@view(C_d_hg[(H + 1):(H + L)])) + C_j_g[g] = sum(c_G_g[g] .* gov.C_d_j) - sum(@view(C_d_hg[(H + L + 1):(H + L + J)])) + C_l_g[g] = sum(c_E_g[g] .* rotw.C_d_l) - sum(@view(C_d_hg[(H + 1):(H + L)])) a = sum(@view(C_real_hg[1:H])) b = sum(C_d_h .* b_HH_g[g] .- pos(@view(C_d_hg[1:H]) .- b_CFH_g[g] .* I_d_h))