Exemplo n.º 1
0
    def test_that_swarm_can_update_the_scores_of_all_particles_if_scores_equal_swarmsize(
            self):
        s = Swarm(swarm_size=10,
                  bounds=Bounds(np.array([1]), np.array([2])),
                  parameters=PsoParameters(0.15, 0.15, 0.15),
                  minimum_improvement=10e-8,
                  minimum_step=10e-8)

        with self.assertRaises(ValueError):
            s.update_scores(list(range(9)))
Exemplo n.º 2
0
    def test_that_swarm_can_update_the_scores_of_all_particles(self, mock):
        s = Swarm(swarm_size=10,
                  bounds=Bounds(np.array([1]), np.array([2])),
                  parameters=PsoParameters(0.15, 0.15, 0.15),
                  minimum_improvement=10e-8,
                  minimum_step=10e-8)

        s.update_scores(list(range(10)))

        self.assertTrue(mock.called)
        self.assertEqual(mock.call_count, 10)