GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/activations/quadratic-barrier.cpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 26 27 96.3%
Branches: 22 44 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/quadratic-barrier.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 exposeActivationQuadraticBarrier() {
20
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActivationBounds>(
21 "ActivationBounds",
22 "Activation bounds.\n\n"
23 "The activation bounds describe the lower and upper vector plus it "
24 "activation range\n"
25 "(between 0 and 1), its default value is 1. Note that a full activation "
26 "is defined by\n"
27 "1 and the activation range is equally distributed between the lower and "
28 "upper bounds.",
29
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::init<Eigen::VectorXd, Eigen::VectorXd, bp::optional<double> >(
30 20 bp::args("self", "lb", "ub", "beta"),
31 "Initialize the activation bounds.\n\n"
32 ":param lb: lower bounds\n"
33 ":param ub: upper bounds\n"
34 ":param beta: range of activation (between 0 to 1, default 1)"))
35
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 .add_property("lb", bp::make_getter(&ActivationBounds::lb),
36
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ActivationBounds::lb,
37 10 bp::return_internal_reference<>()),
38 "lower bounds")
39
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 .add_property("ub", bp::make_getter(&ActivationBounds::ub),
40
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_setter(&ActivationBounds::lb,
41 10 bp::return_internal_reference<>()),
42 "upper bounds")
43
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property("beta", &ActivationBounds::beta, "beta")
44
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActivationBounds>());
45
46 boost::python::register_ptr_to_python<
47 10 boost::shared_ptr<ActivationModelQuadraticBarrier> >();
48
49
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::class_<ActivationModelQuadraticBarrier,
50 bp::bases<ActivationModelAbstract> >(
51 "ActivationModelQuadraticBarrier",
52 "Inequality activation model.\n\n"
53 "The activation is zero when r is between the lower (lb) and upper (ub) "
54 "bounds, beta\n"
55 "determines how much of the total range is not activated. This is the "
56 "activation\n"
57 "equations:\n"
58 "a(r) = 0.5 * ||r||^2 for lb > r > ub\n"
59 "a(r) = 0. for lb <= r <= ub.",
60
1/2
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 bp::init<ActivationBounds>(bp::args("self", "bounds"),
61 "Initialize the activation model.\n\n"
62 ":param bounds: activation bounds"))
63
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calc", &ActivationModelQuadraticBarrier::calc,
64
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
65 "Compute the inequality activation.\n\n"
66 ":param data: activation data\n"
67 ":param r: residual vector")
68
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("calcDiff", &ActivationModelQuadraticBarrier::calcDiff,
69
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self", "data", "r"),
70 "Compute the derivatives of inequality activation.\n\n"
71 ":param data: activation data\n"
72 "Note that the Hessian is constant, so we don't write again this "
73 "value.\n"
74 "It assumes that calc has been run first.\n"
75 ":param r: residual vector \n")
76
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def("createData", &ActivationModelQuadraticBarrier::createData,
77
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::args("self"), "Create the weighted quadratic action data.")
78
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .add_property(
79 "bounds",
80
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 bp::make_function(&ActivationModelQuadraticBarrier::get_bounds,
81 bp::return_internal_reference<>()),
82
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 bp::make_function(&ActivationModelQuadraticBarrier::set_bounds),
83 "bounds (beta, lower and upper bounds)")
84
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 .def(CopyableVisitor<ActivationModelQuadraticBarrier>());
85 10 }
86
87 } // namespace python
88 } // namespace crocoddyl
89