Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/activations/quadratic.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 10 | 10 | 100.0% |
Branches: | 9 | 18 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-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.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 exposeActivationQuad() { | |
20 | boost::python::register_ptr_to_python< | ||
21 | 10 | boost::shared_ptr<ActivationModelQuad> >(); | |
22 | |||
23 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActivationModelQuad, bp::bases<ActivationModelAbstract> >( |
24 | "ActivationModelQuad", | ||
25 | "Quadratic activation model.\n\n" | ||
26 | "A quadratic action describes a quadratic function that depends on the " | ||
27 | "residual, i.e.\n" | ||
28 | "0.5 *||r||^2.", | ||
29 |
1/2✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
|
20 | bp::init<std::size_t>(bp::args("self", "nr"), |
30 | "Initialize the activation model.\n\n" | ||
31 | ":param nr: dimension of the cost-residual vector")) | ||
32 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
20 | .def("calc", &ActivationModelQuad::calc, bp::args("self", "data", "r"), |
33 | "Compute the 0.5 * ||r||^2.\n\n" | ||
34 | ":param data: activation data\n" | ||
35 | ":param r: residual vector") | ||
36 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calcDiff", &ActivationModelQuad::calcDiff, |
37 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
38 | "Compute the derivatives of a quadratic function.\n\n" | ||
39 | "Note that the Hessian is constant, so we don't write again this " | ||
40 | "value.\n" | ||
41 | "It assumes that calc has been run first.\n" | ||
42 | ":param data: activation data\n" | ||
43 | ":param r: residual vector \n") | ||
44 |
2/4✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
20 | .def("createData", &ActivationModelQuad::createData, bp::args("self"), |
45 | "Create the quadratic activation data.\n\n") | ||
46 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActivationModelQuad>()); |
47 | 10 | } | |
48 | |||
49 | } // namespace python | ||
50 | } // namespace crocoddyl | ||
51 |