1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2020-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 |
|
|
#include "crocoddyl/core/activations/quadratic-flat-log.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 exposeActivationQuadFlatLog() { |
19 |
|
|
boost::python::register_ptr_to_python< |
20 |
|
10 |
boost::shared_ptr<ActivationModelQuadFlatLog> >(); |
21 |
|
|
|
22 |
✓✗ |
10 |
bp::class_<ActivationModelQuadFlatLog, bp::bases<ActivationModelAbstract> >( |
23 |
|
|
"ActivationModelQuadFlatLog", |
24 |
|
|
"Quadratic flat activation model.\n" |
25 |
|
|
"A quadratic flat action describes a quadratic flat function that " |
26 |
|
|
"depends on the residual, i.e.\n" |
27 |
|
|
"log(1 + ||r||^2 / alpha).", |
28 |
✓✗ |
20 |
bp::init<int, double>(bp::args("self", "nr", "alpha"), |
29 |
|
|
"Initialize the activation model.\n\n" |
30 |
|
|
":param nr: dimension of the cost-residual vector" |
31 |
|
|
"param alpha: width of quadratic basin near zero")) |
32 |
|
|
.def("calc", &ActivationModelQuadFlatLog::calc, |
33 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
34 |
|
|
"Compute the log(1 + ||r||^2 / alpha).\n" |
35 |
|
|
":param data: activation data\n" |
36 |
✓✗ |
10 |
":param r: residual vector") |
37 |
|
|
.def("calcDiff", &ActivationModelQuadFlatLog::calcDiff, |
38 |
✓✗ |
20 |
bp::args("self", "data", "r"), |
39 |
|
|
"Compute the derivatives of a quadratic flat function.\n" |
40 |
|
|
"Note that the Hessian is constant, so we don't write again this " |
41 |
|
|
"value.\n" |
42 |
|
|
":param data: activation data\n" |
43 |
✓✗ |
10 |
":param r: residual vector \n") |
44 |
|
|
.def("createData", &ActivationModelQuadFlatLog::createData, |
45 |
✓✗✓✗
|
20 |
bp::args("self"), "Create the quadratic flat activation data.\n") |
46 |
|
|
.add_property( |
47 |
✓✗ |
10 |
"alpha", bp::make_function(&ActivationModelQuadFlatLog::get_alpha), |
48 |
✓✗✓✗
|
30 |
bp::make_function(&ActivationModelQuadFlatLog::set_alpha), "alpha") |
49 |
✓✗ |
10 |
.def(CopyableVisitor<ActivationModelQuadFlatLog>()); |
50 |
|
10 |
} |
51 |
|
|
|
52 |
|
|
} // namespace python |
53 |
|
|
} // namespace crocoddyl |