NOMAD Source  Version 4.0.0 Beta
EvaluatorControl Class Reference

Class to control the evaluation of points using a queue. More...

#include <EvaluatorControl.hpp>

Collaboration diagram for EvaluatorControl:

Public Member Functions

 EvaluatorControl (std::shared_ptr< Evaluator > evaluator, const std::shared_ptr< EvaluatorControlGlobalParameters > &evalContGlobalParams, const std::shared_ptr< EvaluatorControlParameters > &evalContParams)
 Constructor. More...
 
virtual ~EvaluatorControl ()
 Destructor. More...
 
void addMainThread (const int threadNum, const std::shared_ptr< StopReason< EvalMainThreadStopType >> evalMainThreadStopReason, const std::shared_ptr< Evaluator > &evaluator, const std::shared_ptr< EvaluatorControlParameters > &evalContParams)
 
bool isMainThread (const int threadNum) const
 
const std::set< int > & getMainThreads () const
 
int getNbMainThreads () const
 
std::shared_ptr< EvaluatorsetEvaluator (std::shared_ptr< Evaluator > evaluator)
 
size_t getBbEval () const
 Get the number of blackbox evaluations. More...
 
void setBbEval (const size_t bbEval)
 Set blackbox evaluations number. More...
 
size_t getBbEvalNotOk () const
 Get the number of blackbox evaluations that are not ok. More...
 
size_t getFeasBbEval () const
 Get the number of feasible blackbox evaluations. More...
 
size_t getSgteEval (const int mainThreadNum=-1) const
 
void resetSgteEval (const int mainThreadNum=-1)
 
size_t getTotalSgteEval () const
 
size_t getBbEvalInSubproblem (const int mainThreadNum=-1) const
 
void resetBbEvalInSubproblem (const int mainThreadNum=-1)
 
size_t getBlockEval () const
 Get the number of block evaluations. More...
 
size_t getIndexSuccBlockEval () const
 Get the index of block evaluations. More...
 
size_t getNbEval () const
 
void setNbEval (const size_t nbEval)
 Set the number of evaluations. More...
 
size_t getLapMaxBbEval (const int mainThreadNum) const
 
void setLapMaxBbEval (const size_t maxBbEval)
 
void resetLapBbEval ()
 
size_t getLapBbEval (const int threadNum=-1) const
 
size_t getNbPhaseOneSuccess () const
 
size_t getNbRelativeSuccess () const
 
size_t getIndexFeasEval () const
 
size_t getIndexInfeasEval () const
 
size_t getQueueSize (const int mainThreadNum=-1) const
 
bool getDoneWithEval (const int mainThreadNum) const
 
void setDoneWithEval (const int mainThreadNum, const bool doneWithEval)
 
void setBarrier (const std::shared_ptr< Barrier > &barrier)
 
const std::shared_ptr< Barrier > & getBarrier (const int threadNum=-1) const
 
void setBestIncumbent (const int mainThreadNum, const std::shared_ptr< EvalPoint > &bestIncumbent)
 
const std::shared_ptr< EvalPoint > & getBestIncumbent (const int mainThreadNum) const
 
void setComputeSuccessTypeFunction (const ComputeSuccessFunction &computeSuccessFunction)
 
void setUserCompMethod (const std::shared_ptr< ComparePriorityMethod > &compMethod)
 
void setLastSuccessfulDir (const std::shared_ptr< Direction > &dir)
 
void setStopReason (const int mainThreadNum, const EvalMainThreadStopType &s)
 
const StopReason< EvalMainThreadStopType > & getStopReason (const int mainThreadNum) const
 
std::string getStopReasonAsString (const int mainThreadNum) const
 
bool testIf (const EvalMainThreadStopType &s) const
 
bool checkEvalTerminate (const int mainThreadNum) const
 
std::vector< EvalPointretrieveAllEvaluatedPoints (const int threadNum=-1)
 Get all points that were just evaluated. This is especially useful when cache is not used. More...
 
void addEvaluatedPoint (const int threadNum, const EvalPoint &evaluatedPoint)
 
bool remainsEvaluatedPoints (const int threadNum) const
 
void clearEvaluatedPoints (const int threadNum)
 
const SuccessTypegetSuccessType (const int threadNum) const
 
void setSuccessType (const int threadNum, const SuccessType &success)
 
Double getHMax (const int threadNum) const
 Get the max infeasibility to keep a point in barrier. More...
 
const std::shared_ptr< EvaluatorControlGlobalParameters > & getEvaluatorControlGlobalParams () const
 Get the global parameters for *this. More...
 
std::shared_ptr< EvalParametersgetEvalParams (const int threadNum=-1) const
 Get the Evaluator's parameters. More...
 
