NOMAD Source  Version 4.0.0 Beta
MegaIteration Class Referenceabstract

Class to manage the iterations. More...

#include <MegaIteration.hpp>

Inheritance diagram for MegaIteration:
Collaboration diagram for MegaIteration:

Public Member Functions

 MegaIteration (const Step *parentStep, size_t k, std::shared_ptr< Barrier > barrier, SuccessType success)
 Constructor. More...
 
size_t getNbIterations () const
 
const std::shared_ptr< Iteration > & getIter (size_t i) const
 
size_t getK () const
 
void setK (const size_t k)
 
size_t getNextK () const
 
const std::shared_ptr< Barrier > & getBarrier () const
 
void setBarrier (const std::shared_ptr< Barrier > &barrier)
 
const SuccessTypegetSuccessType () const
 
void setSuccessType (const SuccessType &success)
 
void computeMaxXFeasXInf (size_t &maxXFeas, size_t &maxXInf)
 Compute the number of xFeas and xInf points to use to create iterations. More...
 
virtual void read (std::istream &is)
 
virtual void display (std::ostream &os) const
 
- Public Member Functions inherited from Step
 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 StepgetParentStep () 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...
 
const std::shared_ptr< AllStopReasons > & getAllStopReasons () const
 
const std::shared_ptr< RunParameters > & getRunParams () const
 
const std::shared_ptr< PbParameters > & getPbParams () const
 
void addCallback (const CallbackType &callbackType, const StepEndCbFunc &stepEndCbFunc)
 Set user callback. More...
 
