ROL
ROL_FletcherStatusTest.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_FletcherStatusTest_H
11 #define ROL_FletcherStatusTest_H
12 
13 #include "ROL_StatusTest.hpp"
14 
21 namespace ROL {
22 
23 template <class Real>
24 class FletcherStatusTest : public StatusTest<Real> {
25 private:
26 
27  Real gtol_;
28  Real ctol_;
29  Real stol_;
30  int max_iter_;
31 
32 public:
33 
34  virtual ~FletcherStatusTest() {}
35 
36  FletcherStatusTest( ROL::ParameterList &parlist ) {
37  Real em6(1e-6);
38  gtol_ = parlist.sublist("Status Test").get("Gradient Tolerance", em6);
39  ctol_ = parlist.sublist("Status Test").get("Constraint Tolerance", em6);
40  stol_ = parlist.sublist("Status Test").get("Step Tolerance", em6*gtol_);
41  max_iter_ = parlist.sublist("Status Test").get("Iteration Limit", 100);
42  }
43 
44  FletcherStatusTest( Real gtol = 1e-6, Real ctol = 1e-6, Real stol = 1e-12, int max_iter = 100 ) :
45  gtol_(gtol), ctol_(ctol), stol_(stol), max_iter_(max_iter) {}
46 
49  virtual bool check( AlgorithmState<Real> &state ) {
50  if ( ((state.gnorm > gtol_) || (state.cnorm > ctol_)) &&
51  (state.snorm > stol_) && (state.aggregateGradientNorm > gtol_) &&
52  (state.iter < max_iter_) && (!state.flag)) {
53  return true;
54  }
55  else {
56  state.statusFlag = ((state.gnorm <= gtol_) && (state.cnorm <= ctol_) ? EXITSTATUS_CONVERGED
57  : state.snorm <= stol_ ? EXITSTATUS_STEPTOL
59  : state.iter >= max_iter_ ? EXITSTATUS_MAXITER
60  : state.flag==true ? EXITSTATUS_CONVERGED
61  : EXITSTATUS_LAST);
62  return false;
63  }
64  }
65 
66 }; // class FletcherStatusTest
67 
68 } // namespace ROL
69 
70 #endif
71 
EExitStatus statusFlag
Definition: ROL_Types.hpp:126
State for algorithm class. Will be used for restarts.
Definition: ROL_Types.hpp:109
Provides an interface to check status of optimization algorithms for problems with equality constrain...
virtual bool check(AlgorithmState< Real > &state)
Check algorithm status.
FletcherStatusTest(Real gtol=1e-6, Real ctol=1e-6, Real stol=1e-12, int max_iter=100)
Provides an interface to check status of optimization algorithms.
FletcherStatusTest(ROL::ParameterList &parlist)