@@ -22,8 +22,8 @@ Solve for the optimal network by solving the inner problem and the outer problem
2222# Examples
2323```julia
2424param = init_parameters(K = 10)
25- param, graph = create_graph(param)
26- param [:Zjn][61] = 10.0
25+ graph = create_graph(param)
26+ graph [:Zjn][61] = 10.0
2727results = optimal_network(param, graph)
2828plot_graph(graph, results[:Ijk])
2929```
@@ -32,8 +32,8 @@ function optimal_network(param, graph; I0=nothing, Il=nothing, Iu=nothing, verbo
3232
3333 # I0=nothing; Il=nothing; Iu=nothing; verbose=false; return_model = false; return_model = 0;
3434 # Check param.Zjn and make matrix if vector:
35- if length (size (param [:Zjn ])) == 1
36- param [:Zjn ] = reshape (param [:Zjn ], param [:J ], 1 )
35+ if length (size (graph [:Zjn ])) == 1
36+ graph [:Zjn ] = reshape (graph [:Zjn ], graph [:J ], 1 )
3737 end
3838 graph = dict_to_namedtuple (graph)
3939 param = dict_to_namedtuple (param)
@@ -67,7 +67,7 @@ function optimal_network(param, graph; I0=nothing, Il=nothing, Iu=nothing, verbo
6767 # INITIALIZATION
6868
6969 auxdata = create_auxdata (param, graph, edges, I0)
70- model, recover_allocation = get_model (param, auxdata)
70+ model, recover_allocation = get_model (auxdata)
7171
7272 if return_model == 1
7373 return model, recover_allocation
@@ -85,7 +85,7 @@ function optimal_network(param, graph; I0=nothing, Il=nothing, Iu=nothing, verbo
8585 weight_old = 0.5
8686 I1 = zeros (J, J)
8787 # K in average infrastructure units
88- K_infra = (param. K / mean (graph. delta_i[graph. adjacency.== 1 ]))
88+ K_infra = (param. K / mean (graph. delta_i[graph. adjacency .== 1 ]))
8989 distance = 0.0
9090 all_vars = all_variables_except_kappa_ex (model)
9191 start_values = start_value .(all_vars)
@@ -121,7 +121,7 @@ function optimal_network(param, graph; I0=nothing, Il=nothing, Iu=nothing, verbo
121121 else
122122 error (" Solver returned with error code $(termination_status (model)) ." )
123123 end
124- elseif param[ : warm_start] # Set next run starting values to previous run solution.
124+ elseif param. warm_start # Set next run starting values to previous run solution.
125125 vars_solution = value .(all_vars)
126126 set_start_value .(all_vars, vars_solution)
127127 used_warm_start = true
@@ -133,7 +133,7 @@ function optimal_network(param, graph; I0=nothing, Il=nothing, Iu=nothing, verbo
133133 PQ = dropdims (sum (PQ + permutedims (PQ, [2 , 1 , 3 ]), dims= 3 ), dims = 3 )
134134 else
135135 PQ = repeat (results[:PCj ], 1 , J)
136- matm = permutedims (repeat (param[ :m ] , 1 , J, J), [3 , 2 , 1 ])
136+ matm = permutedims (repeat (graph . m , 1 , J, J), [3 , 2 , 1 ])
137137 cost = dropdims (sum (matm .* results[:Qjkn ] .^ param. nu, dims= 3 ), dims = 3 ) .^ ((param. beta + 1 ) / param. nu)
138138 PQ .*= cost
139139 PQ += PQ'
0 commit comments