Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/activations/weighted-quadratic.cpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 16 | 16 | 100.0% |
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/activations/weighted-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 exposeActivationWeightedQuad() { | |
20 | boost::python::register_ptr_to_python< | ||
21 | 10 | boost::shared_ptr<ActivationModelWeightedQuad> >(); | |
22 | |||
23 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActivationModelWeightedQuad, bp::bases<ActivationModelAbstract> >( |
24 | "ActivationModelWeightedQuad", | ||
25 | "Weighted quadratic activation model.\n\n" | ||
26 | "A weighted quadratic action describes a quadratic function that depends " | ||
27 | "on the residual,\n" | ||
28 | "i.e. 0.5 *||r||_w^2.", | ||
29 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::init<Eigen::VectorXd>( |
30 | 20 | bp::args("self", "weights"), | |
31 | "Initialize the activation model.\n\n" | ||
32 | ":param weights: weights vector, note that nr=weights.size()")) | ||
33 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calc", &ActivationModelWeightedQuad::calc, |
34 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
35 | "Compute the 0.5 * ||r||_w^2.\n\n" | ||
36 | ":param data: activation data\n" | ||
37 | ":param r: residual vector") | ||
38 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calcDiff", &ActivationModelWeightedQuad::calcDiff, |
39 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
40 | "Compute the derivatives of a quadratic function.\n\n" | ||
41 | ":param data: activation data\n" | ||
42 | "Note that the Hessian is constant, so we don't write again this " | ||
43 | "value.\n" | ||
44 | "It assumes that calc has been run first.\n" | ||
45 | ":param r: residual vector \n") | ||
46 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("createData", &ActivationModelWeightedQuad::createData, |
47 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self"), "Create the weighted quadratic action data.") |
48 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property("weights", |
49 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_function(&ActivationModelWeightedQuad::get_weights, |
50 | 10 | bp::return_internal_reference<>()), | |
51 | &ActivationModelWeightedQuad::set_weights, | ||
52 | "weights of the quadratic term") | ||
53 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActivationModelWeightedQuad>()); |
54 | 10 | } | |
55 | |||
56 | } // namespace python | ||
57 | } // namespace crocoddyl | ||
58 |