PGA/route.py
def split_mutate(self, p=0.618):
        """
        split this route into two routes
        :param p: the probability of put node into first route
        :return: route 1 and route 2 from this route
        """
        sequence1 = []
        sequence2 = []
        for node in self.sequence:
            if random.random() < p:
                sequence1.append(node)
            else:
                sequence2.append(node)
        route1 = Route(sequence=sequence1, g_map=self.g_map, punish=self.punish)
        route2 = Route(sequence=sequence2, g_map=self.g_map, punish=self.punish)
        if len(route2.sequence) == 0:
            return [route1]
        elif len(route1.sequence) == 0:
            return [route2]
        else:
            return route1, route2

        split this route into two routes
        :param p: the probability of put node into first route
        :return: route 1 and route 2 from this route
        
split this route into two routes
split this route into two routes
def split_mutate(self, p=0.618):
        sequence1 = []
        sequence2 = []
        for node in self.sequence:
            if random.random() < p:
                sequence1.append(node)
            else:
                sequence2.append(node)
        route1 = Route(sequence=sequence1, g_map=self.g_map, punish=self.punish)
        route2 = Route(sequence=sequence2, g_map=self.g_map, punish=self.punish)
        if len(route2.sequence) == 0:
            return [route1]
        elif len(route1.sequence) == 0:
            return [route2]
        else:
            return route1, route2
def split_mutate ( self , p = 0.618 ) : sequence1 = [ ] sequence2 = [ ] for node in self . sequence : if random . random ( ) < p : sequence1 . append ( node ) else : sequence2 . append ( node ) route1 = Route ( sequence = sequence1 , g_map = self . g_map , punish = self . punish ) route2 = Route ( sequence = sequence2 , g_map = self . g_map , punish = self . punish ) if len ( route2 . sequence ) == 0 : return [ route1 ] elif len ( route1 . sequence ) == 0 : return [ route2 ] else : return route1 , route2
split this route into two routes
split this route into two routes
"""
        split this route into two routes
        :param p: the probability of put node into first route
        :return: route 1 and route 2 from this route
        """
None
self
p
the probability of put node into first route
the probability of put node into first route