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