PGA/route.py
def random_reverse_mutate(self):
        """
        randomly swap two node in this route
        :return: None
        """
        copy_sequence = self.sequence.copy()
        copy_cost = self.cost
        pos1 = random.randint(0, len(self.sequence) - 1)
        pos2 = random.randint(0, len(self.sequence) - 1)
        self.sequence[pos1], self.sequence[pos2] = self.sequence[pos2], self.sequence[pos1]
        self.refresh_state()
        if self.cost > copy_cost:
            del self.sequence
            self.sequence = copy_sequence
            self.refresh_state()

        randomly swap two node in this route
        :return: None
        
randomly swap two node in this route
randomly swap two node in this route
def random_reverse_mutate(self):
        copy_sequence = self.sequence.copy()
        copy_cost = self.cost
        pos1 = random.randint(0, len(self.sequence) - 1)
        pos2 = random.randint(0, len(self.sequence) - 1)
        self.sequence[pos1], self.sequence[pos2] = self.sequence[pos2], self.sequence[pos1]
        self.refresh_state()
        if self.cost > copy_cost:
            del self.sequence
            self.sequence = copy_sequence
            self.refresh_state()
def random_reverse_mutate ( self ) : copy_sequence = self . sequence . copy ( ) copy_cost = self . cost pos1 = random . randint ( 0 , len ( self . sequence ) - 1 ) pos2 = random . randint ( 0 , len ( self . sequence ) - 1 ) self . sequence [ pos1 ] , self . sequence [ pos2 ] = self . sequence [ pos2 ] , self . sequence [ pos1 ] self . refresh_state ( ) if self . cost > copy_cost : del self . sequence self . sequence = copy_sequence self . refresh_state ( )
randomly swap two node in this route
randomly swap two node in this route
"""
        randomly swap two node in this route
        :return: None
        """
None
self