@@ -32,9 +32,8 @@ function solve_allocation_by_duality_cgc(x0, auxdata, verbose=true)
3232 n = graph. J * param. N
3333
3434 # Get the Hessian structure
35- hess_str = hessian_structure_duality (auxdata)
36- auxdata = (auxdata... , hess = hess_str, hess_ind = CartesianIndex .(hess_str[1 ], hess_str[2 ]))
37- nnz_hess = length (hess_str[1 ])
35+ auxdata = (auxdata... , hess = hessian_structure_duality (auxdata))
36+ nnz_hess = length (auxdata. hess[1 ])
3837
3938 prob = Ipopt. CreateIpoptProblem (
4039 n,
@@ -186,13 +185,14 @@ function hessian_duality_cgc(
186185 for k in neighbors # TODO : add to loop below ??
187186 T += res. Qjk[j, k]^ (1 + beta) / kappa[j, k]
188187 end
189- Cprime = Lj[j]/ omegaj[j] * (PDj[j] / Pjn[j, nd])^ sigma * param. uprimeinvprime (PDj[j]/ omegaj[j], graph. hj[j])
190188 Gprime = sigma * (Pjn[j, n] * Pjn[j, nd])^ (- sigma) * PDj[j]^ (2 * sigma- 1 )
189+ # Adding all derivative terms apart from second part of T'
191190 if nd == n
191+ Cprime = Lj[j]/ omegaj[j] * (PDj[j] / Pjn[j, nd])^ sigma * param. uprimeinvprime (PDj[j]/ omegaj[j], graph. hj[j])
192+ term += (Cprime + (1 + beta) * Pprime / P * T) * G
192193 Gprime -= sigma / PDj[j] * G^ ((sigma+ 1 )/ sigma)
193194 end
194- # Adding all derivative terms apart from second part of T'
195- term += (Cprime + (1 + beta) * Pprime / P * T) * G + (res. Cj[j] + T) * Gprime
195+ term += (res. Cj[j] + T) * Gprime
196196 end
197197 # Constant term for iterating through neighbors for computing T'_2 G
198198 cons = numbetam1 / (numbetam1 + nu* beta) * P^ (1 + beta) * G
@@ -224,7 +224,7 @@ function hessian_duality_cgc(
224224 term += K * (Pprime* A* B + P* A* Bprime)
225225 end
226226 # This computes the remaining derivative of D^n_j (T'_2 G)
227- term += cons * K / (1 + beta) * Bprime * B^ (- nu* beta/ (numbetam1+ nu* beta))
227+ term += cons * K / (1 + beta) * Bprime * B^ (( - nu* beta) / (numbetam1+ nu* beta))
228228 elseif jd == k # P^x_k (P' is zero)
229229 Bprime = - cons2 * A * B^ ((numbetam1 - nu* beta)/ numbetam1) # simply the negative
230230 if nd == n # P^n_k
@@ -234,7 +234,7 @@ function hessian_duality_cgc(
234234 term += K * P* A* Bprime
235235 end
236236 # This computes the remaining derivative of D^n_j (T'_2 G)
237- term += cons * K / (1 + beta) * Bprime * B^ (- nu* beta/ (numbetam1+ nu* beta))
237+ term += cons * K / (1 + beta) * Bprime * B^ (( - nu* beta) / (numbetam1+ nu* beta))
238238 end
239239 end
240240
0 commit comments