GCC Code Coverage Report


Directory: ./
File: unittest/test_solvers.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 101 101 100.0%
Branches: 234 456 51.3%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2024, LAAS-CNRS, New York University,
5 // Max Planck Gesellschaft, University of Edinburgh,
6 // INRIA, Heriot-Watt University
7 // Copyright note valid unless otherwise stated in individual files.
8 // All rights reserved.
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #define BOOST_TEST_NO_MAIN
12 #define BOOST_TEST_ALTERNATIVE_INIT_API
13
14 #include "crocoddyl/core/utils/callbacks.hpp"
15 #include "factory/solver.hpp"
16 #include "unittest_common.hpp"
17
18 using namespace boost::unit_test;
19 using namespace crocoddyl::unittest;
20
21 //____________________________________________________________________________//
22
23 7 void test_kkt_dimension(ActionModelTypes::Type action_type, size_t T) {
24 // Create action models
25 boost::shared_ptr<crocoddyl::ActionModelAbstract> model =
26
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 ActionModelFactory().create(action_type);
27 boost::shared_ptr<crocoddyl::ActionModelAbstract> model2 =
28
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 ActionModelFactory().create(action_type, ActionModelFactory::Second);
29 boost::shared_ptr<crocoddyl::ActionModelAbstract> modelT =
30
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 ActionModelFactory().create(action_type, ActionModelFactory::Terminal);
31
32 // Create the kkt solver
33
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 SolverFactory factory;
34 boost::shared_ptr<crocoddyl::SolverKKT> kkt =
35 boost::static_pointer_cast<crocoddyl::SolverKKT>(
36
1/2
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 factory.create(SolverTypes::SolverKKT, model, model2, modelT, T));
37
38 // define some aliases
39
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 const std::size_t ndx = kkt->get_ndx();
40
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 const std::size_t nu = kkt->get_nu();
41
42 // Test the different matrix sizes
43
6/12
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 7 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 7 times.
7 BOOST_CHECK_EQUAL(kkt->get_kkt().rows(), 2 * ndx + nu);
44
6/12
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 7 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 7 times.
7 BOOST_CHECK_EQUAL(kkt->get_kkt().cols(), 2 * ndx + nu);
45
6/12
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 7 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 7 times.
7 BOOST_CHECK_EQUAL(kkt->get_kktref().size(), 2 * ndx + nu);
46
6/12
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 7 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 7 times.
7 BOOST_CHECK_EQUAL(kkt->get_primaldual().size(), 2 * ndx + nu);
47
6/12
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 7 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 7 times.
7 BOOST_CHECK_EQUAL(kkt->get_us().size(), T);
48
6/12
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 7 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 7 times.
7 BOOST_CHECK_EQUAL(kkt->get_xs().size(), T + 1);
49 7 }
50
51 //____________________________________________________________________________//
52
53 7 void test_kkt_search_direction(ActionModelTypes::Type action_type, size_t T) {
54 // Create action models
55 boost::shared_ptr<crocoddyl::ActionModelAbstract> model =
56
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 ActionModelFactory().create(action_type);
57 boost::shared_ptr<crocoddyl::ActionModelAbstract> model2 =
58
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 ActionModelFactory().create(action_type, ActionModelFactory::Second);
59 boost::shared_ptr<crocoddyl::ActionModelAbstract> modelT =
60
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 ActionModelFactory().create(action_type, ActionModelFactory::Terminal);
61
62 // Create the kkt solver
63
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 SolverFactory factory;
64 boost::shared_ptr<crocoddyl::SolverKKT> kkt =
65 boost::static_pointer_cast<crocoddyl::SolverKKT>(
66
1/2
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
14 factory.create(SolverTypes::SolverKKT, model, model2, modelT, T));
67
68 // Generate the different state along the trajectory
69 const boost::shared_ptr<crocoddyl::ShootingProblem>& problem =
70
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 kkt->get_problem();
71 const boost::shared_ptr<crocoddyl::StateAbstract>& state =
72 7 problem->get_runningModels()[0]->get_state();
73 7 std::vector<Eigen::VectorXd> xs;
74 7 std::vector<Eigen::VectorXd> us;
75
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 7 times.
77 for (std::size_t i = 0; i < T; ++i) {
76 const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model =
77 70 problem->get_runningModels()[i];
78
2/4
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 70 times.
✗ Branch 6 not taken.
70 xs.push_back(state->rand());
79
3/6
✓ Branch 3 taken 70 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 70 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 70 times.
✗ Branch 10 not taken.
70 us.push_back(Eigen::VectorXd::Random(model->get_nu()));
80 }
81
2/4
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
7 xs.push_back(state->rand());
82
83 // Compute the search direction
84
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 kkt->setCandidate(xs, us);
85
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 kkt->computeDirection();
86
87 // define some aliases
88
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 const std::size_t ndx = kkt->get_ndx();
89
1/2
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 const std::size_t nu = kkt->get_nu();
90
2/4
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
7 Eigen::MatrixXd kkt_mat = kkt->get_kkt();
91
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 Eigen::Block<Eigen::MatrixXd> hess = kkt_mat.block(0, 0, ndx + nu, ndx + nu);
92
93 // Checking the symmetricity of the Hessian
94
9/18
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 7 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 7 times.
7 BOOST_CHECK((hess - hess.transpose()).isZero(1e-9));
95
96 // Check initial state
97
15/30
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 7 times.
✗ Branch 17 not taken.
✓ Branch 21 taken 7 times.
✗ Branch 22 not taken.
✓ Branch 26 taken 7 times.
✗ Branch 27 not taken.
✓ Branch 30 taken 7 times.
✗ Branch 31 not taken.
✓ Branch 34 taken 7 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 7 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 7 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 7 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 7 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 7 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 7 times.
✗ Branch 53 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 7 times.
7 BOOST_CHECK((state->diff_dx(state->integrate_x(xs[0], kkt->get_dxs()[0]),
98 kkt->get_problem()->get_x0()))
99 .isZero(1e-9));
100 7 }
101
102 //____________________________________________________________________________//
103
104 25 void test_solver_against_kkt_solver(SolverTypes::Type solver_type,
105 ActionModelTypes::Type action_type,
106 size_t T) {
107 // Create action models
108 boost::shared_ptr<crocoddyl::ActionModelAbstract> model =
109
2/4
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
25 ActionModelFactory().create(action_type);
110 boost::shared_ptr<crocoddyl::ActionModelAbstract> model2 =
111
2/4
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
25 ActionModelFactory().create(action_type, ActionModelFactory::Second);
112 boost::shared_ptr<crocoddyl::ActionModelAbstract> modelT =
113
2/4
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
25 ActionModelFactory().create(action_type, ActionModelFactory::Terminal);
114
115 // Create the testing and KKT solvers
116
1/2
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
25 SolverFactory solver_factory;
117 boost::shared_ptr<crocoddyl::SolverAbstract> solver =
118
1/2
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
50 solver_factory.create(solver_type, model, model2, modelT, T);
119 boost::shared_ptr<crocoddyl::SolverAbstract> kkt =
120
1/2
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
50 solver_factory.create(SolverTypes::SolverKKT, model, model2, modelT, T);
121
122 // Get the pointer to the problem so we can create the equivalent kkt solver.
123 const boost::shared_ptr<crocoddyl::ShootingProblem>& problem =
124
1/2
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 solver->get_problem();
125
126 // Generate the different state along the trajectory
127 const boost::shared_ptr<crocoddyl::StateAbstract>& state =
128 25 problem->get_runningModels()[0]->get_state();
129 25 std::vector<Eigen::VectorXd> xs;
130 25 std::vector<Eigen::VectorXd> us;
131
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 25 times.
275 for (std::size_t i = 0; i < T; ++i) {
132 const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model =
133 250 problem->get_runningModels()[i];
134
2/4
✓ Branch 2 taken 250 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 250 times.
✗ Branch 6 not taken.
250 xs.push_back(state->rand());
135
3/6
✓ Branch 3 taken 250 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 250 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 250 times.
✗ Branch 10 not taken.
250 us.push_back(Eigen::VectorXd::Random(model->get_nu()));
136 }
137
2/4
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
25 xs.push_back(state->rand());
138
139 // Define the callback function
140 25 std::vector<boost::shared_ptr<crocoddyl::CallbackAbstract> > cbs;
141
2/4
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
25 cbs.push_back(boost::make_shared<crocoddyl::CallbackVerbose>());
142
1/2
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 kkt->setCallbacks(cbs);
143
1/2
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 solver->setCallbacks(cbs);
144
145 // Print the name of the action model for introspection
146
2/4
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
25 std::cout << ActionModelTypes::all[action_type] << std::endl;
147
148 // Solve the problem using the KKT solver
149
1/2
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 kkt->solve(xs, us, 100);
150
151 // Solve the problem using the solver in testing
152
1/2
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 solver->solve(xs, us, 100);
153
154 // check trajectory dimensions
155
6/12
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 25 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 25 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 25 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 25 times.
25 BOOST_CHECK_EQUAL(solver->get_us().size(), T);
156
6/12
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 25 times.
✗ Branch 10 not taken.
✓ Branch 15 taken 25 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 25 times.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 25 times.
25 BOOST_CHECK_EQUAL(solver->get_xs().size(), T + 1);
157
158 // initial state
159
9/18
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 25 times.
✗ Branch 12 not taken.
✓ Branch 17 taken 25 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 25 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 25 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 25 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 25 times.
✗ Branch 31 not taken.
✗ Branch 35 not taken.
✓ Branch 36 taken 25 times.
25 BOOST_CHECK((solver->get_xs()[0] - problem->get_x0()).isZero(1e-9));
160
161 // check solutions against each other
162
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 25 times.
275 for (unsigned int t = 0; t < T; ++t) {
163 const boost::shared_ptr<crocoddyl::ActionModelAbstract>& model =
164
1/2
✓ Branch 2 taken 250 times.
✗ Branch 3 not taken.
250 solver->get_problem()->get_runningModels()[t];
165 250 std::size_t nu = model->get_nu();
166
12/24
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 250 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 250 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 250 times.
✗ Branch 17 not taken.
✓ Branch 20 taken 250 times.
✗ Branch 21 not taken.
✓ Branch 24 taken 250 times.
✗ Branch 25 not taken.
✓ Branch 28 taken 250 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 250 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 250 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 250 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 250 times.
✗ Branch 41 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 250 times.
250 BOOST_CHECK(
167 (state->diff_dx(solver->get_xs()[t], kkt->get_xs()[t])).isZero(1e-9));
168
11/22
✓ Branch 1 taken 250 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 250 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 250 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 250 times.
✗ Branch 16 not taken.
✓ Branch 20 taken 250 times.
✗ Branch 21 not taken.
✓ Branch 24 taken 250 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 250 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 250 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 250 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 250 times.
✗ Branch 37 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 250 times.
250 BOOST_CHECK((solver->get_us()[t].head(nu) - kkt->get_us()[t]).isZero(1e-9));
169 }
170
12/24
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
✓ Branch 11 taken 25 times.
✗ Branch 12 not taken.
✓ Branch 16 taken 25 times.
✗ Branch 17 not taken.
✓ Branch 20 taken 25 times.
✗ Branch 21 not taken.
✓ Branch 24 taken 25 times.
✗ Branch 25 not taken.
✓ Branch 28 taken 25 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 25 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 25 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 25 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 25 times.
✗ Branch 41 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 25 times.
25 BOOST_CHECK(
171 (state->diff_dx(solver->get_xs()[T], kkt->get_xs()[T])).isZero(1e-9));
172 25 }
173
174 //____________________________________________________________________________//
175
176 7 void register_kkt_solver_unit_tests(ActionModelTypes::Type action_type,
177 const std::size_t T) {
178
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 boost::test_tools::output_test_stream test_name;
179
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 test_name << "test_SolverKKT_" << action_type;
180
4/8
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
7 test_suite* ts = BOOST_TEST_SUITE(test_name.str());
181
4/8
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
7 std::cout << "Running " << test_name.str() << std::endl;
182
5/10
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
7 ts->add(BOOST_TEST_CASE(boost::bind(&test_kkt_dimension, action_type, T)));
183 14 ts->add(
184
5/10
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
7 BOOST_TEST_CASE(boost::bind(&test_kkt_search_direction, action_type, T)));
185
3/6
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
7 framework::master_test_suite().add(ts);
186 7 }
187
188 25 void register_solvers_againt_kkt_unit_tests(SolverTypes::Type solver_type,
189 ActionModelTypes::Type action_type,
190 const std::size_t T) {
191
2/4
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
25 boost::test_tools::output_test_stream test_name;
192
4/8
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 25 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
25 test_name << "test_" << solver_type << "_vs_SolverKKT_" << action_type;
193
4/8
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 25 times.
✗ Branch 12 not taken.
25 test_suite* ts = BOOST_TEST_SUITE(test_name.str());
194
4/8
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 25 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
25 std::cout << "Running " << test_name.str() << std::endl;
195
5/10
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 25 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 25 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 25 times.
✗ Branch 15 not taken.
25 ts->add(BOOST_TEST_CASE(boost::bind(&test_solver_against_kkt_solver,
196 solver_type, action_type, T)));
197
3/6
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
25 framework::master_test_suite().add(ts);
198 25 }
199
200 //____________________________________________________________________________//
201
202 1 bool init_function() {
203 1 std::size_t T = 10;
204
205
2/2
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1 times.
8 for (size_t i = 0; i < ActionModelTypes::all.size(); ++i) {
206 7 register_kkt_solver_unit_tests(ActionModelTypes::all[i], T);
207 }
208
209 // We start from 1 as 0 is the kkt solver
210
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
6 for (size_t s = 1; s < SolverTypes::all.size(); ++s) {
211
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 5 times.
30 for (size_t i = 0; i < ActionModelTypes::ActionModelImpulseFwdDynamics_HyQ;
212 ++i) {
213 25 register_solvers_againt_kkt_unit_tests(SolverTypes::all[s],
214 25 ActionModelTypes::all[i], T);
215 }
216 }
217 1 return true;
218 }
219
220 //____________________________________________________________________________//
221
222 1 int main(int argc, char* argv[]) {
223 1 return ::boost::unit_test::unit_test_main(&init_function, argc, argv);
224 }
225