1 /*-------------------------------------------------------------------------------------*/ 2 /* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ 3 /* */ 4 /* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ 5 /* Charles Audet - Ecole Polytechnique, Montreal */ 6 /* Gilles Couture - Ecole Polytechnique, Montreal */ 7 /* John Dennis - Rice University, Houston */ 8 /* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ 9 /* Christophe Tribes - Ecole Polytechnique, Montreal */ 10 /* */ 11 /* funded in part by AFOSR and Exxon Mobil */ 12 /* */ 13 /* Author: Sebastien Le Digabel */ 14 /* */ 15 /* Contact information: */ 16 /* Ecole Polytechnique de Montreal - GERAD */ 17 /* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ 18 /* e-mail: nomad@gerad.ca */ 19 /* phone : 1-514-340-6053 #6928 */ 20 /* fax : 1-514-340-5665 */ 21 /* */ 22 /* This program is free software: you can redistribute it and/or modify it under the */ 23 /* terms of the GNU Lesser General Public License as published by the Free Software */ 24 /* Foundation, either version 3 of the License, or (at your option) any later */ 25 /* version. */ 26 /* */ 27 /* This program is distributed in the hope that it will be useful, but WITHOUT ANY */ 28 /* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A */ 29 /* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ 30 /* */ 31 /* You should have received a copy of the GNU Lesser General Public License along */ 32 /* with this program. If not, see <http://www.gnu.org/licenses/>. */ 33 /* */ 34 /* You can find information on the NOMAD software at www.gerad.ca/nomad */ 35 /*-------------------------------------------------------------------------------------*/ 36 /** 37 \file SMesh.hpp 38 \brief Class for the static orthogonal MADS mesh (headers) 39 \author Christophe Tribes 40 \date 2010-04-06 41 \see OrthogonalMesh.cpp SMesh.cpp 42 */ 43 #ifndef __SMESH__ 44 #define __SMESH__ 45 46 #include "Point.hpp" 47 #include "OrthogonalMesh.hpp" 48 49 namespace NOMAD { 50 51 /// Class for the MADS orthogonal static mesh. 52 /** 53 - The static mesh is defined with the basic directions and a 54 mesh size parameter delta^k. 55 - The mesh size parameter is defined with a single mesh index (the integer r^k) 56 and the initial mesh size delta^0 for all coordinates. 57 - The poll size parameter Delta^k (single value for all coordinates) is not 58 used to define the mesh but to define the poll trial points. 59 - At each MADS iteration the mesh is updated with 60 delta^k+1 = tau^w+ delta^k and w+ >= 0 (dominating iteration) 61 or with 62 delta^k+1 = tau^w- delta^k and w- < 0 (iteration failure). 63 The mesh is not changed after improving iterations. 64 - Mesh and poll size parameters are stored as NOMAD::Point objects 65 (one value for each variable). The scaling is done once based on initial mesh size. 66 - See the MADS papers for more details on the mesh. 67 */ 68 69 class SMesh : public NOMAD::OrthogonalMesh { 70 71 private: 72 73 int _initial_mesh_index; 74 int _mesh_index; 75 int _min_mesh_index; ///< Minimal value reached by the mesh index 76 int _max_mesh_index; ///< Maximal value reached by the mesh index 77 78 /*--------------------------------------------------------------*/ 79 80 /// Private affectation operator. 81 /** 82 \param m The right-hand side object -- \b IN. 83 */ 84 const SMesh & operator = ( const SMesh & m ); 85 86 /// Check the minimal poll size criterion. 87 bool check_min_poll_size_criterion ( ) const; 88 89 /// Check the minimal mesh size criterion. 90 bool check_min_mesh_size_criterion ( ) const; 91 92 /// Access to the mesh size parameter delta^k. 93 /** 94 \return delta The mesh size parameter delta^k -- \b OUT. 95 \param i The index of the mesh size 96 */ 97 NOMAD::Double get_delta ( int i ) const ; 98 99 100 /// Access to the poll size parameter Delta^k. 101 /** 102 \return Delta The poll size parameter Delta^k -- \b OUT. 103 \param i The index of the poll size 104 */ 105 NOMAD::Double get_Delta ( int i ) const ; 106 107 108 109 /*--------------------------------------------------------------*/ 110 111 public: 112 113 /// Constructor. 114 /** 115 \param delta_0 Initial mesh size delta_0 -- \b IN. 116 \param Delta_min Minimal poll size Delta_min (may be undefined) -- \b IN. 117 \param delta_min Minimal mesh size delta_min (may be undefined) -- \b IN. 118 \param mesh_update_basis Mesh update basis (tau), default=4 -- \b IN. 119 \param mesh_coarsening_step Mesh coarsening step (w+), default=1 -- \b IN. 120 \param mesh_refining_step Mesh refining step (w-), default=-1 -- \b IN. 121 \param initial_mesh_index Initial mesh index ell_0, default=0 -- \b IN. 122 \param limit_max_mesh_index Limit max of the mesh index, default=L_LIMITS -- \b IN. 123 \param fixed_variables Fixed variables -- \b IN. 124 */ SMesh(const NOMAD::Point & delta_0,const NOMAD::Point & Delta_min,const NOMAD::Point & delta_min,const NOMAD::Point & fixed_variables,NOMAD::Double mesh_update_basis=4.0,int mesh_coarsening_step=1,int mesh_refining_step=-1,int initial_mesh_index=0,int limit_max_mesh_index=NOMAD::L_LIMITS)125 SMesh ( const NOMAD::Point & delta_0 , 126 const NOMAD::Point & Delta_min , 127 const NOMAD::Point & delta_min , 128 const NOMAD::Point & fixed_variables , 129 NOMAD::Double mesh_update_basis=4.0, 130 int mesh_coarsening_step=1, 131 int mesh_refining_step=-1, 132 int initial_mesh_index=0, 133 int limit_max_mesh_index=NOMAD::L_LIMITS) 134 : NOMAD::OrthogonalMesh ( delta_0, 135 Delta_min, 136 delta_min, 137 fixed_variables, 138 mesh_update_basis, 139 mesh_coarsening_step, 140 mesh_refining_step , 141 limit_max_mesh_index ), 142 _initial_mesh_index ( initial_mesh_index ), 143 _mesh_index ( _initial_mesh_index ), 144 _min_mesh_index ( initial_mesh_index ), 145 _max_mesh_index ( initial_mesh_index ) {} 146 147 148 /// Copy constructor. 149 /** 150 \param m The copied object -- \b IN. 151 */ SMesh(const SMesh & m)152 SMesh ( const SMesh & m ) 153 : OrthogonalMesh(m) , 154 _initial_mesh_index ( m._initial_mesh_index ), 155 _mesh_index ( m._initial_mesh_index ), 156 _min_mesh_index( m._initial_mesh_index ), 157 _max_mesh_index ( m._initial_mesh_index ) {} 158 159 /// Destructor. ~SMesh(void)160 virtual ~SMesh ( void ) 161 { 162 _delta_0.clear(); 163 _Delta_0.clear(); 164 _delta_min.clear(); 165 _Delta_min.clear(); 166 } 167 168 169 /// Access to the mesh index. 170 /** 171 \return A Point with the mesh index. 172 */ get_mesh_indices(void) const173 const NOMAD::Point get_mesh_indices ( void ) const 174 { 175 return NOMAD::Point( 1 , NOMAD::Double(_mesh_index) ); 176 } 177 178 /// Access to the min mesh index reached so far. 179 /** 180 \return A Point with the mesh index. 181 */ get_min_mesh_indices(void) const182 const NOMAD::Point get_min_mesh_indices ( void ) const 183 { 184 return NOMAD::Point( 1 , NOMAD::Double(_min_mesh_index) ); 185 } 186 187 188 /// Access to the max mesh index reached so far. 189 /** 190 \return A Point with the mesh index. 191 */ get_max_mesh_indices(void) const192 const NOMAD::Point get_max_mesh_indices ( void ) const 193 { 194 return NOMAD::Point( 1 , NOMAD::Double(_max_mesh_index) ); 195 } 196 197 198 /// Manually set the mesh index using a point. (set_mesh_indices for consistency with XMesh) 199 /** 200 \param r The mesh index provided as a point -- \b IN. 201 */ 202 void set_mesh_indices ( const NOMAD::Point & r ); 203 204 205 206 /// Manually set the limit mesh index used for termination criterion (max value for SMesh). 207 /** 208 \param l The limit mesh index for all coordinates -- \b IN. 209 */ 210 void set_limit_mesh_index ( int l ); 211 212 213 214 /// Test if finest mesh so far. 215 /** 216 \return True if mesh index greater or equal to the maximal mesh index; False otherwise. 217 */ is_finest(void) const218 bool is_finest(void) const {return _mesh_index >= _max_mesh_index; } 219 220 221 /// Access to the mesh ratios after a success 222 /** 223 \return A point with the ratio for each coordinate 224 */ 225 NOMAD::Point get_mesh_ratio_if_success( void ) const; 226 227 228 /// Update the provided mesh indices (the Mesh is unchanged). 229 /** 230 \param success Type of success of the iteration -- \b IN. 231 \param mesh_indices The mesh indices before and after the update -- \b IN/OUT. 232 \param dir The direction that is considered (opt) -- \b IN. 233 */ 234 void update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir=NULL ) const ; 235 236 237 /// Update the Mesh. 238 /** 239 \param success Type of success of the iteration -- \b IN. 240 \param dir The direction that is considered (opt) -- \b IN. 241 */ 242 void update ( NOMAD::success_type success , const NOMAD::Direction *dir=NULL); 243 244 245 /// Reset the mesh to its original size (mesh indices). reset(void)246 void reset ( void ) 247 { 248 set_mesh_indices( NOMAD::Point(1,NOMAD::Double(_initial_mesh_index))) ; 249 _min_mesh_index=_initial_mesh_index ; 250 _max_mesh_index=_initial_mesh_index; 251 } 252 253 /// Access to the mesh size parameter delta^k. 254 /** 255 \param delta The mesh size parameter delta^k -- \b OUT. 256 \return A boolean equal to \c true if all values are 257 strictly inferior than the associated minimal 258 mesh size delta_min 259 (stopping criterion MIN_MESH_SIZE). 260 */ 261 virtual bool get_delta ( NOMAD::Point & delta ) const ; 262 263 264 265 266 /// Access to the larget mesh size so far. 267 /** 268 \return delta_max The largest mesh size reached so far -- \b OUT. 269 */ 270 NOMAD::Point get_delta_max ( void ) const ; 271 272 /// Access to the poll size parameter Delta^k. 273 /** 274 \param Delta The poll size parameter Delta^k -- \b OUT. 275 \return A boolean equal to \c true if all values are 276 strictly inferior than the associated minimal 277 mesh size Delta_min 278 (stopping criterion MIN_POLL_SIZE). 279 */ 280 virtual bool get_Delta ( NOMAD::Point & Delta ) const ; 281 282 283 /// Check the stopping conditions on the minimal poll and mesh sizes. 284 /** 285 \param stop Stop flag -- \b IN/OUT. 286 \param stop_reason Stop reason -- \b OUT. 287 */ 288 void check_min_mesh_sizes ( bool & stop , 289 NOMAD::stop_type & stop_reason ) const; 290 /// Display. 291 /** 292 \param out The NOMAD::Display object -- \b IN. 293 */ 294 void display ( const NOMAD::Display & out ) const; 295 296 297 /// Scale and project the ith component of a vector on the mesh 298 /** 299 \param i The vector component number -- \b IN. 300 \param l The vector component value -- \b IN. 301 \return The ith component of a vector after mesh scaling and projection 302 */ 303 NOMAD::Double scale_and_project(int i, const NOMAD::Double & l) const ; 304 305 306 }; 307 } 308 309 #endif 310