ROL
ROL_BundleStatusTest.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_BUNDLESTATUSTEST_H
11 #define ROL_BUNDLESTATUSTEST_H
12 
13 #include "ROL_StatusTest.hpp"
14 #include "ROL_Types.hpp"
15 
16 namespace ROL {
17 
18 template <class Real>
19 class BundleStatusTest : public StatusTest<Real> {
20 private:
21 
22  Real tol_;
23  int max_iter_;
24 
25 public:
26 
27  virtual ~BundleStatusTest() {}
28 
29  BundleStatusTest( ROL::ParameterList &parlist ) {
30  Real em6(1e-6);
31  tol_ = parlist.sublist("Step").sublist("Bundle").get("Epsilon Solution Tolerance", em6);
32  max_iter_ = parlist.sublist("Status Test").get("Iteration Limit", 100);
33  }
34 
35  BundleStatusTest( Real tol = 1.e-6, int max_iter = 100 ) :
36  tol_(tol), max_iter_(max_iter) {}
37 
40  virtual bool check( AlgorithmState<Real> &state ) {
41  bool stat = false;
42  if ( (std::max(state.aggregateGradientNorm,state.aggregateModelError) > tol_)
43  && (state.iter < max_iter_)
44  && (state.flag == false) ) {
45  stat = true;
46  }
47  else {
49  : state.iter >= max_iter_ ? EXITSTATUS_MAXITER
50  : state.flag == true ? EXITSTATUS_CONVERGED
51  : EXITSTATUS_LAST);
52  }
53  return stat;
54  }
55 
56 }; // class BundleStatusTest
57 
58 } // namespace ROL
59 
60 #endif
virtual bool check(AlgorithmState< Real > &state)
Check algorithm status.
EExitStatus statusFlag
Definition: ROL_Types.hpp:126
Contains definitions of custom data types in ROL.
State for algorithm class. Will be used for restarts.
Definition: ROL_Types.hpp:109
BundleStatusTest(ROL::ParameterList &parlist)
Provides an interface to check status of optimization algorithms.
BundleStatusTest(Real tol=1.e-6, int max_iter=100)