コード例 #1
0
 def test_lagrangian_size(self):
     self.assertEqual(
         al.NonsmoothAugmentedLagrangian(
             prog=self.prog, include_x_bounds=True).lagrangian_size(), 1)
     self.assertEqual(
         al.NonsmoothAugmentedLagrangian(
             prog=self.prog, include_x_bounds=False).lagrangian_size(), 1)
コード例 #2
0
 def test_eval_ad(self):
     dut = al.NonsmoothAugmentedLagrangian(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)
コード例 #3
0
 def test_eval_double(self):
     dut = al.NonsmoothAugmentedLagrangian(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)
コード例 #4
0
 def test_nonsmooth_augmented_lagrangian_deprecation(self):
     # Remove after 2022-07-01.
     with catch_drake_warnings(expected_count=1):
         dut = al.NonsmoothAugmentedLagrangian(prog=self.prog,
                                               include_x_bounds=True)
         self.assertEqual(dut.lagrangian_size(), 1)
コード例 #5
0
 def test_is_equality(self):
     self.assertEqual(
         al.NonsmoothAugmentedLagrangian(
             prog=self.prog, include_x_bounds=True).is_equality(), [False])