ROL
ROL_Constraint_Partitioned.hpp
Go to the documentation of this file.
1 // Rapid Optimization Library (ROL) Package
2 // Copyright (2014) Sandia Corporation
3 //
4 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
5 // license for use of this work by or on behalf of the U.S. Government.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met:
10 //
11 // 1. Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 //
18 // 3. Neither the name of the Corporation nor the names of the
19 // contributors may be used to endorse or promote products derived from
20 // this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
23 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
26 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34 // Questions? Contact lead developers:
35 // Drew Kouri (dpkouri@sandia.gov) and
36 // Denis Ridzal (dridzal@sandia.gov)
37 //
38 // ************************************************************************
39 // @HEADER
40 
41 #ifndef ROL_CONSTRAINT_PARTITIONED_H
42 #define ROL_CONSTRAINT_PARTITIONED_H
43 
45 #include "ROL_Constraint.hpp"
46 
47 namespace ROL {
48 
55 template<typename Real>
56 class Constraint_Partitioned : public Constraint<Real> {
57 private:
58  std::vector<Ptr<Constraint<Real>>> cvec_;
59  std::vector<bool> isInequality_; // Label whether cvec_[i] is inequality
60  const int offset_; // Offset for slack variables
61  Ptr<Vector<Real>> scratch_; // Scratch vector for intermediate computation
62  int ncval_; // Number of constraint evaluations
63  bool initialized_; // Is scratch vector initialized?
64 
65 public:
66  Constraint_Partitioned(const std::vector<Ptr<Constraint<Real>>> &cvec,
67  bool isInequality = false,
68  int offset = 0);
69  Constraint_Partitioned(const std::vector<Ptr<Constraint<Real>>> &cvec,
70  std::vector<bool> isInequality,
71  int offset = 0);
72 
73  int getNumberConstraintEvaluations(void) const;
74  Ptr<Constraint<Real>> get(int ind = 0) const;
75 
76  void update( const Vector<Real> &x, UpdateType type, int iter = -1 ) override;
77  void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) override;
78  void value( Vector<Real> &c, const Vector<Real> &x, Real &tol ) override;
79  void applyJacobian( Vector<Real> &jv,
80  const Vector<Real> &v,
81  const Vector<Real> &x,
82  Real &tol ) override;
85  const Vector<Real> &v,
86  const Vector<Real> &x,
87  Real &tol ) override;
89  const Vector<Real> &u,
90  const Vector<Real> &v,
91  const Vector<Real> &x,
92  Real &tol ) override;
93  virtual void applyPreconditioner(Vector<Real> &pv,
94  const Vector<Real> &v,
95  const Vector<Real> &x,
96  const Vector<Real> &g,
97  Real &tol) override;
98 
99 // Definitions for parametrized (stochastic) equality constraints
100 public:
101  void setParameter(const std::vector<Real> &param) override;
102 
103 private:
104  Vector<Real>& getOpt( Vector<Real> &xs ) const;
105  const Vector<Real>& getOpt( const Vector<Real> &xs ) const;
106  Vector<Real>& getSlack( Vector<Real> &xs, int ind ) const;
107  const Vector<Real>& getSlack( const Vector<Real> &xs, int ind ) const;
108 
109 }; // class Constraint_Partitioned
110 
111 } // namespace ROL
112 
114 
115 #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:80
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.