bool getOpportunisticEval (const int mainThreadNum=-1) const
 Get or Set the value of some parameters. More...
 
void setOpportunisticEval (const bool opportunistic)
 
bool getUseCache (const int mainThreadNum=-1) const
 
void setUseCache (const bool usecache)
 
EvalType getEvalType (const int mainThreadNum=-1) const
 
size_t getMaxBbEvalInSubproblem (const int mainThreadNum=-1) const
 
void setMaxBbEvalInSubproblem (const size_t maxBbEval)
 
void lockQueue ()
 Lock the queue. More...
 
void unlockQueue (const bool doSort=true)
 Unlock the queue. More...
 
bool addToQueue (const EvalQueuePointPtr &evalQueuePoint)
 Add a single point to the queue. More...
 
bool popEvalPoint (EvalQueuePointPtr &evalQueuePoint, Evaluator *&evaluator, Double &hMax)
 Get the top point from the queue and pop it. More...
 
bool popBlock (BlockForEval &block)
 Pop eval points from the queue to fill a block of size BB_MAX_BLOCK_SIZE. More...
 
size_t clearQueue (const int mainThreadNum, const bool showDebug=false)
 Clear queue. More...
 
void start ()
 Start evaluation. More...
 
SuccessType run ()
 Continuous evaluation - running on all threads simultaneously. More...
 
void stop ()
 Stop evaluation. More...
 
void restart ()
 Restart. More...
 
bool evalBlock (BlockForEval &block)
 Evaluates a block of points. More...
 
bool evalSinglePoint (EvalPoint &evalPoint, const int mainThreadNum, const Double &hMax=INF)
 Evaluates a single point. More...
 
std::vector< bool > evalBlockOfPoints (Block &block, const Evaluator &evaluator, const Double &hMax=INF)
 Evaluates a block of points. More...
 
bool updateEvalStatusBeforeEval (EvalPoint &evalPoint)
 Updates eval status. More...
 
void updateEvalStatusAfterEval (EvalPoint &evalPoint, bool evalOk)
 Updates eval status. More...
 
bool reachedMaxEval () const
 Did we reach one of the evaluation parameters: MAX_EVAL, MAX_BB_EVAL, MAX_BLOCK_EVAL ? More...
 
bool reachedMaxStepEval (const int mainThreadNum=-1) const
 Did we reach Max LAP, MAX_SGTE_EVAL (temporary max evals)? More...
 
void debugDisplayQueue () const
 For debugging purposes. Show the contents of the evaluation queue. More...
 

Private Member Functions

void init (std::shared_ptr< Evaluator > evaluator, const std::shared_ptr< EvaluatorControlParameters > &evalContParams)
 Helper for constructor. More...
 
void destroy ()
 Helper for destructor. More...
 
EvcMainThreadInfogetMainThreadInfo (const int mainThreadNum=-1) const
 Get the EvcMainThreadInfo associated with this thread number. More...
 
void computeSuccess (EvalQueuePointPtr evalQueuePoint, const bool evalOk, const Double &hMax)
 Helper function called during evaluation. More...
 
void sort ()
 Sort the queue with respect to the selected sort strategy. Called by unlockQueue(). More...
 
bool stopMainEval (const int mainThreadNum) const
 Did we reach a stop condition (for a main thread)? More...
 
void displayDebugWaitingInfo (time_t &lastDisplayed) const
 Debug trace when a thread is waiting. More...
 
void AddStatsInfo (const BlockForEval &block) const
 Stats Output. More...
 
void AddDirectToFileInfo (EvalQueuePointPtr evalQueuePoint) const
 History and Solution file output. More...
 

Private Attributes

std::shared_ptr< EvaluatorControlGlobalParameters_evalContGlobalParams
 The parameters controlling the behavior of the class. More...
 
std::set< int > _mainThreads
 
std::map< int, EvcMainThreadInfo_mainThreadInfo
 Info about main threads. More...
 
std::vector< EvalQueuePointPtr_evalPointQueue
 The queue of points to be evaluated. More...
 
std::shared_ptr< ComparePriorityMethod_userCompMethod
 User-implemented comparison method to sort points before evaluation. More...
 
std::atomic< size_t > _bbEval
 The number of blackbox evaluations performed. More...
 
std::atomic< size_t > _bbEvalNotOk
 The number of blackbox evaluations that are not ok. More...
 
std::atomic< size_t > _feasBBEval
 The number of feasible blackbox evaluations obtained. More...
 
std::atomic< size_t > _infBBEval
 The number of infeasible blackbox evaluations obtained. More...
 
std::atomic< size_t > _totalSgteEval
 The total number of sgte evaluations. Used for stats exclusively. More...
 
