Skip to content

Commit c9066ec

Browse files
authored
Merge pull request #50 from OptimalTransportNetworks/development
Create sparse hessian structure for CGC case.
2 parents b7ca787 + 8b78c7c commit c9066ec

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/models/solve_allocation_by_duality_cgc.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function solve_allocation_by_duality_cgc(x0, auxdata, verbose=true)
3232
n = graph.J * param.N
3333

3434
# Get the Hessian structure
35-
auxdata = (auxdata..., hess = hessian_structure_duality(auxdata))
35+
auxdata = (auxdata..., hess = hessian_structure_duality_cgc(auxdata))
3636
nnz_hess = length(auxdata.hess[1])
3737

3838
prob = Ipopt.CreateIpoptProblem(
@@ -108,6 +108,18 @@ function gradient_duality_cgc(x::Vector{Float64}, grad_f::Vector{Float64}, auxda
108108
return
109109
end
110110

111+
# Hessian structure function
112+
function hessian_structure_duality_cgc(auxdata)
113+
graph = auxdata.graph
114+
param = auxdata.param
115+
116+
# Create the Hessian structure
117+
H_structure = tril(repeat(sparse(I(graph.J)), param.N, param.N) + kron(sparse(ones(Int, param.N, param.N)), sparse(graph.adjacency)))
118+
119+
# Get the row and column indices of non-zero elements
120+
rows, cols, _ = findnz(H_structure)
121+
return rows, cols
122+
end
111123

112124
# Hessian computation function
113125
function hessian_duality_cgc(

0 commit comments

Comments
 (0)