NOMAD Source  Version 4.0.0 Beta
PhaseOne.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_PHASE_ONE__
47 #define __NOMAD400_PHASE_ONE__
48 
49 #include "../../Eval/EvalPoint.hpp"
50 #include "../../Algos/Algorithm.hpp"
51 #include "../../Algos/AlgoStopReasons.hpp"
52 #include "../../Algos/Mads/Mads.hpp"
53 
54 #include "../../nomad_nsbegin.hpp"
55 
56 /// Class for phase one search of MADS to satisfy Extreme Barrier (EB) constraints.
57 /**
58  This algorithm is called as a SearchMethod for Mads that modifies the problem to minimize the infeasibility of EB constraints. This is done when initial point has infeasible EB constraint. Then a sub-optimization using Mads solves the modified problem. Once completed, the parent Mads continues on the regular problem. Points for which an EB constraint is infeasible have their objective set to infinity.
59  */
60 class PhaseOne: public Algorithm
61 {
62 private:
63 
64  std::shared_ptr<Mads> _mads;
65  std::shared_ptr<AlgoStopReasons<MadsStopType>> _madsStopReasons;
66 
67 
68  /**
69  The list of ::BBOutputType parameters used for this Phase One.
70  Used to recompute h values at the end of Phase One.
71  Since the recompute methods are static, this member
72  needs to be static.
73  */
75 
76 public:
77  /// Constructor
78  /**
79  \param parentStep The parent of this step -- \b IN.
80  \param stopReasons The Phase One stop reasons -- \b IN/OUT.
81  \param runParams Parameters for algorithm -- \b IN.
82  \param refPbParams Parameters for original optimization problem. Phase One use its own copy -- \b IN.
83  */
84  explicit PhaseOne(const Step* parentStep,
85  std::shared_ptr<AlgoStopReasons<PhaseOneStopType>> stopReasons,
86  const std::shared_ptr<RunParameters>& runParams,
87  const std::shared_ptr<PbParameters>& refPbParams)
88  : Algorithm(parentStep, stopReasons, runParams, std::make_shared<PbParameters>(*refPbParams)),
89  _mads(nullptr)
90  {
91  init();
92  }
93  virtual ~PhaseOne() {}
94 
95  static void setBBOutputTypes(const BBOutputTypeList& bboutputtypes) { _bboutputtypes = bboutputtypes; }
96 
97  /**
98  - Setup EvalPoint success computation to be based on h rather than f.
99  - Recompute points in cache.
100  - Setup stop if feasible criterion.
101  - Setup Mads
102 
103  */
104  virtual void startImp() override;
105  virtual bool runImp() override;
106  virtual void endImp() override;
107 
108  virtual void readInformationForHotRestart() override;
109 
110 private:
111  /// Helper for constructor
112  void init();
113 
114  /*------------------------*/
115  /* Private helper methods */
116  /*------------------------*/
117  /**
118  Static function called by Cache::processOnAllPoints().
119  */
120  static void recomputeH(EvalPoint& evalPoint);
121 
122  /**
123  Static function called by Cache::processOnAllPoints().
124  */
125  static void recomputeHPB(EvalPoint& evalPoint);
126 
127 };
128 
129 #include "../../nomad_nsend.hpp"
130 
131 #endif // __NOMAD400_PHASE_ONE__
PhaseOne::readInformationForHotRestart
virtual void readInformationForHotRestart() override
Helper for start() when doing a hot restart.
PhaseOne::_bboutputtypes
static BBOutputTypeList _bboutputtypes
Definition: PhaseOne.hpp:74
Algorithm
Generic class for any direct search optimizer algorithm.
Definition: Algorithm.hpp:68
BBOutputTypeList
std::vector< BBOutputType > BBOutputTypeList
Definition for the list of blackbox output types.
Definition: BBOutputType.hpp:76
PhaseOne::PhaseOne
PhaseOne(const Step *parentStep, std::shared_ptr< AlgoStopReasons< PhaseOneStopType >> stopReasons, const std::shared_ptr< RunParameters > &runParams, const std::shared_ptr< PbParameters > &refPbParams)
Constructor.
Definition: PhaseOne.hpp:84
Step
Base class of all types of steps (Iteration, Termination, Initialization, Poll, Mads,...
Definition: Step.hpp:68
PhaseOne::recomputeHPB
static void recomputeHPB(EvalPoint &evalPoint)
PhaseOne::endImp
virtual void endImp() override
Default implementation of the end tasks of an algorithm.
PhaseOne::runImp
virtual bool runImp() override
Each algorithm must implement its run tasks.
PhaseOne::setBBOutputTypes
static void setBBOutputTypes(const BBOutputTypeList &bboutputtypes)
Definition: PhaseOne.hpp:95
PhaseOne::_mads
std::shared_ptr< Mads > _mads
Definition: PhaseOne.hpp:64
EvalPoint
Class for the representation of an evaluation point.
Definition: EvalPoint.hpp:75
AlgoStopReasons
Template class for algorithm stop reasons.
Definition: AlgoStopReasons.hpp:65
PhaseOne
Class for phase one search of MADS to satisfy Extreme Barrier (EB) constraints.
Definition: PhaseOne.hpp:60
PhaseOne::recomputeH
static void recomputeH(EvalPoint &evalPoint)
PbParameters
The class for the parameters defining the optimization problem.
Definition: PbParameters.hpp:58
PhaseOne::startImp
virtual void startImp() override
PhaseOne::~PhaseOne
virtual ~PhaseOne()
Definition: PhaseOne.hpp:93
PhaseOne::init
void init()
Helper for constructor.
PhaseOne::_madsStopReasons
std::shared_ptr< AlgoStopReasons< MadsStopType > > _madsStopReasons
Definition: PhaseOne.hpp:65