def test_convergence(self): gnCriterion = GradientNormCriterion(10**-3) step_opt = ArmijoBacktracking(1, 0.5) opt = DFP(gnCriterion, step_opt) res = opt.optimize(self.f, np.array([-1, -2])) self.assertInRange(res.x, np.array([1, 1]), 10**-2)
def test_convergence(self): gnCriterion = GradientNormCriterion(10**-3) step_opt = ArmijoBacktracking(1, 0.5) unc_opt = BFGS(gnCriterion, step_opt) opt = Penalty(unc_opt) res = opt.optimize(self.f, np.array([-6, 9]), eq_constraints=[lambda x: x[0] + x[1] - 2], ineq_constraints=[lambda x: -x[0]]) self.assertInRange(res.x, np.array([1, 1]), 10**-3)
def test_convergence(self): gnCriterion = GradientNormCriterion(10**-3) step_opt = ArmijoBacktracking(1, 0.5) unc_opt = BFGS(gnCriterion, step_opt) opt = AugmentedLagrangian(unc_opt) res = opt.optimize(self.f, np.array([4, 8]), eq_constraints=[lambda x: x[0] - 1], ineq_constraints=[lambda x: x[0] + x[1] - 2]) self.assertInRange(res.x, np.array([1, 0]), 10**-3)
def test_convergence(self): step_opt = ArmijoBacktracking(1, 0.5) arg_criterion = IterationNumberCriterion(500) unc_opt = HookeJeeves(arg_criterion, HookeJeeves.generate_pertubation_vector(2, 0.1)) opt = Interior(unc_opt, epsilon=10**-4) res = opt.optimize(self.f, np.array([-1, -1]), eq_constraints=[lambda x: x[0] - 1], ineq_constraints=[lambda x: x[0] + x[1] - 2]) self.assertInRange(res.x, np.array([1, 0]), 10**-3)
def setUp(self): self.__x0 = np.array([0, 0]) self.__gnCriterion = GradientNormCriterion(10**-3) self.__step_opt = ArmijoBacktracking(1, 0.5) self.__n = 3 self.__opt = np.array([3, 1])