std::atomic< size_t > _blockEval
 The number of block evaluations performed. More...
 
std::atomic< size_t > _indexSuccBlockEval
 The index of the last successfull evaluation block. More...
 
std::atomic< size_t > _indexBestFeasEval
 The index of the best feasible evaluation. More...
 
std::atomic< size_t > _indexBestInfeasEval
 The index of the best infeasible evaluation. More...
 
std::atomic< size_t > _nbEvalSentToEvaluator
 
std::atomic< size_t > _nbRelativeSuccess
 
std::atomic< size_t > _nbPhaseOneSuccess
 
bool _allDoneWithEval
 All evaluations done. The queue can be destroyed. More...
 

Detailed Description

Class to control the evaluation of points using a queue.

Todo:
Complete the description.

Definition at line 75 of file EvaluatorControl.hpp.

Constructor & Destructor Documentation

◆ EvaluatorControl()

EvaluatorControl::EvaluatorControl ( std::shared_ptr< Evaluator evaluator,
const std::shared_ptr< EvaluatorControlGlobalParameters > &  evalContGlobalParams,
const std::shared_ptr< EvaluatorControlParameters > &  evalContParams 
)
inlineexplicit

Constructor.

Parameters
evaluatorThe blackbox evaluator – IN.
evalContGlobalParamsThe parameters controlling how the class works – IN.
evalContParamsThe parameters for main threads – IN.

Definition at line 195 of file EvaluatorControl.hpp.

198  : _evalContGlobalParams(evalContGlobalParams),
199  _mainThreads(),
200  _mainThreadInfo(),
201  _evalPointQueue(),
202  _userCompMethod(nullptr),
203 #ifdef _OPENMP
204  _evalQueueLock(),
205 #endif // _OPENMP
206  _bbEval(0),
207  _bbEvalNotOk(0),
208  _feasBBEval(0),
209  _infBBEval(0),
210  _totalSgteEval(0),
211  _blockEval(0),
218  _allDoneWithEval(false)
219 #ifdef TIME_STATS
220  ,_evalTime(0.0)
221 #endif // TIME_STATS
222  {
223  init(evaluator, evalContParams);
224  }

◆ ~EvaluatorControl()

virtual EvaluatorControl::~EvaluatorControl ( )
inlinevirtual

Destructor.

Definition at line 227 of file EvaluatorControl.hpp.

228  {
229  destroy();
230  }

Member Function Documentation

◆ AddDirectToFileInfo()

void EvaluatorControl::AddDirectToFileInfo ( EvalQueuePointPtr  evalQueuePoint) const
private

History and Solution file output.

◆ addEvaluatedPoint()

void EvaluatorControl::addEvaluatedPoint ( const int  threadNum,
const EvalPoint evaluatedPoint 
)

◆ addMainThread()

void EvaluatorControl::addMainThread ( const int  threadNum,
const std::shared_ptr< StopReason< EvalMainThreadStopType >>  evalMainThreadStopReason,
const std::shared_ptr< Evaluator > &  evaluator,
const std::shared_ptr< EvaluatorControlParameters > &  evalContParams 
)

◆ AddStatsInfo()

void EvaluatorControl::AddStatsInfo ( const BlockForEval block) const
private

Stats Output.

◆ addToQueue()

bool EvaluatorControl::addToQueue ( const EvalQueuePointPtr evalQueuePoint)

Add a single point to the queue.

Returns
true if point was inserted in queue

◆ checkEvalTerminate()

bool EvaluatorControl::checkEvalTerminate ( const int  mainThreadNum) const

◆ clearEvaluatedPoints()

void EvaluatorControl::clearEvaluatedPoints ( const int  threadNum)

◆ clearQueue()

size_t EvaluatorControl::clearQueue ( const int  mainThreadNum,
const bool  showDebug = false 
)

Clear queue.

Parameters
mainThreadNumClear points generated by this main thread only, If -1, clear all queue.
showDebugIf true, print points erased from the queue.
Returns
Number of points erased

◆ computeSuccess()

void EvaluatorControl::computeSuccess ( EvalQueuePointPtr  evalQueuePoint,
const bool  evalOk,
const Double hMax 
)
private

Helper function called during evaluation.

Update EvalQueuePointPtr after evaluation.

Parameters
evalQueuePointThe queue point of interest – IN/OUT.
evalOkFlag to specific if evaluation was OK – IN.
hMaxThe max infeasibility to keep a point in barrier – IN.

◆ debugDisplayQueue()

void EvaluatorControl::debugDisplayQueue ( ) const

For debugging purposes. Show the contents of the evaluation queue.

◆ destroy()

void EvaluatorControl::destroy ( )
private

Helper for destructor.

