示例#1
0
 def test_supersimplex_methods(self):
     result = opt.minimize(self.f,
                           self.x0,
                           "supersimplex",
                           maxiter=10,
                           tol=1e-2,
                           inner_tol=1e-8,
                           min_inner_maxiter=100,
                           max_inner_maxiter=10000)
     self.assertArraysAlmostEqual(result.x, self.answer)
示例#2
0
 def test_minimize_evolutionary(self):
     result = opt.minimize(self.f, self.x0, "evolve", maxiter=20)
     self.assertLess(np.linalg.norm(result.x - self.answer), 0.1)
示例#3
0
 def test_minimize_brute_force(self):
     result = opt.minimize(self.f, self.x0, "brute", maxiter=10)
     self.assertArraysAlmostEqual(result.x, self.answer)
示例#4
0
 def test_minimize_swarm(self):
     result = opt.minimize(self.f, self.x0, "swarm", maxiter=30)
     self.assertArraysAlmostEqual(result.x, self.answer)
示例#5
0
 def test_minimize_methods(self):
     for method in ("simplex", "customcg", "basinhopping", "CG", "BFGS",
                    "L-BFGS-B"):  # "homebrew"
         print("Method = ", method)
         result = opt.minimize(self.f, self.x0, method, maxiter=1000)
         self.assertArraysAlmostEqual(result.x, self.answer)