Exemplo n.º 1
0
 def test_halt_expected(self):
     """
     Ensure the function returns true if we're in a halting state.
     """
     g1 = Genome([1, 2, 3])
     g1.fitness = MAX_REWARD
     g2 = Genome([1, 2, 3])
     g2.fitness = 3
     g3 = Genome([1, 2, 3])
     g3.fitness = 2
     # Any fittest solution with fitness >= MAX_REWARD means call a halt.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertTrue(result)
Exemplo n.º 2
0
 def test_halt_expected(self):
     """
     Ensure the function returns true if we're in a halting state.
     """
     g1 = Genome([1, 2, 3])
     g1.fitness = MAX_REWARD
     g2 = Genome([1, 2, 3])
     g2.fitness = 3
     g3 = Genome([1, 2, 3])
     g3.fitness = 2
     # Any fittest solution with fitness >= MAX_REWARD means call a halt.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertTrue(result)
Exemplo n.º 3
0
 def test_halt_not(self):
     """
     Ensures if the fittest genome has fitness < 4 then halt doesn't
     succeed.
     """
     g1 = Genome([1, 2, 3])
     g1.fitness = MAX_REWARD - 0.1
     g2 = Genome([1, 2, 3])
     g2.fitness = 3
     g3 = Genome([1, 2, 3])
     g3.fitness = 2
     # Any fittest solution with fitness >= 4 means call a halt.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertFalse(result)
Exemplo n.º 4
0
 def test_halt_not(self):
     """
     Ensures if the fittest genome has fitness < 4 then halt doesn't
     succeed.
     """
     g1 = Genome([1, 2, 3])
     g1.fitness = MAX_REWARD - 0.1
     g2 = Genome([1, 2, 3])
     g2.fitness = 3
     g3 = Genome([1, 2, 3])
     g3.fitness = 2
     # Any fittest solution with fitness >= 4 means call a halt.
     population = [g1, g2, g3]
     result = halt(population, 1)
     self.assertFalse(result)