Skip to content

Commit 684e38b

Browse files
committed
Minors.
1 parent 3cec892 commit 684e38b

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/models/solve_allocation_by_duality_cgc.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function hessian_duality_cgc(
194194
# Now terms sum_k(Q^n_{jk} - Q^n_{kj}) as well as T'G + TG'
195195
for k in neighbors
196196
diff = Pjn[k, n] - Pjn[j, n]
197-
if diff > 0 # Flows in the direction of k
197+
if diff >= 0 # Flows in the direction of k
198198
tmp = Qjkn[j, k, n]
199199
T = Qjk[j, k]^(1+beta) / kappa[j, k]
200200
PK0 = PCj[j] * (1 + beta) / kappa[j, k]
@@ -260,6 +260,7 @@ function recover_allocation_duality_cgc(x, auxdata)
260260
Lj = graph.Lj
261261
m = param.m
262262
nu = param.nu
263+
beta = param.beta
263264
hj1malpha = (graph.hj / (1-param.alpha)) .^ (1-param.alpha)
264265
nadj = .!graph.adjacency
265266

@@ -287,26 +288,27 @@ function recover_allocation_duality_cgc(x, auxdata)
287288

288289
# Calculate the aggregate flows Qjk
289290
Qjk = zeros(graph.J, graph.J)
290-
temp = (kappa ./ ((1 + param.beta) * PCj)) .^ (nu/(nu-1))
291+
temp = (kappa ./ ((1 + beta) * PCj)) .^ (nu/(nu-1))
291292
temp[nadj] .= 0
292293
for n in 1:param.N
293294
Lambda = repeat(Pjn[:, n], 1, graph.J)
294295
LL = max.(Lambda' - Lambda, 0) # P^n_k - P^n_j (non-negative flows)
295296
Qjk += m[n] * (LL / m[n]) .^ (nu/(nu-1))
296297
end
297-
Qjk = (Qjk .* temp) .^ (nu-1)/(nu*param.beta)
298+
Qjk = (Qjk .* temp) .^ (nu-1)/(nu*beta)
298299

299300
# Calculate the flows Qjkn
300301
Qjkn = zeros(graph.J, graph.J, param.N)
301-
temp = kappa ./ ((1 + param.beta) * PCj .* Qjk .^ (1+param.beta-nu))
302+
temp = kappa ./ ((1 + beta) * PCj .* Qjk .^ (1+beta-nu))
302303
temp[nadj .| isinf.(temp)] .= 0 # Because of the max() clause, Qjk may be zero
303304
for n in 1:param.N
304305
Lambda = repeat(Pjn[:, n], 1, graph.J)
305306
LL = max.(Lambda' - Lambda, 0) # P^n_k - P^n_j (non-negative flows)
306307
Qjkn[:, :, n] = ((LL .* temp) / m[n]) .^ (1/(nu-1))
307308
end
309+
308310
# Now calculating consumption bundle pre-transport cost
309-
temp = Qjk .^ (1+param.beta) ./ kappa
311+
temp = Qjk .^ (1+beta) ./ kappa
310312
temp[nadj] .= 0
311313
Dj = Cj + sum(temp, dims = 2)
312314
Djn = Dj .* (Pjn ./ PCj) .^ (-param.sigma)

0 commit comments

Comments
 (0)