ROL
ROL_Constraint_Partitioned.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_CONSTRAINT_PARTITIONED_H
11 #define ROL_CONSTRAINT_PARTITIONED_H
12 
14 #include "ROL_Constraint.hpp"
15 
16 namespace ROL {
17 
24 template<typename Real>
25 class Constraint_Partitioned : public Constraint<Real> {
26 private:
27  std::vector<Ptr<Constraint<Real>>> cvec_;
28  std::vector<bool> isInequality_; // Label whether cvec_[i] is inequality
29  const int offset_; // Offset for slack variables
30  Ptr<Vector<Real>> scratch_; // Scratch vector for intermediate computation
31  int ncval_; // Number of constraint evaluations
32  bool initialized_; // Is scratch vector initialized?
33 
34 public:
35  Constraint_Partitioned(const std::vector<Ptr<Constraint<Real>>> &cvec,
36  bool isInequality = false,
37  int offset = 0);
38  Constraint_Partitioned(const std::vector<Ptr<Constraint<Real>>> &cvec,
39  std::vector<bool> isInequality,
40  int offset = 0);
41 
42  int getNumberConstraintEvaluations(void) const;
43  Ptr<Constraint<Real>> get(int ind = 0) const;
44 
45  void update( const Vector<Real> &x, UpdateType type, int iter = -1 ) override;
46  void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) override;
47  void value( Vector<Real> &c, const Vector<Real> &x, Real &tol ) override;
48  void applyJacobian( Vector<Real> &jv,
49  const Vector<Real> &v,
50  const Vector<Real> &x,
51  Real &tol ) override;
54  const Vector<Real> &v,
55  const Vector<Real> &x,
56  Real &tol ) override;
58  const Vector<Real> &u,
59  const Vector<Real> &v,
60  const Vector<Real> &x,
61  Real &tol ) override;
62  virtual void applyPreconditioner(Vector<Real> &pv,
63  const Vector<Real> &v,
64  const Vector<Real> &x,
65  const Vector<Real> &g,
66  Real &tol) override;
67 
68 // Definitions for parametrized (stochastic) equality constraints
69 public:
70  void setParameter(const std::vector<Real> &param) override;
71 
72 private:
73  Vector<Real>& getOpt( Vector<Real> &xs ) const;
74  const Vector<Real>& getOpt( const Vector<Real> &xs ) const;
75  Vector<Real>& getSlack( Vector<Real> &xs, int ind ) const;
76  const Vector<Real>& getSlack( const Vector<Real> &xs, int ind ) const;
77 
78 }; // class Constraint_Partitioned
79 
80 } // namespace ROL
81 
83 
84 #endif
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
void setParameter(const std::vector< Real > &param) override
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
std::vector< Ptr< Constraint< Real > > > cvec_
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the adjoint of the the constraint Jacobian at , , to vector .
virtual void applyPreconditioner(Vector< Real > &pv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g, Real &tol) override
Apply a constraint preconditioner at , , to vector . Ideally, this preconditioner satisfies the follo...
Vector< Real > & getOpt(Vector< Real > &xs) const
Constraint_Partitioned(const std::vector< Ptr< Constraint< Real >>> &cvec, bool isInequality=false, int offset=0)
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the constraint Jacobian at , , to vector .
Has both inequality and equality constraints. Treat inequality constraint as equality with slack vari...
Vector< Real > & getSlack(Vector< Real > &xs, int ind) const
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update constraint function.
Defines the general constraint operator interface.