예제 #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]
    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
 def build(self, deme_location, location_store):
     new_location = GeneticFunctions.create_random_location(
         self.parameters.dimensions)
     return NQueensGeneticMember(self.parameters, new_location, 1)
예제 #4
0
 def build(self, build_params):
     return GeneticFunctions.create_random_location(
         self.parameters.dimensions)