NOMAD Source  Version 4.0.0 Beta
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Termination.hpp
Go to the documentation of this file.
1 #ifndef __NOMAD400_TERMINATION__
2 #define __NOMAD400_TERMINATION__
3 
4 #include "../Algos/Step.hpp"
5 
6 #include "../nomad_nsbegin.hpp"
7 
8 /// Class for termination of an algorithm.
9 /**
10  The terminate function checks for termination criterions such as MAX_ITERATIONS, MAX_TIME, STOP_IF_FEASIBLE and set the stop reason.
11  */
12 class Termination: public Step
13 {
14 public:
15  /// Constructor
16  explicit Termination(const Step* parentStep,
17  const std::shared_ptr<RunParameters>& runParams = nullptr,
18  const std::shared_ptr<PbParameters>& pbParams = nullptr)
19  : Step(parentStep, runParams, pbParams)
20  {
21  init();
22  }
23  /// Destructor
25 
26  /**
27  The terminate function is called when algorithm are performing iterations during a run. At each iteration, we test if a stop criterion is reached.
28  */
29  virtual bool terminate(size_t iteration);
30 
31  virtual void start() override; ///< Not really useful ... but a step must have a start.
32  virtual bool run() override; ///< Not really useful ... but a step must have a run.
33 
34  /**
35  Upon completing an algorithm run, this end function is called to display termination info.
36  */
37  virtual void end() override;
38 
39 private:
40 
41  /// Helper for constructor
42  void init();
43 
44 
45 };
46 
47 #include "../nomad_nsend.hpp"
48 
49 #endif // __NOMAD400_TERMINATION__
Termination(const Step *parentStep, const std::shared_ptr< RunParameters > &runParams=nullptr, const std::shared_ptr< PbParameters > &pbParams=nullptr)
Constructor.
Definition: Termination.hpp:16
virtual void end() override
virtual bool terminate(size_t iteration)
~Termination()
Destructor.
Definition: Termination.hpp:24
Base class of all types of steps (Iteration, Termination, Initialization, Poll, Mads,...).
Definition: Step.hpp:24
Class for termination of an algorithm.
Definition: Termination.hpp:12
virtual void start() override
Not really useful ... but a step must have a start.
void init()
Helper for constructor.
virtual bool run() override
Not really useful ... but a step must have a run.