◆ displayDebugWaitingInfo()

void EvaluatorControl::displayDebugWaitingInfo ( time_t &  lastDisplayed) const
private

Debug trace when a thread is waiting.

◆ evalBlock()

bool EvaluatorControl::evalBlock ( BlockForEval block)

Evaluates a block of points.

Updates the Eval members of the evaluation points. Also updates the fields specific to EvalQueuePoints.

Parameters
blockThe block of points to evaluate – IN/OUT.
Returns
true if at least one evaluation worked (evalOk), false otherwise.

◆ evalBlockOfPoints()

std::vector<bool> EvaluatorControl::evalBlockOfPoints ( Block block,
const Evaluator evaluator,
const Double hMax = INF 
)

Evaluates a block of points.

For each point, true if evaluation worked false otherwise.

Remarks
Updates only the Eval members.
Parameters
blockThe block of points to evaluate – IN/OUT.
evaluatorEvaluator to be used for all these points
hMaxThe max infeasibilyt to keep a point in barrier – IN.
Returns
A vector of booleans, of the same size as block.

◆ evalSinglePoint()

bool EvaluatorControl::evalSinglePoint ( EvalPoint evalPoint,
const int  mainThreadNum,
const Double hMax = INF 
)

Evaluates a single point.

Creates a block with a single point and evaluates it using EvaluatorControl::evalBlockOfPoints().
Updates only the Eval members.

Parameters
evalPointThe point to evaluate – IN.
mainThreadNumThread number of the main thread that generated this point
hMaxThe max infeasibility for keeping points in barrier – IN.
Returns
true if evaluation worked (evalOk), false otherwise.

◆ getBarrier()

const std::shared_ptr<Barrier>& EvaluatorControl::getBarrier ( const int  threadNum = -1) const

◆ getBbEval()

size_t EvaluatorControl::getBbEval ( ) const
inline

Get the number of blackbox evaluations.

Definition at line 247 of file EvaluatorControl.hpp.

247 { return _bbEval; }

◆ getBbEvalInSubproblem()

size_t EvaluatorControl::getBbEvalInSubproblem ( const int  mainThreadNum = -1) const

◆ getBbEvalNotOk()

size_t EvaluatorControl::getBbEvalNotOk ( ) const
inline

Get the number of blackbox evaluations that are not ok.

Definition at line 253 of file EvaluatorControl.hpp.

253 { return _bbEvalNotOk; }

◆ getBestIncumbent()

const std::shared_ptr<EvalPoint>& EvaluatorControl::getBestIncumbent ( const int  mainThreadNum) const

◆ getBlockEval()

size_t EvaluatorControl::getBlockEval ( ) const
inline

Get the number of block evaluations.

Definition at line 266 of file EvaluatorControl.hpp.

266 { return _blockEval; }

◆ getDoneWithEval()

bool EvaluatorControl::getDoneWithEval ( const int  mainThreadNum) const

◆ getEvalParams()

std::shared_ptr<EvalParameters> EvaluatorControl::getEvalParams ( const int  threadNum = -1) const

Get the Evaluator's parameters.

◆ getEvalType()

EvalType EvaluatorControl::getEvalType ( const int  mainThreadNum = -1) const

◆ getEvaluatorControlGlobalParams()

const std::shared_ptr<EvaluatorControlGlobalParameters>& EvaluatorControl::getEvaluatorControlGlobalParams ( ) const
inline

Get the global parameters for *this.

Definition at line 343 of file EvaluatorControl.hpp.

343 { return _evalContGlobalParams; }

◆ getFeasBbEval()

size_t EvaluatorControl::getFeasBbEval ( ) const
inline

Get the number of feasible blackbox evaluations.

Definition at line 256 of file EvaluatorControl.hpp.

256 { return _feasBBEval; }

◆ getHMax()

Double EvaluatorControl::getHMax ( const int  threadNum) const

Get the max infeasibility to keep a point in barrier.

◆ getIndexFeasEval()

size_t EvaluatorControl::getIndexFeasEval ( ) const
inline

Definition at line 297 of file EvaluatorControl.hpp.

297 { return _indexBestFeasEval; }

◆ getIndexInfeasEval()

size_t EvaluatorControl::getIndexInfeasEval ( ) const
inline

Definition at line 298 of file EvaluatorControl.hpp.

298 { return _indexBestInfeasEval; }

◆ getIndexSuccBlockEval()

size_t EvaluatorControl::getIndexSuccBlockEval ( ) const
inline

Get the index of block evaluations.

Definition at line 269 of file EvaluatorControl.hpp.

269 { return _indexSuccBlockEval; }

◆ getLapBbEval()

