NOMAD Source  Version 4.0.0 Beta
EvalPoint Class Reference

Class for the representation of an evaluation point. More...

#include <EvalPoint.hpp>

Inheritance diagram for EvalPoint:
Collaboration diagram for EvalPoint:

Public Member Functions

 EvalPoint ()
 Constructor #1. More...
 
 EvalPoint (size_t n)
 Constructor #2. More...
 
 EvalPoint (const Point &x)
 Constructor #3. More...
 
 EvalPoint (const EvalPoint &evalPoint)
 Copy constructor. More...
 
EvalPointoperator= (const EvalPoint &evalPoint)
 Affectation operator. More...
 
virtual ~EvalPoint ()
 Destructor. More...
 
const PointgetX () const
 Get Point part of this EvalPoint. More...
 
EvalgetEval (const EvalType &evalType=EvalType::BB) const
 Get the Eval part of this EvalPoint, using the right EvalType (BB or SGTE) More...
 
void setEval (const Eval &eval, const EvalType &evalType)
 Set the Eval part of this EvalPoint, using the right EvalType (BB or SGTE) More...
 
void clearEvalSgte ()
 Clear the surrogate evaluation of *this. More...
 
Double getF (const EvalType &evalType=EvalType::BB) const
 Get the objective function value of Eval of this EvalType. More...
 
void setF (const Double f, const EvalType &evalType)
 Set the objective function value of the Eval of this EvalType. More...
 
Double getH (const EvalType &evalType=EvalType::BB) const
 Get the infeasibility measure of the Eval of this EvalType. More...
 
void setH (const Double &h, const EvalType &evalType)
 Set the infeasibility measure of the Eval of this EvalType. More...
 
std::string getBBO (const EvalType &evalType) const
 Get the blackbox output for the Eval of this EvalType as a string. More...
 
void setBBO (const std::string &bbo, const BBOutputTypeList &bboutputtypes, const EvalType &evalType=EvalType::BB, const bool evalOk=true)
 Set the blackbox output for the Eval of this EvalType from a string. More...
 
void setBBO (const std::string &bbo, const std::string &sBBOutputTypes, const EvalType &evalType=EvalType::BB, const bool evalOk=true)
 Set the true or surrogate blackbox output from a string. More...
 
void setBBO (const BBOutput &bbo, const EvalType &evalType=EvalType::BB, const bool evalOk=true)
 Set the true or surrogate blackbox output. More...
 
EvalStatusType getEvalStatus (const EvalType &evalType) const
 Get evaluation status of the Eval of this EvalType. More...
 
void setEvalStatus (const EvalStatusType &evalStatus, const EvalType &evalType)
 Set evaluation status of the Eval of this EvalType. More...
 
size_t getTag () const
 
void updateTag () const
 Modifies mutable _tag, and increments static _currentTag. More...
 
int getThreadAlgo () const
 
void setThreadAlgo (const int threadAlgo)
 
short getNumberEval () const
 
void setNumberEval (const short numEval)
 
void incNumberEval ()
 
const std::shared_ptr< PointgetPointFrom () const
 Get the Point which was the center when this point was generated. More...
 
const std::shared_ptr< PointgetPointFrom (const Point &fixedVariable) const
 Get the Point which was the center when this point was generated. More...
 
void setPointFrom (const std::shared_ptr< Point > pointFrom)
 Set the Point for which this point was generated. More...
 
void setPointFrom (std::shared_ptr< Point > pointFrom, const Point &fixedVariable)
 Set the Point for which this point was generated. More...
 
bool isFeasible (const EvalType &evalType) const
 Get evaluation feasibility flag f the Eval of this EvalType. More...
 
void recomputeFH (const BBOutputTypeList &bbOutputType)
 Recompute f and h, for a given list of blackbox output type considering that raw blackbox output is set. More...
 
bool dominates (const EvalPoint &rhs, const EvalType &evalType) const
 Comparison operator used by NM algorithm. More...
 
EvalPoint makeFullSpacePointFromFixed (const Point &fixedVariable) const
 Convert a point from sub space to full space using fixed variables. More...
 
