Skip to content

Commit 7f5ffd4

Browse files
committed
Slightly more accurate solution.
1 parent ca2cc80 commit 7f5ffd4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/models/solve_allocation_by_duality_cgc.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ function hessian_duality_cgc(
146146

147147
# Constant term: first part of Bprime
148148
cons = m1dbeta * n1dnum1 * numbetam1
149-
# Constant in T'
150-
cons2 = numbetam1 / (numbetam1+nu*beta)
149+
## Constant in T'
150+
# cons2 = numbetam1 / (numbetam1+nu*beta)
151+
# New: constant in T' -> More accurate!
152+
cons3 = m1dbeta * n1dnum1 * (numbetam1+nu*beta) / (1+beta)
151153

152154
# Precompute elements
153155
res = recover_allocation_duality_cgc(x, auxdata)
@@ -201,10 +203,13 @@ function hessian_duality_cgc(
201203
if jd == j
202204
KPprimeAB1 = m1dbeta * Pjn[j, nd]^(-sigma) * PCj[j]^(sigma-1)
203205
term += Qjkn[j, k, n] * (KPprimeAB1 - KPAprimeB1 + KPABprime1) # Derivative of Qjkn
204-
term += T * (((1+beta) * KPprimeAB1 + cons2 * KPABprime1) * G + Gprime) # T'G + TG'
206+
# term += T * (((1+beta) * KPprimeAB1 + cons2 * KPABprime1) * G + Gprime) # T'G + TG'
207+
term += T * ((1+beta) * KPprimeAB1 * G + Gprime) # T'G (first part) + TG'
208+
term += cons3 * Qjkn[j, k, nd] / PCj[j] * G # Second part of T'G
205209
elseif jd == k
206210
term += Qjkn[j, k, n] * (KPAprimeB1 - KPABprime1) # Derivative of Qjkn
207-
term -= T * cons2 * KPABprime1 * G # T'G: second part [B'(k) has opposite sign]
211+
# term -= T * cons2 * KPABprime1 * G # T'G: second part [B'(k) has opposite sign]
212+
term -= cons3 * Qjkn[j, k, nd] / PCj[j] * G # Second part of T'G
208213
end
209214
end
210215
if Qjkn[k, j, n] > 0 # Flows in the direction of j

0 commit comments

Comments
 (0)