1 #ifndef __MASTER_SLAVES__ 2 #define __MASTER_SLAVES__ 3 4 #include "Cache_Server.hpp" 5 6 using namespace NOMAD; 7 using namespace std; 8 9 // Cache server: 10 class Master_Slaves { 11 12 private: 13 14 int _rank; // process rank 15 int _np; // number of processes 16 17 int _bbe; // max number of evaluations for each process 18 int _ns; // number of free variables for each process 19 20 Parameters & _p; // parameters 21 bool _debug; // debug display flag 22 23 static const int TAG_SIGNAL; 24 static const int TAG_I1; 25 static const int TAG_I2; 26 static const int TAG_R1; 27 static const int TAG_D1; 28 static const int TAG_CSTOP; 29 static char STOP_SIGNAL; 30 static char OPTI_RES_SIGNAL; 31 static char OPTI_DATA_SIGNAL; 32 33 // Receive an optimization result from the pollster: 34 void receive_optimization_result ( int & pollster_mesh_index , 35 bool & stop_algo , 36 double *& best_feasible , 37 double *& best_infeasible , 38 int source ) const; 39 40 // Send an optimization result to the master: 41 void send_optimization_result ( int pollster_mesh_index , 42 bool stop_algo , 43 const Eval_Point * bf , 44 const Eval_Point * bi , 45 stop_type st ) const; 46 47 // Send optimization data from the master to a slave: 48 void send_optimization_data ( int pollster_mesh_index , 49 bool stop_algo , 50 const double * best_feasible , 51 const double * best_infeasible , 52 int source ) const; 53 54 // Receive optimization data from the master: 55 void receive_optimization_data ( bool & stop_algo , 56 Point & x0 , 57 Double & fx0 ) const; 58 59 void receive_optimization_data ( bool & stop_algo , 60 Point & x0 , 61 Double & fx0 , 62 int & pollster_mesh_index , 63 int * free_vars ) const; 64 65 // Check the initial mesh size values: 66 static bool check_delta ( const Point & delta ); 67 68 public: 69 70 // Constructor: Master_Slaves(int rank,int np,int bbe,int ns,Parameters & p,bool debug)71 Master_Slaves ( int rank , 72 int np , 73 int bbe , 74 int ns , 75 Parameters & p , 76 bool debug ) 77 : _rank ( rank ) , 78 _np ( np ) , 79 _bbe ( bbe ) , 80 _ns ( ns ) , 81 _p ( p ) , 82 _debug ( debug ) {} 83 84 // Destructor: ~Master_Slaves(void)85 virtual ~Master_Slaves ( void ) {} 86 87 // Start the master: 88 void start ( void ) const; 89 90 // Stop the master: 91 void stop ( void ) const; 92 93 // MADS run: 94 void mads_run ( Cache & cache ); 95 96 }; 97 98 99 #endif 100