@@ -10,31 +10,31 @@ width, height = 13, 13
1010param, g0 = create_graph (param, width, height, type = " map" )
1111
1212# Set fundamentals
13- param[:Zjn ] = ones (param[:J ], 1 ) .* 1e-3 # matrix of productivity (not 0 to avoid numerical glitches)
14- param[:Lj ] = ones (param[:J ]) .* 1e-3 # matrix of population
13+ param[:Zjn ] = ones (param[:J ], 1 ) .* 1e-7 # matrix of productivity (not 0 to avoid numerical glitches)
14+ param[:Lj ] = ones (param[:J ]) .* 1e-7 # matrix of population
1515
1616Ni = find_node (g0, ceil (width/ 2 ), ceil (height/ 2 )) # center
1717param[:Zjn ][Ni] = 1 # more productive node
1818param[:Lj ][Ni] = 1 # more productive node
1919
20- Random. seed! (5 )
20+ Random. seed! (10 ) # use 5, 8, 10 or 11
2121nb_cities = 20 # draw a number of random cities in space
2222for i in 1 : nb_cities- 1
2323 newdraw = false
2424 while newdraw == false
25- j = round (Int, 1 + rand () * (g0 [:J ] - 1 ))
26- if param[:Lj ][j] <= 1e-3
25+ j = round (Int, 1 + rand () * (param [:J ] - 1 ))
26+ if param[:Lj ][j] <= 1e-7
2727 newdraw = true
2828 param[:Lj ][j] = 1
2929 end
3030 end
3131end
3232
3333param[:hj ] = param[:Hj ] ./ param[:Lj ]
34- param[:hj ][param[:Lj ] .== 1e-3 ] .= 1
34+ param[:hj ][param[:Lj ] .== 1e-7 ] .= 1 # catch errors in places with infinite housing per capita
3535
3636# Draw geography
37- z = zeros (g0 [:J ]) # altitude of each node
37+ z = zeros (param [:J ]) # altitude of each node
3838geographies = Dict ()
3939geographies[:blank ] = (z = z, obstacles = nothing )
4040
@@ -63,10 +63,7 @@ geographies[:river] = (z = geographies[:mountain].z,
6363 11 + (5 - 1 )* width 12 + (5 - 1 )* width;
6464 12 + (5 - 1 )* width 13 + (5 - 1 )* width])
6565
66- g = apply_geography (g0, geographies[:river ],
67- along_abstacle_delta_i = 1 ,
68- along_abstacle_delta_tau = 1 ,
69- alpha_up_i = 10 , alpha_down_i = 10 )
66+ g = apply_geography (g0, geographies[:river ], alpha_up_i = 10 , alpha_down_i = 10 )
7067results[:river ] = optimal_network (param, g)
7168
7269# Reinit and put another river and bridges
@@ -82,8 +79,7 @@ geographies[:bridges] = (z = mountain_height * exp.(-((g0[:x] .- mount_x).^2 .+
8279 12 + (5 - 1 )* width 13 + (5 - 1 )* width])
8380
8481g = apply_geography (g0, geographies[:bridges ], alpha_up_i = 10 , alpha_down_i = 10 ,
85- across_abstacle_delta_i = 2 ,
86- along_abstacle_delta_tau = 1 )
82+ across_obstacle_delta_i = 2 )
8783results[:bridges ] = optimal_network (param, g)
8884
8985# Allowing for water transport
@@ -117,12 +113,12 @@ plots = Vector{Any}(undef, length(simulation))
117113i = 0
118114for s in simulation
119115 i += 1
120- plots[i] = plot_graph (g , results[Symbol (s)][:Ijk ],
116+ plots[i] = plot_graph (g0 , results[Symbol (s)][:Ijk ],
121117 geography = geographies[Symbol (s)], obstacles = obstacles[i] == " on" ,
122118 mesh = true , mesh_transparency = 0.2 ,
123- node_sizes = results[Symbol (s)][:cj ] .* (param[:Lj ] .> 1e-3 ),
124- node_shades = param[:Zjn ],
125- edge_min_thickness = 1.5 )
119+ node_sizes = results[Symbol (s)][:cj ] .* (param[:Lj ] .> 1e-7 ),
120+ node_shades = param[:Zjn ], node_color = :seismic ,
121+ edge_min_thickness = 1 , edge_max_thickness = 4 )
126122 title! (plots[i], " Geography $(s) " )
127123end
128124
0 commit comments