NOMAD Source
Version 4.0.0 Beta
|
Go to the documentation of this file.
47 #ifndef __NOMAD400_STEP__
48 #define __NOMAD400_STEP__
50 #include "../Algos/MeshBase.hpp"
51 #include "../Eval/Barrier.hpp"
52 #include "../Output/OutputInfo.hpp"
53 #include "../Param/PbParameters.hpp"
54 #include "../Param/RunParameters.hpp"
55 #include "../Type/CallbackType.hpp"
56 #include "../Type/EvalType.hpp"
57 #include "../Util/AllStopReasons.hpp"
59 #include "../nomad_nsbegin.hpp"
116 const std::shared_ptr<RunParameters> &runParams =
nullptr,
117 const std::shared_ptr<PbParameters> &pbParams =
nullptr)
125 throw Exception(__FILE__, __LINE__,
"Parent step is NULL. This constructor is for child steps having a parent only.");
129 _name =
"Child step";
143 std::shared_ptr<AllStopReasons> stopReasons,
144 const std::shared_ptr<RunParameters> &runParams =
nullptr,
145 const std::shared_ptr<PbParameters> &pbParams =
nullptr)
154 throw Exception(__FILE__, __LINE__,
"StopReason is NULL. Must be provided for this child step.");
224 std::vector<std::string>& paramLines);
229 void AddOutputInfo(
const std::string& s,
bool isBlockStart,
bool isBlockEnd)
const;
249 Step* retStep =
nullptr;
252 while (
nullptr != step)
254 if (
nullptr !=
dynamic_cast<T
>(step))
266 return dynamic_cast<T
>(retStep);
291 virtual void setAlgoComment(
const std::string& algoComment,
const bool force =
false);
331 virtual bool runImp() = 0 ;
341 virtual void endImp() = 0 ;
390 StepException(
const std::string& file,
const size_t line,
const std::string & msg,
const Step* step)
400 #include "../nomad_nsend.hpp"
402 #endif // __NOMAD400_STEP__
OutputLevel
Level of output AKA Display degree.
void debugShowCallStack() const
For debugging purposes. Show the stack of Steps for this step.
const std::shared_ptr< PbParameters > & getPbParams() const
static bool _showWarnings
virtual const std::string & getName() const
Get the name of this step.
virtual ~Step()
Destructor.
static StepEndCbFunc _cbMegaIterationEnd
virtual std::string getAlgoComment() const
const Algorithm * getRootAlgorithm() const
Get Algorithm ancestor that has no Algorithm ancestor.
std::shared_ptr< RunParameters > _runParams
The run parameters that control a step.
static void userInterrupt(int signalValue)
Interruption call by user.
Step()
Constructor #1 for MainStep (no parent)
Generic class for any direct search optimizer algorithm.
StepException(const std::string &file, const size_t line, const std::string &msg, const Step *step)
Constructor.
static void setUserTerminate()
Interruption requested.
const Step * _parentStep
The parent of this step.
Base class of all types of steps (Iteration, Termination, Initialization, Poll, Mads,...
std::shared_ptr< AllStopReasons > _stopReasons
The stop reasons of an algorithm.
static void runCallback(CallbackType callbackType, const Step &step, bool &stop)
Run user callback.
static bool _userInterrupt
Interrupt NOMAD if Ctrl-C is pressed.
const std::shared_ptr< AllStopReasons > & getAllStopReasons() const
static bool _userTerminate
Terminate NOMAD if Ctrl-C is pressed again.
virtual void setAlgoComment(const std::string &algoComment, const bool force=false)
void AddOutputWarning(const std::string &s) const
void verifyGenerateAllPointsBeforeEval(const std::string &method, const bool expected) const
Helper for validating steps depending on parameter GENERATE_ALL_POINTS_BEFORE_EVAL.
Step(const Step *parentStep, std::shared_ptr< AllStopReasons > stopReasons, const std::shared_ptr< RunParameters > &runParams=nullptr, const std::shared_ptr< PbParameters > &pbParams=nullptr)
Constructor #3: for a child Step with a provided stopReason (such as an algorithm)
bool isAnAlgorithm() const
void init()
Helper for constructor.
T getParentOfType(const bool stopAtAlgo=true) const
Template function to get the parent of given type.
std::string getAlgoName() const
void AddOutputInfo(const std::string &s, bool isBlockStart, bool isBlockEnd) const
display output
const Step * getParentStep() const
Get the parent step.
static bool getUserInterrupt()
std::shared_ptr< PbParameters > _pbParams
The problem parameters that control a step.
std::string _name
The name of this step.
virtual void hotRestartOnUserInterrupt()
Helper for hot restart functionalities.
virtual void resetPreviousAlgoComment(const bool force=false)
const std::shared_ptr< RunParameters > & getRunParams() const
void verifyParentNotNull()
Helper for constructors.
void setName(const std::string &name)
Set the name of this step.
std::function< void(const Step &step, bool &stop)> StepEndCbFunc
Type definitions for callback functions at the end of a step.
static void defaultStepEnd(const Step &step __attribute__((unused)), bool &stop)
static bool getUserTerminate()
Interruption call by user.
void AddOutputHigh(const std::string &s) const
const std::shared_ptr< EvalPoint > getIterationFrameCenter() const
std::function< void(std::vector< std::string > ¶mLines)> HotRestartCbFunc
Type definitions for callback functions for hot restart.
const std::shared_ptr< MeshBase > getIterationMesh() const
void AddOutputError(const std::string &s) const
void addCallback(const CallbackType &callbackType, const StepEndCbFunc &stepEndCbFunc)
Set user callback.
static void disableWarnings()
void hotRestartBeginHelper()
Helpers for hot restart, to be called at the start and end of any override.
@ LEVEL_INFO
Lots of information.
void AddOutputVeryHigh(const std::string &s) const
Step(const Step *parentStep, const std::shared_ptr< RunParameters > &runParams=nullptr, const std::shared_ptr< PbParameters > &pbParams=nullptr)
Constructor #2 for child step of a parent sharing the same stopReason.
void AddOutputDebug(const std::string &s) const
static void debugSegFault(int signalValue)
static StepEndCbFunc _cbIterationEnd
void hotRestartEndHelper()
Helpers for hot restart, to be called at the start and end of any override.
static void defaultHotRestart(std::vector< std::string > ¶mLines __attribute__((unused)))
static HotRestartCbFunc _cbHotRestart
const std::shared_ptr< Barrier > getMegaIterationBarrier() const
virtual void startImp()=0