44 #ifndef ROL_TRUSTREGION_H 45 #define ROL_TRUSTREGION_H 61 Teuchos::RCP<Vector<Real> >
Hs_;
110 Teuchos::ParameterList list = parlist.sublist(
"Step").sublist(
"Trust Region");
111 delmax_ = list.get(
"Maximum Radius",5000.0);
112 eta0_ = list.get(
"Step Acceptance Threshold",0.05);
113 eta1_ = list.get(
"Radius Shrinking Threshold",0.05);
114 eta2_ = list.get(
"Radius Growing Threshold",0.9);
115 gamma0_ = list.get(
"Radius Shrinking Rate (Negative rho)",0.0625);
116 gamma1_ = list.get(
"Radius Shrinking Rate (Positive rho)",0.25);
117 gamma2_ = list.get(
"Radius Growing Rate",2.5);
118 TRsafe_ = list.get(
"Safeguard Size",100.0);
123 useInexact_.push_back(parlist.sublist(
"General").get(
"Inexact Objective Function",
false));
124 useInexact_.push_back(parlist.sublist(
"General").get(
"Inexact Gradient",
false));
125 useInexact_.push_back(parlist.sublist(
"General").get(
"Inexact Hessian-Times-A-Vector",
false));
126 scale_ = list.sublist(
"Inexact").sublist(
"Value").get(
"Tolerance Scaling",1.e-1);
127 omega_ = list.sublist(
"Inexact").sublist(
"Value").get(
"Exponent",0.9);
128 force_ = list.sublist(
"Inexact").sublist(
"Value").get(
"Forcing Sequence Initial Value",1.0);
129 updateIter_ = list.sublist(
"Inexact").sublist(
"Value").get(
"Forcing Sequence Update Frequency",10);
130 forceFactor_ = list.sublist(
"Inexact").sublist(
"Value").get(
"Forcing Sequence Reduction Factor",0.1);
133 softUp_ = parlist.sublist(
"General").get(
"Variable Objective Function",
false);
137 xupdate_ = x.
clone();
157 xupdate_->axpy(1.0,s);
162 Real fold1 = fold, ftol = tol;
163 if ( useInexact_[0] ) {
164 if ( !(cnt_%updateIter_) && (cnt_ != 0) ) {
167 Real c = scale_*std::max(1.e-2,std::min(1.0,1.e4*std::max(pRed_,std::sqrt(
ROL_EPSILON))));
168 ftol = c*std::pow(std::min(eta1_,1.0-eta2_)
169 *std::min(std::max(pRed_,std::sqrt(
ROL_EPSILON)),force_),1.0/omega_);
170 if ( ftol_old_ > ftol || cnt_ == 0 ) {
172 fold1 = pObj.
value(x,ftol_old_);
180 fnew = pObj.
value(*xupdate_,ftol);
184 Real aRed = fold1 - fnew;
191 xupdate_->axpy(-1.0,g.
dual());
193 xupdate_->axpy(-1.0,x);
194 xupdate_->scale(-1.0);
197 pRed_ = -0.5*s.
dot(Hs_->dual());
201 pRed_ -= s.
dot(Hs_->dual());
204 if ( verbosity_ > 0 ) {
205 std::cout << std::endl;
206 std::cout <<
" Computation of actual and predicted reduction" << std::endl;
207 std::cout <<
" Current objective function value: " << fold1 << std::endl;
208 std::cout <<
" New objective function value: " << fnew << std::endl;
209 std::cout <<
" Actual reduction: " << aRed << std::endl;
210 std::cout <<
" Predicted reduction: " << pRed_ << std::endl;
214 aRed -= eps_*((1.0 > std::abs(fold1)) ? 1.0 : std::abs(fold1));
215 pRed_ -= eps_*((1.0 > std::abs(fold1)) ? 1.0 : std::abs(fold1));
217 if ((std::abs(aRed) <
eps_) && (std::abs(pRed_) <
eps_)) {
221 else if ( std::isnan(aRed) || std::isnan(pRed_) ) {
227 if (pRed_ < 0 && aRed > 0) {
230 else if (aRed <= 0 && pRed_ > 0) {
233 else if (aRed <= 0 && pRed_ < 0) {
241 if ( verbosity_ > 0 ) {
242 std::cout <<
" Actual reduction with safeguard: " << aRed << std::endl;
243 std::cout <<
" Predicted reduction with safeguard: " << pRed_ << std::endl;
244 std::cout <<
" Ratio of actual and predicted reduction: " << rho << std::endl;
245 std::cout <<
" Trust-region flag: " << flagTR << std::endl;
253 xupdate_->axpy(-1.0,g.
dual());
255 xupdate_->scale(-1.0);
257 Real pgnorm = xupdate_->norm();
259 xupdate_->set(g.
dual());
261 Real lam = std::min(1.0, del/xupdate_->norm());
262 xupdate_->scale(-lam);
265 xupdate_->scale(-1.0);
267 pgnorm *= xupdate_->norm();
269 decr = ( aRed >= 0.1*eta0_*pgnorm );
270 flagTR = (!decr ? 4 : flagTR);
272 if ( verbosity_ > 0 ) {
273 std::cout <<
" Decrease lower bound (constraints): " << 0.1*eta0_*pgnorm << std::endl;
274 std::cout <<
" Trust-region flag (constraints): " << flagTR << std::endl;
275 std::cout <<
" Is step feasible: " << pObj.
isFeasible(x) << std::endl;
279 if ( verbosity_ > 0 ) {
280 std::cout << std::endl;
284 if ((rho < eta0_ && flagTR == 0) || flagTR >= 2 || !decr ) {
291 Real modelVal = s.
dot(Hs_->dual());
293 modelVal += gs + fold1;
294 Real theta = (1.0-
eta2_)*gs/((1.0-eta2_)*(fold1+gs)+eta2_*modelVal-fnew);
295 del = std::min(gamma1_*snorm,std::max(gamma0_,theta)*del);
301 else if ((rho >= eta0_ && flagTR != 3) || flagTR == 1) {
305 del = std::min(gamma2_*del,delmax_);
329 Teuchos::RCP<Vector<Real> > stmp = x.
clone();
333 Teuchos::RCP<Vector<Real> > xtmp = x.
clone();
335 xtmp->axpy(1.0,*stmp);
338 Teuchos::RCP<Vector<Real> > Bs = x.
clone();
340 Real sBs = Bs->dot(*stmp);
341 Real gs = grad.
dot(*stmp);
342 Real val = gs + 0.5*sBs;
347 while ( val > val0 || !pObj.
isFeasible(*xtmp) ) {
355 xtmp->axpy(1.0,*stmp);
359 sBs = Bs->dot(*stmp);
360 gs = grad.
dot(*stmp);
364 if ( cnt >= maxit ) {
break; }
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Real value(const Vector< Real > &x, Real &tol)
Compute value.
bool isConActivated(void)
TrustRegion(Teuchos::ParameterList &parlist)
Teuchos::RCP< Vector< Real > > xupdate_
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
virtual void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g)
void reducedHessVec(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &p, const Vector< Real > &d, const Vector< Real > &x, Real &tol)
Apply the reduced Hessian to a vector, v. The reduced Hessian first removes elements of v correspondi...
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.
bool isFeasible(const Vector< Real > &v)
void pruneActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x)
Contains definitions for helper functions in ROL.
Defines the linear algebra or vector space interface.
void hessVec(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
virtual Real dot(const Vector &x) const =0
Compute where .
virtual void run(Vector< Real > &s, Real &snorm, Real &del, int &iflag, int &iter, const Vector< Real > &x, const Vector< Real > &grad, const Real &gnorm, ProjectedObjective< Real > &pObj)=0
Real getPredictedReduction(void) const
Teuchos::RCP< Vector< Real > > Hs_
void updateObj(Vector< Real > &x, int iter, ProjectedObjective< Real > &pObj)
virtual void update(Vector< Real > &x, Real &fnew, Real &del, int &nfval, int &ngrad, int &flagTR, const Vector< Real > &s, const Real snorm, const Real fold, const Vector< Real > &g, int iter, ProjectedObjective< Real > &pObj)
void setPredictedReduction(const Real pRed)
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
virtual void set(const Vector &x)
Set where .
void computeProjectedStep(Vector< Real > &v, const Vector< Real > &x)
void project(Vector< Real > &x)
static const double ROL_OVERFLOW
Platform-dependent maximum double.
std::vector< bool > useInexact_
static const double ROL_EPSILON
Platform-dependent machine epsilon.