NOMAD Source  Version 4.0.0 Beta
LH Class Reference

Class for Latin Hypercube algorithm sampling. More...

#include <LH.hpp>

Inheritance diagram for LH:
Collaboration diagram for LH:

Public Member Functions

 LH (const Step *parentStep, std::shared_ptr< AlgoStopReasons< LHStopType >> stopReasons, const std::shared_ptr< RunParameters > &runParams, const std::shared_ptr< PbParameters > &pbParams)
 Constructor. More...
 
virtual ~LH ()
 Destructor. More...
 
virtual void readInformationForHotRestart () override
 Helper for start() when doing a hot restart. More...
 
- Public Member Functions inherited from Algorithm
 Algorithm (const Step *parentStep, std::shared_ptr< AllStopReasons > stopReasons, const std::shared_ptr< RunParameters > &runParams, const std::shared_ptr< PbParameters > &pbParams)
 Constructor. More...
 
virtual ~Algorithm ()
 Destructor. More...
 
const std::shared_ptr< MegaIteration > & getMegaIteration () const
 
void setMegaIteration (const std::shared_ptr< MegaIteration > megaIteration)
 
void setAlgoComment (const std::string &algoComment, const bool force=false) override
 
void resetPreviousAlgoComment (const bool force=false) override
 
std::string getAlgoComment () const override
 
void setEndDisplay (bool endDisplay)
 
bool isSubAlgo () const
 
bool isRootAlgo () const
 
bool terminate (size_t iteration)
 Verify if this Algorithm is ready to be terminated. 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
 
const std::shared_ptr< MeshBasegetIterationMesh () const
 
const std::shared_ptr< EvalPointgetIterationFrameCenter () const
 
const std::shared_ptr< BarriergetMegaIterationBarrier () const
 
void start ()
 
bool run ()
 
void end ()
 
void debugShowCallStack () const
 For debugging purposes. Show the stack of Steps for this step. More...
 
- Public Member Functions inherited from IterationUtils
 IterationUtils (const Step *parentStep)
 Constructor. More...
 
virtual ~IterationUtils ()
 Destructor. More...
 
const SuccessTypegetSuccessType () const
 
void setSuccessType (const SuccessType &success)
 
size_t getTrialPointsCount () const
 
const EvalPointSetgetTrialPoints () const
 
bool insertTrialPoint (const EvalPoint &evalPoint)
 Insert a trial point. More...
 
void clearTrialPoints (void)
 Clear trial points. More...
 
virtual bool postProcessing (const EvalType &evalType)
 Helper for end task. More...
 
void verifyPointsAreOnMesh (const std::string &name) const
 Helper for start task. More...
 
bool snapPointToBoundsAndProjectOnMesh (Point &point, const ArrayOfDouble &lowerBound, const ArrayOfDouble &upperBound)
 Snap a given trial point to the bounds and project on mesh. More...
 
bool evalTrialPoints (Step *step)
 Start evaluation of the trial points. More...
 
size_t getNbEvalPointsThatNeededEval () const
 Get the number of evaluation points in the queue for evaluation. More...
 
void updatePointsWithFrameCenter ()
 Add current frame center as originator of each point in trialPoints. More...
 

Private Member Functions

void init ()
 Helper for constructor. More...
 
virtual void startImp () override
 Implementation for start task. More...
 
virtual bool runImp () override
 Implementation for run tasks. More...
 
virtual void endImp () override
 Implementation for end task. More...
 
void generateTrialPoints () override
 Generate the trial points of an algorithm iteration before evaluation.
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 ()
 
- Protected Member Functions inherited from Algorithm
void saveInformationForHotRestart () const
 Helper for end() More...
 
void displayBestSolutions () const
 Helper for end() More...
 
void displayEvalCounts () const
 Helper for end() More...
 
void hotRestartOnUserInterrupt () override
 Helper for hot restart. 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 inherited from Algorithm
std::unique_ptr< Initialization_initialization
 To initialize the algorithm (X0) More...
 
std::unique_ptr< Termination_termination
 To verify termination conditions. More...
 
std::shared_ptr< MegaIteration_megaIteration
 MegaIteration used to keep information between steps. More...
 
std::string _algoComment
 Comment to appear in the stats, e.g. "Phase One". More...
 
std::vector< std::string > _prevAlgoComment
 Pile of previous comments, used when going back to the main algo after running a sub-algo. More...
 
bool _forceAlgoComment
 When true, do not change comment until reset is called. More...
 
bool _endDisplay
 
NOMAD::SuccessType _algoBestSuccess
 The best succes type of the algorithm (cannot always get this information from _megaIteration). More...
 
bool _algoSuccessful
 
- 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...
 
- Protected Attributes inherited from IterationUtils
EvalPointSet _trialPoints
 The points generated during the start(). Used for run() and postProcessing(). More...
 
size_t _nbEvalPointsThatNeedEval
 
const Step_parentStep
 
SuccessType _success
 Success type of this step. More...
 
Iteration_iterAncestor
 
MegaIteration_megaIterAncestor
 
- 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 for Latin Hypercube algorithm sampling.

Generate the trial points using LHS and evaluate them.

Todo:
Complete documentation

Definition at line 60 of file LH.hpp.

Constructor & Destructor Documentation

◆ LH()

LH::LH ( const Step parentStep,
std::shared_ptr< AlgoStopReasons< LHStopType >>  stopReasons,
const std::shared_ptr< RunParameters > &  runParams,
const std::shared_ptr< PbParameters > &  pbParams 
)
inlineexplicit

Constructor.

Definition at line 65 of file LH.hpp.

69  : Algorithm(parentStep, stopReasons, runParams, pbParams),
70  IterationUtils(this)
71  {
72  init();
73  }

◆ ~LH()

virtual LH::~LH ( )
inlinevirtual

Destructor.

Definition at line 76 of file LH.hpp.

76 {}

Member Function Documentation

◆ endImp()

virtual void LH::endImp ( )
overrideprivatevirtual

Implementation for end task.

Clean-up evaluation queue.

Reimplemented from Algorithm.

◆ generateTrialPoints()

void LH::generateTrialPoints ( )
overrideprivatevirtual

Generate the trial points of an algorithm iteration before evaluation.

Virtual function that algorithm iteration steps must implement

Note
For LH, the generation of points uses LHS for sampling with the problem's bounds and X0.

Implements IterationUtils.

◆ init()

void LH::init ( )
private

Helper for constructor.

◆ readInformationForHotRestart()

virtual void LH::readInformationForHotRestart ( )
inlineoverridevirtual

Helper for start() when doing a hot restart.

Implements Algorithm.

Definition at line 79 of file LH.hpp.

79 {}

◆ runImp()

virtual bool LH::runImp ( )
overrideprivatevirtual

Implementation for run tasks.

Evaluation of the trial points

Returns
true a better point has been obtained, false otherwise.

Implements Algorithm.

◆ startImp()

virtual void LH::startImp ( )
overrideprivatevirtual

Implementation for start task.

Call LH::generateTrialPoints

Reimplemented from Algorithm.


The documentation for this class was generated from the following file:
IterationUtils::IterationUtils
IterationUtils(const Step *parentStep)
Constructor.
Definition: IterationUtils.hpp:105
LH::init
void init()
Helper for constructor.
Algorithm::Algorithm
Algorithm(const Step *parentStep, std::shared_ptr< AllStopReasons > stopReasons, const std::shared_ptr< RunParameters > &runParams, const std::shared_ptr< PbParameters > &pbParams)
Constructor.
Definition: Algorithm.hpp:105