44 #ifndef ROL_BUNDLE_STEP_H 45 #define ROL_BUNDLE_STEP_H 56 #include "Teuchos_ParameterList.hpp" 57 #include "Teuchos_RCP.hpp" 82 Teuchos::RCP<Vector<Real> >
y_;
114 : bundle_(Teuchos::null), lineSearch_(Teuchos::null),
115 QPiter_(0), QPmaxit_(0), QPtol_(0.), step_flag_(0),
116 y_(Teuchos::null), linErrNew_(0.), valueNew_(0.),
117 aggSubGradNew_(Teuchos::null), aggSubGradOldNorm_(0.),
118 aggLinErrNew_(0.), aggLinErrOld_(0.), aggDistMeasNew_(0.),
119 T_(0.), tol_(0.), m1_(0.), m2_(0.), m3_(0.), nu_(0.),
120 ls_maxit_(0), first_print_(true), isConvex_(false),
123 state->searchSize = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Initial Trust-Region Parameter", 1.e3);
124 T_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Maximum Trust-Region Parameter", 1.e8);
125 tol_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Epsilon Solution Tolerance", 1.e-6);
126 m1_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Upper Threshold for Serious Step", 0.1);
127 m2_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Lower Threshold for Serious Step", 0.2);
128 m3_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Upper Threshold for Null Step", 0.9);
129 nu_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Tolerance for Trust-Region Parameter", 1.e-3);
132 Real coeff = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Distance Measure Coefficient", 0.0);
133 unsigned maxSize = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Maximum Bundle Size", 200);
134 unsigned remSize = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Removal Size for Bundle Update", 2);
135 if ( parlist.sublist(
"Step").sublist(
"Bundle").get(
"Cutting Plane Solver",0) == 1 ) {
139 bundle_ = Teuchos::rcp(
new Bundle<Real>(maxSize,coeff,remSize));
141 isConvex_ = ((coeff == 0.0) ?
true :
false);
144 QPtol_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Cutting Plane Tolerance", 1.e-8);
145 QPmaxit_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Cutting Plane Iteration Limit", 1000);
149 = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Maximum Number of Function Evaluations",20);
151 lineSearch_ = LineSearchFactory<Real>(parlist);
160 Real searchSize = state->searchSize;
162 state->searchSize = searchSize;
164 bundle_->initialize(*(state->gradientVec));
168 aggSubGradNew_ = x.
clone();
169 aggSubGradOldNorm_ = algo_state.
gnorm;
175 first_print_ =
false;
176 QPiter_ = (step_flag_ ? 0 :
QPiter_);
177 Real v = 0.0, l = 0.0, u =
T_, gd = 0.0;
183 QPiter_ += bundle_->solveDual(state->searchSize,QPmaxit_,QPtol_);
184 bundle_->aggregate(*aggSubGradNew_,aggLinErrNew_,aggDistMeasNew_);
190 s.
set(*aggSubGradNew_); s.
scale(-state->searchSize);
200 algo_state.
flag =
true;
205 y_->set(x); y_->plus(s);
207 valueNew_ = obj.
value(*y_,ftol_);
209 obj.
gradient(*(state->gradientVec),*y_,ftol_);
212 gd = s.
dot(*(state->gradientVec));
213 linErrNew_ = algo_state.
value - (valueNew_ - gd);
215 bool SS1 = (valueNew_-algo_state.
value < m1_*v);
217 bool NS2a = (bundle_->computeAlpha(algo_state.
snorm,linErrNew_) <= m3_*
aggLinErrOld_);
218 bool NS2b = (std::abs(algo_state.
value-valueNew_) <= aggSubGradOldNorm_ +
aggLinErrOld_);
222 bool SS2 = (gd >= m2_*v || state->searchSize >= T_-
nu_);
229 l = state->searchSize;
230 state->searchSize = 0.5*(u+l);
234 if ( NS2a || NS2b ) {
241 u = state->searchSize;
242 state->searchSize = 0.5*(u+l);
248 bool NS3 = (gd - bundle_->computeAlpha(algo_state.
snorm,linErrNew_) >= m2_*v);
255 if ( NS2a || NS2b ) {
265 int ls_nfval = 0, ls_ngrad = 0;
266 lineSearch_->run(alpha,valueNew_,ls_nfval,ls_ngrad,gd,s,x,obj,con);
267 if ( ls_nfval == ls_maxit_ ) {
281 u = state->searchSize;
282 state->searchSize = 0.5*(u+l);
287 u = state->searchSize;
288 state->searchSize = 0.5*(u+l);
305 if ( !algo_state.
flag ) {
309 bundle_->reset(*aggSubGradNew_,aggLinErrNew_,algo_state.
snorm);
316 Real valueOld = algo_state.
value;
318 bundle_->update(step_flag_,valueNew_-valueOld,algo_state.
snorm,*(state->gradientVec),s);
322 bundle_->update(step_flag_,linErrNew_,algo_state.
snorm,*(state->gradientVec),s);
329 algo_state.
gnorm = (state->gradientVec)->norm();
336 std::stringstream hist;
338 hist << std::setw(6) << std::left <<
"iter";
339 hist << std::setw(15) << std::left <<
"value";
340 hist << std::setw(15) << std::left <<
"gnorm";
341 hist << std::setw(15) << std::left <<
"snorm";
342 hist << std::setw(10) << std::left <<
"#fval";
343 hist << std::setw(10) << std::left <<
"#grad";
344 hist << std::setw(15) << std::left <<
"znorm";
345 hist << std::setw(15) << std::left <<
"alpha";
346 hist << std::setw(15) << std::left <<
"TRparam";
347 hist << std::setw(10) << std::left <<
"QPiter";
353 std::stringstream hist;
354 hist <<
"\n" <<
"Bundle Trust-Region Algorithm \n";
360 std::stringstream hist;
361 hist << std::scientific << std::setprecision(6);
362 if ( algo_state.
iter == 0 && first_print_ ) {
364 if ( print_header ) {
368 hist << std::setw(6) << std::left << algo_state.
iter;
369 hist << std::setw(15) << std::left << algo_state.
value;
370 hist << std::setw(15) << std::left << algo_state.
gnorm;
373 if ( step_flag_ && algo_state.
iter > 0 ) {
374 if ( print_header ) {
379 hist << std::setw(6) << std::left << algo_state.
iter;
380 hist << std::setw(15) << std::left << algo_state.
value;
381 hist << std::setw(15) << std::left << algo_state.
gnorm;
382 hist << std::setw(15) << std::left << algo_state.
snorm;
383 hist << std::setw(10) << std::left << algo_state.
nfval;
384 hist << std::setw(10) << std::left << algo_state.
ngrad;
387 hist << std::setw(15) << std::left << state->searchSize;
388 hist << std::setw(10) << std::left <<
QPiter_;
Provides the interface to evaluate objective functions.
virtual void scale(const Real alpha)=0
Compute where .
virtual void plus(const Vector &x)=0
Compute , where .
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
Real aggregateGradientNorm
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
std::string printName(void) const
Print step name.
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
virtual Real dot(const Vector &x) const =0
Compute where .
State for algorithm class. Will be used for restarts.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
virtual Teuchos::RCP< const StepState< Real > > getStepState(void) const
Get state for step object.
void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Initialize step with bound constraint.
Teuchos::RCP< Vector< Real > > y_
std::string printHeader(void) const
Print iterate header.
Provides the interface to apply upper and lower bound constraints.
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Update step, if successful.
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Compute step.
Provides the interface to compute bundle trust-region steps.
Teuchos::RCP< Bundle< Real > > bundle_
virtual void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Initialize step with bound constraint.
Teuchos::RCP< Vector< Real > > iterateVec
virtual void set(const Vector &x)
Set where .
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
Provides the interface for and implements a bundle. The semidefinite quadratic subproblem is solved u...
Teuchos::RCP< Vector< Real > > aggSubGradNew_
Teuchos::RCP< LineSearch< Real > > lineSearch_
BundleStep(Teuchos::ParameterList &parlist)
Provides the interface for and implments a bundle.
static const double ROL_EPSILON
Platform-dependent machine epsilon.