ROL
ROL_FletcherObjectiveE.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 
45 #ifndef ROL_FLETCHEROBJECTIVEE_H
46 #define ROL_FLETCHEROBJECTIVEE_H
47 
49 
50 namespace ROL {
51 
52 template<typename Real>
54 private:
55  // Temporaries
56  Ptr<Vector<Real>> Tv_; // Temporary for matvecs
57  Ptr<Vector<Real>> w_; // first component of augmented system solve solution
58  Ptr<Vector<Real>> v_; // second component of augmented system solve solution
59  Ptr<Vector<Real>> wdual_; // first component of augmented system solve solution in dual space
60  Ptr<Vector<Real>> wg_; // first component of augmented system solve solution for gradient
61  Ptr<Vector<Real>> vg_; // second component of augmented system solve solution for gradient
62  Ptr<Vector<Real>> xzeros_; // zero vector
63  Ptr<Vector<Real>> czeros_; // zero vector
64 
65  // Required for Fletcher penalty function definition
69  using FletcherObjectiveBase<Real>::delta_; // regularization parameter
76  using FletcherObjectiveBase<Real>::fPhi_; // value of penalty function
77  using FletcherObjectiveBase<Real>::gPhi_; // gradient of penalty function
78  using FletcherObjectiveBase<Real>::y_; // multiplier estimate
79  using FletcherObjectiveBase<Real>::fval_; // value of objective function
80  using FletcherObjectiveBase<Real>::g_; // gradient of objective value
81  using FletcherObjectiveBase<Real>::c_; // constraint value
82  using FletcherObjectiveBase<Real>::scaledc_; // sigma_ * c_
83  using FletcherObjectiveBase<Real>::gL_; // gradient of Lagrangian (g - A*y)
84  using FletcherObjectiveBase<Real>::gLdual_; // dual gradient of Lagrangian (g - A*y)
85  using FletcherObjectiveBase<Real>::cnorm_; // norm of constraint violation
90  using FletcherObjectiveBase<Real>::multSolverError_; // Error from augmented system solve in value()
91  using FletcherObjectiveBase<Real>::gradSolveError_; // Error from augmented system solve in gradient()
104 
105  class AugSystem : public LinearOperator<Real> {
106  private:
107  const Ptr<Constraint<Real>> con_;
108  const Ptr<const Vector<Real>> x_;
109  const Real delta_;
110  public:
111  AugSystem(const Ptr<Constraint<Real>> &con,
112  const Ptr<const Vector<Real>> &x,
113  const Real delta) : con_(con), x_(x), delta_(delta) {}
114 
115  void apply(Vector<Real> &Hv, const Vector<Real> &v, Real &tol) const {
116  PartitionedVector<Real> &Hvp = dynamic_cast<PartitionedVector<Real>&>(Hv);
117  const PartitionedVector<Real> &vp = dynamic_cast<const PartitionedVector<Real>&>(v);
118 
119  con_->applyAdjointJacobian(*Hvp.get(0), *vp.get(1), *x_, tol);
120  Hvp.get(0)->plus(vp.get(0)->dual());
121 
122  con_->applyJacobian(*Hvp.get(1), *vp.get(0), *x_, tol);
123  Hvp.get(1)->axpy(-delta_*delta_, vp.get(1)->dual());
124  }
125  };
126 
127  class AugSystemPrecond : public LinearOperator<Real> {
128  private:
129  const Ptr<Constraint<Real>> con_;
130  const Ptr<const Vector<Real>> x_;
131  const Ptr<const Vector<Real>> g_;
132  public:
134  const Ptr<const Vector<Real>> x,
135  const Ptr<const Vector<Real>> g) : con_(con), x_(x), g_(g) {}
136 
137  void apply(Vector<Real> &Hv, const Vector<Real> &v, Real &tol) const {
138  Hv.set(v.dual());
139  }
140  void applyInverse(Vector<Real> &Hv, const Vector<Real> &v, Real &tol) const {
141  PartitionedVector<Real> &Hvp = dynamic_cast<PartitionedVector<Real>&>(Hv);
142  const PartitionedVector<Real> &vp = dynamic_cast<const PartitionedVector<Real>&>(v);
143 
144  Hvp.set(0, vp.get(0)->dual());
145  con_->applyPreconditioner(*(Hvp.get(1)),*(vp.get(1)),*x_,*g_, tol);
146  }
147  };
148 
149 public:
150  FletcherObjectiveE(const ROL::Ptr<Objective<Real>> &obj,
151  const ROL::Ptr<Constraint<Real>> &con,
152  const Vector<Real> &xprim,
153  const Vector<Real> &xdual,
154  const Vector<Real> &cprim,
155  const Vector<Real> &cdual,
156  ROL::ParameterList &parlist);
157 
158  Real value( const Vector<Real> &x, Real &tol ) override;
159  void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) override;
160  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
161 
162 protected:
163 
164  void solveAugmentedSystem(Vector<Real> &v1, Vector<Real> &v2, const Vector<Real> &b1, const Vector<Real> &b2, const Vector<Real> &x, Real &tol, bool refine = false) override;
165 
166 }; // class FletcherObjectiveE
167 
168 } // namespace ROL
169 
171 
172 #endif
Provides the interface to evaluate objective functions.
void solveAugmentedSystem(Vector< Real > &v1, Vector< Real > &v2, const Vector< Real > &b1, const Vector< Real > &b2, const Vector< Real > &x, Real &tol, bool refine=false) override
const Ptr< Constraint< Real > > con_
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: ROL_Vector.hpp:226
ROL::Ptr< const Vector< Real > > get(size_type i) const
Defines the linear algebra of vector space on a generic partitioned vector.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Ptr< Vector< Real > > czeros_
AugSystem(const Ptr< Constraint< Real >> &con, const Ptr< const Vector< Real >> &x, const Real delta)
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
FletcherObjectiveE(const ROL::Ptr< Objective< Real >> &obj, const ROL::Ptr< Constraint< Real >> &con, const Vector< Real > &xprim, const Vector< Real > &xdual, const Vector< Real > &cprim, const Vector< Real > &cdual, ROL::ParameterList &parlist)
void set(const V &x)
Set where .
const Ptr< const Vector< Real > > x_
AugSystemPrecond(const Ptr< Constraint< Real >> con, const Ptr< const Vector< Real >> x, const Ptr< const Vector< Real >> g)
Provides the interface to apply a linear operator.
Ptr< Vector< Real > > xzeros_
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
Ptr< Vector< Real > > wdual_
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:209
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
Defines the general constraint operator interface.