Exemplo n.º 1
0
    def select_at_random(self):
        if len(self.location_store) == 0:
            return GeneticFunctions.create_random_location(
                self.parameters.dimensions)

        index = random.randint(0, len(self.location_store) - 1)

        return self.locations[index]
Exemplo n.º 2
0
    def selectLocation(self, demeLocation):
        member_count = len(self.deme_controller.members)
        if member_count == 1:
            return super(NQueensGeneticMember,
                         self).selectLocation(demeLocation)

        new_location = GeneticFunctions.switch_positions(
            demeLocation, self.mutationCount)
        return super(NQueensGeneticMember, self).selectLocation(new_location)
    def create_unique_location(size, import_size, x_offset):
        random_location = GeneticFunctions.create_random_location(import_size)

        current_value = import_size
        start_val = [(current_value + x) for x in range(0, x_offset)]
        current_value = current_value + x_offset
        start_string = []
        for v in start_val:
            start_string.append(v)

        end_position = import_size + x_offset
        end_length = size - end_position
        end_val = [(current_value + x) for x in range(0, end_length)]

        end_string = []
        for v in end_val:
            end_string.append(v)

        start_string.extend(random_location)
        start_string.extend(end_string)
        return start_string
Exemplo n.º 4
0
    def selectLocation(self, demeLocation):
        currentLocation = demeLocation
        currentLocation = GeneticFunctions.switch_positions(
            currentLocation, self.mutationCount)

        return currentLocation
 def build(self, deme_location, location_store):
     new_location = GeneticFunctions.switch_positions(deme_location, 3)
     return NQueensGeneticMember(self.parameters, new_location, self.parameters.mutation_count)
 def build(self, deme_location, location_store):
     new_location = GeneticFunctions.create_random_location(
         self.parameters.dimensions)
     return NQueensGeneticMember(self.parameters, new_location, 1)
Exemplo n.º 7
0
 def build(self, build_params):
     return GeneticFunctions.create_random_location(
         self.parameters.dimensions)