size_t EvaluatorControl::getLapBbEval ( const int  threadNum = -1) const

◆ getLapMaxBbEval()

size_t EvaluatorControl::getLapMaxBbEval ( const int  mainThreadNum) const

◆ getMainThreadInfo()

EvcMainThreadInfo& EvaluatorControl::getMainThreadInfo ( const int  mainThreadNum = -1) const
private

Get the EvcMainThreadInfo associated with this thread number.

Get EvcMainThreadInfo associated with this thread number.

Parameters
mainThreadNumMain thread number. If -1, use current thread number, assuming it is a main thread. – IN.
Returns
EvcMainThreadInfo associated with this thread number.

◆ getMainThreads()

const std::set<int>& EvaluatorControl::getMainThreads ( ) const
inline

Definition at line 241 of file EvaluatorControl.hpp.

241 { return _mainThreads; }

◆ getMaxBbEvalInSubproblem()

size_t EvaluatorControl::getMaxBbEvalInSubproblem ( const int  mainThreadNum = -1) const

◆ getNbEval()

size_t EvaluatorControl::getNbEval ( ) const

Get the total number of evaluations. Total number of evaluations, including:

  • blackbox evaluations (EvaluatorControl::_bbEval),
  • blackbox evaluations for which countEval returned false
  • cache hits. Not including sgte evaluations (EvaluatorControl::_sgteEval).
Note
Member EvaluatorControl:: holds only the first two values. Cache hits are added in this method.

◆ getNbMainThreads()

int EvaluatorControl::getNbMainThreads ( ) const
inline

Definition at line 242 of file EvaluatorControl.hpp.

242 { return int(_mainThreads.size()); }

◆ getNbPhaseOneSuccess()

size_t EvaluatorControl::getNbPhaseOneSuccess ( ) const
inline

Definition at line 295 of file EvaluatorControl.hpp.

295 {return _nbPhaseOneSuccess; }

◆ getNbRelativeSuccess()

size_t EvaluatorControl::getNbRelativeSuccess ( ) const
inline

Definition at line 296 of file EvaluatorControl.hpp.

296 {return _nbRelativeSuccess; }

◆ getOpportunisticEval()

bool EvaluatorControl::getOpportunisticEval ( const int  mainThreadNum = -1) const

Get or Set the value of some parameters.

◆ getQueueSize()

size_t EvaluatorControl::getQueueSize ( const int  mainThreadNum = -1) const

◆ getSgteEval()

size_t EvaluatorControl::getSgteEval ( const int  mainThreadNum = -1) const

◆ getStopReason()

const StopReason<EvalMainThreadStopType>& EvaluatorControl::getStopReason ( const int  mainThreadNum) const

◆ getStopReasonAsString()

std::string EvaluatorControl::getStopReasonAsString ( const int  mainThreadNum) const

◆ getSuccessType()

const SuccessType& EvaluatorControl::getSuccessType ( const int  threadNum) const

◆ getTotalSgteEval()

size_t EvaluatorControl::getTotalSgteEval ( ) const
inline

Definition at line 260 of file EvaluatorControl.hpp.

260 { return _totalSgteEval; }

◆ getUseCache()

bool EvaluatorControl::getUseCache ( const int  mainThreadNum = -1) const

◆ init()

void EvaluatorControl::init ( std::shared_ptr< Evaluator evaluator,
const std::shared_ptr< EvaluatorControlParameters > &  evalContParams 
)
private

Helper for constructor.

◆ isMainThread()

bool EvaluatorControl::isMainThread ( const int  threadNum) const
inline

Definition at line 239 of file EvaluatorControl.hpp.

239 { return (_mainThreads.end() != _mainThreads.find(threadNum)); }

◆ lockQueue()

void EvaluatorControl::lockQueue ( )

Lock the queue.

Typically, this is done before adding points.

◆ popBlock()

bool EvaluatorControl::popBlock ( BlockForEval block)

Pop eval points from the queue to fill a block of size BB_MAX_BLOCK_SIZE.

Parameters
blockThe eval queue point block created – OUTr.
Returns
true if the block has at least one point, false otherwise.

◆ popEvalPoint()

bool EvaluatorControl::popEvalPoint ( EvalQueuePointPtr evalQueuePoint,
Evaluator *&  evaluator,
Double hMax 
)

Get the top point from the queue and pop it.

Parameters
evalQueuePointThe eval point popped from the queue – OUT.
evaluatorEvaluator with which this point must be evaluated – IN / OUT
hMaxhMax for evaluation of this point – IN / OUT
Returns
true if it worked, false otherwise.

◆ reachedMaxEval()

bool EvaluatorControl::reachedMaxEval ( ) const