EvalPoint makeSubSpacePointFromFixed (const Point &fixedVariable) const
 Convert a point from full space to sub space using fixed variables. More...
 
bool operator== (const EvalPoint &evalPoint) const
 Comparison operator ==. More...
 
bool operator!= (const EvalPoint &evalPoint) const
 Comparison operator !=. More...
 
bool operator< (const EvalPoint &x) const
 Comparison operator <, used for set ordering. More...
 
bool isEvalOk (const EvalType &evalType) const
 
std::string display (const ArrayOfDouble &format=ArrayOfDouble()) const override
 Display with or without format. More...
 
std::string displayAll () const
 Display both true and surrogate evaluations. Useful for debugging. More...
 
bool toEval (short maxPointEval, const EvalType &evalType) const
 Function to test if evaluation is required. More...
 
bool isDefined () const override
 
- Public Member Functions inherited from Point
 Point (const size_t n=0, const Double &val=Double())
 
 Point (const Point &pt)
 Copy constructors. More...
 
Pointoperator= (const Point &pt)
 Assignment operator. More...
 
Pointoperator= (const ArrayOfDouble &aod)
 Assignment operator. More...
 
virtual ~Point ()
 Destructor. More...
 
std::string display (const ArrayOfDouble &prec=ArrayOfDouble()) const override
 Formated point display. More...
 
std::string displayNoPar (const ArrayOfDouble &prec=ArrayOfDouble()) const
 Formated point display. More...
 
bool operator< (const Point &point __attribute__((unused))) const
 Comparison operator <. More...
 
Point operator+ (const Direction &dir) const
 Addition point = point + direction. More...
 
Point makeFullSpacePointFromFixed (const Point &fixedVariable) const
 Convert a point from sub space to full space using fixed variables. More...
 
Point makeSubSpacePointFromFixed (const Point &fixedVariable, const bool verifyValues=true) const
 Convert a point from full space to sub space using fixed variables. More...
 
Point projectPointToSubspace (const Point &fixedVariable) const
 Project a point from full space to sub space using fixed variables. More...
 
bool hasFixed (const Point &fixedVariable) const
 Verify if a point is part of the sub-space defined by fixed variable. More...
 
- Public Member Functions inherited from ArrayOfDouble
 ArrayOfDouble (const size_t n=0, const Double &val=Double())
 Constructor. More...
 
 ArrayOfDouble (const ArrayOfDouble &coords)
 Copy constructor. More...
 
ArrayOfDoubleoperator= (const ArrayOfDouble &coords)
 Affectation operator. More...
 
virtual ~ArrayOfDouble ()
 Destructor. More...
 
Doubleoperator[] (size_t i) const
 Operator []. More...
 
size_t size () const
 Access to the dimension of the array. More...
 
void reset (size_t n=0, const Double &d=Double())
 Change the ArrayOfDouble dimension, and set all coordinates to d. More...
 
void resize (size_t n, const Double &d=Double())
 Change the dimensionof the array. The values are kept. More...
 
bool isEmpty () const
 Test if empty. More...
 
void set (const Double &d) const
 Set all the coordinates to a specific value. More...
 
void set (size_t index, const Double &d, bool relative=false, const Double &lb=Double(), const Double &ub=Double())
 
void set (size_t n, const Double *a)
 Set the coordinates with an array of reals. More...
 
bool isComplete () const
 Check if all the coordinates are defined. More...
 
size_t nbDefined () const
 Count the number of defined values. More...
 
bool toBeDefined () const
 
void snapToBounds (const ArrayOfDouble &lb, const ArrayOfDouble &ub, const ArrayOfDouble &frameCenter, const ArrayOfDouble &meshSize)
 Snap an array to the bounds. Remain on mesh centered on frameCenter. More...
 
bool inBounds (const ArrayOfDouble &lowerBound, const ArrayOfDouble &upperBound) const
 Verify if the array is inside the bounds. Ignores undefined bounds. More...
 
void readValuesAsArray (const ArrayOfString &valueString)
 Read values and fill the array with corresponding double values. More...
 
