Exemplo n.º 1
0
 def test_lagrangian_size(self):
     self.assertEqual(
         al.AugmentedLagrangianNonsmooth(
             prog=self.prog, include_x_bounds=True).lagrangian_size(), 1)
     self.assertEqual(
         al.AugmentedLagrangianNonsmooth(
             prog=self.prog, include_x_bounds=False).lagrangian_size(), 1)
     self.assertEqual(
         al.AugmentedLagrangianSmooth(
             prog=self.prog, include_x_bounds=True).lagrangian_size(), 1)
     self.assertEqual(
         al.AugmentedLagrangianSmooth(
             prog=self.prog, include_x_bounds=False).lagrangian_size(), 1)
Exemplo n.º 2
0
 def test_is_equality(self):
     self.assertEqual(
         al.AugmentedLagrangianNonsmooth(
             prog=self.prog, include_x_bounds=True).is_equality(), [False])
     self.assertEqual(
         al.AugmentedLagrangianSmooth(prog=self.prog,
                                      include_x_bounds=True).is_equality(),
         [False])
Exemplo n.º 3
0
 def test_eval_ad_smooth(self):
     dut = al.AugmentedLagrangianSmooth(prog=self.prog,
                                        include_x_bounds=True)
     x_val = InitializeAutoDiff(np.array([1., 3]))
     s_val = np.array([AutoDiffXd(1.)])
     al_val, constraint_residue, cost = dut.Eval(x=x_val,
                                                 s=s_val,
                                                 lambda_val=np.array([0.5]),
                                                 mu=0.1)
     self.assertIsInstance(al_val, AutoDiffXd)
     self.assertIsInstance(constraint_residue, np.ndarray)
     self.assertIsInstance(cost, AutoDiffXd)
Exemplo n.º 4
0
 def test_eval_double_smooth(self):
     dut = al.AugmentedLagrangianSmooth(prog=self.prog,
                                        include_x_bounds=True)
     self.assertEqual(dut.s_size(), 1)
     x_val = np.array([1., 3])
     s_val = np.array([3.])
     lambda_val = np.array([0.5])
     al_val, constraint_residue, cost = dut.Eval(x=x_val,
                                                 s=s_val,
                                                 lambda_val=lambda_val,
                                                 mu=0.1)
     self.assertIsInstance(al_val, float)
     self.assertIsInstance(constraint_residue, np.ndarray)
     self.assertIsInstance(cost, float)