Did we reach one of the evaluation parameters: MAX_EVAL, MAX_BB_EVAL, MAX_BLOCK_EVAL ?

◆ reachedMaxStepEval()

bool EvaluatorControl::reachedMaxStepEval ( const int  mainThreadNum = -1) const

Did we reach Max LAP, MAX_SGTE_EVAL (temporary max evals)?

Parameters
mainThreadNumNumber of the main thread to update if a stop condition is reached. -1 means use current thread.

◆ remainsEvaluatedPoints()

bool EvaluatorControl::remainsEvaluatedPoints ( const int  threadNum) const

◆ resetBbEvalInSubproblem()

void EvaluatorControl::resetBbEvalInSubproblem ( const int  mainThreadNum = -1)

◆ resetLapBbEval()

void EvaluatorControl::resetLapBbEval ( )

◆ resetSgteEval()

void EvaluatorControl::resetSgteEval ( const int  mainThreadNum = -1)

◆ restart()

void EvaluatorControl::restart ( )

Restart.

◆ retrieveAllEvaluatedPoints()

std::vector<EvalPoint> EvaluatorControl::retrieveAllEvaluatedPoints ( const int  threadNum = -1)

Get all points that were just evaluated. This is especially useful when cache is not used.

Note
List of evaluated points is cleared

◆ run()

SuccessType EvaluatorControl::run ( )

Continuous evaluation - running on all threads simultaneously.

Stop reasons may be controled by parameters MAX_BB_EVAL, MAX_EVAL, OPPORTUNISTIC_EVAL.
If strategy is opportunistic, stop as soon as a successful point is found.

Returns
The success type of the evaluations.

◆ setBarrier()

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

◆ setBbEval()

void EvaluatorControl::setBbEval ( const size_t  bbEval)
inline

Set blackbox evaluations number.

Definition at line 250 of file EvaluatorControl.hpp.

250 { _bbEval = bbEval; }

◆ setBestIncumbent()

void EvaluatorControl::setBestIncumbent ( const int  mainThreadNum,
const std::shared_ptr< EvalPoint > &  bestIncumbent 
)

◆ setComputeSuccessTypeFunction()

void EvaluatorControl::setComputeSuccessTypeFunction ( const ComputeSuccessFunction computeSuccessFunction)

◆ setDoneWithEval()

void EvaluatorControl::setDoneWithEval ( const int  mainThreadNum,
const bool  doneWithEval 
)

◆ setEvaluator()

std::shared_ptr<Evaluator> EvaluatorControl::setEvaluator ( std::shared_ptr< Evaluator evaluator)

◆ setLapMaxBbEval()

void EvaluatorControl::setLapMaxBbEval ( const size_t  maxBbEval)

◆ setLastSuccessfulDir()

void EvaluatorControl::setLastSuccessfulDir ( const std::shared_ptr< Direction > &  dir)

◆ setMaxBbEvalInSubproblem()

void EvaluatorControl::setMaxBbEvalInSubproblem ( const size_t  maxBbEval)

◆ setNbEval()

void EvaluatorControl::setNbEval ( const size_t  nbEval)

Set the number of evaluations.

Similarly to EvaluatorControl:getNbEval(), the number of cache hits is removed before setting EvaluatorControl::_nbEvalSentToEvaluator.

◆ setOpportunisticEval()

void EvaluatorControl::setOpportunisticEval ( const bool  opportunistic)

◆ setStopReason()

void EvaluatorControl::setStopReason ( const int  mainThreadNum,
const EvalMainThreadStopType s 
)

◆ setSuccessType()

void EvaluatorControl::setSuccessType ( const int  threadNum,
const SuccessType success 
)

◆ setUseCache()

void EvaluatorControl::setUseCache ( const bool  usecache)

◆ setUserCompMethod()

void EvaluatorControl::setUserCompMethod ( const std::shared_ptr< ComparePriorityMethod > &  compMethod)
inline

Definition at line 317 of file EvaluatorControl.hpp.

317 { _userCompMethod = compMethod; }

◆ sort()

void EvaluatorControl::sort ( )
private

Sort the queue with respect to the selected sort strategy. Called by unlockQueue().

◆ start()

void EvaluatorControl::start ( )
inline

Start evaluation.

Definition at line 405 of file EvaluatorControl.hpp.

405 {}

◆ stop()

void EvaluatorControl::stop ( )

Stop evaluation.

◆ stopMainEval()

bool EvaluatorControl::stopMainEval ( const int  mainThreadNum) const
private

Did we reach a stop condition (for a main thread)?

Parameters
mainThreadNumThe main thread number to verify –IN.

◆ testIf()

bool EvaluatorControl::testIf ( const EvalMainThreadStopType s) const

◆ unlockQueue()