ArrayOfDouble abs () const
 
Double max () const
 Return max of all defined values. More...
 
const ArrayOfDoubleoperator*= (const Double &d)
 Mutiplication with a scalar. More...
 
const ArrayOfDouble operator+ (const ArrayOfDouble &p) const
 Addition with another array. More...
 
const ArrayOfDouble operator- (const ArrayOfDouble &p) const
 Substraction with an other array. More...
 
bool isMultipleOf (const ArrayOfDouble &gran, int &index) const
 
bool operator== (const ArrayOfDouble &coords) const
 Comparison operator ==. More...
 
bool operator!= (const ArrayOfDouble &coords) const
 Comparison operator !=. More...
 
virtual bool operator<= (const ArrayOfDouble &coords) const
 Comparison operator <=. More...
 
virtual bool operator< (const ArrayOfDouble &coords) const
 Comparison operator <. More...
 

Static Public Member Functions

static void clearEvalSgte (EvalPoint &evalPoint)
 Clear the surrogate evaluation of a point. More...
 
static void resetCurrentTag ()
 Reset tag numbers: Use with caution. Expected to be used in unit tests and runner only. More...
 
static bool hasSgteEval (const EvalPoint &evalPoint)
 
static bool hasBbEval (const EvalPoint &evalPoint)
 
- Static Public Member Functions inherited from Point
static bool weakLess (const Point &lhs, const Point &rhs)
 Weak comparison operator. More...
 
static Double dist (const Point &X, const Point &Y)
 Euclidean distance between two points. More...
 
static Direction vectorize (const Point &X, const Point &Y)
 Create a direction by substracting 2 points. More...
 

Private Member Functions

void copyMembers (const EvalPoint &evalPoint)
 Helper for copy constructor and others. More...
 

Private Attributes

EvalUPtr _eval
 Value of the evaluation (truth / blackbox) More...
 
EvalUPtr _evalSgte
 Value of the surrogate evaluation. More...
 
size_t _tag
 Tag: Ordinal representing the order of creation. More...
 
int _threadAlgo
 Main thread that generated this point. More...
 
short _numberEval
 Number of times *this point has been evaluated (blackbox only) More...
 
std::shared_ptr< Point_pointFrom
 The frame center which generated *this point (blackbox only) More...
 

Static Private Attributes

static size_t _currentTag
 Value of the current tag. More...
 

Additional Inherited Members

- Static Public Attributes inherited from ArrayOfDouble
static const std::string pStart
 Static variable used for array delimitation. More...
 
static const std::string pEnd
 Static variable used for array delimitation. More...
 
- Protected Member Functions inherited from ArrayOfDouble
void verifySizesMatch (size_t n1, size_t n2, std::string filename, size_t linenum) const
 Helper function to verify that n1 == n2. More...
 
void compare (const ArrayOfDouble &aod, bool &isInf, bool &isStrictInf) const
 Helper function to compare arrays. More...
 
- Protected Attributes inherited from ArrayOfDouble
size_t _n
 Dimension of the array. More...
 
Double_array
 Values of the array. More...
 

Detailed Description

Class for the representation of an evaluation point.

An evaluation point gathers the point coordinates x, and the blackbox outputs at these coordinates f(x).

Definition at line 75 of file EvalPoint.hpp.

Constructor & Destructor Documentation

◆ EvalPoint() [1/4]

EvalPoint::EvalPoint ( )
explicit

Constructor #1.

◆ EvalPoint() [2/4]

EvalPoint::EvalPoint ( size_t  n)
explicit

Constructor #2.

Parameters
nNumber of variables – IN.

◆ EvalPoint() [3/4]

EvalPoint::EvalPoint ( const Point x)
explicit

Constructor #3.

Parameters
xCoordinates of the eval point – IN.

◆ EvalPoint() [4/4]

EvalPoint::EvalPoint ( const EvalPoint evalPoint)

Copy constructor.

Parameters
evalPointThe copied object – IN.

◆ ~EvalPoint()

virtual EvalPoint::~EvalPoint ( )
virtual

Destructor.

Member Function Documentation

