tools/global_map.py
def initialize(self):
        """
        set nearby station of every customer
        set 'nearby' customer of every customer
        :return: None
        """
        # set nearby station of every customer, evaluated by distance
        for i in range(0, 1001):
            temp_station_d = self.distance_table['distance'][self.__get_index__(i, 1001):self.__get_index__(i, 1100)]
            self.nearby_station_list.append(np.argmin(np.array(temp_station_d)) + 1001)
        for i in range(1001, 1101):
            min_d = 99999999
            min_pos = 0
            for j in range(1001, 1101):
                if i == j:
                    continue
                elif self.distance_table['distance'][self.__get_index__(i, j)] < min_d:
                    min_d = self.distance_table['distance'][self.__get_index__(i, j)]
                    min_pos = j
            self.nearby_station_list.append(min_pos)

        # set 'nearby' customer of every customer, evaluated by distance, demand and time window
        self.nearby_custom_list.append(-1)
        for i in range(1, 1001):
            min_d = 99999999
            min_pos = -1
            demand = self.get_demand(i)
            time = self.get_window(i)
            for j in range(1, 1001):
                if i == j:
                    continue
                else:
                    n_dist = self.distance_table['distance'][self.__get_index__(i, j)]
                    n_demand = self.get_demand(j)
                    n_time = self.get_window(j)
                    if abs(demand[0] - n_demand[0]) >= 0.35 or abs(demand[1] - n_demand[1]) >= 7 or n_dist >= 10000:
                        continue
                    if abs(time[0] - n_time[0]) >= 0.5 or abs(time[1] - n_time[1]) >= 1:
                        continue
                    n_d = abs(demand[0] - n_demand[0]) / 2.5 + 0.1 * abs(demand[1] - n_demand[1]) / 16 + n_dist / 120000
                    n_d += abs(time[0] - n_time[0]) + abs(time[1] - n_time[1])
                    if n_d < min_d:
                        min_d = n_d
                        min_pos = j
            self.nearby_custom_list.append(min_pos)

        set nearby station of every customer
        set 'nearby' customer of every customer
        :return: None
        
set nearby station of every customer
set 'nearby' customer of every customer
set nearby station of every customer set ' nearby ' customer of every customer
def initialize(self):
        for i in range(0, 1001):
            temp_station_d = self.distance_table['distance'][self.__get_index__(i, 1001):self.__get_index__(i, 1100)]
            self.nearby_station_list.append(np.argmin(np.array(temp_station_d)) + 1001)
        for i in range(1001, 1101):
            min_d = 99999999
            min_pos = 0
            for j in range(1001, 1101):
                if i == j:
                    continue
                elif self.distance_table['distance'][self.__get_index__(i, j)] < min_d:
                    min_d = self.distance_table['distance'][self.__get_index__(i, j)]
                    min_pos = j
            self.nearby_station_list.append(min_pos)
        self.nearby_custom_list.append(-1)
        for i in range(1, 1001):
            min_d = 99999999
            min_pos = -1
            demand = self.get_demand(i)
            time = self.get_window(i)
            for j in range(1, 1001):
                if i == j:
                    continue
                else:
                    n_dist = self.distance_table['distance'][self.__get_index__(i, j)]
                    n_demand = self.get_demand(j)
                    n_time = self.get_window(j)
                    if abs(demand[0] - n_demand[0]) >= 0.35 or abs(demand[1] - n_demand[1]) >= 7 or n_dist >= 10000:
                        continue
                    if abs(time[0] - n_time[0]) >= 0.5 or abs(time[1] - n_time[1]) >= 1:
                        continue
                    n_d = abs(demand[0] - n_demand[0]) / 2.5 + 0.1 * abs(demand[1] - n_demand[1]) / 16 + n_dist / 120000
                    n_d += abs(time[0] - n_time[0]) + abs(time[1] - n_time[1])
                    if n_d < min_d:
                        min_d = n_d
                        min_pos = j
            self.nearby_custom_list.append(min_pos)
def initialize ( self ) : for i in range ( 0 , 1001 ) : temp_station_d = self . distance_table [ 'distance' ] [ self . __get_index__ ( i , 1001 ) : self . __get_index__ ( i , 1100 ) ] self . nearby_station_list . append ( np . argmin ( np . array ( temp_station_d ) ) + 1001 ) for i in range ( 1001 , 1101 ) : min_d = 99999999 min_pos = 0 for j in range ( 1001 , 1101 ) : if i == j : continue elif self . distance_table [ 'distance' ] [ self . __get_index__ ( i , j ) ] < min_d : min_d = self . distance_table [ 'distance' ] [ self . __get_index__ ( i , j ) ] min_pos = j self . nearby_station_list . append ( min_pos ) self . nearby_custom_list . append ( - 1 ) for i in range ( 1 , 1001 ) : min_d = 99999999 min_pos = - 1 demand = self . get_demand ( i ) time = self . get_window ( i ) for j in range ( 1 , 1001 ) : if i == j : continue else : n_dist = self . distance_table [ 'distance' ] [ self . __get_index__ ( i , j ) ] n_demand = self . get_demand ( j ) n_time = self . get_window ( j ) if abs ( demand [ 0 ] - n_demand [ 0 ] ) >= 0.35 or abs ( demand [ 1 ] - n_demand [ 1 ] ) >= 7 or n_dist >= 10000 : continue if abs ( time [ 0 ] - n_time [ 0 ] ) >= 0.5 or abs ( time [ 1 ] - n_time [ 1 ] ) >= 1 : continue n_d = abs ( demand [ 0 ] - n_demand [ 0 ] ) / 2.5 + 0.1 * abs ( demand [ 1 ] - n_demand [ 1 ] ) / 16 + n_dist / 120000 n_d += abs ( time [ 0 ] - n_time [ 0 ] ) + abs ( time [ 1 ] - n_time [ 1 ] ) if n_d < min_d : min_d = n_d min_pos = j self . nearby_custom_list . append ( min_pos )
set nearby station of every customer
set 'nearby' customer of every customer
set nearby station of every customer set ' nearby ' customer of every customer
"""
        set nearby station of every customer
        set 'nearby' customer of every customer
        :return: None
        """ # set nearby station of every customer, evaluated by distance # set 'nearby' customer of every customer, evaluated by distance, demand and time window
None
self