예제 #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)
예제 #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])
예제 #3
0
 def test_eval_ad_nonsmooth(self):
     dut = al.AugmentedLagrangianNonsmooth(prog=self.prog,
                                           include_x_bounds=True)
     x_val = InitializeAutoDiff(np.array([1., 3]))
     al_val, constraint_residue, cost = dut.Eval(x=x_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)
예제 #4
0
 def test_eval_double_nonsmooth(self):
     dut = al.AugmentedLagrangianNonsmooth(prog=self.prog,
                                           include_x_bounds=True)
     x_val = np.array([1., 3])
     lambda_val = np.array([0.5])
     al_val, constraint_residue, cost = dut.Eval(x=x_val,
                                                 lambda_val=lambda_val,
                                                 mu=0.1)
     self.assertIsInstance(al_val, float)
     self.assertIsInstance(constraint_residue, np.ndarray)
     self.assertIsInstance(cost, float)