◆ clearEvalSgte() [1/2]

void EvalPoint::clearEvalSgte ( )
inline

Clear the surrogate evaluation of *this.

Definition at line 149 of file EvalPoint.hpp.

149 { _evalSgte = nullptr; }

◆ clearEvalSgte() [2/2]

static void EvalPoint::clearEvalSgte ( EvalPoint evalPoint)
inlinestatic

Clear the surrogate evaluation of a point.

Definition at line 152 of file EvalPoint.hpp.

152 { evalPoint.clearEvalSgte(); }

◆ copyMembers()

void EvalPoint::copyMembers ( const EvalPoint evalPoint)
private

Helper for copy constructor and others.

◆ display()

std::string EvalPoint::display ( const ArrayOfDouble format = ArrayOfDouble()) const
overridevirtual

Display with or without format.

Reimplemented from ArrayOfDouble.

◆ displayAll()

std::string EvalPoint::displayAll ( ) const

Display both true and surrogate evaluations. Useful for debugging.

◆ dominates()

bool EvalPoint::dominates ( const EvalPoint rhs,
const EvalType evalType 
) const

Comparison operator used by NM algorithm.

Parameters
rhsSecond eval points to compare – IN.
evalTypeBlackbox or surrogate evaluation – IN.
Returns
true if *this dominates x.

◆ getBBO()

std::string EvalPoint::getBBO ( const EvalType evalType) const

Get the blackbox output for the Eval of this EvalType as a string.

◆ getEval()

Eval* EvalPoint::getEval ( const EvalType evalType = EvalType::BB) const

Get the Eval part of this EvalPoint, using the right EvalType (BB or SGTE)

◆ getEvalStatus()

EvalStatusType EvalPoint::getEvalStatus ( const EvalType evalType) const

Get evaluation status of the Eval of this EvalType.

◆ getF()

Double EvalPoint::getF ( const EvalType evalType = EvalType::BB) const

Get the objective function value of Eval of this EvalType.

◆ getH()

Double EvalPoint::getH ( const EvalType evalType = EvalType::BB) const

Get the infeasibility measure of the Eval of this EvalType.

◆ getNumberEval()

short EvalPoint::getNumberEval ( ) const
inline

Definition at line 217 of file EvalPoint.hpp.

217 { return _numberEval; }

◆ getPointFrom() [1/2]

const std::shared_ptr<Point> EvalPoint::getPointFrom ( ) const
inline

Get the Point which was the center when this point was generated.

Definition at line 222 of file EvalPoint.hpp.

222 { return _pointFrom; }

◆ getPointFrom() [2/2]

const std::shared_ptr<Point> EvalPoint::getPointFrom ( const Point fixedVariable) const

Get the Point which was the center when this point was generated.

Returns a Point in the Subspace defined by the fixedVariable

◆ getTag()

size_t EvalPoint::getTag ( ) const
inline

Definition at line 209 of file EvalPoint.hpp.

209 { return _tag; }

◆ getThreadAlgo()

int EvalPoint::getThreadAlgo ( ) const
inline

Definition at line 214 of file EvalPoint.hpp.

214 { return _threadAlgo; }

◆ getX()

const Point* EvalPoint::getX ( ) const
inline

Get Point part of this EvalPoint.

Definition at line 140 of file EvalPoint.hpp.

140 { return dynamic_cast<const Point*>(this); }

◆ hasBbEval()

static bool EvalPoint::hasBbEval ( const EvalPoint evalPoint)
static

◆ hasSgteEval()

static bool EvalPoint::hasSgteEval ( const EvalPoint evalPoint)
static

◆ incNumberEval()

void EvalPoint::incNumberEval ( )
inline

Definition at line 219 of file EvalPoint.hpp.

219 { _numberEval++; }

◆ isDefined()

bool EvalPoint::isDefined ( ) const
inlineoverridevirtual
Warning
It is unclear if the caller wants to verify if the base point is defined, or if f is defined. To avoid mistakes and confusion, throw an error.

Reimplemented from ArrayOfDouble.

Definition at line 321 of file EvalPoint.hpp.

