def test_schwefel(self): """Test the schwefel benchmark.""" schwefel = Utility().get_benchmark('schwefel') fun = schwefel.function() self.assertTrue(callable(fun)) self.assertAlmostEqual(fun(self.D, self.array3), 0.0, places=3)
def test_schwefel221(self): """Test the schwefel 221 benchmark.""" schwefel221 = Utility().get_benchmark('schwefel221') fun = schwefel221.function() self.assertTrue(callable(fun)) self.assertEqual(fun(self.D, self.array), 0.0)
def test_sphere(self): """Test the sphere benchmark.""" sphere = Utility().get_benchmark('sphere') fun = sphere.function() self.assertTrue(callable(fun)) self.assertEqual(fun(self.D, self.array), 0.0)
def test_ackley(self): """Test the ackley benchmark.""" ackley = Utility().get_benchmark('ackley') fun = ackley.function() self.assertTrue(callable(fun)) self.assertAlmostEqual(fun(self.D, self.array), 0.0, places=10)
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)
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)
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)
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)
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)
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)
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)
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)
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()