NOMAD Source
Version 4.0.0 Beta
|
Class to perform the Reflect, Expansion, Inside_Contraction, Outside_Contraction steps of a Nelder Mead algorithm. More...
#include <NMReflective.hpp>
Public Member Functions | |
NMReflective (const Step *parentStep) | |
Constructor. More... | |
virtual | ~NMReflective () |
void | generateTrialPoints () override |
Generate new points to evaluate. More... | |
void | setCurrentNMStepType (NMStepType stepType) |
Set the parameters for a given step type. More... | |
NMStepType | getNextNMStepType () const |
![]() | |
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... | |
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 > | |
T | getParentOfType (const bool stopAtAlgo=true) const |
Template function to get the parent of given type. More... | |
bool | isAnAlgorithm () const |
const Algorithm * | getRootAlgorithm () 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< MeshBase > | getIterationMesh () const |
const std::shared_ptr< EvalPoint > | getIterationFrameCenter () const |
const std::shared_ptr< Barrier > | getMegaIterationBarrier () 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... | |
![]() | |
NMIterationUtils (const Step *parentStep) | |
Constructor. More... | |
![]() | |
IterationUtils (const Step *parentStep) | |
Constructor. More... | |
virtual | ~IterationUtils () |
Destructor. More... | |
const SuccessType & | getSuccessType () const |
void | setSuccessType (const SuccessType &success) |
size_t | getTrialPointsCount () const |
const EvalPointSet & | getTrialPoints () 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 () |
virtual void | startImp () override |
Implementation of the start task. More... | |
virtual bool | runImp () override |
Implementation of the run task. More... | |
virtual void | endImp () override |
No end task is required. More... | |
void | setNextNMStepType () |
Helper for NMReflective::runImp. More... | |
void | setAfterReflect () |
void | setAfterExpand () |
void | setAfterOutsideContract () |
void | setAfterInsideContract () |
bool | insertInY (const EvalPoint &x) |
bool | insertInYBest (const EvalPoint &x1, const EvalPoint &x2) |
bool | pointDominatesY0 (const EvalPoint &x) const |
Helper for the setAfterXXXX functions. More... | |
bool | YnDominatesPoint (const EvalPoint &x) const |
Helper for the setAfterXXXX functions. More... | |
bool | pointDominatesPtsInY (const EvalPoint &x, size_t nb) const |
Helper for the setAfterXXXX functions. More... | |
bool | makeListY0 () |
Create the undominated list of points from Y. More... | |
bool | makeListYn () |
Create the dominated list of points from Y. More... | |
void | displayY0nInfo () const |
Private Attributes | |
NMStepType | _nextStepType |
Double | _delta |
Double | _deltaE |
Double | _deltaOC |
Double | _deltaIC |
EvalPoint | _xr |
EvalPoint | _xe |
EvalPoint | _xoc |
EvalPoint | _xic |
std::vector< EvalPoint > | _nmY0 |
Vector of undominated points extracted from simplex (the simplex has a loose ordering-->tied points can exist). More... | |
std::vector< EvalPoint > | _nmYn |
Vector of dominated points extracted from simplex (the simplex has a loose ordering-->tied points can exist). More... | |
Additional Inherited Members | |
![]() | |
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 > ¶mLines) |
static void | disableWarnings () |
![]() | |
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... | |
![]() | |
void | updateYCharacteristics (void) |
Update the simplex diameter and volumes from NMIterationUtils::_nmY. More... | |
void | displayYInfo (void) const |
Display all the characteristics of a simplex. More... | |
int | getRankDZ () const |
void | setStopReason () const |
Set the stop reason according to NMIterationUtils::_currentStepType. 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... | |
![]() | |
Double | _rankEps |
The precision for the rank calculation. Default is DEFAULT_EPSILON. More... | |
NMStepType | _currentStepType |
The step type (REFLECT, EXPAND, INSIDE_CONTRACTION, OUTSIDE_CONTRACTION) More... | |
std::shared_ptr< NMSimplexEvalPointSet > | _nmY |
The Nelder Mead simplex. More... | |
![]() | |
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 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 |
Class to perform the Reflect, Expansion, Inside_Contraction, Outside_Contraction steps of a Nelder Mead algorithm.
The function NMReflective::getNextNMStepType decides which Nelder Mead step comes next. The next step type is updated when calling run (NMReflective::runImp).
The class maintains the lists of undominated (Y0) and dominated points (Yn) extracted from simplex. See the NM-Mads paper: https://link.springer.com/article/10.1007/s10589-018-0016-0 for details.
To compare points we use a dominance operator from EvalPoint::dominates.
Definition at line 65 of file NMReflective.hpp.
|
inlineexplicit |
Constructor.
parentStep | The parent of this NM step |
Definition at line 84 of file NMReflective.hpp.
|
inlinevirtual |
Definition at line 92 of file NMReflective.hpp.
|
private |
|
inlineoverrideprivatevirtual |
|
overridevirtual |
Generate new points to evaluate.
A new point is obtained using the simplex. xt = yc + dela*d. Delta is the reflective factor. The value depends the step type (REFLECT, EXPAND, INSIDE_CONTRACTION, OUTSIDE_CONTRACTION). yc is the barycenter of the simplex. We have d=yc-yn where yn is the last point of Y.
The point is snapped to bounds and projected on the mesh.
Implements IterationUtils.
|
inline |
Definition at line 109 of file NMReflective.hpp.
|
private |
The delta parameter used to create the trial point is different for EXPANSION, INSIDE_CONTRACTION, OUTSIDE_CONTRACTION. The possible delta parameters are obtained from _runParams. The validity of the parameters are checked.
The flag to perform a standalone Nelder Mead optimization is also set.
|
private |
Insert a point in the simplex Y. If a point is inserted, the last point of Y is removed, return true
. If Y is unchanged, the insertion failed, return false
.
Update Y0, Yn and the simplex characteristic if necessary.
Try to insert the best of two points in the simplex.
true
if the simplex has changed and false
otherwise.
|
private |
Create the undominated list of points from Y.
|
private |
Create the dominated list of points from Y.
|
private |
Helper for the setAfterXXXX functions.
|
private |
Helper for the setAfterXXXX functions.
|
overrideprivatevirtual |
Implementation of the run task.
Evaluate the trial point and store it locally. Call IterationUtils::postProcessing.
true
if a better point is obtained false
otherwise. Implements Step.
|
private |
EXPAND follows REFLECT. The expand point is xe.
In NM-Mads paper: xr belongs to the expansion zone. xe has been evaluated. The best point between xr and xe is inserted in the simplex Y. If a proper simplex Y is obtained the iteration is completed, if not the next step can be a SHRINK.
|
private |
INSIDE_CONTRACTION follows REFLECT. The inside contraction point is xic.
In NM-Mads paper: xr belongs to the inside contraction zone. If xic belongs to the inside contraction zone (that is Yn dominates xic), iteration is completed. Otherwise insert xic in Y. If a proper simplex Y is obtained, the iteration is completed, if not the next step can be a SHRINK.
|
private |
OUTSIDE_CONTRACTION follows REFLECT. The outside contraction point is xoc.
In NM-Mads paper: xr belongs to the outside contraction zone. The best point between xr and xoc is inserted in Y. If a proper simplex Y is obtained the iteration is completed, if not the next step can be a SHRINK.
|
private |
Reflect is always the first step of Nelder Mead iteration. The reflect point is xr. In NM-Mads paper, depending on which zone xr belongs to, we perform another step:
void NMReflective::setCurrentNMStepType | ( | NMStepType | stepType | ) |
Set the parameters for a given step type.
The name of the step and the value of delta are changed according to stepType.
|
private |
Helper for NMReflective::runImp.
|
overrideprivatevirtual |
Implementation of the start task.
Call NMReflective::generateTrialPoints and update the trial points.
Implements Step.
|
private |
Helper for the setAfterXXXX functions.
|
private |
Definition at line 71 of file NMReflective.hpp.
|
private |
Definition at line 71 of file NMReflective.hpp.
|
private |
Definition at line 71 of file NMReflective.hpp.
|
private |
Definition at line 71 of file NMReflective.hpp.
|
private |
Definition at line 70 of file NMReflective.hpp.
|
private |
Vector of undominated points extracted from simplex (the simplex has a loose ordering-->tied points can exist).
Definition at line 75 of file NMReflective.hpp.
|
private |
Vector of dominated points extracted from simplex (the simplex has a loose ordering-->tied points can exist).
Definition at line 76 of file NMReflective.hpp.
|
private |
Definition at line 73 of file NMReflective.hpp.
|
private |
Definition at line 73 of file NMReflective.hpp.
|
private |
Definition at line 73 of file NMReflective.hpp.
|
private |
Definition at line 73 of file NMReflective.hpp.