322  {
323  throw Exception(__FILE__,__LINE__,"Error: Calling EvalPoint::isDefined(). Choose ArrayOfDouble::isDefined() or Double::isDefined() instead.");
324  }

◆ isEvalOk()

bool EvalPoint::isEvalOk ( const EvalType evalType) const

◆ isFeasible()

bool EvalPoint::isFeasible ( const EvalType evalType) const

Get evaluation feasibility flag f the Eval of this EvalType.

◆ makeFullSpacePointFromFixed()

EvalPoint EvalPoint::makeFullSpacePointFromFixed ( const Point fixedVariable) const

Convert a point from sub space to full space using fixed variables.

Remarks
The evaluation part of *this is unchanged.

◆ makeSubSpacePointFromFixed()

EvalPoint EvalPoint::makeSubSpacePointFromFixed ( const Point fixedVariable) const

Convert a point from full space to sub space using fixed variables.

Remarks
The evaluation part of *this is unchanged.

◆ operator!=()

bool EvalPoint::operator!= ( const EvalPoint evalPoint) const
inline

Comparison operator !=.

Parameters
evalPointThe right-hand side object – IN.
Returns
false if *this == p, true if not.

Definition at line 285 of file EvalPoint.hpp.

285 { return !(*this == evalPoint); }

◆ operator<()

bool EvalPoint::operator< ( const EvalPoint x) const

Comparison operator <, used for set ordering.

Parameters
xRight-hand side object – IN.
Returns
true if *this < x, false if not..

◆ operator=()

EvalPoint& EvalPoint::operator= ( const EvalPoint evalPoint)

Affectation operator.

Parameters
evalPointThe right-hand side object – IN.
Returns
*this as the result of the affectation.

◆ operator==()

bool EvalPoint::operator== ( const EvalPoint evalPoint) const

Comparison operator ==.

Parameters
evalPointThe right-hand side object – IN.
Returns
true if *this == p, false if not.

◆ recomputeFH()

void EvalPoint::recomputeFH ( const BBOutputTypeList bbOutputType)

Recompute f and h, for a given list of blackbox output type considering that raw blackbox output is set.

Parameters
bbOutputTypeThe list of blackbox output types.

◆ resetCurrentTag()

static void EvalPoint::resetCurrentTag ( )
static

Reset tag numbers: Use with caution. Expected to be used in unit tests and runner only.

◆ setBBO() [1/3]

void EvalPoint::setBBO ( const BBOutput bbo,
const EvalType evalType = EvalType::BB,
const bool  evalOk = true 
)

Set the true or surrogate blackbox output.

Parameters
bboA blackbox evaluation output – IN.
evalTypeBlackbox or surrogate evaluation – IN.
evalOkFlag for evaluation status – IN.

◆ setBBO() [2/3]

void EvalPoint::setBBO ( const std::string &  bbo,
const BBOutputTypeList bboutputtypes,
const EvalType evalType = EvalType::BB,
const bool  evalOk = true 
)

Set the blackbox output for the Eval of this EvalType from a string.

Parameters
bboThe string containg the raw result of the blackbox evaluation – IN.
bboutputtypesThe list of blackbox output types – IN.
evalTypeBlackbox or surrogate evaluation – IN.
evalOkFlag for evaluation status – IN.

◆ setBBO() [3/3]

void EvalPoint::setBBO ( const std::string &  bbo,
const std::string &  sBBOutputTypes,
const EvalType evalType = EvalType::BB,
const bool  evalOk = true 
)

Set the true or surrogate blackbox output from a string.

Parameters
bboThe string containg the raw result of the blackbox evaluation – IN.
sBBOutputTypesThe blackbox output types coded as a single string – IN.
evalTypeBlackbox or surrogate evaluation – IN.
evalOkFlag for evaluation status – IN.

◆ setEval()

void EvalPoint::setEval ( const Eval eval,
const EvalType evalType 
)

Set the Eval part of this EvalPoint, using the right EvalType (BB or SGTE)

◆ setEvalStatus()

void EvalPoint::setEvalStatus ( const EvalStatusType evalStatus,
const EvalType evalType 
)