void EvaluatorControl::unlockQueue ( const bool  doSort = true)

Unlock the queue.

We are done adding points. If doSort is true, the points in the queue are sorted using ComparePriority.

◆ updateEvalStatusAfterEval()

void EvaluatorControl::updateEvalStatusAfterEval ( EvalPoint evalPoint,
bool  evalOk 
)

Updates eval status.

Update point's evalStatus, knowing that the evaluation has just ended.

Parameters
evalPointThe evalPoint – IN/OUT.
evalOkStatus of evaluation – IN.

◆ updateEvalStatusBeforeEval()

bool EvaluatorControl::updateEvalStatusBeforeEval ( EvalPoint evalPoint)

Updates eval status.

Find the point in the cache and update its evalStatus to IN_PROGRESS, knowing that the evaluation is about to start.

Parameters
evalPointThe evaluation point – IN/OUT.
Returns
true if the point must be evaluated, false otherwise.

Member Data Documentation

◆ _allDoneWithEval

bool EvaluatorControl::_allDoneWithEval
private

All evaluations done. The queue can be destroyed.

Definition at line 182 of file EvaluatorControl.hpp.

◆ _bbEval

std::atomic<size_t> EvaluatorControl::_bbEval
private

The number of blackbox evaluations performed.

Remarks
Atomic for thread-safety.
Atomic is also supported by OpenMP, but here I find it clearer to declare it atomic from the start.

Definition at line 109 of file EvaluatorControl.hpp.

◆ _bbEvalNotOk

std::atomic<size_t> EvaluatorControl::_bbEvalNotOk
private

The number of blackbox evaluations that are not ok.

Remarks
Atomic for thread-safety.
Atomic is also supported by OpenMP, but here I find it clearer to declare it atomic from the start.

Definition at line 118 of file EvaluatorControl.hpp.

◆ _blockEval

std::atomic<size_t> EvaluatorControl::_blockEval
private

The number of block evaluations performed.

Remarks
Atomic for thread-safety.

Definition at line 145 of file EvaluatorControl.hpp.

◆ _evalContGlobalParams

std::shared_ptr<EvaluatorControlGlobalParameters> EvaluatorControl::_evalContGlobalParams
private

The parameters controlling the behavior of the class.

Definition at line 77 of file EvaluatorControl.hpp.

◆ _evalPointQueue

std::vector<EvalQueuePointPtr> EvaluatorControl::_evalPointQueue
private

The queue of points to be evaluated.

Todo:
Have means to reorder the queue and change the comparison function during the run.

The queue is implemented as a vector. Points are added at the end of the queue. Points are sorted using ComparePriority which is called in unlockQueue() when the user is done adding points to the queue.
Sorting the queue can also be done by providing another function.

Definition at line 93 of file EvaluatorControl.hpp.

◆ _feasBBEval

std::atomic<size_t> EvaluatorControl::_feasBBEval
private

The number of feasible blackbox evaluations obtained.

Remarks
Atomic for thread-safety.
Atomic is also supported by OpenMP, but here I find it clearer to declare it atomic from the start.

Definition at line 127 of file EvaluatorControl.hpp.

◆ _indexBestFeasEval

std::atomic<size_t> EvaluatorControl::_indexBestFeasEval
private

The index of the best feasible evaluation.

Remarks
Atomic for thread-safety.

Definition at line 157 of file EvaluatorControl.hpp.

◆ _indexBestInfeasEval

std::atomic<size_t> EvaluatorControl::_indexBestInfeasEval
private

The index of the best infeasible evaluation.

Remarks
Atomic for thread-safety.

Definition at line 163 of file EvaluatorControl.hpp.

◆ _indexSuccBlockEval

std::atomic<size_t> EvaluatorControl::_indexSuccBlockEval
private

The index of the last successfull evaluation block.

Remarks
Atomic for thread-safety.

Definition at line 151 of file EvaluatorControl.hpp.

◆ _infBBEval

std::atomic<size_t> EvaluatorControl::_infBBEval
private

The number of infeasible blackbox evaluations obtained.

Remarks
Atomic for thread-safety.
Atomic is also supported by OpenMP, but here I find it clearer to declare it atomic from the start.

Definition at line 136 of file EvaluatorControl.hpp.

◆ _mainThreadInfo

std::map<int, EvcMainThreadInfo> EvaluatorControl::_mainThreadInfo
mutableprivate

Info about main threads.

Definition at line 81 of file EvaluatorControl.hpp.

◆ _mainThreads

std::set<int> EvaluatorControl::_mainThreads
private

Definition at line 79 of file EvaluatorControl.hpp.

◆ _nbEvalSentToEvaluator

