GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/solvers/fddp.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 16 17 94.1%
Branches: 11 22 50.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh,
5 // Heriot-Watt University
6 // Copyright note valid unless otherwise stated in individual files.
7 // All rights reserved.
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "crocoddyl/core/solvers/fddp.hpp"
11
12 #include "python/crocoddyl/core/core.hpp"
13 #include "python/crocoddyl/utils/copyable.hpp"
14
15 namespace crocoddyl {
16 namespace python {
17
18 32 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SolverFDDP_solves, SolverFDDP::solve, 0,
19 5)
20 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SolverFDDP_computeDirections,
21 SolverDDP::computeDirection, 0, 1)
22
23 10 void exposeSolverFDDP() {
24 10 bp::register_ptr_to_python<boost::shared_ptr<SolverFDDP> >();
25
26
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<SolverFDDP, bp::bases<SolverDDP> >(
27 "SolverFDDP",
28 "Feasibility-driven DDP (FDDP) solver.\n\n"
29 "The FDDP solver computes an optimal trajectory and control commands by "
30 "iterates\n"
31 "running backward and forward passes. The backward-pass updates locally "
32 "the\n"
33 "quadratic approximation of the problem and computes descent direction,\n"
34 "and the forward-pass rollouts this new policy by integrating the system "
35 "dynamics\n"
36 "along a tuple of optimized control commands U*.\n"
37 ":param shootingProblem: shooting problem (list of action models along "
38 "trajectory.)",
39
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<boost::shared_ptr<ShootingProblem> >(
40 20 bp::args("self", "problem"),
41 "Initialize the vector dimension.\n\n"
42 ":param problem: shooting problem."))
43
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("solve", &SolverFDDP::solve,
44
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 SolverFDDP_solves(
45
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "init_xs", "init_us", "maxiter", "is_feasible",
46 "init_reg"),
47 "Compute the optimal trajectory xopt, uopt as lists of T+1 and "
48 "T terms.\n\n"
49 "From an initial guess init_xs,init_us (feasible or not), "
50 "iterate\n"
51 "over computeDirection and tryStep until stoppingCriteria is "
52 "below\n"
53 "threshold. It also describes the globalization strategy used\n"
54 "during the numerical optimization.\n"
55 ":param init_xs: initial guess for state trajectory with T+1 "
56 "elements (default [])\n"
57 ":param init_us: initial guess for control trajectory with T "
58 "elements (default []).\n"
59 ":param maxiter: maximum allowed number of iterations (default "
60 "100).\n"
61 ":param is_feasible: true if the init_xs are obtained from "
62 "integrating the init_us (rollout)\n"
63 "(default False).\n"
64 ":param init_reg: initial guess for the regularization value. "
65 "Very low values are typical\n"
66 " used with very good guess points (default "
67 "1e-9).\n"
68 ":returns the optimal trajectory xopt, uopt and a boolean that "
69 "describes if convergence was reached."))
70
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("updateExpectedImprovement", &SolverFDDP::updateExpectedImprovement,
71 bp::return_value_policy<bp::copy_const_reference>(),
72
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Update the expected improvement model\n\n")
73
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("th_acceptNegStep",
74
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&SolverFDDP::get_th_acceptnegstep),
75
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(&SolverFDDP::set_th_acceptnegstep),
76 "threshold for step acceptance in ascent direction")
77
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<SolverFDDP>());
78 10 }
79
80 } // namespace python
81 } // namespace crocoddyl
82