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 Evaluator_Control.hpp 38 \brief Control of the blackbox evaluations (headers) 39 \author Sebastien Le Digabel 40 \date 2010-04-15 41 \see Evaluator_Control.cpp 42 */ 43 #ifndef __EVALUATOR_CONTROL__ 44 #define __EVALUATOR_CONTROL__ 45 46 #include "Barrier.hpp" 47 #include "Pareto_Front.hpp" 48 #include "Slave.hpp" 49 #include "Quad_Model.hpp" 50 51 #ifdef USE_TGP 52 #include "TGP_Model.hpp" 53 #endif 54 55 #ifdef R_VERSION 56 extern "C" { 57 #include <Rinternals.h> 58 } 59 #endif 60 61 62 namespace NOMAD { 63 64 /// Control of the blackbox evaluations. 65 /** 66 This class allows the evaluation of a list of trial point. 67 */ 68 class Evaluator_Control : private NOMAD::Uncopyable { 69 70 private: 71 72 static bool _force_quit; ///< Forces NOMAD to terminate if Ctrl-C is pressed. 73 static bool _force_evaluation_failure; ///< Forces an evaluation failure. 74 75 const NOMAD::Parameters & _p; ///< Parameters. 76 NOMAD::Evaluator * _ev; ///< The evaluator. 77 78 NOMAD::Cache * _cache; ///< Cache for true function evaluations. 79 NOMAD::Cache * _sgte_cache; ///< Cache for surrogate evaluations. 80 81 /// List of points to be evaluated. 82 std::set<NOMAD::Priority_Eval_Point> _eval_lop; 83 84 /// Flag to enable or disable the model ordering. 85 bool _model_eval_sort; 86 87 /// Flag equal to \c true if the destructor has to delete \c this->_ev. 88 bool _del_ev; 89 90 /// Flag equal to \c true if the destructor has to erase the cache. 91 bool _del_cache; 92 93 /// Flag equal to \c true if the destructor has to erase the cache for surrogates. 94 bool _del_sgte_cache; 95 96 #ifdef USE_MPI 97 NOMAD::Eval_Point ** _eval_in_progress; ///< List of evaluations in progress. 98 int _nb_in_progress; ///< Number of evaluations in progress. 99 100 /// Elop tag. 101 /** 102 Unique tag associated to \c this->eval_lop(). 103 */ 104 int _elop_tag; 105 106 /// Elop tag for each slave. 107 /** 108 _slaves_elop_tags[k] corresponds to the Elop tag for slave \c k. 109 */ 110 int * _slaves_elop_tags; 111 112 NOMAD::Slave * _slave; // Slave object for master process 113 #endif 114 115 #ifdef USE_TGP 116 NOMAD::TGP_Model * _last_TGP_model; ///< Last TGP model from the model search. 117 #endif 118 119 NOMAD::Model_Stats _model_ordering_stats; ///< Model ordering stats. 120 NOMAD::Stats & _stats; ///< Algorithm stats. 121 122 /** 123 - Lattest tag of a point that has been written for \c display_stats 124 or \c stats_file. 125 - It is used to avoid any double display at the end of a run. 126 */ 127 mutable int _last_stats_tag; 128 129 /// Same as \c this->_last_stats_bbe for the number of blackbox evaluations. 130 mutable int _last_stats_bbe; 131 132 /// Last entry in the history file to avoid cache hits. 133 mutable int _last_history_bbe; 134 135 /// Process an already evaluated Eval_Point. 136 /** 137 \param x The point -- \b IN. 138 \param barrier The barrier -- \b IN/OUT. 139 \param pareto_front The Pareto front -- \b IN/OUT 140 (may be NULL). 141 */ 142 void process_eval_point ( const NOMAD::Eval_Point & x , 143 NOMAD::Barrier & barrier , 144 NOMAD::Pareto_Front * pareto_front ) const; 145 146 /// Save the solution file or update the history file. 147 /** 148 \param file_name Name of the file -- \b IN. 149 \param x Lattest solution -- \b IN. 150 \param is_sol Flag equal to \c true if the file is 151 a solution file; otherwise it is a history file. 152 \param display_bimv Display best infeasible (min. viol.) if \c true 153 */ 154 void write_sol_or_his_file ( const std::string & file_name , 155 const NOMAD::Eval_Point & x , 156 bool is_sol , 157 bool display_bimv=false) const; 158 159 /// Display evaluation result. 160 /** 161 \param x Lattest evaluation -- \b IN. 162 \param display_degree Display degree -- \b IN. 163 \param search Search type -- \b IN. 164 \param one_eval_success Success for one evaluation -- \b IN. 165 \param success Success for a series of evaluations -- \b IN. 166 */ 167 void display_eval_result ( const NOMAD::Eval_Point & x , 168 NOMAD::dd_type display_degree , 169 NOMAD::search_type search , 170 NOMAD::success_type one_eval_success , 171 NOMAD::success_type success ) const; 172 173 /// Check if evaluations have to be stopped. 174 /** 175 Checks the opportunistic strategy stopping criterion. 176 \param x The lattest evaluation -- \b IN. 177 \param search Search type -- \b IN. 178 \param k Evaluation index -- \b IN. 179 \param nb_points Number of points to evaluate -- \b IN. 180 \param stop \c true if the algorithm has to be stopped -- \b IN. 181 \param display_degree Display degree -- \b IN. 182 \param one_eval_success Success for one evaluation -- \b IN. 183 \param success Success for a series of evaluations -- \b IN. 184 \param init_nb_eval Initial number of evaluations -- \b IN. 185 \param f0 Initial value of the objective function -- \b IN 186 (may be undefined). 187 \param barrier Barrier -- \b IN. 188 \param nb_success Number of successes -- \b IN/OUT. 189 \param one_for_luck \c true if one additional evaluation is made 190 according to parameter \c OPPORTUNISTIC_LUCKY_EVAL 191 -- \b IN/OUT. 192 */ 193 bool stop_evaluations ( const NOMAD::Eval_Point & x , 194 NOMAD::search_type search , 195 int k , 196 int nb_points , 197 bool stop , 198 NOMAD::dd_type display_degree , 199 NOMAD::success_type one_eval_success , 200 NOMAD::success_type success , 201 int init_nb_eval , 202 const NOMAD::Double & f0 , 203 const NOMAD::Barrier & barrier , 204 int & nb_success , 205 bool & one_for_luck ) const; 206 207 /// Check the opportunistic strategy stopping criterion. 208 /** 209 \param display_degree Display degree -- \b IN. 210 \param one_eval_success Success for one evaluation -- \b IN. 211 \param init_nb_eval Initial number of evaluations -- \b IN. 212 \param f0 Initial value of the objective function -- \b IN 213 (may be undefined). 214 \param barrier Barrier -- \b IN. 215 \param nb_success Number of successes -- \b IN/OUT. 216 \param one_for_luck \c true if one additional evaluation is made 217 according to parameter OPPORTUNISTIC_LUCKY_EVAL 218 -- \b IN/OUT. 219 \return A boolean equal to \c true to stop the evaluations; 220 Otherwise, continue the evaluations. 221 */ 222 bool check_opportunistic_criterion ( NOMAD::dd_type display_degree , 223 NOMAD::success_type one_eval_success , 224 int init_nb_eval , 225 const NOMAD::Double & f0 , 226 const NOMAD::Barrier & barrier , 227 int & nb_success , 228 bool & one_for_luck ) const; 229 230 /// Quadratic model ordering (parameter \c MODEL_EVAL_SORT). 231 /** 232 \param display_degree Display degree -- \b IN. 233 \param modified_list To indicate a change in the evaluation list -- \b OUT. 234 */ 235 void quad_model_ordering ( NOMAD::dd_type display_degree , 236 bool & modified_list ); 237 238 /// TGP model ordering (parameter \c MODEL_EVAL_SORT). 239 /** 240 \param display_degree Display degree -- \b IN. 241 \param modified_list To indicate a change in the evaluation list -- \b OUT. 242 */ 243 void TGP_model_ordering ( NOMAD::dd_type display_degree , 244 bool & modified_list ); 245 246 /// Count the output stats (STAT_SUM and STAT_AVG). 247 /** 248 \param x Lattest evaluation -- \b IN. 249 */ 250 void count_output_stats ( const NOMAD::Eval_Point & x ); 251 252 /// Search a point in the cache. 253 /** 254 \param x The point -- \b IN/OUT. 255 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 256 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 257 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 258 (may be \c NULL). 259 \param count_eval Count or not a simulated evaluation -- \b OUT. 260 \param h_max Maximal feasibility value -- \b IN. 261 \param display_degree Display degree -- \b IN. 262 \return A boolean equal to \c true if the point is in cache. 263 */ 264 bool cache_check ( const NOMAD::Eval_Point *& x , 265 NOMAD::Barrier & true_barrier , 266 NOMAD::Barrier & sgte_barrier , 267 NOMAD::Pareto_Front * pareto_front , 268 bool & count_eval , 269 const NOMAD::Double & h_max , 270 NOMAD::dd_type display_degree ) const; 271 272 /// Evaluate a point. 273 /* 274 \param x The point -- \b IN/OUT. 275 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 276 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 277 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 278 (may be \c NULL). 279 \param count_eval Count or not the evaluation -- \b OUT. 280 \param stop Stop flag -- \b IN/OUT. 281 \param stop_reason Stop reason -- \b OUT. 282 \param h_max Maximal feasibility value -- \b IN. 283 */ 284 void eval_point ( NOMAD::Eval_Point & x , 285 NOMAD::Barrier & true_barrier , 286 NOMAD::Barrier & sgte_barrier , 287 NOMAD::Pareto_Front * pareto_front , 288 bool & count_eval , 289 bool & stop , 290 NOMAD::stop_type & stop_reason , 291 const NOMAD::Double & h_max ); 292 293 294 295 /// Evaluate points. 296 /* 297 \param list_x The list of points -- \b IN/OUT. 298 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 299 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 300 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 301 (may be \c NULL). 302 \param list_count_eval A list of bool for counted evaluations -- \b OUT. 303 \param stop Stop flag -- \b IN/OUT. 304 \param stop_reason Stop reason -- \b OUT. 305 \param h_max Maximal feasibility value -- \b IN. 306 */ 307 void eval_points ( std::list<NOMAD::Eval_Point *> & list_x , 308 NOMAD::Barrier & true_barrier , 309 NOMAD::Barrier & sgte_barrier , 310 NOMAD::Pareto_Front * pareto_front , 311 std::list<bool> & list_count_eval , 312 bool & stop , 313 NOMAD::stop_type & stop_reason , 314 const NOMAD::Double & h_max ); 315 316 317 318 319 /// Check if a search is opportunistic or not. 320 /** 321 \param t Search type -- \b IN. 322 \return A boolean equal to \c true if the search is opportunistic. 323 */ 324 bool is_opportunistic ( NOMAD::search_type t ) const; 325 326 /// Check stopping criteria. 327 /** 328 \param search Search type -- \b IN. 329 \param count_eval Count or not the evaluation -- \b IN. 330 \param x Lattest evaluation -- \b IN/OUT. 331 \param stop Stop flag -- \b IN/OUT. 332 \param stop_reason Stop reason -- \b OUT. 333 */ 334 void check_stopping_criteria ( NOMAD::search_type search , 335 bool count_eval , 336 const NOMAD::Eval_Point & x , 337 bool & stop , 338 NOMAD::stop_type & stop_reason ) const; 339 340 #ifdef USE_MPI 341 342 /// Receive an evaluation result from a slave. 343 /** 344 \param search Search type -- \b IN. 345 \param x A pointer to the evaluation -- \b OUT. 346 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 347 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 348 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 349 (may be \c NULL). 350 \param slave_rank Slave rank -- \b IN. 351 \param stop Stop flag -- \b IN/OUT. 352 \param stop_reason Stop reason -- \b OUT. 353 */ 354 void receive_eval_result ( NOMAD::search_type search , 355 NOMAD::Eval_Point * x , 356 NOMAD::Barrier & true_barrier , 357 NOMAD::Barrier & sgte_barrier , 358 NOMAD::Pareto_Front * pareto_front , 359 int slave_rank , 360 bool & stop , 361 NOMAD::stop_type & stop_reason ); 362 363 /// Check if the evaluation of a point is already in progress. 364 /** 365 \param x The point -- \b IN. 366 \return A boolean equal to \c true if the evaluation 367 of the point is already in progress. 368 */ 369 bool already_in_progress ( const NOMAD::Eval_Point & x ) const; 370 371 #endif 372 373 /// Evaluate a list of points. 374 /** 375 - "Evaluate a list of points" is abbreviated with "eval_lop". 376 - This method is private and is called by the public eval_lop method. 377 - This method is defined twice in the .cpp for scalar and parallel versions. 378 - The method clears the list of points \c this->_eval_lop. 379 \param search Search type -- \b IN. 380 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 381 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 382 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 383 (may be \c NULL). 384 \param stop Stop flag -- \b IN/OUT. 385 \param stop_reason Stop reason -- \b OUT. 386 \param new_feas_inc Pointer to the new feasible incumbent -- \b OUT. 387 \param new_infeas_inc Pointer to the new infeasible incumbent -- \b OUT. 388 \param success Success for these evaluations -- \b OUT. 389 \param evaluated_pts List of processed points -- \b OUT. 390 */ 391 void private_eval_list_of_points 392 ( NOMAD::search_type search , 393 NOMAD::Barrier & true_barrier , 394 NOMAD::Barrier & sgte_barrier , 395 NOMAD::Pareto_Front * pareto_front , 396 bool & stop , 397 NOMAD::stop_type & stop_reason , 398 const NOMAD::Eval_Point *& new_feas_inc , 399 const NOMAD::Eval_Point *& new_infeas_inc , 400 NOMAD::success_type & success , 401 std::list<const NOMAD::Eval_Point *> & evaluated_pts ); 402 403 404 #ifdef MODEL_STATS 405 /// Display stats on an evaluation for which a model has been used. 406 /** 407 \param evaluated_pts List of evaluated points -- \b IN. 408 */ 409 void display_model_stats 410 ( const std::list<const NOMAD::Eval_Point *> & evaluated_pts ) const; 411 #endif 412 413 public: 414 415 /// Constructor. 416 /** 417 \param p Parameters -- \b IN. 418 \param stats Stats -- \b IN/OUT. 419 \param ev Pointer to the Evaluator -- \b IN (may be \c NULL). 420 \param cache Pointer to the cache -- \b IN/OUT (may be \c NULL). 421 \param sgte_cache Pointer to the surrogate cache -- \b IN/OUT (may be \c NULL). 422 */ 423 Evaluator_Control ( const NOMAD::Parameters & p , 424 NOMAD::Stats & stats , 425 NOMAD::Evaluator * ev , 426 NOMAD::Cache * cache , 427 NOMAD::Cache * sgte_cache ); 428 429 /// Destructor. 430 virtual ~Evaluator_Control ( void ); 431 432 /// Force quit (called by pressing Ctrl-C). force_quit(void)433 static void force_quit ( void ) 434 { 435 Evaluator_Control::_force_quit = true; 436 } 437 438 /// Force evaluation failure. force_evaluation_failure(void)439 static void force_evaluation_failure ( void ) 440 { 441 Evaluator_Control::_force_evaluation_failure = true; 442 } 443 444 445 /// Display in stats file according to parameter \c STATS_FILE. 446 /** 447 \param file_name Name of the output file -- \b IN. 448 \param x Pointer to the lattest evaluation -- \b IN (may be \c NULL). 449 \param feasible Equal to \c true if \c x is feasible -- \b IN. 450 \param multi_obj Pointer to several objective values -- \b IN (may be \c NULL). 451 */ 452 void stats_file ( const std::string & file_name , 453 const NOMAD::Eval_Point * x , 454 bool feasible , 455 const NOMAD::Point * multi_obj ) const; 456 457 /// Display stats during NOMAD::Mads::run() for minimal and normal display. 458 /** 459 \param header Boolean equal to \c true if a header has to be displayed 460 -- \b IN. 461 \param out Display -- \b IN. 462 \param stats List of stats to display -- \b IN. 463 \param x Pointer to the lattest evaluation -- \b IN (may be \c NULL). 464 \param feasible Equal to \c true if \c x is feasible -- \b IN. 465 \param multi_obj Pointer to several objective values -- \b IN (may be \c NULL). 466 */ 467 void display_stats ( bool header , 468 const NOMAD::Display & out , 469 const std::list<std::string> & stats , 470 const NOMAD::Eval_Point * x , 471 bool feasible , 472 const NOMAD::Point * multi_obj ) const; 473 474 /// Display a real according to parameter \c DISPLAY_STATS. 475 /** 476 \param out Display -- \b IN. 477 \param d The real to display -- \b IN. 478 \param format The format 479 -- \b IN -- \b optional (default = empty string). 480 */ 481 void display_stats_real ( const NOMAD::Display & out , 482 const NOMAD::Double & d , 483 const std::string & format = "" ) const; 484 485 /// Display a number according to its type \c DISPLAY_STATS. 486 /** 487 \param out Display -- \b IN. 488 \param d The number to display -- \b IN. 489 \param bbType The type to display -- \b IN. 490 */ 491 void display_stats_type ( const NOMAD::Display & out , 492 const NOMAD::Double & d , 493 const NOMAD::bb_input_type & bbType ) const; 494 495 /// Display an integer according to parameter \c DISPLAY_STATS. 496 /** 497 \param out Display -- \b IN. 498 \param i The integer to display -- \b IN. 499 \param max_i Maximal value of \c i used to determine the display width 500 -- \b IN -- \b optional (default = \c -1). 501 \param format The format 502 -- \b IN -- \b optional (default = empty string). 503 */ 504 void display_stats_int ( const NOMAD::Display & out , 505 int i , 506 int max_i = -1 , 507 const std::string & format = "" ) const; 508 509 /// Display a point according to parameter \c DISPLAY_STATS. 510 /** 511 \param out Display -- \b IN. 512 \param display_stats List of stats to display -- \b IN. 513 \param it Iterator for the list \c stats -- \b IN/OUT. 514 \param x Pointer to the point -- \b IN (may be \c NULL). 515 \param bbType Vector of input type -- \b IN -- \b optional (default = \c empty vector). 516 */ 517 void display_stats_point ( const NOMAD::Display & out , 518 const std::list<std::string> & display_stats , 519 std::list<std::string>::const_iterator & it , 520 const NOMAD::Point * x , 521 const std::vector<NOMAD::bb_input_type> & bbType = std::vector<NOMAD::bb_input_type> (0) ) const; 522 523 /// Display model ordering stats ( parameter \c MODEL_EVAL_SORT ). 524 /** 525 \param out Display -- \b IN. 526 */ display_model_ordering_stats(const NOMAD::Display & out) const527 void display_model_ordering_stats ( const NOMAD::Display & out ) const 528 { 529 out << _model_ordering_stats << std::endl; 530 } 531 532 /// Save the caches. 533 /** 534 \param overwrite A boolean equal to \c true if the cache files 535 may be overwritten -- \b IN. 536 \return A boolean equal to \c true if the caches could be saved. 537 */ 538 bool save_caches ( bool overwrite ); 539 540 /// Update the solution file. 541 /** 542 \param x The lattest solution -- \b IN. 543 \param display_bimv Required to display least infeasible (default=false) -- \b IN 544 */ 545 void write_solution_file ( const NOMAD::Eval_Point & x , bool display_bimv=false) const; 546 547 /// Update a barrier from another barrier. 548 /** 549 Update barrier \c b1 from points in barrier \c b2 and treat 550 these points as evaluations (used in VNS search). 551 \param b1 First barrier -- \b IN/OUT. 552 \param b2 Second barrier -- \b IN. 553 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 554 (may be \c NULL). 555 \param display_degree Display degree -- \b IN. 556 \param search Search type -- \b IN. 557 \return Success for these simulated evaluations. 558 */ 559 NOMAD::success_type process_barrier_points ( NOMAD::Barrier & b1 , 560 const NOMAD::Barrier & b2 , 561 NOMAD::Pareto_Front * pareto_front , 562 NOMAD::dd_type display_degree , 563 NOMAD::search_type search ) const; 564 /// Access to the cache (#1). 565 /** 566 Non-const version. 567 \return The cache. 568 */ get_cache(void)569 NOMAD::Cache & get_cache ( void ) { return *_cache; } 570 571 /// Access to the cache (#2). 572 /** 573 Const version. 574 \return The cache. 575 */ get_cache(void) const576 const NOMAD::Cache & get_cache ( void ) const { return *_cache; } 577 578 /// Access to the surrogate cache (#1). 579 /** 580 Non-const version. 581 \return The surrogate cache. 582 */ get_sgte_cache(void)583 NOMAD::Cache & get_sgte_cache ( void ) { return *_sgte_cache; } 584 585 /// Access to the surrogate cache (#2). 586 /** 587 Const version. 588 \return The surrogate cache. 589 */ get_sgte_cache(void) const590 const NOMAD::Cache & get_sgte_cache ( void ) const { return *_sgte_cache; } 591 592 /// Access to the evaluator. 593 /** 594 \return The evaluator. 595 */ get_evaluator(void) const596 NOMAD::Evaluator * get_evaluator ( void ) const { return _ev; } 597 598 /// Access to \c _last_stats_tag. 599 /** 600 \return \c _last_stats_tag. 601 */ get_last_stats_tag(void) const602 int get_last_stats_tag ( void ) const { return _last_stats_tag; } 603 604 /// Access to _last_stats_bbe. 605 /** 606 \return _last_stats_bbe. 607 */ get_last_stats_bbe(void) const608 int get_last_stats_bbe ( void ) const { return _last_stats_bbe; } 609 610 /// Set the evaluator. 611 /** 612 \param e A pointer to the evaluator -- \b IN. 613 */ set_evaluator(NOMAD::Evaluator * e)614 void set_evaluator ( NOMAD::Evaluator * e ) { _ev = e; } 615 616 #ifdef USE_TGP 617 /// Set the last TGP model from the model search. 618 /** 619 \param m The last TGP model -- \b IN. 620 */ set_last_TGP_model(NOMAD::TGP_Model * m)621 void set_last_TGP_model ( NOMAD::TGP_Model * m ) { _last_TGP_model = m; } 622 #endif 623 624 /// Reset. 625 void reset ( void ); 626 627 628 /// Order eval list of points based on surrogate (1st) or model (2nd) 629 /** 630 \param search Search type -- \b IN. 631 \param stop Stop flag -- \b IN/OUT. 632 \param stop_reason Stop reason -- \b OUT. 633 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 634 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 635 */ 636 void ordering_lop 637 ( NOMAD::search_type search , // IN : search type 638 bool & stop , 639 NOMAD::stop_type & stop_reason , 640 NOMAD::Barrier & true_barrier , // IN/OUT: truth barrier 641 NOMAD::Barrier & sgte_barrier // IN/OUT: surrogate barrier 642 ); 643 644 645 646 647 /// Evaluation of a list of points (public version that calls the private version). 648 /** 649 \param search Search type -- \b IN. 650 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 651 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 652 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 653 (may be \c NULL). 654 \param stop Stop flag -- \b IN/OUT. 655 \param stop_reason Stop reason -- \b OUT. 656 \param new_feas_inc Pointer to the new feasible incumbent -- \b OUT. 657 \param new_infeas_inc Pointer to the new infeasible incumbent -- \b OUT. 658 \param success Success for this series of evaluations -- \b OUT. 659 \param evaluated_pts List of processed points -- \b OUT. 660 */ 661 void eval_list_of_points 662 ( NOMAD::search_type search , 663 NOMAD::Barrier & true_barrier , 664 NOMAD::Barrier & sgte_barrier , 665 NOMAD::Pareto_Front * pareto_front , 666 bool & stop , 667 NOMAD::stop_type & stop_reason , 668 const NOMAD::Eval_Point *& new_feas_inc , 669 const NOMAD::Eval_Point *& new_infeas_inc , 670 NOMAD::success_type & success , 671 std::list<const NOMAD::Eval_Point *> * evaluated_pts = NULL ); 672 673 /// Add a point to the list of points to be evaluated. 674 /** 675 - The point has to be a dynamic object. 676 - It can be deleted into the method and be \c NULL after that. 677 - The point is also snapped to bounds. 678 - Periodic variables are checked. 679 \param x The point -- \b IN/OUT. 680 \param display_degree Display degree -- \b IN. 681 \param snap_to_bounds Boolean equal to \c true if the 682 point has to be snapped to bounds -- \b IN. 683 \param f_sgte Objective value for the surrogate -- \b IN 684 (may be undefined). 685 \param h_sgte Feasibility value for the surrogate -- \b IN 686 (may be undefined). 687 \param f_model Objective value for the model -- \b IN 688 (may be undefined). 689 \param h_model Feasibility value for the model -- \b IN 690 (may be undefined). 691 692 */ 693 void add_eval_point ( NOMAD::Eval_Point *& x , 694 NOMAD::dd_type display_degree , 695 bool snap_to_bounds , 696 const NOMAD::Double & f_sgte , 697 const NOMAD::Double & h_sgte , 698 const NOMAD::Double & f_model , 699 const NOMAD::Double & h_model ); 700 701 /// Display the list of evaluation points \c _eval_lop. 702 /** 703 \param t Search type -- \b IN 704 -- \b optional (default = NOMAD::UNDEFINED_SEARCH ). 705 */ 706 void display_eval_lop ( NOMAD::search_type t = NOMAD::UNDEFINED_SEARCH ) const; 707 708 /// Access to the number of evaluation points. 709 /** 710 \return The number of evaluation points. 711 */ get_nb_eval_points(void) const712 int get_nb_eval_points ( void ) const 713 { 714 return static_cast<int> ( _eval_lop.size() ); 715 } 716 717 /// Access to the list of evaluation points. 718 /** 719 \return The list of evaluation points. 720 */ get_eval_lop(void) const721 const std::set<NOMAD::Priority_Eval_Point> & get_eval_lop ( void ) const 722 { 723 return _eval_lop; 724 } 725 726 /// Clear the list of evaluation points. clear_eval_lop(void)727 void clear_eval_lop ( void ) { reduce_eval_lop(0); } 728 729 /// Reduce the list of evaluation points. 730 /** 731 \param n New size of the list -- \b IN. 732 */ 733 void reduce_eval_lop ( int n ); 734 735 /// Enable the model ordering. enable_model_eval_sort(void)736 void enable_model_eval_sort ( void ) { _model_eval_sort = true; } 737 738 /// Disable the model ordering. disable_model_eval_sort(void)739 void disable_model_eval_sort ( void ) { _model_eval_sort = false; } 740 741 #ifdef USE_MPI 742 743 /// Access to the number of evaluations in progress. 744 /** 745 \return the number of evaluations in progress. 746 */ get_nb_eval_in_progress(void) const747 int get_nb_eval_in_progress ( void ) const { return _nb_in_progress; } 748 749 /// Wait for evaluations in progress. 750 /** 751 \param search Search type -- \b IN. 752 \param true_barrier Barrier for true evaluations -- \b IN/OUT. 753 \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. 754 \param pareto_front A pointer to the Pareto front -- \b IN/OUT 755 (may be \c NULL). 756 \param stop Stop flag -- \b IN/OUT. 757 \param stop_reason Stop reason -- \b OUT. 758 \param success Success for these evaluations -- \b OUT. 759 \param evaluated_pts List of processed points -- \b OUT. 760 */ 761 void wait_for_evaluations ( NOMAD::search_type search , 762 NOMAD::Barrier & true_barrier , 763 NOMAD::Barrier & sgte_barrier , 764 NOMAD::Pareto_Front * pareto_front , 765 bool & stop , 766 NOMAD::stop_type & stop_reason , 767 NOMAD::success_type & success , 768 std::list<const NOMAD::Eval_Point *> 769 & evaluated_pts ); 770 #endif 771 }; 772 } 773 #endif 774