Ejemplo n.º 1
0
    def test_crossover_with(self):
        parent1 = BitCondition(self.bitstring1, self.bitstring3)
        inbred1, inbred2 = parent1.crossover_with(parent1)
        self.assertTrue(inbred1 == inbred2 == parent1)

        parent2 = BitCondition(self.bitstring4, self.bitstring3)
        child1, child2 = parent1.crossover_with(parent2)
        self.assertTrue(
            child1.mask == child2.mask == parent1.mask == parent2.mask
        )
        self.assertFalse(child1.bits != ~child2.bits & child1.mask)