Skip to content

Commit

Permalink
Update search_and_matching.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Oct 28, 2024
1 parent a8e9d19 commit f1c0e96
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/markets/search_and_matching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function perform_firms_market!(
pr_size_f = S_f[F_g] ./ sum(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)
pr_cum_f_ = 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
Expand Down Expand Up @@ -398,7 +398,7 @@ function perform_firms_market!(
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_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)
pr_cum_f_ = pr_price_f + pr_size_f
end
end
I_g = findall(DM_d_ig .> 0)
Expand All @@ -416,7 +416,7 @@ function perform_firms_market!(
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_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)
pr_cum_f_ = pr_price_f + pr_size_f

# I_g = I_g[randperm(length(I_g))]
shuffle!(I_g)
Expand All @@ -440,7 +440,7 @@ function perform_firms_market!(
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_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)
pr_cum_f_ = pr_price_f + pr_size_f
end
end
I_g = findall(DM_d_ig_ .> 0)
Expand Down Expand Up @@ -515,7 +515,7 @@ function perform_retail_market!(
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_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)
pr_cum_f_ = pr_price_f + pr_size_f

shuffle!(H_g)
for j in eachindex(H_g)
Expand All @@ -538,7 +538,7 @@ function perform_retail_market!(
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_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)
pr_cum_f_ = pr_price_f + pr_size_f
end
end
H_g = findall(C_d_hg .> 0)
Expand All @@ -552,7 +552,7 @@ function perform_retail_market!(
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_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)
pr_cum_f_ = pr_price_f + pr_size_f

H_g = shuffle(H_g)
for j in eachindex(H_g)
Expand All @@ -575,8 +575,7 @@ function perform_retail_market!(
pr_price_f = max.(0, exp.(-2 .* P_f[F_g]) ./ sum(exp.(-2 .* 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_cum_f_ = (pr_price_f + pr_size_f) ./ sum(pr_price_f + pr_size_f)

pr_cum_f_ = pr_price_f + pr_size_f
end
end
H_g = findall(C_d_hg_ .> 0)
Expand Down

0 comments on commit f1c0e96

Please sign in to comment.