1 #ifndef __CACHE_SERVER__
2 #define __CACHE_SERVER__
3 
4 #include "mpi.h"
5 #include "nomad.hpp"
6 
7 using namespace NOMAD;
8 using namespace std;
9 
10 // Cache server:
11 class Cache_Server : public Cache {
12 
13 private:
14 
15   int                       _rank;             // process rank
16   int                       _np;               // number of processes
17 
18   bool                      _debug;            // debug display flag
19 
20   Clock                     _clock;            // clock
21 
22   Double                    _h_min;            // h_min (min feasibility)
23   int                       _max_bbe;          // max number of bb evaluations
24 
25   const Eval_Point        * _bf;               // best points
26   const Eval_Point        * _bi1;
27   const Eval_Point        * _bi2;
28 
29   Eval_Point              * _stop_point;       // stopping point
30 
31   mutable int               _multiple_evals;   // number of multiple evaluations
32   mutable int               _cache_hits;       // number of cache hits
33   mutable int               _cache_search_pts; // number of cache search points
34 
35   Point                  ** _waited_pts;      // list of points beeing evaluated
36   list<const Eval_Point*> * _clients_ext_pts; // replaces _extern_pts
37 
38   // process the best feasible point signal:
39   void process_bf_signal ( int source ) const;
40 
41   // process the extern point signal:
42   void process_ep_signal ( int source ) const;
43 
44   // process the find signal:
45   void process_find_signal ( int source ) const;
46 
47   // process the insertion signal:
48   void process_insert_signal ( int source );
49 
50   // update and display the best points:
51   void update_best_points ( const Eval_Point & x , int source );
52 
53 public:
54 
55   static const int  TAG_SIGNAL;
56   static const int  TAG_CACHE_HIT;
57   static const int  TAG_X1;
58   static const int  TAG_X2;
59   static const int  TAG_X3;
60   static const int  TAG_X4;
61   static const int  TAG_X5;
62   static const int  TAG_X6;
63   static const int  TAG_X7;
64   static const int  TAG_BBOR;
65   static const int  TAG_BBOC;
66   static const int  TAG_NB_EP;
67   static const int  TAG_EP;
68   static const int  TAG_BF;
69   static       char STOP_SIGNAL;
70   static       char FIND_SIGNAL;
71   static       char INSERT_SIGNAL;
72   static       char NB_EP_SIGNAL;
73   static       char EP_SIGNAL;
74   static       char BF_SIGNAL;
75 
76   // Constructor:
77   Cache_Server ( const Display & out                  ,
78 		 int             rank                 ,
79 		 int             np                   ,
80 		 const Double  & h_min                ,
81 		 int             max_bbe              ,
82 		 bool            allow_multiple_evals ,
83 		 bool            debug                  );
84 
85   // Destructor:
86   virtual ~Cache_Server ( void );
87 
88   // Start the server:
89   void start ( void );
90 
91   // Stop the server:
92   void stop ( void ) const;
93 
94   // Display the clients extern points:
display_extern_pts(void) const95   void display_extern_pts ( void ) const { display_extern_pts(_out); }
96   void display_extern_pts ( const Display & out ) const;
97 
98   // Display the best points:
display_best_points(void) const99   void display_best_points ( void ) const { display_best_points(_out); }
100   void display_best_points ( const Display & out ) const;
101 
102   // Display the current best solution:
103   void display_current_solution ( void ) const;
104 
105   // Find a point:
106   virtual const Eval_Point * find ( const Eval_Point & x ) const;
107 
108   // Insert a point:
109   virtual void insert ( const NOMAD::Eval_Point & x );
110 
111   // Get the number of extern points:
112   virtual int get_nb_extern_points ( void ) const;
113 
114   // Get and remove an extern point:
115   virtual const Eval_Point * get_and_remove_extern_point ( void ) const;
116 
117 };
118 
119 
120 #endif
121