Пример #1
0
    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)
Пример #2
0
    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
Пример #3
0
 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()
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
            ],
            "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,