def setUp(self): self.config = { "max_population": 10, "bitstring_generation": { "genome_length": 10 }, "codons": [ "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1011", "1111" ] } self.generator = BitStringGenerator(self.config)
def __init__(self, config, **kwargs): self.config = config self.recorder = kwargs.get("recorder", None) self.generator = BitStringGenerator(self.config) # mutation stats self.method = None self.index = None self.mutation_probability = None self.random_probability = None self.mutated = False self.before_mutation = None self.after_mutation = None
def setUp(self): self.config = { "max_population": 10, "bitstring_generation": { "genome_length": 10 }, "codons": [ "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1011", "1111" ] } generator = BitStringGenerator(self.config) self.bitstr_1 = generator.generate_random_bitstr() self.bitstr_2 = generator.generate_random_bitstr()
def setUp(self): self.config = { "max_population": 10, "bitstring_generation": { "genome_length": 10 }, "codons": [ "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1011", "1111" ], "mutation": { "method": ["POINT_MUTATION"], "probability": 1.0 } } generator = BitStringGenerator(self.config) self.bitstr = generator.generate_random_bitstr() self.mutation = BitStringMutation(self.config)
def setUp(self): self.config = { "max_population": 10, "bitstring_generation": { "genome_length": 10 }, "codons": [ "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1011", "1111" ], "crossover": { "method": "ONE_POINT_CROSSOVER", "probability": 1.0 } } generator = BitStringGenerator(self.config) self.bitstr_1 = generator.generate_random_bitstr() self.bitstr_2 = generator.generate_random_bitstr() self.crossover = BitStringCrossover(self.config)
], "selection": { "method": "TOURNAMENT_SELECTION", "tournament_size": 2 }, "crossover": { "method": "ONE_POINT_CROSSOVER", "probability": 0.8 }, "mutation": { "method": ["POINT_MUTATION"], "probability": 0.2 } } generator = BitStringGenerator(config) # genetic operators selection = Selection(config) crossover = BitStringCrossover(config) mutation = BitStringMutation(config) # run GA population = generator.init() details = play.play_details( population=population, evaluate=evaluate, functions=None, selection=selection, crossover=crossover,