Beispiel #1
0
 def test_reproduce(self):
     seed = 1234
     res1 = sda(self.func, None, self.ld_bounds, seed=seed)
     res2 = sda(self.func, None, self.ld_bounds, seed=seed)
     res3 = sda(self.func, None, self.ld_bounds, seed=seed)
     # If we have reproducible results, x components found has to
     # be exactly the same, which is not the case with no seeding
     assert_equal(res1.x, res2.x)
     assert_equal(res1.x, res3.x)
Beispiel #2
0
 def test_reproduce(self):
     seed = 1234
     res1 = sda(self.func, None, self.ld_bounds, seed=seed)
     res2 = sda(self.func, None, self.ld_bounds, seed=seed)
     res3 = sda(self.func, None, self.ld_bounds, seed=seed)
     # If we have reproducible results, x components found has to
     # be exactly the same, which is not the case with no seeding
     assert_equal(res1.x, res2.x)
     assert_equal(res1.x, res3.x)
Beispiel #3
0
 def test_high_dim(self):
     ret = sda(self.func, None, self.hd_bounds)
     assert_allclose(ret.fun, 0., atol=1e-12)
Beispiel #4
0
 def test_low_dim(self):
     ret = sda(self.func, None, self.ld_bounds, seed=self.seed)
     assert_allclose(ret.fun, 0., atol=1e-12)
Beispiel #5
0
 def test_high_dim(self):
     ret = sda(self.func, None, self.hd_bounds)
     assert_allclose(ret.fun, 0., atol=1e-12)
Beispiel #6
0
 def test_low_dim(self):
     ret = sda(self.func, None, self.ld_bounds, seed=self.seed)
     assert_allclose(ret.fun, 0., atol=1e-12)
 def Solve(self, problem):
     lb, ub = problem.GetBounds()
     ret = sda(lambda x: problem.Calculate(x), None, bounds=list(zip(lb, ub)), \
               seed=100, maxfun=self.max_iters, visit=2.72, maxiter=self.max_iters)
     n_evals = problem.GetCalculationsStatistics()
     return ret.x, ret.fun, n_evals