NOMAD Source  Version 4.0.0 Beta
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AlgoStopReasons< StopType > Class Template Reference

Template class for algorithm stop reasons. More...

#include <AlgoStopReasons.hpp>

Inheritance diagram for AlgoStopReasons< StopType >:
Collaboration diagram for AlgoStopReasons< StopType >:

Public Member Functions

 AlgoStopReasons ()
 Constructor. More...
 
 ~AlgoStopReasons ()
 Destructor. More...
 
StopReason< StopType > & getAlgoStopReason ()
 Access to the algo stop reason (no the other generic stop reasons). More...
 
void set (StopType s)
 Set the algo stop reason to a specific stop type. More...
 
std::string getStopReasonAsString () const override
 Get the stop reason that requires termination as a string. More...
 
bool checkTerminate () const override
 Check among generic stop reasons and algo stop reason if the algorithm must terminate. More...
 
bool testIf (StopType s)
 Test for a specific algorithm stop type. More...
 
void setStarted () override
 Reset stop reasons to their default STARTED state. More...
 
- Public Member Functions inherited from AllStopReasons
 AllStopReasons ()
 Constructor. More...
 
virtual ~AllStopReasons ()
 Destructor. More...
 
StopReason< BaseStopType > & getBaseStopReason ()
 
StopReason< EvalStopType > & getEvalStopReason ()
 
StopReason< IterStopType > & getIterStopReason ()
 
void set (IterStopType s)
 
bool testIf (IterStopType s)
 Test IterStopType. More...
 

Static Public Member Functions

static std::shared_ptr
< AlgoStopReasons< StopType > > 
get (std::shared_ptr< AllStopReasons > allStopReasons)
 Access to the AlgoStopReasons. More...
 
- Static Public Member Functions inherited from AllStopReasons
static void set (BaseStopType s)
 
static void set (EvalStopType s)
 
static bool testIf (BaseStopType s)
 Test static BaseStopType. More...
 
static bool testIf (EvalStopType s)
 Test static EvalStopType. More...
 
static std::string getEvalStopReasonAsString ()
 Get the eval stop reason as a string. More...
 
static std::string getBaseStopReasonAsString ()
 Get the base stop reason as a string. More...
 
static bool checkBaseTerminate ()
 
static bool checkEvalTerminate ()
 

Private Attributes

StopReason< StopType > _algoStopReason
 

Detailed Description

template<typename StopType>
class AlgoStopReasons< StopType >

Template class for algorithm stop reasons.

The StopType defines which algorithm is considered.
At some point during an algorithm a stop reason is set. It can be specific to the algorithm or generic (that is be an AllStopReasons stop type).
The stop reasons in AllStopReasons are private and not directly accessible. But the AlgoStopReasons::checkTerminate() function, checks both AllStopReasons and AlgoStopReasons.

Definition at line 20 of file AlgoStopReasons.hpp.

Constructor & Destructor Documentation

template<typename StopType >
AlgoStopReasons< StopType >::AlgoStopReasons ( )
inlineexplicit

Constructor.

Definition at line 26 of file AlgoStopReasons.hpp.

26  : AllStopReasons()
27  {
28  }
AllStopReasons()
Constructor.
template<typename StopType >
AlgoStopReasons< StopType >::~AlgoStopReasons ( )
inline

Destructor.

Definition at line 31 of file AlgoStopReasons.hpp.

32  {}

Member Function Documentation

template<typename StopType >
bool AlgoStopReasons< StopType >::checkTerminate ( ) const
inlineoverridevirtual

Check among generic stop reasons and algo stop reason if the algorithm must terminate.

Reimplemented from AllStopReasons.

Definition at line 61 of file AlgoStopReasons.hpp.

62  {
65  }
virtual bool checkTerminate() const
Check if among all stop reasons, one requires a termination.
bool checkTerminate() const
Check if the stop reason requires a termination.
StopReason< StopType > _algoStopReason
template<typename StopType >
static std::shared_ptr<AlgoStopReasons<StopType> > AlgoStopReasons< StopType >::get ( std::shared_ptr< AllStopReasons allStopReasons)
inlinestatic

Access to the AlgoStopReasons.

Definition at line 68 of file AlgoStopReasons.hpp.

69  {
70  std::shared_ptr<AlgoStopReasons<StopType>> stopReasons = std::dynamic_pointer_cast<AlgoStopReasons<StopType>>( allStopReasons );
71 
72  if ( stopReasons == nullptr )
73  throw Exception(__FILE__, __LINE__, "Invalid shared pointer cast");
74  return stopReasons;
75  }
Exception utility.
Template class for algorithm stop reasons.
template<typename StopType >
StopReason<StopType>& AlgoStopReasons< StopType >::getAlgoStopReason ( )
inline

Access to the algo stop reason (no the other generic stop reasons).

Definition at line 41 of file AlgoStopReasons.hpp.

41 { return _algoStopReason; }
StopReason< StopType > _algoStopReason
template<typename StopType >
std::string AlgoStopReasons< StopType >::getStopReasonAsString ( ) const
inlineoverridevirtual

Get the stop reason that requires termination as a string.

If no termination is required, an empty string is returned.

Reimplemented from AllStopReasons.

Definition at line 49 of file AlgoStopReasons.hpp.

50  {
51  std::string stopReason= AllStopReasons::getStopReasonAsString();
52 
53  if ( ! _algoStopReason.isStarted() )
54  stopReason += _algoStopReason.getStopReasonAsString() + " (Algo) ";
55 
56  return stopReason;
57 
58  }
virtual std::string getStopReasonAsString() const
Get the stop reason that requires termination as a string.
bool isStarted() const
Check if it is in STARTED state.
Definition: StopReason.hpp:183
std::string getStopReasonAsString() const
Translate the stop reason into a string for display.
Definition: StopReason.hpp:189
StopReason< StopType > _algoStopReason
template<typename StopType >
void AlgoStopReasons< StopType >::set ( StopType  s)
inline

Set the algo stop reason to a specific stop type.

Definition at line 44 of file AlgoStopReasons.hpp.

45  {
47  }
void set(T s)
Set the stop reason if it is listed in dictionnary.
Definition: StopReason.hpp:166
StopReason< StopType > _algoStopReason
template<typename StopType >
void AlgoStopReasons< StopType >::setStarted ( )
inlineoverridevirtual

Reset stop reasons to their default STARTED state.

Reimplemented from AllStopReasons.

Definition at line 87 of file AlgoStopReasons.hpp.

88  {
91  }
void setStarted()
Reset the stop reason to the default STARTED state.
Definition: StopReason.hpp:177
StopReason< StopType > _algoStopReason
virtual void setStarted()
Reset all stop reasons to their default STARTED state.
template<typename StopType >
bool AlgoStopReasons< StopType >::testIf ( StopType  s)
inline

Test for a specific algorithm stop type.

Used to pass a sub-algorithm stop reason to a parent algorithm stop reason.

Definition at line 81 of file AlgoStopReasons.hpp.

82  {
83  return ( _algoStopReason.get() == s );
84  }
T get() const
The stop reason.
Definition: StopReason.hpp:160
StopReason< StopType > _algoStopReason

Member Data Documentation

template<typename StopType >
StopReason<StopType> AlgoStopReasons< StopType >::_algoStopReason
private

Definition at line 36 of file AlgoStopReasons.hpp.


The documentation for this class was generated from the following file: