ROL
ROL_FletcherObjectiveE.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_FLETCHEROBJECTIVEE_H
11 #define ROL_FLETCHEROBJECTIVEE_H
12 
14 
15 namespace ROL {
16 
17 template<typename Real>
19 private:
20  // Temporaries
21  Ptr<Vector<Real>> Tv_; // Temporary for matvecs
22  Ptr<Vector<Real>> w_; // first component of augmented system solve solution
23  Ptr<Vector<Real>> v_; // second component of augmented system solve solution
24  Ptr<Vector<Real>> wdual_; // first component of augmented system solve solution in dual space
25  Ptr<Vector<Real>> wg_; // first component of augmented system solve solution for gradient
26  Ptr<Vector<Real>> vg_; // second component of augmented system solve solution for gradient
27  Ptr<Vector<Real>> xzeros_; // zero vector
28  Ptr<Vector<Real>> czeros_; // zero vector
29 
30  // Required for Fletcher penalty function definition
34  using FletcherObjectiveBase<Real>::delta_; // regularization parameter
41  using FletcherObjectiveBase<Real>::fPhi_; // value of penalty function
42  using FletcherObjectiveBase<Real>::gPhi_; // gradient of penalty function
43  using FletcherObjectiveBase<Real>::y_; // multiplier estimate
44  using FletcherObjectiveBase<Real>::fval_; // value of objective function
45  using FletcherObjectiveBase<Real>::g_; // gradient of objective value
46  using FletcherObjectiveBase<Real>::c_; // constraint value
47  using FletcherObjectiveBase<Real>::scaledc_; // sigma_ * c_
48  using FletcherObjectiveBase<Real>::gL_; // gradient of Lagrangian (g - A*y)
49  using FletcherObjectiveBase<Real>::gLdual_; // dual gradient of Lagrangian (g - A*y)
50  using FletcherObjectiveBase<Real>::cnorm_; // norm of constraint violation
55  using FletcherObjectiveBase<Real>::multSolverError_; // Error from augmented system solve in value()
56  using FletcherObjectiveBase<Real>::gradSolveError_; // Error from augmented system solve in gradient()
69 
70  class AugSystem : public LinearOperator<Real> {
71  private:
72  const Ptr<Constraint<Real>> con_;
73  const Ptr<const Vector<Real>> x_;
74  const Real delta_;
75  public:
76  AugSystem(const Ptr<Constraint<Real>> &con,
77  const Ptr<const Vector<Real>> &x,
78  const Real delta) : con_(con), x_(x), delta_(delta) {}
79 
80  void apply(Vector<Real> &Hv, const Vector<Real> &v, Real &tol) const {
81  PartitionedVector<Real> &Hvp = dynamic_cast<PartitionedVector<Real>&>(Hv);
82  const PartitionedVector<Real> &vp = dynamic_cast<const PartitionedVector<Real>&>(v);
83 
84  con_->applyAdjointJacobian(*Hvp.get(0), *vp.get(1), *x_, tol);
85  Hvp.get(0)->plus(vp.get(0)->dual());
86 
87  con_->applyJacobian(*Hvp.get(1), *vp.get(0), *x_, tol);
88  Hvp.get(1)->axpy(-delta_*delta_, vp.get(1)->dual());
89  }
90  };
91 
92  class AugSystemPrecond : public LinearOperator<Real> {
93  private:
94  const Ptr<Constraint<Real>> con_;
95  const Ptr<const Vector<Real>> x_;
96  const Ptr<const Vector<Real>> g_;
97  public:
99  const Ptr<const Vector<Real>> x,
100  const Ptr<const Vector<Real>> g) : con_(con), x_(x), g_(g) {}
101 
102  void apply(Vector<Real> &Hv, const Vector<Real> &v, Real &tol) const {
103  Hv.set(v.dual());
104  }
105  void applyInverse(Vector<Real> &Hv, const Vector<Real> &v, Real &tol) const {
106  PartitionedVector<Real> &Hvp = dynamic_cast<PartitionedVector<Real>&>(Hv);
107  const PartitionedVector<Real> &vp = dynamic_cast<const PartitionedVector<Real>&>(v);
108 
109  Hvp.set(0, vp.get(0)->dual());
110  con_->applyPreconditioner(*(Hvp.get(1)),*(vp.get(1)),*x_,*g_, tol);
111  }
112  };
113 
114 public:
115  FletcherObjectiveE(const ROL::Ptr<Objective<Real>> &obj,
116  const ROL::Ptr<Constraint<Real>> &con,
117  const Vector<Real> &xprim,
118  const Vector<Real> &xdual,
119  const Vector<Real> &cprim,
120  const Vector<Real> &cdual,
121  ROL::ParameterList &parlist);
122 
123  Real value( const Vector<Real> &x, Real &tol ) override;
124  void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) override;
125  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
126 
127 protected:
128 
129  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;
130 
131 }; // class FletcherObjectiveE
132 
133 } // namespace ROL
134 
136 
137 #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:192
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:46
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:175
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.