ROL
ROL_DoubleDogLeg.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 #ifndef ROL_DOUBLEDOGLEG_H
45 #define ROL_DOUBLEDOGLEG_H
46 
51 #include "ROL_TrustRegion.hpp"
52 #include "ROL_Types.hpp"
53 #include "ROL_HelperFunctions.hpp"
54 
55 namespace ROL {
56 
57 template<class Real>
58 class DoubleDogLeg : public TrustRegion<Real> {
59 private:
60 
61  Teuchos::RCP<CauchyPoint<Real> > cpt_;
62 
63  Teuchos::RCP<Vector<Real> > s_;
64  Teuchos::RCP<Vector<Real> > v_;
65  Teuchos::RCP<Vector<Real> > Hp_;
66 
67  Real pRed_;
68 
69 public:
70 
71  // Constructor
72  DoubleDogLeg( Teuchos::ParameterList &parlist ) : TrustRegion<Real>(parlist), pRed_(0) {
73  cpt_ = Teuchos::rcp(new CauchyPoint<Real>(parlist));
74  }
75 
76  void initialize( const Vector<Real> &x, const Vector<Real> &s, const Vector<Real> &g) {
78  cpt_->initialize(x,s,g);
79  s_ = s.clone();
80  v_ = s.clone();
81  Hp_ = g.clone();
82  }
83 
84  void run( Vector<Real> &s,
85  Real &snorm,
86  int &iflag,
87  int &iter,
88  const Real del,
89  TrustRegionModel<Real> &model ) {
90  Real tol = std::sqrt(ROL_EPSILON<Real>());
91  const Real one(1), zero(0), half(0.5), p2(0.2), p8(0.8), two(2);
92  // Set s to be the (projected) gradient
93  model.dualTransform(*Hp_,*model.getGradient());
94  s.set(Hp_->dual());
95  // Compute (quasi-)Newton step
96  model.invHessVec(*s_,*Hp_,s,tol);
97  Real sNnorm = s_->norm();
98  Real tmp = -s_->dot(s);
99  bool negCurv = (tmp > zero ? true : false);
100  Real gsN = std::abs(tmp);
101  // Check if (quasi-)Newton step is feasible
102  if ( negCurv ) {
103  // Use Cauchy point
104  cpt_->run(s,snorm,iflag,iter,del,model);
105  pRed_ = cpt_->getPredictedReduction();
106  iflag = 2;
107  }
108  else {
109  // Approximately solve trust region subproblem using double dogleg curve
110  if (sNnorm <= del) { // Use the (quasi-)Newton step
111  s.set(*s_);
112  s.scale(-one);
113  snorm = sNnorm;
114  pRed_ = half*gsN;
115  iflag = 0;
116  }
117  else { // The (quasi-)Newton step is outside of trust region
118  model.hessVec(*Hp_,s,s,tol);
119  Real alpha = zero;
120  Real beta = zero;
121  Real gnorm = s.norm();
122  Real gnorm2 = gnorm*gnorm;
123  Real gBg = Hp_->dot(s.dual());
124  Real gamma1 = gnorm/gBg;
125  Real gamma2 = gnorm/gsN;
126  Real eta = p8*gamma1*gamma2 + p2;
127  if (eta*sNnorm <= del || gBg <= zero) { // Dogleg Point is inside trust region
128  alpha = del/sNnorm;
129  beta = zero;
130  s.set(*s_);
131  s.scale(-alpha);
132  snorm = del;
133  iflag = 1;
134  }
135  else {
136  if (gnorm2*gamma1 >= del) { // Cauchy Point is outside trust region
137  alpha = zero;
138  beta = -del/gnorm;
139  s.scale(beta);
140  snorm = del;
141  iflag = 2;
142  }
143  else { // Find convex combination of Cauchy and Dogleg point
144  s.scale(-gamma1*gnorm);
145  v_->set(s);
146  v_->axpy(eta,*s_);
147  v_->scale(-one);
148  Real wNorm = v_->dot(*v_);
149  Real sigma = del*del-std::pow(gamma1*gnorm,two);
150  Real phi = s.dot(*v_);
151  Real theta = (-phi + std::sqrt(phi*phi+wNorm*sigma))/wNorm;
152  s.axpy(theta,*v_);
153  snorm = del;
154  alpha = theta*eta;
155  beta = (one-theta)*(-gamma1*gnorm);
156  iflag = 3;
157  }
158  }
159  pRed_ = -(alpha*(half*alpha-one)*gsN + half*beta*beta*gBg + beta*(one-alpha)*gnorm2);
160  }
161  }
162  model.primalTransform(*s_,s);
163  s.set(*s_);
164  snorm = s.norm();
166  }
167 };
168 
169 }
170 
171 #endif
Teuchos::RCP< CauchyPoint< Real > > cpt_
void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g)
virtual void scale(const Real alpha)=0
Compute where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:143
virtual void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g)
Contains definitions of custom data types in ROL.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Provides interface for and implements trust-region subproblem solvers.
Provides the interface to evaluate trust-region model functions.
Contains definitions for helper functions in ROL.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:74
virtual Real dot(const Vector &x) const =0
Compute where .
virtual void dualTransform(Vector< Real > &tv, const Vector< Real > &v)
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:213
Provides interface for the double dog leg trust-region subproblem solver.
Teuchos::RCP< Vector< Real > > s_
DoubleDogLeg(Teuchos::ParameterList &parlist)
virtual const Teuchos::RCP< const Vector< Real > > getGradient(void) const
void setPredictedReduction(const Real pRed)
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &s, Real &tol)
Apply Hessian approximation to vector.
virtual void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &s, Real &tol)
Apply inverse Hessian approximation to vector.
Teuchos::RCP< Vector< Real > > v_
Provides interface for the Cauchy point trust-region subproblem solver.
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:196
virtual Real norm() const =0
Returns where .
void run(Vector< Real > &s, Real &snorm, int &iflag, int &iter, const Real del, TrustRegionModel< Real > &model)
virtual void primalTransform(Vector< Real > &tv, const Vector< Real > &v)
Teuchos::RCP< Vector< Real > > Hp_