@@ -11,42 +11,42 @@ height = 9
1111nb_cities = 20
1212
1313param = init_parameters (K = 100 , annealing = false )
14- param, g = create_graph (param, width, height, type = " triangle" ) # case with random cities, one good
14+ graph = create_graph (param, width, height, type = " triangle" ) # case with random cities, one good
1515
1616# set fundamentals
1717
1818Random. seed! (5 )
19- minpop = minimum (param [:Lj ])
20- param [:Zjn ] = fill (minpop, g [:J ], 1 ) # matrix of productivity
19+ minpop = minimum (graph [:Lj ])
20+ graph [:Zjn ] = fill (minpop, graph [:J ], 1 ) # matrix of productivity
2121
22- Ni = find_node (g , ceil (width/ 2 ), ceil (height/ 2 )) # find center
23- param [:Zjn ][Ni] = 1 # more productive node
24- param [:Lj ][Ni] = 1 # more productive node
22+ Ni = find_node (graph , ceil (width/ 2 ), ceil (height/ 2 )) # find center
23+ graph [:Zjn ][Ni] = 1 # more productive node
24+ graph [:Lj ][Ni] = 1 # more productive node
2525
2626for i in 1 : nb_cities- 1
2727 newdraw = false
2828 while newdraw == false
29- j = round (Int, 1 + rand () * (g [:J ] - 1 ))
30- if param [:Lj ][j] <= minpop
29+ j = round (Int, 1 + rand () * (graph [:J ] - 1 ))
30+ if graph [:Lj ][j] <= minpop
3131 newdraw = true
32- param [:Lj ][j] = 1
32+ graph [:Lj ][j] = 1
3333 end
3434 end
3535end
3636
37- param [:hj ] = param [:Hj ] ./ param [:Lj ]
38- param [:hj ][param [:Lj ] .== minpop] .= 1
37+ graph [:hj ] = graph [:Hj ] ./ graph [:Lj ]
38+ graph [:hj ][graph [:Lj ] .== minpop] .= 1
3939
4040# Convex case
4141results = Vector {Any} (undef, 3 )
42- results[1 ] = optimal_network (param, g )
42+ results[1 ] = optimal_network (param, graph )
4343
4444# Nonconvex - no annealing
4545param[:gamma ] = 2
46- results[2 ] = optimal_network (param, g )
46+ results[2 ] = optimal_network (param, graph )
4747
4848# Nonconvex - annealing
49- results[3 ] = annealing (param, g , results[2 ][:Ijk ], perturbation_method = " rebranching" )
49+ results[3 ] = annealing (graph , results[2 ][:Ijk ], perturbation_method = " rebranching" )
5050
5151welfare_increase = (results[3 ][:welfare ] / results[2 ][:welfare ]) ^ (1 / (param[:alpha ] * (1 - param[:rho ]))) # compute welfare increase in consumption equivalent
5252
@@ -55,18 +55,18 @@ welfare_increase = (results[3][:welfare] / results[2][:welfare]) ^ (1 / (param[:
5555
5656plots = Vector {Any} (undef, 6 ) # Initialize an empty array to hold the subplots
5757
58- plots[1 ] = plot_graph (g , results[1 ][:Ijk ], node_sizes = results[1 ][:Lj ], node_shades = results[1 ][:Cj ], node_sizes_scale = 40 )
58+ plots[1 ] = plot_graph (graph , results[1 ][:Ijk ], node_sizes = results[1 ][:Lj ], node_shades = results[1 ][:Cj ], node_sizes_scale = 40 )
5959title! (plots[1 ], " Convex Network (I_{jk})" )
60- plots[2 ] = plot_graph (g , results[1 ][:Qjkn ][:, :, 1 ], edge_color = :brown , arrows = true , node_sizes = results[1 ][:Lj ], node_shades = results[1 ][:Cj ], node_sizes_scale = 40 )
60+ plots[2 ] = plot_graph (graph , results[1 ][:Qjkn ][:, :, 1 ], edge_color = :brown , arrows = true , node_sizes = results[1 ][:Lj ], node_shades = results[1 ][:Cj ], node_sizes_scale = 40 )
6161title! (plots[2 ], " Convex Shipping (Q_{jk})" )
6262
63- plots[3 ] = plot_graph (g , results[2 ][:Ijk ], node_sizes = results[2 ][:Lj ], node_shades = results[2 ][:Cj ], node_sizes_scale = 40 )
63+ plots[3 ] = plot_graph (graph , results[2 ][:Ijk ], node_sizes = results[2 ][:Lj ], node_shades = results[2 ][:Cj ], node_sizes_scale = 40 )
6464title! (plots[3 ], " Nonconvex Network (I_{jk})" )
65- plots[4 ] = plot_graph (g , results[2 ][:Qjkn ][:, :, 1 ], edge_color = :brown , arrows = true , node_sizes = results[2 ][:Lj ], node_shades = results[2 ][:Cj ], node_sizes_scale = 40 )
65+ plots[4 ] = plot_graph (graph , results[2 ][:Qjkn ][:, :, 1 ], edge_color = :brown , arrows = true , node_sizes = results[2 ][:Lj ], node_shades = results[2 ][:Cj ], node_sizes_scale = 40 )
6666title! (plots[4 ], " Nonconvex Shipping (Q_{jk})" )
6767
6868plots[5 ] = plots[3 ]
69- plots[6 ] = plot_graph (g , results[3 ][:Ijk ], node_sizes = results[3 ][:Lj ], node_shades = results[3 ][:Cj ], node_sizes_scale = 40 )
69+ plots[6 ] = plot_graph (graph , results[3 ][:Ijk ], node_sizes = results[3 ][:Lj ], node_shades = results[3 ][:Cj ], node_sizes_scale = 40 )
7070title! (plots[6 ], " Nonconvex Network (I_{jk})" )
7171annotate! (plots[6 ], [(0.5 , 1.04 , text (" With Annealing. Welfare increase: $(round ((welfare_increase- 1 )* 100 , digits = 2 )) %" , :black , :center , 10 ))])
7272
0 commit comments