NOMAD Source  Version 4.0.0 Beta
MegaSearchPoll.hpp
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------------*/
2 /* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct Search - */
3 /* */
4 /* NOMAD - Version 4.0.0 has been created by */
5 /* Viviane Rochon Montplaisir - Polytechnique Montreal */
6 /* Christophe Tribes - Polytechnique Montreal */
7 /* */
8 /* The copyright of NOMAD - version 4.0.0 is owned by */
9 /* Charles Audet - Polytechnique Montreal */
10 /* Sebastien Le Digabel - Polytechnique Montreal */
11 /* Viviane Rochon Montplaisir - Polytechnique Montreal */
12 /* Christophe Tribes - Polytechnique Montreal */
13 /* */
14 /* NOMAD v4 has been funded by Rio Tinto, Hydro-Québec, NSERC (Natural */
15 /* Sciences and Engineering Research Council of Canada), InnovÉÉ (Innovation */
16 /* en Énergie Électrique) and IVADO (The Institute for Data Valorization) */
17 /* */
18 /* NOMAD v3 was created and developed by Charles Audet, Sebastien Le Digabel, */
19 /* Christophe Tribes and Viviane Rochon Montplaisir and was funded by AFOSR */
20 /* and Exxon Mobil. */
21 /* */
22 /* NOMAD v1 and v2 were created and developed by Mark Abramson, Charles Audet, */
23 /* Gilles Couture, and John E. Dennis Jr., and were funded by AFOSR and */
24 /* Exxon Mobil. */
25 /* */
26 /* Contact information: */
27 /* Polytechnique Montreal - GERAD */
28 /* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */
29 /* e-mail: nomad@gerad.ca */
30 /* */
31 /* This program is free software: you can redistribute it and/or modify it */
32 /* under the terms of the GNU Lesser General Public License as published by */
33 /* the Free Software Foundation, either version 3 of the License, or (at your */
34 /* option) any later version. */
35 /* */
36 /* This program is distributed in the hope that it will be useful, but WITHOUT */
37 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
38 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License */
39 /* for more details. */
40 /* */
41 /* You should have received a copy of the GNU Lesser General Public License */
42 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
43 /* */
44 /* You can find information on the NOMAD software at www.gerad.ca/nomad */
45 /*---------------------------------------------------------------------------------*/
46 #ifndef __NOMAD400_MEGASEARCHPOLL__
47 #define __NOMAD400_MEGASEARCHPOLL__
48 
49 #include "../../Algos/IterationUtils.hpp"
50 #include "../../Algos/Mads/MadsIteration.hpp"
51 
52 #include "../../nomad_nsbegin.hpp"
53 
54 /// Class for the mega search and poll of MADS
55 /**
56  Calling the start function generates search and poll trial points at the same time before starting evaluation.
57  Calling the run function starts the evaluaions.
58  The postprocessing is performed when calling the end funcion.
59  */
60 class MegaSearchPoll: public Step, public IterationUtils
61 {
62 private:
63  /**
64  Hash table to remember which iteration generated this point.
65  I tried working around it, but in the end it is easier to just
66  remember the iteration.
67  Mutable because it is updated in generateTrialPoints().
68  */
69  mutable std::map<EvalPoint, std::shared_ptr<MadsIteration>, EvalPointCompare> _iterForPoint;
70 
71 public:
72  /// Constructor
73  /**
74  \param parentStep The parent of this step
75  */
76  explicit MegaSearchPoll(const Step* parentStep )
77  : Step( parentStep ),
78  IterationUtils( parentStep ),
80  {
81  init();
82  }
83 
84  // Destructor
85  virtual ~MegaSearchPoll()
86  {
87  _iterForPoint.clear();
88  }
89 
90  /**
91  Get which iteration generated a point. This is used by evaluator control interface. Having the iteration, gives access to the mesh and some of its attributes.
92  */
93  const std::shared_ptr<MadsIteration> getIterForPoint(const EvalPoint& point) const;
94 
95 private:
96 
97  /// Generate the trial poins for the search and poll steps.
98  /**
99  Call MegaSearchPoll::generateTrialPoints.
100  */
101  virtual void startImp() override;
102 
103  ///Start evaluations
104  virtual bool runImp() override;
105 
106  /**
107  Call for postprocessing: computation of a new hMax and update of the barrier.
108  */
109  virtual void endImp() override ;
110 
111  void init();
112 
113  /// Generate new points to evaluate
114  /**
115  The trial points are produced using poll and search. The duplicates are removed and they are merged all together.
116  */
117  void generateTrialPoints() override ;
118 
119 
120 };
121 
122 #include "../../nomad_nsend.hpp"
123 
124 #endif // __NOMAD400_MEGASEARCHPOLL__
MegaSearchPoll::runImp
virtual bool runImp() override
Start evaluations.
Step
Base class of all types of steps (Iteration, Termination, Initialization, Poll, Mads,...
Definition: Step.hpp:68
MegaSearchPoll::_iterForPoint
std::map< EvalPoint, std::shared_ptr< MadsIteration >, EvalPointCompare > _iterForPoint
Definition: MegaSearchPoll.hpp:69
MegaSearchPoll
Class for the mega search and poll of MADS.
Definition: MegaSearchPoll.hpp:60
MegaSearchPoll::generateTrialPoints
void generateTrialPoints() override
Generate new points to evaluate.
IterationUtils
Class of utils (attributes and helper functions) for some phases of an algorithm that involve Iterati...
Definition: IterationUtils.hpp:64
EvalPoint
Class for the representation of an evaluation point.
Definition: EvalPoint.hpp:75
MegaSearchPoll::endImp
virtual void endImp() override
MegaSearchPoll::getIterForPoint
const std::shared_ptr< MadsIteration > getIterForPoint(const EvalPoint &point) const
MegaSearchPoll::~MegaSearchPoll
virtual ~MegaSearchPoll()
Definition: MegaSearchPoll.hpp:85
MegaSearchPoll::startImp
virtual void startImp() override
Generate the trial poins for the search and poll steps.
MegaSearchPoll::MegaSearchPoll
MegaSearchPoll(const Step *parentStep)
Constructor.
Definition: MegaSearchPoll.hpp:76
EvalPointCompare
Class for eval point compare.
Definition: EvalPoint.hpp:356
MegaSearchPoll::init
void init()