def runTest(self): n = 2 npt = n + 1 x0 = np.array([-1.2, 1.0]) delta = 0.5 xl = -1e2 * np.ones((n, )) xu = 1e2 * np.ones((n, )) model = Model(npt, x0, rosenbrock(x0), xl, xu, 1) model.add_new_sample(0, rosenbrock(x0)) x1 = x0 + delta * np.array([1.0, 0.0]) model.change_point(1, x1 - model.xbase, rosenbrock(x1)) x2 = x0 + delta * np.array([0.0, 1.0]) model.change_point(2, x2 - model.xbase, rosenbrock(x2)) model.kopt = 0 # force this # Here (use delta=1), Lagrange polynomials are (1-x-y), 1-x and 1-y # Maximum value in ball is for (1-x-y) at (x,y)=(1/sqrt2, 1/sqrt2) --> max value = 1 + sqrt(2) self.assertAlmostEqual(model.poisedness_constant(delta), 1.0 + sqrt(2.0), places=6, msg="Poisedness wrong")
def runTest(self): # Based originally on DFO book, Figure 3.3 - solution from Mathematica n = 2 npt = 2 * n + 1 x0 = np.array([0.5, 0.5]) xl = -1e2 * np.ones((n, )) xu = 1e2 * np.ones((n, )) model = Model(npt, x0, objfun(x0), xl, xu, 1) x1 = np.array([0.524, 0.0006]) model.change_point(1, x1 - model.xbase, objfun(x1)) x2 = np.array([0.032, 0.323]) model.change_point(2, x2 - model.xbase, objfun(x2)) x3 = np.array([0.187, 0.89]) model.change_point(3, x3 - model.xbase, objfun(x3)) x4 = np.array([0.982, 0.368]) model.change_point(4, x4 - model.xbase, objfun(x4)) delta = 0.5 model.kopt = 0 # force base point self.assertAlmostEqual(model.poisedness_constant(delta), 1.10018, places=3, msg="Poisedness wrong")
def runTest(self): # DFO book, Figure 3.1 (note errata) - solution from Mathematica n = 2 npt = (n + 1) * (n + 2) // 2 x0 = np.array([0.5, 0.5]) xl = -1e2 * np.ones((n, )) xu = 1e2 * np.ones((n, )) model = Model(npt, x0, objfun(x0), xl, xu, 1) x1 = np.array([0.05, 0.1]) model.change_point(1, x1 - model.xbase, objfun(x1)) x2 = np.array([0.1, 0.05]) model.change_point(2, x2 - model.xbase, objfun(x2)) x3 = np.array([0.95, 0.9]) model.change_point(3, x3 - model.xbase, objfun(x3)) x4 = np.array([0.9, 0.95]) model.change_point(4, x4 - model.xbase, objfun(x4)) x5 = np.array([0.85, 0.85]) model.change_point(5, x5 - model.xbase, objfun(x5)) delta = 0.5 model.kopt = 0 # force base point self.assertAlmostEqual(model.poisedness_constant(delta), 294.898, places=2, msg="Poisedness wrong")