Set evaluation status of the Eval of this EvalType.

◆ setF()

void EvalPoint::setF ( const Double  f,
const EvalType evalType 
)

Set the objective function value of the Eval of this EvalType.

◆ setH()

void EvalPoint::setH ( const Double h,
const EvalType evalType 
)

Set the infeasibility measure of the Eval of this EvalType.

◆ setNumberEval()

void EvalPoint::setNumberEval ( const short  numEval)
inline

Definition at line 218 of file EvalPoint.hpp.

218 { _numberEval = numEval; }

◆ setPointFrom() [1/2]

void EvalPoint::setPointFrom ( const std::shared_ptr< Point pointFrom)

Set the Point for which this point was generated.

◆ setPointFrom() [2/2]

void EvalPoint::setPointFrom ( std::shared_ptr< Point pointFrom,
const Point fixedVariable 
)

Set the Point for which this point was generated.

Use the fixedVariable to convert pointFrom from Subspace dimension to the full dimension.

◆ setThreadAlgo()

void EvalPoint::setThreadAlgo ( const int  threadAlgo)
inline

Definition at line 215 of file EvalPoint.hpp.

215 { _threadAlgo = threadAlgo; }

◆ toEval()

bool EvalPoint::toEval ( short  maxPointEval,
const EvalType evalType 
) const

Function to test if evaluation is required.

Depending on the status of the Eval, should we evaluate (possibly re-evaluate) this point?

Parameters
maxPointEvalThe maximum number of point evaluations – IN.
evalTypeBlackbox or surrogate evaluation – IN.
Returns
true if evaluation is required and false otherwise.

◆ updateTag()

void EvalPoint::updateTag ( ) const

Modifies mutable _tag, and increments static _currentTag.

Member Data Documentation

◆ _currentTag

size_t EvalPoint::_currentTag
staticprivate

Value of the current tag.

Definition at line 79 of file EvalPoint.hpp.

◆ _eval

EvalUPtr EvalPoint::_eval
private

Value of the evaluation (truth / blackbox)

Definition at line 81 of file EvalPoint.hpp.

◆ _evalSgte

EvalUPtr EvalPoint::_evalSgte
private

Value of the surrogate evaluation.

Definition at line 83 of file EvalPoint.hpp.

◆ _numberEval

short EvalPoint::_numberEval
private

Number of times *this point has been evaluated (blackbox only)

Definition at line 89 of file EvalPoint.hpp.

◆ _pointFrom

std::shared_ptr<Point> EvalPoint::_pointFrom
private

The frame center which generated *this point (blackbox only)

Definition at line 91 of file EvalPoint.hpp.

◆ _tag

size_t EvalPoint::_tag
mutableprivate

Tag: Ordinal representing the order of creation.

Definition at line 85 of file EvalPoint.hpp.

◆ _threadAlgo

int EvalPoint::_threadAlgo
private

Main thread that generated this point.

Definition at line 87 of file EvalPoint.hpp.


The documentation for this class was generated from the following file:
Point
Class for the representation of a point.
Definition: Point.hpp:68
EvalPoint::clearEvalSgte
void clearEvalSgte()
Clear the surrogate evaluation of *this.
Definition: EvalPoint.hpp:149
EvalPoint::_pointFrom
std::shared_ptr< Point > _pointFrom
The frame center which generated *this point (blackbox only)
Definition: EvalPoint.hpp:91
Exception
Exception utility.
Definition: WriteAttributeDefinitionFile.cpp:86
EvalPoint::_numberEval
short _numberEval
Number of times *this point has been evaluated (blackbox only)
Definition: EvalPoint.hpp:89
EvalPoint::_tag
size_t _tag
Tag: Ordinal representing the order of creation.
Definition: EvalPoint.hpp:85
EvalPoint::_threadAlgo
int _threadAlgo
Main thread that generated this point.
Definition: EvalPoint.hpp:87
EvalPoint::_evalSgte
EvalUPtr _evalSgte
Value of the surrogate evaluation.
Definition: EvalPoint.hpp:83