2 #ifndef __NOMAD400_STEP__
3 #define __NOMAD400_STEP__
7 #include "../Algos/AllStopReasons.hpp"
8 #include "../Algos/MeshBase.hpp"
9 #include "../Eval/Barrier.hpp"
10 #include "../Eval/EvaluatorControl.hpp"
11 #include "../Output/OutputInfo.hpp"
12 #include "../Output/OutputQueue.hpp"
13 #include "../Param/RunParameters.hpp"
14 #include "../Type/CallbackType.hpp"
16 #include "../nomad_nsbegin.hpp"
20 typedef std::function<void(const Step& step, bool &stop)>
StepEndCbFunc;
69 const std::shared_ptr<RunParameters> &runParams =
nullptr,
70 const std::shared_ptr<PbParameters> &pbParams =
nullptr )
78 throw Exception( __FILE__ , __LINE__ ,
"Parent step is NULL. This constructor is for child steps having a parent only.");
96 std::shared_ptr<AllStopReasons> stopReasons ,
97 const std::shared_ptr<RunParameters> &runParams =
nullptr,
98 const std::shared_ptr<PbParameters> &pbParams =
nullptr )
107 throw Exception( __FILE__ , __LINE__ ,
"StopReason is NULL. Must be provided for this child step.");
166 const NOMAD::Step& step,
169 std::vector<std::string>& paramLines);
173 void AddOutputInfo(
const std::string& s,
bool isBlockStart,
bool isBlockEnd)
const;
193 Step* retStep =
nullptr;
198 if (
nullptr != dynamic_cast<T>(step))
256 virtual void start() ;
298 #include "../nomad_nsend.hpp"
300 #endif // __NOMAD400_STEP__
virtual ~Step()
Destructor.
void AddOutputDebug(const std::string &s) const
Step()
Constructor #1 for MainStep (no parent)
const Step * _parentStep
The parent of this step.
void AddOutputVeryHigh(const std::string &s) const
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) ...
static bool _userTerminate
Terminate NOMAD if Ctrl-C is pressed again.
const std::shared_ptr< EvalPoint > getIterationFrameCenter() const
static void setUserTerminate()
Interruption requested.
void init()
Helper for constructors.
virtual void end()
What a step does.
static void userInterrupt(int signalValue)
Interruption call by user with a signal value.
void verifyGenerateAllPointsBeforeEval(const std::string &method, const bool expected) const
Helper for validating steps depending on parameter GENERATE_ALL_POINTS_BEFORE_EVAL.
static bool getUserInterrupt()
const Step * getParentOfType(const bool stopAtAlgo=true) const
Template function to get the parent of given type.
std::string _name
The name of this step.
std::shared_ptr< AllStopReasons > _stopReasons
The stop reasons of an algorithm.
virtual void hotRestartOnUserInterrupt()
Helper for hot restart functionalities.
static bool _userInterrupt
Interrupt NOMAD if Ctrl-C is pressed.
void AddOutputHigh(const std::string &s) const
void addCallback(const NOMAD::CallbackType &callbackType, const NOMAD::StepEndCbFunc &stepEndCbFunc)
Set user callback.
void verifyParentNotNull()
Helper for constructors.
static void runCallback(NOMAD::CallbackType callbackType, const NOMAD::Step &step, bool &stop)
Run user callback.
Point getSubFixedVariable() const
virtual const std::string getName() const
Get the name of this step.
std::shared_ptr< PbParameters > _pbParams
The problem parameters that control a step.
void AddOutputError(const std::string &s) const
const Step * getParentStep() const
Get the parent 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.
bool isAnAlgorithm() const
const std::shared_ptr< Barrier > getMegaIterationBarrier() const
void AddOutputWarning(const std::string &s) const
const std::shared_ptr< MeshBase > getIterationMesh() const
void setName(const std::string &name)
Set the name of this step.
static NOMAD::StepEndCbFunc _cbIterationEnd
std::shared_ptr< AllStopReasons > getAllStopReasons() const
Base class of all types of steps (Iteration, Termination, Initialization, Poll, Mads,...).
virtual void start()
What a step does.
static NOMAD::HotRestartCbFunc _cbHotRestart
std::function< void(std::vector< std::string > ¶mLines)> HotRestartCbFunc
Type definitions for callback functions for hot restart.
virtual bool run()
What a step does.
static void defaultHotRestart(std::vector< std::string > ¶mLines __attribute__((unused)))
void hotRestartEndHelper()
Helpers for hot restart, to be called at the start and end of any override.
Class for the representation of a point.
void hotRestartBeginHelper()
Helpers for hot restart, to be called at the start and end of any override.
void AddOutputInfo(const std::string &s, bool isBlockStart, bool isBlockEnd) const
display output
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.
static NOMAD::StepEndCbFunc _cbMegaIterationEnd
std::shared_ptr< RunParameters > _runParams
The run parameters that control a step.