Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some refactoring of market functions #36

Merged
merged 4 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/markets/search_and_matching_credit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ function search_and_matching_credit(firms::AbstractFirms, model)
DL_i = zeros(size(DL_d_i))
I_FG = findall(DL_d_i .> 0)
shuffle!(I_FG)
s_L_e_i = sum(L_e_i)
for i in I_FG
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))))
DL_i[i] = max(0.0, min(DL_d_i[i], zeta_LTV * K_e_i[i] - L_e_i[i], E_k / zeta - s_L_e_i - sum(DL_i)))
end
return DL_i
end
7 changes: 2 additions & 5 deletions src/markets/search_and_matching_labour.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ function search_and_matching_labour(firms::AbstractFirms, model)
shuffle!(H_E)

# fire workers if vacancies are negative
for e in eachindex(H_E)
for h in H_E

# find employer of worker
h = H_E[e]
i = O_h[h]

# if employer has negative vacancies, fire the worker
Expand All @@ -53,9 +52,7 @@ function search_and_matching_labour(firms::AbstractFirms, model)
# while there are no more vacancies or unemployed workers
while !isempty(H_U) && !isempty(I_V)
shuffle!(I_V)
for f in eachindex(I_V)
# select random vacancy
i = I_V[f]
for i in I_V
# select random unemployed worker
h = H_U[1]
# employ worker
Expand Down
2 changes: 1 addition & 1 deletion test/deterministic/make_model_deterministic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end
function rand(s::DynamicSampler)
idx = minimum(minimum.(s.level_buckets; init=typemax(Int)))
weight = s.weights[idx]
level = ceil(Int, log2(weight)) - first(s.level_inds) + 1
level = ceil(Int, log2(weight)) - s.info.level_min + 1
idx_in_level = findfirst(x -> x == idx, s.level_buckets[level])
return idx
end
Expand Down
Loading