| 73 | }; |
| 74 | |
| 75 | void Function(py::module& m) |
| 76 | { |
| 77 | ::py::class_< |
| 78 | dart::optimizer::Function, |
| 79 | PyFunction, |
| 80 | std::shared_ptr<dart::optimizer::Function>>(m, "Function") |
| 81 | .def(::py::init<>()) |
| 82 | .def(::py::init<const std::string&>(), ::py::arg("name")) |
| 83 | .def( |
| 84 | "setName", |
| 85 | +[](dart::optimizer::Function* self, const std::string& newName) { |
| 86 | self->setName(newName); |
| 87 | }, |
| 88 | ::py::arg("newName")) |
| 89 | .def( |
| 90 | "getName", |
| 91 | +[](const dart::optimizer::Function* self) -> const std::string& { |
| 92 | return self->getName(); |
| 93 | }, |
| 94 | ::py::return_value_policy::reference_internal); |
| 95 | |
| 96 | ::py::class_< |
| 97 | dart::optimizer::NullFunction, |
| 98 | dart::optimizer::Function, |
| 99 | std::shared_ptr<dart::optimizer::NullFunction>>(m, "NullFunction") |
| 100 | // .def(::py::init<>()) |
| 101 | // .def(::py::init<const std::string &>(), |
| 102 | // ::py::arg("name")) |
| 103 | .def( |
| 104 | "eval", |
| 105 | +[](dart::optimizer::NullFunction* self, |
| 106 | const Eigen::VectorXd& _arg0_) -> double { |
| 107 | return self->eval(_arg0_); |
| 108 | }, |
| 109 | ::py::arg("arg0_")); |
| 110 | |
| 111 | ::py::class_< |
| 112 | dart::optimizer::MultiFunction, |
| 113 | std::shared_ptr<dart::optimizer::MultiFunction>>(m, "MultiFunction"); |
| 114 | |
| 115 | ::py::class_< |
| 116 | dart::optimizer::ModularFunction, |
| 117 | dart::optimizer::Function, |
| 118 | std::shared_ptr<dart::optimizer::ModularFunction>>(m, "ModularFunction") |
| 119 | // .def(::py::init<>()) |
| 120 | // .def(::py::init<const std::string &>(), |
| 121 | // ::py::arg("name")) |
| 122 | .def( |
| 123 | "eval", |
| 124 | +[](dart::optimizer::ModularFunction* self, |
| 125 | const Eigen::VectorXd& _x) -> double { return self->eval(_x); }, |
| 126 | ::py::arg("x")) |
| 127 | .def( |
| 128 | "setCostFunction", |
| 129 | +[](dart::optimizer::ModularFunction* self, |
| 130 | dart::optimizer::CostFunction _cost) { |
| 131 | self->setCostFunction(_cost); |
| 132 | }, |
no test coverage detected