std::atomic<size_t> EvaluatorControl::_nbEvalSentToEvaluator
private

The number of evaluations performed through this:

  • Including evaluations for which countEval returned false.
  • Not including cache hits.

Definition at line 170 of file EvaluatorControl.hpp.

◆ _nbPhaseOneSuccess

std::atomic<size_t> EvaluatorControl::_nbPhaseOneSuccess
private

The number of PhaseOne success evaluations performed through this.

Definition at line 180 of file EvaluatorControl.hpp.

◆ _nbRelativeSuccess

std::atomic<size_t> EvaluatorControl::_nbRelativeSuccess
private

The number of full success evaluations performed through this.

Definition at line 175 of file EvaluatorControl.hpp.

◆ _totalSgteEval

std::atomic<size_t> EvaluatorControl::_totalSgteEval
private

The total number of sgte evaluations. Used for stats exclusively.

Definition at line 139 of file EvaluatorControl.hpp.

◆ _userCompMethod

std::shared_ptr<ComparePriorityMethod> EvaluatorControl::_userCompMethod
private

User-implemented comparison method to sort points before evaluation.

Definition at line 95 of file EvaluatorControl.hpp.


The documentation for this class was generated from the following file:
EvaluatorControl::_mainThreads
std::set< int > _mainThreads
Definition: EvaluatorControl.hpp:79
EvaluatorControl::_blockEval
std::atomic< size_t > _blockEval
The number of block evaluations performed.
Definition: EvaluatorControl.hpp:145
EvaluatorControl::_bbEval
std::atomic< size_t > _bbEval
The number of blackbox evaluations performed.
Definition: EvaluatorControl.hpp:109
EvaluatorControl::_infBBEval
std::atomic< size_t > _infBBEval
The number of infeasible blackbox evaluations obtained.
Definition: EvaluatorControl.hpp:136
EvaluatorControl::_indexBestInfeasEval
std::atomic< size_t > _indexBestInfeasEval
The index of the best infeasible evaluation.
Definition: EvaluatorControl.hpp:163
EvaluatorControl::_mainThreadInfo
std::map< int, EvcMainThreadInfo > _mainThreadInfo
Info about main threads.
Definition: EvaluatorControl.hpp:81
EvaluatorControl::_nbRelativeSuccess
std::atomic< size_t > _nbRelativeSuccess
Definition: EvaluatorControl.hpp:175
EvaluatorControl::_feasBBEval
std::atomic< size_t > _feasBBEval
The number of feasible blackbox evaluations obtained.
Definition: EvaluatorControl.hpp:127
EvaluatorControl::_nbPhaseOneSuccess
std::atomic< size_t > _nbPhaseOneSuccess
Definition: EvaluatorControl.hpp:180
EvaluatorControl::_bbEvalNotOk
std::atomic< size_t > _bbEvalNotOk
The number of blackbox evaluations that are not ok.
Definition: EvaluatorControl.hpp:118
EvaluatorControl::destroy
void destroy()
Helper for destructor.
EvaluatorControl::_evalPointQueue
std::vector< EvalQueuePointPtr > _evalPointQueue
The queue of points to be evaluated.
Definition: EvaluatorControl.hpp:93
EvaluatorControl::_indexBestFeasEval
std::atomic< size_t > _indexBestFeasEval
The index of the best feasible evaluation.
Definition: EvaluatorControl.hpp:157
EvaluatorControl::_indexSuccBlockEval
std::atomic< size_t > _indexSuccBlockEval
The index of the last successfull evaluation block.
Definition: EvaluatorControl.hpp:151
EvaluatorControl::_userCompMethod
std::shared_ptr< ComparePriorityMethod > _userCompMethod
User-implemented comparison method to sort points before evaluation.
Definition: EvaluatorControl.hpp:95
EvaluatorControl::_totalSgteEval
std::atomic< size_t > _totalSgteEval
The total number of sgte evaluations. Used for stats exclusively.
Definition: EvaluatorControl.hpp:139
EvaluatorControl::_nbEvalSentToEvaluator
std::atomic< size_t > _nbEvalSentToEvaluator
Definition: EvaluatorControl.hpp:170
EvaluatorControl::_allDoneWithEval
bool _allDoneWithEval
All evaluations done. The queue can be destroyed.
Definition: EvaluatorControl.hpp:182
EvaluatorControl::_evalContGlobalParams
std::shared_ptr< EvaluatorControlGlobalParameters > _evalContGlobalParams
The parameters controlling the behavior of the class.
Definition: EvaluatorControl.hpp:77
EvaluatorControl::init
void init(std::shared_ptr< Evaluator > evaluator, const std::shared_ptr< EvaluatorControlParameters > &evalContParams)
Helper for constructor.