def network_setup(self, Tract_density, Tractx, Tracty, i, lon, lat, cnum): """Initialize everything for networks: location, distance matrix, degreesequence, cost, cluster_coeff, efficiency, diameter Input: Tract_density - 1D numpy array: population data of each tract in the area Tractx - 1D numpy array Tracty - 1D numpy array i - the number of the network in the system: i = 1, 2, 3 representing water, power and gas Output: \ """ self.Nodelocation(Tract_density, Tractx, Tracty, lon, lat, cnum) ##from GOOGLE API get the elevation self.GoogleAPIele() self.Distmatrix() #Decision of network adjacent matrix of three networks while (1): self.sampleseq = np.random.poisson(dt.fitdegree[i], size=self.nodenum) if (self.sampleseq.all() != 0): #if(np.max(self.sampleseq) >= 5): #continue break self.connection(self.sampleseq, dt.num) self.create_edgelist() self.degree, self.Ndegree = sf.degreeNdegree(self.Adjmatrix) #Plot each single infrastructure network # self.drawnetwork(dt.Type1, dt.llon, dt.rlon, dt.llat, dt.rlat) #plt.savefig("{} network.png".format(self.name), dpi = 2000) ##Calculate the network topology features self.cal_topology_feature() self.cost_cal(dt.Type2, Tract_density, Tractx, Tracty, cnum)
Shelby_Water.x, Shelby_Water.y, Shelby_Water.Type = WX, WY, WType Shelby_Power.x, Shelby_Power.y, Shelby_Power.Type = PX, PY, PType Shelby_Gas.x, Shelby_Gas.y, Shelby_Gas.Type = GX, GY, GType supplytrandemandxy(Shelby_Water) supplytrandemandxy(Shelby_Power) supplytrandemandxy(Shelby_Gas) ShelbyNetwork = [Shelby_Water, Shelby_Power, Shelby_Gas] edge = [Wedge, Pedge, Gedge] for i in range(len(ShelbyNetwork)): Network = ShelbyNetwork[i] Network.Distmatrix() Adjmatrix(Network, edge[i], Network.Type) Network.degree, Network.Ndegree = sf.degreeNdegree(Network.Adjmatrix) Network.drawnetwork(dt.Type1, dt.llon, dt.rlon, dt.llat, dt.rlat) Network.cal_topology_feature() # cost(Network, Tract_pop, Tractx, Tracty, Geox, Geoy) cost(Network, Tract_pop, Tractx, Tracty, Geox, Geoy, dt.cnum) # ##------------------------------------------------------------------------------ #plt.figure(figsize = (20, 12)) #Base = bm.BaseMapSet(dt.Type1, dt.llon, dt.rlon, dt.llat, dt.rlat) # #Wx, Wy = Base(Wlon, Wlat) #Px, Py = Base(Plon, Plat) #Gx, Gy = Base(Glon, Glat) # ###Water network