def test_one_way_ring_null_alg(self): pop_xs = ( ((1.0, ), (2.0, ), (3.0, )), ((2.0, ), (2.0, ), (2.0, )), ((3.0, ), (3.0, ), (3.0, )), ((4.0, ), (4.0, ), (4.0, )), ) # Since we evolve the populations in index-order, the champion of pop1 ([1, ]) # will travel along the ring until pop4 out_pop_xs = ( ((1.0, ), (2.0, ), (3.0, )), ((1.0, ), (2.0, ), (2.0, )), ((1.0, ), (3.0, ), (3.0, )), ((1.0, ), (4.0, ), (4.0, )), ) top = topology.one_way_ring(4) top.set_weight(1.0) self.do_test_migr_setup(pop_xs, out_pop_xs, top, 1) # We set the probability to 0.0 between islands 0 and 1. During migration, # it is the the champion of pop2 - (2.0, ) which travels along the ring top.set_weight(0, 1, 0.0) out_pop_xs_2 = ( ((1.0, ), (2.0, ), (3.0, )), ((2.0, ), (2.0, ), (2.0, )), ((2.0, ), (3.0, ), (3.0, )), ((2.0, ), (4.0, ), (4.0, )), ) self.do_test_migr_setup(pop_xs, out_pop_xs_2, top, 1) # We set the probability to 0.0, not migration should happen top.set_weight(0.0) self.do_test_migr_setup(pop_xs, pop_xs, top, 1)
def test_chain_break(self): """ Testing 'chain breaking' after push_back in one-way-ring """ t = topology.ring(2) t.set_weight(0, 1, 0.1) t.set_weight(1, 0, 0.2) t.push_back() # In two-way ring, the weights between the first and second island should be the same after push_back self.assertEqual(t.get_weight(0, 1), 0.1) self.assertEqual(t.get_weight(1, 0), 0.2) self.assertEqual(t.get_weight(1, 2), 1.0) self.assertEqual(t.get_weight(2, 1), 1.0) self.assertEqual(t.get_weight(2, 0), 1.0) self.assertEqual(t.get_weight(0, 2), 1.0) # In one-way-ring, the edge 1->0 will be broken # and replaced by 1->2 and 2->0 with weights 1.0 each t = topology.one_way_ring(2) t.set_weight(0, 1, 0.1) t.set_weight(1, 0, 0.2) t.push_back() self.assertEqual(t.get_weight(0, 1), 0.1) self.assertEqual(t.get_weight(1, 2), 1.0) self.assertEqual(t.get_weight(2, 0), 1.0)