Example #1
0
 def test_GN_quadratic(self):
     GN = Optimization.GaussNewton()
     xopt = GN.minimize(getQuadratic(self.A,self.b),np.array([0,0]))
     x_true = np.array([5.,5.])
     print('xopt: ', xopt)
     print('x_true: ', x_true)
     self.assertTrue(np.linalg.norm(xopt-x_true,2) < TOL, True)
Example #2
0
 def test_GN_quadratic(self):
     GN = Optimization.GaussNewton()
     xopt = GN.minimize(getQuadratic(self.A,self.b),np.array([0,0]))
     x_true = np.array([5.,5.])
     print('xopt: ', xopt)
     print('x_true: ', x_true)
     self.assertTrue(np.linalg.norm(xopt-x_true,2) < TOL, True)
Example #3
0
 def test_ProjGradient_quadraticBounded(self):
     PG = Optimization.ProjectedGradient(debug=True)
     PG.lower, PG.upper = -2, 2
     xopt = PG.minimize(getQuadratic(self.A,self.b),np.array([0,0]))
     x_true = np.array([2.,2.])
     print('xopt: ', xopt)
     print('x_true: ', x_true)
     self.assertTrue(np.linalg.norm(xopt-x_true,2) < TOL, True)
Example #4
0
 def test_ProjGradient_quadraticBounded(self):
     PG = Optimization.ProjectedGradient(debug=True)
     PG.lower, PG.upper = -2, 2
     xopt = PG.minimize(getQuadratic(self.A,self.b),np.array([0,0]))
     x_true = np.array([2.,2.])
     print('xopt: ', xopt)
     print('x_true: ', x_true)
     self.assertTrue(np.linalg.norm(xopt-x_true,2) < TOL, True)
Example #5
0
 def test_ProjGradient_quadratic1Bound(self):
     myB = np.array([-5,1])
     PG = Optimization.ProjectedGradient()
     PG.lower, PG.upper = -2, 2
     xopt = PG.minimize(getQuadratic(self.A,myB),np.array([0,0]))
     x_true = np.array([2.,-1.])
     print('xopt: ', xopt)
     print('x_true: ', x_true)
     self.assertTrue(np.linalg.norm(xopt-x_true,2) < TOL, True)
Example #6
0
 def test_ProjGradient_quadratic1Bound(self):
     myB = np.array([-5,1])
     PG = Optimization.ProjectedGradient()
     PG.lower, PG.upper = -2, 2
     xopt = PG.minimize(getQuadratic(self.A,myB),np.array([0,0]))
     x_true = np.array([2.,-1.])
     print('xopt: ', xopt)
     print('x_true: ', x_true)
     self.assertTrue(np.linalg.norm(xopt-x_true,2) < TOL, True)