def test_crossover(self): self.set_random_seed() c1 = Chromosome(10, random=True) c2 = Chromosome(10, random=True) c1copy = c1.copy() print(c1.path) print(c2.path) child1, child2 = c1.crossover(c2) assert c1copy == c1 np.testing.assert_array_equal(child1.path, [2, 1, 8, 9, 0, 6, 7, 3, 4, 5]) np.testing.assert_array_equal(child2.path, [3, 5, 8, 2, 9, 4, 1, 6, 7, 0])
def test_copy(self): c1 = Chromosome(500, random=True) c2 = c1.copy() np.testing.assert_array_equal(c2.path, c1.path) assert_not_equal( id(c2), id(c1))
def test_copy(self): c1 = Chromosome(500, random=True) c2 = c1.copy() np.testing.assert_array_equal(c2.path, c1.path) assert_not_equal(id(c2), id(c1))