@@ -223,40 +223,6 @@ TEST_F(C3CartpoleTest, UpdateCostMatrix) {
223223 }
224224}
225225
226- // Test if user can update the LCS for the C3 problem
227- TEST_F (C3CartpoleTest, UpdateLCSTest) {
228- std::vector<drake::solvers::LinearEqualityConstraint*>
229- pre_dynamic_constraints = pOpt->GetDynamicConstraints ();
230- vector<MatrixXd> pre_Al (N);
231- for (int i = 0 ; i < N; ++i) {
232- pre_Al[i] = pre_dynamic_constraints[i]->GetDenseA ();
233- }
234-
235- // Dynamics
236- vector<MatrixXd> An (N, MatrixXd::Identity (n, n));
237- vector<MatrixXd> Bn (N, MatrixXd::Identity (n, k));
238- vector<MatrixXd> Dn (N, MatrixXd::Identity (n, m));
239- vector<VectorXd> dn (N, VectorXd::Ones (n));
240-
241- // Complimentary constraints
242- vector<MatrixXd> En (N, MatrixXd::Identity (m, n));
243- vector<MatrixXd> Fn (N, MatrixXd::Identity (m, m));
244- vector<VectorXd> cn (N, VectorXd::Ones (m));
245- vector<MatrixXd> Hn (N, MatrixXd::Identity (m, k));
246-
247- LCS TestSystem (An, Bn, Dn, dn, En, Fn, Hn, cn, dt);
248-
249- pOpt->UpdateLCS (TestSystem);
250-
251- std::vector<drake::solvers::LinearEqualityConstraint*>
252- pst_dynamic_constraints = pOpt->GetDynamicConstraints ();
253- for (int i = 0 ; i < N; ++i) {
254- // Linear Equality A matrix should be updated
255- MatrixXd pst_Al = pst_dynamic_constraints[i]->GetDenseA ();
256- EXPECT_EQ (pre_Al[i].isApprox (pst_Al), false );
257- }
258- }
259-
260226class C3CartpoleTestParameterizedScalingLCSTest
261227 : public C3CartpoleTest,
262228 public ::testing::WithParamInterface<std::tuple<bool , bool >> {};
@@ -368,6 +334,46 @@ class C3CartpoleTypedTest : public testing::Test, public C3CartpoleProblem {
368334using projection_types = ::testing::Types<C3QP, C3MIQP, C3Plus>;
369335TYPED_TEST_SUITE (C3CartpoleTypedTest, projection_types);
370336
337+ // Test if user can update the LCS for the C3 problem
338+ TYPED_TEST (C3CartpoleTypedTest, UpdateLCSTest) {
339+ c3::C3* pOpt = this ->pOpt .get ();
340+ auto dt = this ->dt ;
341+ std::vector<drake::solvers::LinearEqualityConstraint*>
342+ pre_dynamic_constraints = pOpt->GetDynamicConstraints ();
343+ auto & N = this ->N ;
344+ auto n = this ->n ;
345+ auto k = this ->k ;
346+ auto m = this ->m ;
347+ vector<MatrixXd> pre_Al (N);
348+ for (int i = 0 ; i < N; ++i) {
349+ pre_Al[i] = pre_dynamic_constraints[i]->GetDenseA ();
350+ }
351+
352+ // Dynamics
353+ vector<MatrixXd> An (N, MatrixXd::Identity (n, n));
354+ vector<MatrixXd> Bn (N, MatrixXd::Identity (n, k));
355+ vector<MatrixXd> Dn (N, MatrixXd::Identity (n, m));
356+ vector<VectorXd> dn (N, VectorXd::Ones (n));
357+
358+ // Complimentary constraints
359+ vector<MatrixXd> En (N, MatrixXd::Identity (m, n));
360+ vector<MatrixXd> Fn (N, MatrixXd::Identity (m, m));
361+ vector<VectorXd> cn (N, VectorXd::Ones (m));
362+ vector<MatrixXd> Hn (N, MatrixXd::Identity (m, k));
363+
364+ LCS TestSystem (An, Bn, Dn, dn, En, Fn, Hn, cn, dt);
365+
366+ pOpt->UpdateLCS (TestSystem);
367+
368+ std::vector<drake::solvers::LinearEqualityConstraint*>
369+ pst_dynamic_constraints = pOpt->GetDynamicConstraints ();
370+ for (int i = 0 ; i < N; ++i) {
371+ // Linear Equality A matrix should be updated
372+ MatrixXd pst_Al = pst_dynamic_constraints[i]->GetDenseA ();
373+ EXPECT_EQ (pre_Al[i].isApprox (pst_Al), false );
374+ }
375+ }
376+
371377// Test the cartpole example
372378// This test will take some time to complete ~30s
373379TYPED_TEST (C3CartpoleTypedTest, End2EndCartpoleTest) {
0 commit comments