def test_ridge(self): """Test the ridge function.""" fun = get_problem('ridge', dimension=self.dimension, lower=-64, upper=64) self.assertAlmostEqual(fun(self.array10), 371.0, delta=1e-4)
def test_hgbat(self): """Test the hgbat function.""" fun = get_problem('hgbat', self.dimension, -100, 100) self.assertAlmostEqual(fun(self.array10), 61.91502622129181, delta=60)
def test_stepint(self): """Test the stepint function.""" fun = get_problem('stepint', self.dimension) self.assertEqual(fun(self.array9), -5.0)
def test_styblinski_tang(self): """Test the styblinski tang function.""" fun = get_problem('styblinski_tang', dimension=2) self.assertAlmostEqual(fun(self.array4), -78.332, places=3)
def test_schwefel222(self): """Test the schwefel 222 function.""" fun = get_problem('schwefel222', self.dimension) self.assertEqual(fun(self.array), 0.0)
def test_ackley(self): """Test the ackley function.""" fun = get_problem('ackley', self.dimension) self.assertAlmostEqual(fun(self.array), 0.0, places=10)
def test_griewank(self): """Test the griewank function.""" fun = get_problem('griewank', self.dimension) self.assertEqual(fun(self.array), 0.0)
def test_rastrigin(self): """Test the rastrigin function.""" rastrigin = get_problem('rastrigin', dimension=self.dimension) self.assertEqual(rastrigin(self.array), 0.0)
def test_michalewicz(self): """Test the michalewicz function.""" fun = get_problem('michalewicz', dimension=2, lower=0, upper=np.pi) self.assertAlmostEqual(fun(np.asarray([2.20, 1.57])), -1.8013, delta=1e-3)
def test_happy_cat(self): """Test the happy cat function.""" fun = get_problem('happy_cat', self.dimension, alpha=0.125) self.assertAlmostEqual(fun(self.array10), 15.1821333, delta=1e-4)
def test_qing(self): """Test the qing function.""" fun = get_problem('qing', self.dimension, -500, 500) self.assertAlmostEqual(fun(self.array10), 584.0, delta=1e-4)
def test_weierstrass(self): """Test the weierstrass function.""" fun = get_problem('weierstrass', self.dimension, -100, 100) self.assertAlmostEqual(fun(self.array10), 0.0, delta=1e-4)
def test_modified_schwefel(self): """Test the modified schwefel function.""" fun = get_problem('modified_schwefel', self.dimension, -100, 100) self.assertAlmostEqual(fun(self.array10), 6.9448853328785844, delta=350)
def test_katsuura(self): """Test the katsuura function.""" fun = get_problem('katsuura', self.dimension, -100, 100) self.assertAlmostEqual(fun(self.array10), 3837.4739882594373, delta=4000)
def test_powell(self): """Tests the powell function.""" fun = get_problem('powell', dimension=2, lower=-4, upper=5) self.assertAlmostEqual(fun(np.zeros(2)), 0.0)
def test_levy(self): """Test the levy function.""" fun = get_problem('levy', dimension=2, lower=0, upper=np.pi) self.assertAlmostEqual(fun(np.ones(2)), 0.0)
def test_cosine_mixture(self): """Test the cosine mixture function.""" fun = get_problem('cosine_mixture', dimension=2, lower=-1, upper=1) self.assertAlmostEqual(fun(np.zeros(2)), -0.2)
def test_sphere2(self): """Test the sphere 2 function.""" fun = get_problem('sphere2', dimension=2, lower=-1, upper=1) self.assertAlmostEqual(fun(np.zeros(2)), 0.0)
def test_rosenbrock(self): """Test the rosenbrock function.""" fun = get_problem('rosenbrock', self.dimension) self.assertEqual(fun(self.array2), 0.0)
def test_sphere3(self): """Test the sphere 3 function.""" fun = get_problem('sphere3', dimension=2, lower=-65.536, upper=65.536) self.assertAlmostEqual(fun(np.zeros(2)), 0.0)
def test_sphere(self): """Test the sphere function.""" fun = get_problem('sphere', self.dimension) self.assertEqual(fun(self.array), 0.0)
def test_trid(self): """Test the trid function.""" fun = get_problem('trid', dimension=2) self.assertAlmostEqual(fun(np.array([2.0, 2.0])), -2.0)
def test_schwefel(self): """Test the schwefel function.""" fun = get_problem('schwefel', self.dimension) self.assertAlmostEqual(fun(self.array3), 0.0, places=3)
def test_perm(self): """Test the perm function.""" fun = get_problem('perm', dimension=2) self.assertAlmostEqual(fun(np.array([1.0, 0.5])), 0.0)
def test_whitley(self): """Test the whitley function.""" fun = get_problem('whitley', self.dimension) self.assertEqual(fun(self.array2), 0.0)
def test_zakharov(self): """Test the zakharov function.""" fun = get_problem('zakharov', 2, -5, 10) self.assertAlmostEqual(fun(np.zeros(2)), 0.0)
def test_sum_squares(self): """Test the sum squares function.""" fun = get_problem('sum_squares', self.dimension) self.assertEqual(fun(self.array), 0.0)
def test_dixon_price(self): """Test the dixon price function.""" fun = get_problem('dixon_price', 2, -10, 10) solution = np.array([1.0, 0.70710678]) self.assertAlmostEqual(fun(solution), 0.0)
def test_step3(self): """Test the step3 function.""" fun = get_problem('step3', self.dimension) self.assertEqual(fun(self.array), 0.0)
def test_schaffer_n4(self): """Test the schaffer n. 4 function.""" fun = get_problem('schaffer4', lower=-100, upper=100) self.assertAlmostEqual(fun(self.array10[:2]), 0.97545, delta=1e-4)