Пример #1
0
    def test_griewank(self):
        """Test the griewank benchmark."""

        griewank = Utility().get_benchmark('griewank')
        fun = griewank.function()
        self.assertTrue(callable(fun))
        self.assertEqual(fun(self.D, self.array), 0.0)
Пример #2
0
    def test_rastrigin(self):
        """Test the rastrigin benchmark."""

        rastrigin = Utility().get_benchmark('rastrigin')
        fun = rastrigin.function()
        self.assertTrue(callable(fun))
        self.assertEqual(fun(self.D, self.array), 0.0)
Пример #3
0
    def test_rosenbrock(self):
        """Test the rosenbrock benchmark."""

        rosenbrock = Utility().get_benchmark('rosenbrock')
        fun = rosenbrock.function()
        self.assertTrue(callable(fun))
        self.assertEqual(fun(self.D, self.array2), 0.0)
Пример #4
0
    def test_step3(self):
        """Test the step3 benchmark."""

        step3 = Utility().get_benchmark('step3')
        fun = step3.function()
        self.assertTrue(callable(fun))
        self.assertEqual(fun(self.D, self.array), 0.0)
Пример #5
0
    def test_stepint(self):
        """Test the stepint benchmark."""

        stepint = Utility().get_benchmark('stepint')
        fun = stepint.function()
        self.assertTrue(callable(fun))
        self.assertEqual(fun(self.D, self.array9), 25.0 - 6 * self.D)
Пример #6
0
    def test_sumSquares(self):
        """Test the sum squares benchmark."""

        sumSquares = Utility().get_benchmark('sumSquares')
        fun = sumSquares.function()
        self.assertTrue(callable(fun))
        self.assertEqual(fun(self.D, self.array), 0.0)
Пример #7
0
    def test_styblinskiTang(self):
        """Test the styblinski tang benchmark."""

        styblinskiTang = Utility().get_benchmark('styblinskiTang')
        fun = styblinskiTang.function()
        self.assertTrue(callable(fun))
        self.assertAlmostEqual(fun(2, self.array4), -78.332, places=3)
Пример #8
0
    def test_whitley(self):
        """Test the whitley benchmark."""

        whitley = Utility().get_benchmark('whitley')
        fun = whitley.function()
        self.assertTrue(callable(fun))
        self.assertEqual(fun(self.D, self.array2), 0.0)
Пример #9
0
class UtilityTestCase(TestCase):
	def setUp(self):
		self.u = Utility()

	def test_get_bad_benchmark_fine(self):
		self.assertRaises(TypeError, lambda: self.u.get_benchmark('hihihihihihihihihi'))
		self.assertRaises(TypeError, lambda: self.u.get_benchmark(MyBenchmark))
		self.assertRaises(TypeError, lambda: self.u.get_benchmark(NoLimits))
Пример #10
0
    def assertBounds(self, bench, lower, upper):
        """Checking the bounds.

        Arguments:
            bench [Benchmark]: Benchmark to test.
            lower [float]: Lower bound.
            upper [type]: Upper bound.

        Returns:
            [fun]: Returns benchmarks evaluation function.
        """

        b = Utility().get_benchmark(bench)
        self.assertEqual(b.Lower, lower)
        self.assertEqual(b.Upper, upper)
        return b.function()
Пример #11
0
	def setUp(self):
		self.u = Utility()