Loading...
Searching...
No Matches
constraint-bound.hpp
Go to the documentation of this file.
1//
2// Copyright (c) 2018 CNRS
3//
4// This file is part of tsid
5// tsid is free software: you can redistribute it
6// and/or modify it under the terms of the GNU Lesser General Public
7// License as published by the Free Software Foundation, either version
8// 3 of the License, or (at your option) any later version.
9// tsid is distributed in the hope that it will be
10// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Lesser Public License for more details. You should have
13// received a copy of the GNU Lesser General Public License along with
14// tsid If not, see
15// <http://www.gnu.org/licenses/>.
16//
17
18
19#ifndef __tsid_python_constriant_bound_hpp__
20#define __tsid_python_constriant_bound_hpp__
21
23
25
26namespace tsid
27{
28 namespace python
29 {
30 namespace bp = boost::python;
31
32 template<typename ConstraintBound>
34 : public boost::python::def_visitor< ConstraintPythonVisitor<ConstraintBound> >
35 {
36 template<class PyClass>
37
38 void visit(PyClass& cl) const
39 {
40 cl
41 .def(bp::init<std::string>((bp::arg("name")), "Default constructor with name."))
42 .def(bp::init<std::string, unsigned int>((bp::arg("name"), bp::arg("size")), "Default constructor with name and size."))
43 .def(bp::init<std::string, Eigen::VectorXd, Eigen::VectorXd>((bp::arg("name"), bp::arg("lb"), bp::arg("ub")), "Default constructor with name and constraint."))
44
45 .add_property("rows", &ConstraintBound::rows)
46 .add_property("cols", &ConstraintBound::cols)
47 .def("resize",&ConstraintBound::resize, (bp::arg("r"), bp::arg("c")),"Resize constraint size.")
48
49 .add_property("isEquality", &ConstraintBound::isEquality)
50 .add_property("isInequality", &ConstraintBound::isInequality)
51 .add_property("isBound", &ConstraintBound::isBound)
52
53 .add_property("vector", &ConstraintPythonVisitor::vector)
54 .add_property("lowerBound", &ConstraintPythonVisitor::lowerBound)
55 .add_property("upperBound", &ConstraintPythonVisitor::upperBound)
56
57 .def("setVector", (bool (ConstraintBound::*)(const Eigen::VectorXd &) const) &ConstraintBound::setVector, bp::args("vector"), "Set Vector")
58 .def("setLowerBound", (bool (ConstraintBound::*)(const Eigen::VectorXd &) const) &ConstraintBound::setLowerBound, bp::args("lb"), "Set LowerBound")
59 .def("setUpperBound", (bool (ConstraintBound::*)(const Eigen::VectorXd &) const) &ConstraintBound::setUpperBound, bp::args("ub"), "Set UpperBound")
60 ;
61 }
62 static Eigen::VectorXd vector (const ConstraintBound & self) {return self.vector();}
63 static Eigen::VectorXd lowerBound (const ConstraintBound & self) {return self.lowerBound();}
64 static Eigen::VectorXd upperBound (const ConstraintBound & self) {return self.upperBound();}
65
66 static void expose(const std::string & class_name)
67 {
68 std::string doc = "Constraint Bound info.";
69 bp::class_<ConstraintBound>(class_name.c_str(),
70 doc.c_str(),
71 bp::no_init)
73 }
74 };
75 }
76}
77
78
79#endif // ifndef __tsid_python_constriant_bound_hpp__
Definition: constraint-bound.hpp:27
Definition: constraint-bound.hpp:35
static void expose(const std::string &class_name)
Definition: constraint-bound.hpp:66
void visit(PyClass &cl) const
Definition: constraint-bound.hpp:38
static Eigen::VectorXd lowerBound(const ConstraintBound &self)
Definition: constraint-bound.hpp:63
static Eigen::VectorXd vector(const ConstraintBound &self)
Definition: constraint-bound.hpp:62
static Eigen::VectorXd upperBound(const ConstraintBound &self)
Definition: constraint-bound.hpp:64