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 ) {
137 bundle_ = Teuchos::rcp(
new Bundle<Real>(maxSize,coeff,remSize));
140 bundle_ = Teuchos::rcp(
new Bundle<Real>(maxSize,coeff,remSize));
142 isConvex_ = ((coeff == 0.0) ?
true :
false);
145 QPtol_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Cutting Plane Tolerance", 1.e-8);
146 QPmaxit_ = parlist.sublist(
"Step").sublist(
"Bundle").get(
"Cutting Plane Iteration Limit", 1000);
150 = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Maximum Number of Function Evaluations",20);
152 lineSearch_ = LineSearchFactory<Real>(parlist);
161 Real searchSize = state->searchSize;
163 state->searchSize = searchSize;
165 bundle_->initialize(*(state->gradientVec));
169 aggSubGradNew_ = g.
clone();
170 aggSubGradOldNorm_ = algo_state.
gnorm;
173 lineSearch_->initialize(x,x,g,obj,con);
180 first_print_ =
false;
181 QPiter_ = (step_flag_ ? 0 :
QPiter_);
182 Real v = 0.0, l = 0.0, u =
T_, gd = 0.0;
188 QPiter_ += bundle_->solveDual(state->searchSize,QPmaxit_,QPtol_);
189 bundle_->aggregate(*aggSubGradNew_,aggLinErrNew_,aggDistMeasNew_);
195 s.
set(aggSubGradNew_->dual()); s.
scale(-state->searchSize);
205 algo_state.
flag =
true;
210 y_->set(x); y_->plus(s);
212 valueNew_ = obj.
value(*y_,ftol_);
214 obj.
gradient(*(state->gradientVec),*y_,ftol_);
217 gd = s.
dot(state->gradientVec->dual());
218 linErrNew_ = algo_state.
value - (valueNew_ - gd);
220 bool SS1 = (valueNew_-algo_state.
value < m1_*v);
222 bool NS2a = (bundle_->computeAlpha(algo_state.
snorm,linErrNew_) <= m3_*
aggLinErrOld_);
223 bool NS2b = (std::abs(algo_state.
value-valueNew_) <= aggSubGradOldNorm_ +
aggLinErrOld_);
227 bool SS2 = (gd >= m2_*v || state->searchSize >= T_-
nu_);
234 l = state->searchSize;
235 state->searchSize = 0.5*(u+l);
239 if ( NS2a || NS2b ) {
246 u = state->searchSize;
247 state->searchSize = 0.5*(u+l);
253 bool NS3 = (gd - bundle_->computeAlpha(algo_state.
snorm,linErrNew_) >= m2_*v);
260 if ( NS2a || NS2b ) {
270 int ls_nfval = 0, ls_ngrad = 0;
271 lineSearch_->run(alpha,valueNew_,ls_nfval,ls_ngrad,gd,s,x,obj,con);
272 if ( ls_nfval == ls_maxit_ ) {
286 u = state->searchSize;
287 state->searchSize = 0.5*(u+l);
292 u = state->searchSize;
293 state->searchSize = 0.5*(u+l);
310 if ( !algo_state.
flag ) {
314 bundle_->reset(*aggSubGradNew_,aggLinErrNew_,algo_state.
snorm);
321 Real valueOld = algo_state.
value;
323 bundle_->update(step_flag_,valueNew_-valueOld,algo_state.
snorm,*(state->gradientVec),s);
327 bundle_->update(step_flag_,linErrNew_,algo_state.
snorm,*(state->gradientVec),s);
334 algo_state.
gnorm = (state->gradientVec)->norm();
341 std::stringstream hist;
343 hist << std::setw(6) << std::left <<
"iter";
344 hist << std::setw(15) << std::left <<
"value";
345 hist << std::setw(15) << std::left <<
"gnorm";
346 hist << std::setw(15) << std::left <<
"snorm";
347 hist << std::setw(10) << std::left <<
"#fval";
348 hist << std::setw(10) << std::left <<
"#grad";
349 hist << std::setw(15) << std::left <<
"znorm";
350 hist << std::setw(15) << std::left <<
"alpha";
351 hist << std::setw(15) << std::left <<
"TRparam";
352 hist << std::setw(10) << std::left <<
"QPiter";
358 std::stringstream hist;
359 hist <<
"\n" <<
"Bundle Trust-Region Algorithm \n";
365 std::stringstream hist;
366 hist << std::scientific << std::setprecision(6);
367 if ( algo_state.
iter == 0 && first_print_ ) {
369 if ( print_header ) {
373 hist << std::setw(6) << std::left << algo_state.
iter;
374 hist << std::setw(15) << std::left << algo_state.
value;
375 hist << std::setw(15) << std::left << algo_state.
gnorm;
378 if ( step_flag_ && algo_state.
iter > 0 ) {
379 if ( print_header ) {
384 hist << std::setw(6) << std::left << algo_state.
iter;
385 hist << std::setw(15) << std::left << algo_state.
value;
386 hist << std::setw(15) << std::left << algo_state.
gnorm;
387 hist << std::setw(15) << std::left << algo_state.
snorm;
388 hist << std::setw(10) << std::left << algo_state.
nfval;
389 hist << std::setw(10) << std::left << algo_state.
ngrad;
392 hist << std::setw(15) << std::left << state->searchSize;
393 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.
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.