Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/core/activations/weighted-quadratic-barrier.cpp |
Date: | 2025-01-30 11:01:55 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 19 | 21 | 90.5% |
Branches: | 15 | 30 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2023, University of Edinburgh, Heriot-Watt University | ||
5 | // Copyright note valid unless otherwise stated in individual files. | ||
6 | // All rights reserved. | ||
7 | /////////////////////////////////////////////////////////////////////////////// | ||
8 | |||
9 | #include "crocoddyl/core/activations/weighted-quadratic-barrier.hpp" | ||
10 | |||
11 | #include "python/crocoddyl/core/activation-base.hpp" | ||
12 | #include "python/crocoddyl/core/core.hpp" | ||
13 | #include "python/crocoddyl/utils/copyable.hpp" | ||
14 | |||
15 | namespace crocoddyl { | ||
16 | namespace python { | ||
17 | |||
18 | 10 | void exposeActivationWeightedQuadraticBarrier() { | |
19 | boost::python::register_ptr_to_python< | ||
20 | 10 | std::shared_ptr<ActivationModelWeightedQuadraticBarrier> >(); | |
21 | |||
22 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::class_<ActivationModelWeightedQuadraticBarrier, |
23 | bp::bases<ActivationModelAbstract> >( | ||
24 | "ActivationModelWeightedQuadraticBarrier", | ||
25 | "Inequality activation model.\n\n" | ||
26 | "The activation is zero when r is between the lower (lb) and upper (ub) " | ||
27 | "bounds, beta\n" | ||
28 | "determines how much of the total range is not activated. This is the " | ||
29 | "activation\n" | ||
30 | "equations:\n" | ||
31 | "a(r) = 0.5 * ||r||_w^2 for lb < r < ub\n" | ||
32 | "a(r) = 0. for lb >= r >= ub," | ||
33 | "where w is the vector of weights", | ||
34 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::init<ActivationBounds, Eigen::VectorXd>( |
35 | 20 | bp::args("self", "bounds", "weights"), | |
36 | "Initialize the activation model.\n\n" | ||
37 | ":param bounds: activation bounds\n" | ||
38 | ":param weights: weights")) | ||
39 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calc", &ActivationModelWeightedQuadraticBarrier::calc, |
40 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
41 | "Compute the inequality activation.\n\n" | ||
42 | ":param data: activation data\n" | ||
43 | ":param r: residual vector") | ||
44 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("calcDiff", &ActivationModelWeightedQuadraticBarrier::calcDiff, |
45 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self", "data", "r"), |
46 | "Compute the derivatives of inequality activation.\n\n" | ||
47 | ":param data: activation data\n" | ||
48 | "Note that the Hessian is constant, so we don't write again this " | ||
49 | "value.\n" | ||
50 | "It assumes that calc has been run first.\n" | ||
51 | ":param r: residual vector \n") | ||
52 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def("createData", &ActivationModelWeightedQuadraticBarrier::createData, |
53 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::args("self"), "Create the weighted quadratic action data.") |
54 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property("bounds", |
55 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_function( |
56 | &ActivationModelWeightedQuadraticBarrier::get_bounds, | ||
57 | ✗ | bp::return_value_policy<bp::return_by_value>()), | |
58 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_function( |
59 | &ActivationModelWeightedQuadraticBarrier::set_bounds), | ||
60 | "bounds (beta, lower and upper bounds)") | ||
61 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .add_property("weights", |
62 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | bp::make_function( |
63 | &ActivationModelWeightedQuadraticBarrier::get_weights, | ||
64 | ✗ | bp::return_internal_reference<>()), | |
65 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | bp::make_function( |
66 | &ActivationModelWeightedQuadraticBarrier::set_weights), | ||
67 | "vector of weights") | ||
68 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
10 | .def(CopyableVisitor<ActivationModelWeightedQuadraticBarrier>()); |
69 | 10 | } | |
70 | |||
71 | } // namespace python | ||
72 | } // namespace crocoddyl | ||
73 |