23 ParameterList &trlist = list.sublist(
"Step").sublist(
"Trust Region");
25 state_->searchSize = trlist.get(
"Initial Radius", -1.0);
26 delMax_ = trlist.get(
"Maximum Radius", ROL_INF<Real>());
27 eta0_ = trlist.get(
"Step Acceptance Threshold", 0.05);
28 eta1_ = trlist.get(
"Radius Shrinking Threshold", 0.05);
29 eta2_ = trlist.get(
"Radius Growing Threshold", 0.9);
30 gamma0_ = trlist.get(
"Radius Shrinking Rate (Negative rho)", 0.0625);
31 gamma1_ = trlist.get(
"Radius Shrinking Rate (Positive rho)", 0.25);
32 gamma2_ = trlist.get(
"Radius Growing Rate", 2.5);
33 TRsafe_ = trlist.get(
"Safeguard Size", 100.0);
34 eps_ = TRsafe_*ROL_EPSILON<Real>();
35 interpRad_ = trlist.get(
"Use Radius Interpolation",
false);
37 storageNM_ = trlist.get(
"Nonmonotone Storage Size", 0);
38 useNM_ = (storageNM_ <= 0 ? false :
true);
40 maxit_ = list.sublist(
"General").sublist(
"Krylov").get(
"Iteration Limit", 20);
41 tol1_ = list.sublist(
"General").sublist(
"Krylov").get(
"Absolute Tolerance", 1e-4);
42 tol2_ = list.sublist(
"General").sublist(
"Krylov").get(
"Relative Tolerance", 1e-2);
44 ROL::ParameterList &lmlist = trlist.sublist(
"Lin-More");
45 minit_ = lmlist.get(
"Maximum Number of Minor Iterations", 10);
46 mu0_ = lmlist.get(
"Sufficient Decrease Parameter", 1e-2);
47 spexp_ = lmlist.get(
"Relative Tolerance Exponent", 1.0);
48 spexp_ = std::max(
static_cast<Real
>(1),std::min(spexp_,
static_cast<Real
>(2)));
49 redlim_ = lmlist.sublist(
"Cauchy Point").get(
"Maximum Number of Reduction Steps", 10);
50 explim_ = lmlist.sublist(
"Cauchy Point").get(
"Maximum Number of Expansion Steps", 10);
51 alpha_ = lmlist.sublist(
"Cauchy Point").get(
"Initial Step Size", 1.0);
52 normAlpha_ = lmlist.sublist(
"Cauchy Point").get(
"Normalize Initial Step Size",
false);
53 interpf_ = lmlist.sublist(
"Cauchy Point").get(
"Reduction Rate", 0.1);
54 extrapf_ = lmlist.sublist(
"Cauchy Point").get(
"Expansion Rate", 10.0);
55 qtol_ = lmlist.sublist(
"Cauchy Point").get(
"Decrease Tolerance", 1e-8);
56 interpfPS_ = lmlist.sublist(
"Projected Search").get(
"Backtracking Rate", 0.5);
57 pslim_ = lmlist.sublist(
"Projected Search").get(
"Maximum Number of Steps", 20);
59 ParameterList &glist = list.sublist(
"General");
61 useInexact_.push_back(glist.get(
"Inexact Objective Function",
false));
62 useInexact_.push_back(glist.get(
"Inexact Gradient",
false));
63 useInexact_.push_back(glist.get(
"Inexact Hessian-Times-A-Vector",
false));
65 ParameterList &ilist = trlist.sublist(
"Inexact").sublist(
"Gradient");
66 scale0_ = ilist.get(
"Tolerance Scaling",
static_cast<Real
>(0.1));
67 scale1_ = ilist.get(
"Relative Tolerance",
static_cast<Real
>(2));
69 ParameterList &vlist = trlist.sublist(
"Inexact").sublist(
"Value");
70 scale_ = vlist.get(
"Tolerance Scaling",
static_cast<Real
>(1.e-1));
71 omega_ = vlist.get(
"Exponent",
static_cast<Real
>(0.9));
72 force_ = vlist.get(
"Forcing Sequence Initial Value",
static_cast<Real
>(1.0));
73 updateIter_ = vlist.get(
"Forcing Sequence Update Frequency",
static_cast<int>(10));
74 forceFactor_ = vlist.get(
"Forcing Sequence Reduction Factor",
static_cast<Real
>(0.1));
76 verbosity_ = list.sublist(
"General").get(
"Output Level",0);
77 writeHeader_ = verbosity_ > 2;
79 useSecantPrecond_ = list.sublist(
"General").sublist(
"Secant").get(
"Use as Preconditioner",
false);
80 useSecantHessVec_ = list.sublist(
"General").sublist(
"Secant").get(
"Use as Hessian",
false);
85 model_ = makePtr<TrustRegionModel_U<Real>>(list,secant,mode);
86 if (secant == nullPtr) {
87 std::string secantType = list.sublist(
"General").sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS");
251 std::ostream &outStream ) {
253 Real tol0 = std::sqrt(ROL_EPSILON<Real>());
254 Real inTol =
static_cast<Real
>(0.1)*ROL_OVERFLOW<Real>(), outTol(inTol);
255 Real gfnorm(0), gfnormf(0), tol(0), stol(0), snorm(0);
256 Real ftrial(0), pRed(0), rho(1), q(0), delta(0);
257 int flagCG(0), iterCG(0), maxit(0);
259 initialize(x,g,obj,bnd,outStream);
260 Ptr<Vector<Real>> s = x.
clone();
261 Ptr<Vector<Real>> gmod = g.
clone(), gfree = g.
clone();
262 Ptr<Vector<Real>> pwa1 = x.
clone(), pwa2 = x.
clone(), pwa3 = x.
clone();
263 Ptr<Vector<Real>> dwa1 = g.
clone(), dwa2 = g.
clone(), dwa3 = g.
clone();
265 Real rhoNM(0), sigmac(0), sigmar(0);
266 Real fr(state_->value), fc(state_->value), fmin(state_->value);
271 if (verbosity_ > 0) writeOutput(outStream,
true);
273 while (status_->check(*state_)) {
275 model_->setData(obj,*state_->iterateVec,*state_->gradientVec,gtol_);
279 snorm = dcauchy(*state_->stepVec,alpha_,q,*state_->iterateVec,
280 state_->gradientVec->dual(),state_->searchSize,
281 *model_,*dwa1,*dwa2,outStream);
282 x.
plus(*state_->stepVec);
283 state_->snorm = snorm;
284 delta = state_->searchSize - snorm;
289 gmod->plus(*state_->gradientVec);
292 pwa1->set(gfree->dual());
294 gfree->set(pwa1->dual());
296 applyFreePrecond(*pwa1,*gfree,x,*model_,bnd,tol0,*dwa1,*pwa2);
297 gfnorm = pwa1->norm();
300 gfnorm = gfree->norm();
302 SPiter_ = 0; SPflag_ = 0;
303 if (verbosity_ > 1) {
304 outStream <<
" Norm of free gradient components: " << gfnorm << std::endl;
305 outStream << std::endl;
310 for (
int i = 0; i < minit_; ++i) {
312 flagCG = 0; iterCG = 0;
314 tol = std::min(tol1_,tol2_*std::pow(gfnorm,spexp_));
316 if (gfnorm >
zero && delta >
zero) {
317 snorm = dtrpcg(*s,flagCG,iterCG,*gfree,x,
318 delta,*model_,bnd,tol,stol,maxit,
319 *pwa1,*dwa1,*pwa2,*dwa2,*pwa3,*dwa3,outStream);
322 if (verbosity_ > 1) {
323 outStream <<
" Computation of CG step" << std::endl;
324 outStream <<
" Current face (i): " << i << std::endl;
325 outStream <<
" CG step length: " << snorm << std::endl;
326 outStream <<
" Number of CG iterations: " << iterCG << std::endl;
327 outStream <<
" CG flag: " << flagCG << std::endl;
328 outStream <<
" Total number of iterations: " << SPiter_ << std::endl;
329 outStream << std::endl;
333 snorm = dprsrch(x,*s,q,gmod->
dual(),*model_,bnd,*pwa1,*dwa1,outStream);
337 state_->stepVec->plus(*s);
338 state_->snorm = state_->stepVec->norm();
339 delta = state_->searchSize - state_->snorm;
343 pwa1->set(gfree->dual());
345 gfree->set(pwa1->dual());
347 applyFreePrecond(*pwa1,*gfree,x,*model_,bnd,tol0,*dwa1,*pwa2);
348 gfnormf = pwa1->norm();
351 gfnormf = gfree->norm();
353 if (verbosity_ > 1) {
354 outStream <<
" Norm of free gradient components: " << gfnormf << std::endl;
355 outStream << std::endl;
360 if (gfnormf <= tol) {
364 else if (SPiter_ >= maxit_) {
368 else if (flagCG == 2) {
372 else if (delta <=
zero) {
385 ftrial = computeValue(inTol,outTol,pRed,state_->value,state_->iter,x,*state_->iterateVec,obj);
390 TRUtils::analyzeRatio<Real>(rho,TRflag_,state_->value,ftrial,pRed,eps_,outStream,verbosity_>1);
392 TRUtils::analyzeRatio<Real>(rhoNM,TRflagNM,fr,ftrial,pRed+sigmar,eps_,outStream,verbosity_>1);
393 TRflag_ = (rho < rhoNM ? TRflagNM : TRflag_);
394 rho = (rho < rhoNM ? rhoNM : rho );
401 x.
set(*state_->iterateVec);
405 state_->searchSize = TRUtils::interpolateRadius<Real>(*state_->gradientVec,*state_->stepVec,
406 state_->snorm,pRed,state_->value,ftrial,state_->searchSize,gamma0_,gamma1_,eta2_,
407 outStream,verbosity_>1);
410 state_->searchSize = gamma1_*std::min(state_->snorm,state_->searchSize);
412 computeGradient(x,*state_->gradientVec,*pwa1,state_->searchSize,obj,
false,gtol_,state_->gnorm,outStream);
416 state_->value = ftrial;
419 sigmac += pRed; sigmar += pRed;
420 if (ftrial < fmin) { fmin = ftrial; fc = fmin; sigmac =
zero; L = 0; }
423 if (ftrial > fc) { fc = ftrial; sigmac =
zero; }
424 if (L == storageNM_) { fr = fc; sigmar = sigmac; }
428 if (rho >= eta2_) state_->searchSize = std::min(gamma2_*state_->searchSize, delMax_);
430 dwa1->set(*state_->gradientVec);
432 computeGradient(x,*state_->gradientVec,*pwa1,state_->searchSize,obj,
true,gtol_,state_->gnorm,outStream);
435 state_->iterateVec->set(x);
437 model_->update(x,*state_->stepVec,*dwa1,*state_->gradientVec,
438 state_->snorm,state_->iter);
442 if (verbosity_ > 0) writeOutput(outStream,writeHeader_);
613 const Real tol,
const Real stol,
const int itermax,
616 std::ostream &outStream)
const {
621 Real tol0 = std::sqrt(ROL_EPSILON<Real>());
622 const Real
zero(0), one(1), two(2);
623 Real rho(0), kappa(0), beta(0), sigma(0), alpha(0);
624 Real rtr(0), tnorm(0), sMs(0), pMp(0), sMp(0);
631 applyFreePrecond(r,t,x,model,bnd,tol0,dwa,pwa);
636 pMp = (!hasEcon_ ? rho : p.
dot(p));
638 for (iter = 0; iter < itermax; ++iter) {
640 applyFreeHessian(q,p,x,model,bnd,tol0,pwa);
644 alpha = (kappa>
zero) ? rho/kappa :
zero;
645 sigma = dtrqsol(sMs,pMp,sMp,del);
647 if (kappa <= zero || alpha >= sigma) {
650 iflag = (kappa<=
zero) ? 2 : 3;
656 applyFreePrecond(r,t,x,model,bnd,tol0,dwa,pwa);
661 if (rtr <= stol*stol || tnorm <= tol) {
662 sMs = sMs + two*alpha*sMp + alpha*alpha*pMp;
674 sMs = sMs + two*alpha*sMp + alpha*alpha*pMp;
675 sMp = beta*(sMp + alpha*pMp);
676 pMp = (!hasEcon_ ? rho : p.
dot(p)) + beta*beta*pMp;
679 if (iter == itermax) {
685 return std::sqrt(sMs);
799 std::ios_base::fmtflags osFlags(os.flags());
800 os << std::scientific << std::setprecision(6);
801 if ( state_->iter == 0 ) writeName(os);
802 if ( write_header ) writeHeader(os);
803 if ( state_->iter == 0 ) {
805 os << std::setw(6) << std::left << state_->iter;
806 os << std::setw(15) << std::left << state_->value;
807 os << std::setw(15) << std::left << state_->gnorm;
808 os << std::setw(15) << std::left <<
"---";
809 os << std::setw(15) << std::left << state_->searchSize;
810 os << std::setw(10) << std::left << state_->nfval;
811 os << std::setw(10) << std::left << state_->ngrad;
812 os << std::setw(10) << std::left << nhess_;
813 os << std::setw(10) << std::left << state_->nproj;
814 os << std::setw(10) << std::left <<
"---";
816 os << std::setw(10) << std::left <<
"---";
817 os << std::setw(10) << std::left <<
"---";
823 os << std::setw(6) << std::left << state_->iter;
824 os << std::setw(15) << std::left << state_->value;
825 os << std::setw(15) << std::left << state_->gnorm;
826 os << std::setw(15) << std::left << state_->snorm;
827 os << std::setw(15) << std::left << state_->searchSize;
828 os << std::setw(10) << std::left << state_->nfval;
829 os << std::setw(10) << std::left << state_->ngrad;
830 os << std::setw(10) << std::left << nhess_;
831 os << std::setw(10) << std::left << state_->nproj;
832 os << std::setw(10) << std::left << TRflag_;
834 os << std::setw(10) << std::left << SPiter_;
835 os << std::setw(10) << std::left << SPflag_;