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)
}, "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, mutation=mutation, print_func=print_func, stop_func=stop_func, config=config,