void addCallback (const CallbackType &callbackType, const 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 >
getParentOfType (const bool stopAtAlgo=true) const
 Template function to get the parent of given type. More...
 
bool isAnAlgorithm () const
 
const AlgorithmgetRootAlgorithm () const
 Get Algorithm ancestor that has no Algorithm ancestor. More...
 
std::string getAlgoName () const
 
virtual std::string getAlgoComment () const
 
virtual void setAlgoComment (const std::string &algoComment, const bool force=false)
 
virtual void resetPreviousAlgoComment (const bool force=false)
 
const std::shared_ptr< MeshBasegetIterationMesh () const
 
const std::shared_ptr< EvalPointgetIterationFrameCenter () const
 
const std::shared_ptr< BarriergetMegaIterationBarrier () const
 
void start ()
 
bool run ()
 
void end ()
 
virtual void hotRestartOnUserInterrupt ()
 Helper for hot restart functionalities. More...
 
void debugShowCallStack () const
 For debugging purposes. Show the stack of Steps for this step. More...
 

Protected Member Functions

virtual void startImp () override=0
 
virtual bool runImp () override=0
 
virtual void endImp () override
 Implementation of the end task. More...
 
- Protected Member Functions inherited from Step
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 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...
 

Protected Attributes

std::vector< std::shared_ptr< Iteration > > _iterList
 A collection of additional iterations: Help generate more eval points. More...
 
std::shared_ptr< Barrier_barrier
 
size_t _k
 Main counter. More...
 
size_t _nbIterRun
 Number of iterations run within this MegaIteration. More...
 
SuccessType _megaIterationSuccess
 
- Protected Attributes inherited from Step
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...
 

Private Member Functions

void init ()
 Helper for constructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Step
static bool getUserTerminate ()
 Interruption call by user. More...
 
static void setUserTerminate ()
 Interruption requested. More...
 
static void userInterrupt (int signalValue)
 Interruption call by user. More...
 
static void debugSegFault (int signalValue)
 
static bool getUserInterrupt ()
 
static void runCallback (CallbackType callbackType, const Step &step, bool &stop)
 Run user callback. More...
 
static void runCallback (CallbackType callbackType, std::vector< std::string > &paramLines)
 
static void disableWarnings ()
 
- Static Protected Attributes inherited from Step
static bool _userInterrupt
 Interrupt NOMAD if Ctrl-C is pressed. More...
 
static bool _userTerminate
 Terminate NOMAD if Ctrl-C is pressed again. More...
 
static StepEndCbFunc _cbIterationEnd
 
static StepEndCbFunc _cbMegaIterationEnd
 
static HotRestartCbFunc _cbHotRestart
 
static bool _showWarnings
 

Detailed Description

Class to manage the iterations.

A mega iteration of an algorithm:

  • generates a lot of points over multiple strategies (ex., Poll and Search for Mads).
  • evaluates points
  • performs post-processing

The run and start functions of mega iteration must be implemented for each optimizer that has several phases of points creation that we want to combine before launching evaluations (for example, MadsMegaIteration, NMMegaIteration, ...).

Note
As an hypothesis, the time load is taken by the evaluation, which is parallelized over all evaluations simultaneously. The iteration generation, including trial points generation, has little time load, so they do not need to be parallelized. It is also preferable to keep parallelization to the only place where it matters the most to avoid errors.
There is no parallelization at the algorithmic level. The algorithms are run in main thread(s) only; other threads are available for evaluations.

Definition at line 73 of file MegaIteration.hpp.

Constructor & Destructor Documentation

◆ MegaIteration()

MegaIteration::MegaIteration ( const Step parentStep,
size_t  k,
std::shared_ptr< Barrier barrier,
SuccessType  success 
)
explicit

Constructor.

Parameters
parentStepThe parent step of this step – IN.
kThe main iteration counter – IN.
barrierThe barrier for constraints handling. Belongs to subproblem space. – IN.
successSuccess type of the previous MegaIteration. – IN.

Member Function Documentation

◆ computeMaxXFeasXInf()

void MegaIteration::computeMaxXFeasXInf ( size_t &  maxXFeas,
size_t &  maxXInf 
)

Compute the number of xFeas and xInf points to use to create iterations.

◆ display()

virtual void MegaIteration::display ( std::ostream &  os) const
virtual

Reimplemented in MadsMegaIteration, and NMMegaIteration.

◆ endImp()

virtual void MegaIteration::endImp ( )
overrideprotectedvirtual

Implementation of the end task.

Perform callback check for user termination and clear the iteration list.

Implements Step.

Reimplemented in SgtelibModelMegaIteration, and QuadModelMegaIteration.

◆ getBarrier()

const std::shared_ptr<Barrier>& MegaIteration::getBarrier ( ) const
inline

Definition at line 131 of file MegaIteration.hpp.

131 { return _barrier; }

◆ getIter()

const std::shared_ptr<Iteration>& MegaIteration::getIter ( size_t  i) const
inline

Definition at line 124 of file MegaIteration.hpp.

124 { return _iterList[i]; }

◆ getK()

size_t MegaIteration::getK ( ) const
inline

Definition at line 126 of file MegaIteration.hpp.

126 { return _k; }

◆ getNbIterations()

size_t MegaIteration::getNbIterations ( ) const
inline

Definition at line 123 of file MegaIteration.hpp.

123 { return _iterList.size(); }

◆ getNextK()

size_t MegaIteration::getNextK ( ) const

◆ getSuccessType()

const SuccessType& MegaIteration::getSuccessType ( ) const
inline

Success is initialized with the success of the previous MegaIteration. This is useful to know for the Update step, and some Search steps. At the end of the MegaIteration, Success is updated with the latest SuccessType.

Definition at line 140 of file MegaIteration.hpp.

140 { return _megaIterationSuccess; }

◆ init()

void MegaIteration::init ( )
private

Helper for constructor.

◆ read()

virtual void MegaIteration::read ( std::istream &  is)
virtual

Reimplemented in MadsMegaIteration, and NMMegaIteration.

◆ runImp()

virtual bool MegaIteration::runImp ( )
overrideprotectedpure virtual

Placeholder to be implemented in derived classes. Called by run.

Implements Step.

Implemented in MadsMegaIteration, NMMegaIteration, PSDMadsMegaIteration, SSDMadsMegaIteration, SgtelibModelMegaIteration, and QuadModelMegaIteration.

◆ setBarrier()

void MegaIteration::setBarrier ( const std::shared_ptr< Barrier > &  barrier)
inline

Definition at line 132 of file MegaIteration.hpp.

132 { _barrier = barrier; }

◆ setK()

void MegaIteration::setK ( const size_t  k)
inline

Definition at line 127 of file MegaIteration.hpp.

127 { _k = k; }

◆ setSuccessType()

void MegaIteration::setSuccessType ( const SuccessType success)
inline

Definition at line 141 of file MegaIteration.hpp.

141 { _megaIterationSuccess = success; }

◆ startImp()

virtual void MegaIteration::startImp ( )
overrideprotectedpure virtual

Placeholder to be implemented in derived classes. Called by start.

Implements Step.

Implemented in MadsMegaIteration, NMMegaIteration, PSDMadsMegaIteration, SSDMadsMegaIteration, SgtelibModelMegaIteration, and QuadModelMegaIteration.

Member Data Documentation

◆ _barrier

std::shared_ptr<Barrier> MegaIteration::_barrier
protected

The barrier holds xFeas, xInf and hMax. xFeas and xInf will be used as frame centers.

Note
This barrier is in subspace.

Definition at line 85 of file MegaIteration.hpp.

◆ _iterList

std::vector<std::shared_ptr<Iteration> > MegaIteration::_iterList
protected

A collection of additional iterations: Help generate more eval points.

Definition at line 78 of file MegaIteration.hpp.

◆ _k

size_t MegaIteration::_k
protected

Main counter.

Definition at line 88 of file MegaIteration.hpp.

◆ _megaIterationSuccess

SuccessType MegaIteration::_megaIterationSuccess
protected

Success type of this step. Initialized with the run of the previous mega iteration, so that the update step knows what to do (for example, enlarge or reduce the mesh). At the end of run step during the mega iteration of an algorithm, the success type is updated (MegaIteration::setSuccessType) with the latest success type.

Definition at line 99 of file MegaIteration.hpp.

◆ _nbIterRun

size_t MegaIteration::_nbIterRun
protected

Number of iterations run within this MegaIteration.

Definition at line 89 of file MegaIteration.hpp.


The documentation for this class was generated from the following file:
MegaIteration::_iterList
std::vector< std::shared_ptr< Iteration > > _iterList
A collection of additional iterations: Help generate more eval points.
Definition: MegaIteration.hpp:78
MegaIteration::_barrier
std::shared_ptr< Barrier > _barrier
Definition: MegaIteration.hpp:85
MegaIteration::_k
size_t _k
Main counter.
Definition: MegaIteration.hpp:88
MegaIteration::_megaIterationSuccess
SuccessType _megaIterationSuccess
Definition: MegaIteration.hpp:99