NOMAD Source
Version 4.0.0 Beta
|
Main step to manage an algorithm executable. More...
#include <MainStep.hpp>
Public Member Functions | |
MainStep () | |
Constructor. More... | |
~MainStep () | |
Destructor. More... | |
void | setParamFileName (const std::string ¶mFileName) |
void | setAllParameters (const std::shared_ptr< AllParameters > &allParams) |
void | setEvaluator (std::unique_ptr< Evaluator > ev) |
std::shared_ptr< Subproblem > | getCurrentSubproblem () const |
Get the subproblem that is currently treated. More... | |
void | addAlgo (const std::shared_ptr< Step > algo) |
void | clearAlgos () |
void | start () override |
Start NOMAD. More... | |
bool | run () override |
void | end () override |
void | displayUsage (const char *exeName) |
Helper function called by the code main function if necessary. More... | |
void | displayVersion () |
Helper function called by the code main function if necessary. More... | |
void | displayInfo () |
Helper function called by the code main function if necessary. More... | |
void | displayHelp (const std::string &helpSubject="all", bool devHelp=false) |
Helper function called by the code main function if necessary. More... | |
void | hotRestartOnUserInterrupt () override |
![]() | |
Step () | |
Constructor #1 for MainStep (no parent) More... | |
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. More... | |
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) More... | |
virtual | ~Step () |
Destructor. More... | |
const Step * | getParentStep () const |
Get the parent step. More... | |
virtual const std::string | getName () const |
Get the name of this step. More... | |
void | setName (const std::string &name) |
Set the name of this step. More... | |
std::shared_ptr< AllStopReasons > | getAllStopReasons () const |
void | addCallback (const NOMAD::CallbackType &callbackType, const NOMAD::StepEndCbFunc &stepEndCbFunc) |
Set user callback. More... | |
void | addCallback (const NOMAD::CallbackType &callbackType, const NOMAD::HotRestartCbFunc &hotRestartCbFunc) |
void | AddOutputInfo (const std::string &s, bool isBlockStart, bool isBlockEnd) const |
display output More... | |
void | AddOutputInfo (const std::string &s, OutputLevel outputLevel=OutputLevel::LEVEL_INFO) const |
void | AddOutputError (const std::string &s) const |
void | AddOutputWarning (const std::string &s) const |
void | AddOutputVeryHigh (const std::string &s) const |
void | AddOutputHigh (const std::string &s) const |
void | AddOutputDebug (const std::string &s) const |
void | AddOutputInfo (OutputInfo outputInfo) const |
template<typename T > | |
const Step * | getParentOfType (const bool stopAtAlgo=true) const |
Template function to get the parent of given type. More... | |
bool | isAnAlgorithm () const |
const std::shared_ptr< MeshBase > | getIterationMesh () const |
const std::shared_ptr< EvalPoint > | getIterationFrameCenter () const |
const std::shared_ptr< Barrier > | getMegaIterationBarrier () const |
Point | getSubFixedVariable () const |
Static Public Member Functions | |
static void | setAlgoComment (const std::string &algoComment) |
static const std::string & | getAlgoComment () |
static void | resetPreviousAlgoComment () |
![]() | |
static bool | getUserTerminate () |
Interruption call by user. More... | |
static void | setUserTerminate () |
Interruption requested. More... | |
static void | userInterrupt (int signalValue) |
Interruption call by user with a signal value. More... | |
static bool | getUserInterrupt () |
static void | runCallback (NOMAD::CallbackType callbackType, const NOMAD::Step &step, bool &stop) |
Run user callback. More... | |
static void | runCallback (NOMAD::CallbackType callbackType, std::vector< std::string > ¶mLines) |
Private Member Functions | |
void | init () |
Helper for constructor. More... | |
int | getNumThreads () const |
Helper function when creating the evaluator. More... | |
void | setNumThreads () const |
Set the number of threads for the evaluator. More... | |
void | printNumThreads () const |
bool | detectPhaseOne () |
Detect if a Phase One search is required. More... | |
void | createCache () const |
Helper for start. More... | |
void | updateX0sFromCache () const |
Helper for start. More... | |
Private Attributes | |
std::string | _paramFileName |
The file containing the parameters. More... | |
std::shared_ptr< AllParameters > | _allParams |
std::unique_ptr< Evaluator > | _evaluator |
Used in library running mode (not batch mode) More... | |
std::vector< std::shared_ptr < Step > > | _algos |
std::vector< Subproblem > | _subproblems |
Subproblem definition. More... | |
Static Private Attributes | |
static std::string | _algoComment |
Comment to appear in the stats, e.g. "Phase One". More... | |
static std::string | _prevAlgoComment |
Comment to appear in the stats. Used when going back to the main algo after running a sub-algo. More... | |
Additional Inherited Members | |
![]() | |
void | verifyParentNotNull () |
Helper for constructors. More... | |
void | verifyGenerateAllPointsBeforeEval (const std::string &method, const bool expected) const |
Helper for validating steps depending on parameter GENERATE_ALL_POINTS_BEFORE_EVAL. More... | |
void | init () |
Helper for constructors. More... | |
void | defaultStart () |
bool | defaultRun () |
void | defaultEnd () |
void | hotRestartBeginHelper () |
Helpers for hot restart, to be called at the start and end of any override. More... | |
void | hotRestartEndHelper () |
Helpers for hot restart, to be called at the start and end of any override. More... | |
![]() | |
const Step * | _parentStep |
The parent of this step. More... | |
std::string | _name |
The name of this step. More... | |
std::shared_ptr< AllStopReasons > | _stopReasons |
The stop reasons of an algorithm. More... | |
std::shared_ptr< RunParameters > | _runParams |
The run parameters that control a step. More... | |
std::shared_ptr< PbParameters > | _pbParams |
The problem parameters that control a step. More... | |
![]() | |
static bool | _userInterrupt |
Interrupt NOMAD if Ctrl-C is pressed. More... | |
static bool | _userTerminate |
Terminate NOMAD if Ctrl-C is pressed again. More... | |
static NOMAD::StepEndCbFunc | _cbIterationEnd |
static NOMAD::StepEndCbFunc | _cbMegaIterationEnd |
static NOMAD::HotRestartCbFunc | _cbHotRestart |
Main step to manage an algorithm executable.
MainStep is the root step of an executable running an algorithm. Think of it as a wrapper around the algorithm. MainStep manages all algorithm needs: Parameters, Evaluator and has utility functions (ex. displayUsage). MainStep takes care of the OpenMP parallelism.
Definition at line 27 of file MainStep.hpp.
|
inlineexplicit |
Constructor.
Definition at line 46 of file MainStep.hpp.
MainStep::~MainStep | ( | ) |
Destructor.
|
inline |
Once all algos have been added are executed (call start, run and end for each algo) in the MainStep::run.
Definition at line 99 of file MainStep.hpp.
|
inline |
Definition at line 101 of file MainStep.hpp.
|
private |
Helper for start.
|
private |
Detect if a Phase One search is required.
A phase one search is required if an EB type constraint is not feasible for X0.
void MainStep::displayHelp | ( | const std::string & | helpSubject = "all" , |
bool | devHelp = false |
||
) |
Helper function called by the code main function if necessary.
void MainStep::displayInfo | ( | ) |
Helper function called by the code main function if necessary.
void MainStep::displayUsage | ( | const char * | exeName | ) |
Helper function called by the code main function if necessary.
void MainStep::displayVersion | ( | ) |
Helper function called by the code main function if necessary.
|
overridevirtual |
Calls the default end of a step.
Reimplemented from Step.
|
inlinestatic |
Definition at line 82 of file MainStep.hpp.
std::shared_ptr<Subproblem> MainStep::getCurrentSubproblem | ( | ) | const |
Get the subproblem that is currently treated.
Currently, there is only one.
|
private |
Helper function when creating the evaluator.
|
overridevirtual |
The user has requested a hot restart. Update the parameters with the changes requested by the user (read file or set inline).
Reimplemented from Step.
|
private |
Helper for constructor.
|
private |
|
inlinestatic |
Definition at line 103 of file MainStep.hpp.
|
overridevirtual |
Once all algos have been added are executed (call start, run and end for each algo) in the MainStep::run.
If a stop reason (not the default STARTED) is propagated to the MainStep, the sequence of algos is stopped.
Reimplemented from Step.
|
inlinestatic |
Definition at line 76 of file MainStep.hpp.
void MainStep::setAllParameters | ( | const std::shared_ptr< AllParameters > & | allParams | ) |
|
inline |
The evaluator is unique. All algorithms must use the same evaluator.
Definition at line 74 of file MainStep.hpp.
|
private |
Set the number of threads for the evaluator.
|
inline |
In batch mode: Set the parameter file name, which will be read in start(). In library mode: Set the parameters directly using set_PARAM_NAME(...). In library mode, it is also possible to read a parameter file.
Definition at line 67 of file MainStep.hpp.
|
overridevirtual |
Start NOMAD.
During the main step start, the parameters are read (if parameter file is available), the cache, the evaluator and the evaluator control are created. If an algorithm is set for run in the parameter file, it is added ( MainStep::addAlgo ).
Reimplemented from Step.
|
private |
Helper for start.
|
staticprivate |
Comment to appear in the stats, e.g. "Phase One".
Definition at line 34 of file MainStep.hpp.
|
private |
Definition at line 33 of file MainStep.hpp.
|
private |
Definition at line 31 of file MainStep.hpp.
|
private |
Used in library running mode (not batch mode)
Definition at line 32 of file MainStep.hpp.
|
private |
The file containing the parameters.
Definition at line 30 of file MainStep.hpp.
|
staticprivate |
Comment to appear in the stats. Used when going back to the main algo after running a sub-algo.
Definition at line 35 of file MainStep.hpp.
|
private |
Subproblem definition.
Definition at line 41 of file MainStep.hpp.