NOMAD Source  Version 4.0.0 Beta
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EvcInterface.hpp
Go to the documentation of this file.
1 
2 #ifndef __NOMAD400_EVCINTERFACE__
3 #define __NOMAD400_EVCINTERFACE__
4 
5 #include "../Algos/MainStep.hpp"
6 #include "../Algos/MeshBase.hpp"
7 #include "../Algos/Step.hpp"
8 
9 #include "../Eval/EvaluatorControl.hpp"
10 
11 #include "../nomad_nsbegin.hpp"
12 
13 
14 /// Class interface with EvaluatorControl, used by an Algorithm step through IterationUtils
15 /**
16  \todo Complete documentation
17  */
19 {
20 private:
21 
22  Step* _step; /// The step that uses the EvaluatorControl
23 
24  static std::shared_ptr<EvaluatorControl> _evaluatorControl; ///< Static EvaluatorControl
25 
26 public:
27  /// Constructor
28  /**
29  \param step The step using this EvcInterface
30  */
31  explicit EvcInterface(Step* step )
32  : _step(step )
33  {
34  init();
35  }
36 
37  /*---------*/
38  /* Get/Set */
39  /*---------*/
40 
41  static const std::shared_ptr<EvaluatorControl> getEvaluatorControl()
42  {
43  return _evaluatorControl;
44  }
45 
46  /**
47  If the evaluatorControl attribute is NULL, throws an exception.
48  */
49  static void setEvaluatorControl(const std::shared_ptr<EvaluatorControl>& evaluatorControl);
50 
51 
52  void setBarrier(const std::shared_ptr<Barrier>& subBarrier);
53 
54  /*---------------*/
55  /* Other Methods */
56  /*-------------- */
57 
58  // This method may be used by MegaIteration, or by a SearchMethod or by Poll
59  /**
60  * For each point, look if it is in the cache.
61  * If it is, remove it from the EvalPointSet.
62  * If not, convert it to an EvalQueuePoint and add it to EvaluatorControl's Queue.
63 
64  \param trialPoints The trial points -- \b IN/OUT.
65  \param useMesh Flag to use mesh or no -- \b IN.
66  */
67  void keepPointsThatNeedEval(EvalPointSet &trialPoints , bool useMesh=true );
68 
69 
70  /**
71  When points are generated and added to queue, we can start evaluation.
72  */
74 
75  /// Evaluate a single point.
76  /**
77  Useful for X0. \n
78  This method will convert a point from subspace to full space
79  before calling EvaluatorControl's method of the same name.
80 
81  \param evalPoint The poin to evaluate -- \b IN/OUT.
82  \param hMax The max infeasibility for keeping points in barrier -- \b IN.
83  \return \c true if evaluation worked (evalOk), \c false otherwise.
84  */
85  bool evalSinglePoint(EvalPoint &evalPoint, const Double &hMax = INF);
86 
87 private:
88  /// Helper for constructor
89  void init();
90 
91  /// Helper for init
92  /**
93  Utility that throws an exception when not verified.
94  */
95  void verifyStepNotNull();
96 
97  /// Helper for init and setEvaluatorControl
98  /**
99  Utility that throws an exception when not verified.
100  */
101  static void verifyEvaluatorControlNotNull();
102 
103 };
104 
105 #include "../nomad_nsend.hpp"
106 
107 #endif // __NOMAD400_EVCINTERFACE__
const double INF
Infinity.
Definition: defines.hpp:80
bool evalSinglePoint(EvalPoint &evalPoint, const Double &hMax=INF)
Evaluate a single point.
SuccessType
Success type of an iteration.
Definition: defines.hpp:107
void init()
Helper for constructor.
static void setEvaluatorControl(const std::shared_ptr< EvaluatorControl > &evaluatorControl)
Class interface with EvaluatorControl, used by an Algorithm step through IterationUtils.
static void verifyEvaluatorControlNotNull()
Helper for init and setEvaluatorControl.
EvcInterface(Step *step)
Constructor.
static const std::shared_ptr< EvaluatorControl > getEvaluatorControl()
std::set< EvalPoint, EvalPointCompare > EvalPointSet
Definition for EvalPointSet.
Definition: EvalPoint.hpp:311
void keepPointsThatNeedEval(EvalPointSet &trialPoints, bool useMesh=true)
void setBarrier(const std::shared_ptr< Barrier > &subBarrier)
Base class of all types of steps (Iteration, Termination, Initialization, Poll, Mads,...).
Definition: Step.hpp:24
Custom class for double-precision reals.
Definition: Double.hpp:26
void verifyStepNotNull()
Helper for init.
Class for the representation of an evaluation point.
Definition: EvalPoint.hpp:29
static std::shared_ptr< EvaluatorControl > _evaluatorControl
The step that uses the EvaluatorControl.
SuccessType startEvaluation()