def test_nnewton_analytic(self): k0 = 0.2 target = lambda xs:func_grad_hess(k0, xs) self.assertTrue(is_reasonable_val_grad_hess(target, [0.1], method="c1", h=0.001)) (convq, xs_o, val, grad) = nnewton(target, [0.1], func="vgh", show_lvl=1) self.assertTrue(convq) self.assertAlmostEqual(k0, xs_o[0])
def test_nnewton_analytic(self): k0 = 0.2 target = lambda xs: func_grad_hess(k0, xs) self.assertTrue( is_reasonable_val_grad_hess(target, [0.1], method="c1", h=0.001)) (convq, xs_o, val, grad) = nnewton(target, [0.1], func="vgh", show_lvl=1) self.assertTrue(convq) self.assertAlmostEqual(k0, xs_o[0])
def test_nnewton(self): k0 = 0.2 target = lambda xs: func(k0, xs) (convq, xs_o, val, grad) = nnewton(target, [0.11]) self.assertTrue(convq) self.assertAlmostEqual(k0, xs_o[0])