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 |
boost::shared_ptr<ActivationModelWeightedQuadraticBarrier> >(); |
21 |
|
|
|
22 |
✓✗ |
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 |
✓✗ |
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 |
|
|
.def("calc", &ActivationModelWeightedQuadraticBarrier::calc, |
40 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
41 |
|
|
"Compute the inequality activation.\n\n" |
42 |
|
|
":param data: activation data\n" |
43 |
✓✗ |
10 |
":param r: residual vector") |
44 |
|
|
.def("calcDiff", &ActivationModelWeightedQuadraticBarrier::calcDiff, |
45 |
✓✗ |
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 |
✓✗ |
10 |
":param r: residual vector \n") |
52 |
|
|
.def("createData", &ActivationModelWeightedQuadraticBarrier::createData, |
53 |
✓✗✓✗
|
20 |
bp::args("self"), "Create the weighted quadratic action data.") |
54 |
|
|
.add_property("bounds", |
55 |
✓✗ |
10 |
bp::make_function( |
56 |
|
|
&ActivationModelWeightedQuadraticBarrier::get_bounds, |
57 |
|
|
bp::return_value_policy<bp::return_by_value>()), |
58 |
✓✗ |
20 |
bp::make_function( |
59 |
|
|
&ActivationModelWeightedQuadraticBarrier::set_bounds), |
60 |
✓✗ |
10 |
"bounds (beta, lower and upper bounds)") |
61 |
|
|
.add_property("weights", |
62 |
✓✗ |
10 |
bp::make_function( |
63 |
|
|
&ActivationModelWeightedQuadraticBarrier::get_weights, |
64 |
|
|
bp::return_internal_reference<>()), |
65 |
✓✗ |
20 |
bp::make_function( |
66 |
|
|
&ActivationModelWeightedQuadraticBarrier::set_weights), |
67 |
✓✗ |
10 |
"vector of weights") |
68 |
✓✗ |
10 |
.def(CopyableVisitor<ActivationModelWeightedQuadraticBarrier>()); |
69 |
|
10 |
} |
70 |
|
|
|
71 |
|
|
} // namespace python |
72 |
|
|
} // namespace crocoddyl |