6#include "proxsuite-nlp/third-party/polymorphic_cxx14.hpp"
18template <
typename _Scalar>
struct ConstraintSetTpl {
20 using Scalar = _Scalar;
22 using ActiveType = Eigen::Matrix<bool, Eigen::Dynamic, 1>;
24 ConstraintSetTpl() =
default;
33 virtual Scalar
evaluate(
const ConstVectorRef & )
const {
return 0.; }
39 virtual void projection(
const ConstVectorRef &z, VectorRef zout)
const = 0;
47 VectorRef zout)
const = 0;
57 MatrixRef Jout)
const;
66 MatrixRef Jout)
const;
78 Eigen::Ref<ActiveType> out)
const = 0;
80 virtual ~ConstraintSetTpl() =
default;
82 bool operator==(
const ConstraintSetTpl<Scalar> &rhs) {
return this == &rhs; }
96 const ConstVectorRef &zproj)
const {
98 res +=
static_cast<Scalar
>(0.5) * mu_inv_ * zproj.squaredNorm();
105 VectorRef zprojout)
const {
110 Scalar mu()
const {
return mu_; }
111 Scalar mu_inv()
const {
return mu_inv_; }
114 mutable Scalar mu_ = 0.;
115 mutable Scalar mu_inv_;
121template <
typename _Scalar>
struct ConstraintObjectTpl {
122 using Scalar = _Scalar;
128 shared_ptr<FunctionType> func_;
129 polymorphic<ConstraintSet> set_;
131 const FunctionType &func()
const {
return *func_; }
132 int nr()
const {
return func_->nr(); }
135 ConstraintObjectTpl(ConstraintObjectTpl &&) =
default;
136 ConstraintObjectTpl &operator=(ConstraintObjectTpl &&) =
default;
137 ConstraintObjectTpl(
const ConstraintObjectTpl &) =
default;
138 ConstraintObjectTpl &operator=(
const ConstraintObjectTpl &) =
default;
140 ConstraintObjectTpl(shared_ptr<FunctionType> func,
141 const polymorphic<ConstraintSet> &set)
142 : func_(func), set_(set) {}
144 bool operator==(
const ConstraintObjectTpl &other)
const {
145 return func_ == other.func_;
149#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
150extern template struct PROXSUITE_NLP_EXPLICIT_INSTANTIATION_DECLARATION_DLLAPI
152extern template struct PROXSUITE_NLP_EXPLICIT_INSTANTIATION_DECLARATION_DLLAPI
Base definitions for function classes.
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Twice-differentiable function, with method Jacobian and vector-hessian product evaluation.
Packs a ConstraintSetTpl and C2FunctionTpl together.
Base constraint set type.
virtual Scalar evaluate(const ConstVectorRef &) const
virtual bool disableGaussNewton() const
virtual void applyProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const
Apply a jacobian of the projection/proximal operator to a matrix.
virtual void computeActiveSet(const ConstVectorRef &z, Eigen::Ref< ActiveType > out) const =0
Scalar computeMoreauEnvelope(const ConstVectorRef &zin, VectorRef zprojout) const
Evaluate the Moreau envelope with parameter mu for the given contraint set or nonsmooth penalty at p...
virtual void projection(const ConstVectorRef &z, VectorRef zout) const =0
Compute projection of variable z onto the constraint set.
Scalar evaluateMoreauEnvelope(const ConstVectorRef &zin, const ConstVectorRef &zproj) const
Evaluate the Moreau envelope with parameter mu for the given contraint set or nonsmooth penalty at p...
void setProxParameter(const Scalar mu) const
Update proximal parameter; this applies to when this class is a proximal operator that isn't a projec...
virtual void applyNormalConeProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const
Apply the jacobian of the projection on the normal cone.
virtual void normalConeProjection(const ConstVectorRef &z, VectorRef zout) const =0
Compute projection of z onto the normal cone to the set. The default implementation is just .