42 bp::class_<ConstraintSet, boost::noncopyable>(
44 "Base class for constraint sets or nonsmooth penalties.", bp::no_init)
46 "evaluate", &ConstraintSet::evaluate, (
"self"_a,
"z"),
47 "Evaluate the constraint indicator function or nonsmooth penalty "
48 "on the projection/prox map of :math:`z`.")
49 .def(
"projection", &ConstraintSet::projection,
50 (
"self"_a,
"z",
"zout"))
53 +[](
const ConstraintSet &c,
const ConstVectorRef &z) {
54 context::VectorXs zout(z.size());
55 c.projection(z, zout);
59 .def(
"normalConeProjection", &ConstraintSet::normalConeProjection,
60 (
"self"_a,
"z",
"zout"))
62 "normalConeProjection",
63 +[](
const ConstraintSet &c,
const ConstVectorRef &z) {
64 context::VectorXs zout(z.size());
65 c.normalConeProjection(z, zout);
69 .def(
"applyProjectionJacobian",
70 &ConstraintSet::applyProjectionJacobian, (
"self"_a,
"z",
"Jout"),
71 "Apply the projection Jacobian.")
72 .def(
"applyNormalProjectionJacobian",
73 &ConstraintSet::applyNormalConeProjectionJacobian,
74 (
"self"_a,
"z",
"Jout"),
75 "Apply the normal cone projection Jacobian.")
76 .def(
"computeActiveSet", &ConstraintSet::computeActiveSet,
77 (
"self"_a,
"z",
"out"))
78 .def(
"evaluateMoreauEnvelope", &ConstraintSet::evaluateMoreauEnvelope,
79 (
"self"_a,
"zin",
"zproj"),
80 "Evaluate the Moreau envelope with parameter :math:`\\mu`.")
81 .def(
"setProxParameter", &ConstraintSet::setProxParameter,
82 (
"self"_a,
"mu"),
"Set proximal parameter.")
83 .add_property(
"mu", &ConstraintSet::mu,
"Current proximal parameter.")
84 .def(bp::self == bp::self);
85 bp::scope current_scope;
86 current_scope.attr(
"ConstraintBase") = cls;
88 bp::class_<Constraint>(
89 "ConstraintObject",
"Packs a constraint set together with a function.",
91 (
"self"_a,
"func",
"constraint_set")))
92 .add_property(
"nr", &Constraint::nr,
"Constraint dimension.")
93 .def_readonly(
"func", &Constraint::func_,
"Underlying function.")
94 .def_readonly(
"set", &Constraint::set_,
"Constraint set.");
96 StdVectorPythonVisitor<std::vector<context::Constraint>,
true>::expose(
97 "StdVec_ConstraintObject");
104 "EqualityConstraintSet",
"Cast a function into an equality constraint")
105 .def(bp::init<>(
"self"_a));
109 "Cast a function into a negative inequality constraint h(x) \\leq 0")
110 .def(bp::init<>(
"self"_a));
114 "Box constraint of the form :math:`z \\in [z_\\min, z_\\max]`.")
115 .def(bp::init<context::ConstVectorRef, context::ConstVectorRef>(
116 (
"self"_a,
"lower_limit",
"upper_limit")))
120 bp::def(
"createEqualityConstraint",
122 "Convenience function to create an equality constraint from a "
124 bp::def(
"createInequalityConstraint",
126 "Convenience function to create an inequality constraint from a "
130 "1-norm penalty function.")
131 .def(bp::init<>((
"self"_a)));
134 "ConstraintSetProduct",
"Cartesian product of constraint sets.")
136 std::vector<Eigen::Index>>(
137 (
"self"_a,
"components",
"blockSizes")))
138 .add_property(
"components",
140 bp::return_internal_reference<>()))
141 .add_property(
"blockSizes",
143 bp::return_internal_reference<>()),
144 "Dimensions of each component of the cartesian product.");
146 StdVectorPythonVisitor<std::vector<polymorphic<ConstraintSet>>>::expose(
147 "StdVec_ConstraintObject",
148 eigenpy::details::overload_base_get_item_for_std_vector<
ConstraintObjectTpl< Scalar > Constraint