Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/activations/quadratic-flat-exp.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 16 | 16 | 100.0% |
Branches: | 12 | 24 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2020-2024, 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/activations/quadratic-flat-exp.hpp" | ||
11 | |||
12 | #include "python/crocoddyl/core/activation-base.hpp" | ||
13 | #include "python/crocoddyl/core/core.hpp" | ||
14 | #include "python/crocoddyl/utils/copyable.hpp" | ||
15 | |||
16 | namespace crocoddyl { | ||
17 | namespace python { | ||
18 | |||
19 | 10 | void exposeActivationQuadFlatExp() { | |
20 | boost::python::register_ptr_to_python< | ||
21 | 10 | boost::shared_ptr<ActivationModelQuadFlatExp> >(); | |
22 | |||
23 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActivationModelQuadFlatExp, bp::bases<ActivationModelAbstract> >( |
24 | "ActivationModelQuadFlatExp", | ||
25 | "Quadratic flat activation model.\n\n" | ||
26 | "A quadratic flat action describes a quadratic flat function that " | ||
27 | "depends on the residual, i.e.\n" | ||
28 | "1 - exp(-||r||^2 / alpha).", | ||
29 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::init<std::size_t, double>( |
30 | 20 | bp::args("self", "nr", "alpha"), | |
31 | "Initialize the activation model.\n\n" | ||
32 | ":param nr: dimension of the cost-residual vector" | ||
33 | "param alpha: width of quadratic basin near zero")) | ||
34 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calc", &ActivationModelQuadFlatExp::calc, |
35 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
36 | "Compute the 1 - exp(-||r||^2 / alpha).\n\n" | ||
37 | ":param data: activation data\n" | ||
38 | ":param r: residual vector") | ||
39 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calcDiff", &ActivationModelQuadFlatExp::calcDiff, |
40 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
41 | "Compute the derivatives of a quadratic flat function.\n\n" | ||
42 | "Note that the Hessian is constant, so we don't write again this " | ||
43 | "value.\n" | ||
44 | ":param data: activation data\n" | ||
45 | ":param r: residual vector \n") | ||
46 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("createData", &ActivationModelQuadFlatExp::createData, |
47 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self"), "Create the quadratic flat activation data.\n\n") |
48 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property( |
49 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | "alpha", bp::make_function(&ActivationModelQuadFlatExp::get_alpha), |
50 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_function(&ActivationModelQuadFlatExp::set_alpha), "alpha") |
51 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActivationModelQuadFlatExp>()); |
52 | 10 | } | |
53 | |||
54 | } // namespace python | ||
55 | } // namespace crocoddyl | ||
56 |