Skip to content

Commit

Permalink
Some refactoring of market functions (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Nov 30, 2024
1 parent ba76276 commit 0efdc25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
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

0 comments on commit 0efdc25

Please sign in to comment.