Alps  2.0.2
AlpsKnowledgeBrokerMPI.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the Abstract Library for Parallel Search (ALPS). *
3  * *
4  * ALPS is distributed under the Eclipse Public License as part of the *
5  * COIN-OR repository (http://www.coin-or.org). *
6  * *
7  * Authors: *
8  * *
9  * Yan Xu, Lehigh University *
10  * Aykut Bulut, Lehigh University *
11  * Ted Ralphs, Lehigh University *
12  * *
13  * Conceptual Design: *
14  * *
15  * Yan Xu, Lehigh University *
16  * Ted Ralphs, Lehigh University *
17  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
18  * Matthew Saltzman, Clemson University *
19  * *
20  * *
21  * Copyright (C) 2001-2023, Lehigh University, Yan Xu, Aykut Bulut, and *
22  * Ted Ralphs. *
23  * All Rights Reserved. *
24  *===========================================================================*/
25 
26 
27 #ifndef AlpsKnowledgeBrokerMPI_h_
28 #define AlpsKnowledgeBrokerMPI_h_
29 
30 #include <cmath>
31 #include <iosfwd>
32 
33 // #undef SEEK_SET
34 // #undef SEEK_END
35 // #undef SEEK_CUR
36 #include <mpi.h>
37 
38 #include "AlpsEnumProcessT.h"
39 #include "AlpsKnowledge.h"
40 #include "AlpsKnowledgeBroker.h"
41 #include "AlpsParams.h"
42 
43 //#############################################################################
44 
57 
58  private:
62 
63  protected:
64 
71 
73  int hubNum_;
74 
77 
79  MPI_Comm clusterComm_;
80 
82  MPI_Comm hubComm_;
83 
85  MPI_Group hubGroup_;
86 
89 
92 
95 
97  int* hubRanks_;
98 
101 
104 
107 
110 
112  bool hubWork_;
113 
115  MPI_Request subTreeRequest_;
116 
118  MPI_Request solRequestL_;
119  MPI_Request solRequestR_;
120 
122  MPI_Request modelKnowRequestL_;
123  MPI_Request modelKnowRequestR_;
124 
126  MPI_Request forwardRequestL_;
127  MPI_Request forwardRequestR_;
129 
136 
139 
144 
150  double workQuality_;
151 
154 
157 
160 
164 
167 
170 
173 
176 
179 
183 
186 
189 
192 
195 
198 
201 
204 
208 
215 
218 
222 
226 
229 
233 
240 
247 
250 
253 
255  double rampUpTime_;
256 
259 
261  double idleTime_;
262 
264  double msgTime_;
265 
269 
272 
275 
278 
281 
284 
287 
290 
293 
296 
300 
304 
307 
310 
313 
316 
319 
320  protected:
321 
323  void init();
324 
331  void masterMain(AlpsTreeNode* root);
332 
335  void hubMain();
336 
339  void workerMain();
341 
343  // The same subtree will be explored next time if it still have
344  // unexplored nodes.
345  AlpsReturnStatus doOneUnitWork(int unitWork,
346  double unitTime,
347  AlpsExitStatus & exitStatus,
348  int & numNodesProcessed,
349  int & numNodesBranched,
350  int & numNodesDiscarded,
351  int & numNodesPartial,
352  int & depth,
353  bool & betterSolution);
354 
356  void processMessages(char *&buffer,
357  MPI_Status &status,
358  MPI_Request &request);
359 
361  void rootInitMaster(AlpsTreeNode* root);
362  void rootInitHub();
363  void rootInitWorker();
364 
366  void spiralMaster(AlpsTreeNode* root);
367  void spiralHub();
368  void spiralWorker();
369 
370  //------------------------------------------------------
371 
376  void masterAskHubDonate(int donorID,
377  int receiverID,
378  double receiverWorkload);
379 
381  void hubAskWorkerDonate(int donorID,
382  int receiverID,
383  double receiverWorkload);
384 
386  void updateWorkloadInfo();
387 
388  virtual int getNumNodeLeftSystem()
389  { return static_cast<int>(systemWorkQuantity_); }
390 
392  void donateWork(char*& buf,
393  int tag,
394  MPI_Status* status,
395  int recvID = -1,
396  double recvWL = 0.0);
397 
399  void hubAllocateDonation(char*& buf, MPI_Status* status);
400 
402  void hubBalanceWorkers();
403 
405  void hubSatisfyWorkerRequest(char*& buf, MPI_Status* status);
406 
408  // NOTE: comm is hubComm_ or MPI_COMM_WORLD.
409  void hubReportStatus(int tag, MPI_Comm comm);
410 
412  // NOTE: comm is clusterComm_ or MPI_COMM_WORLD.
413  void hubUpdateCluStatus(char*& buf, MPI_Status* status, MPI_Comm comm);
414 
416  void hubsShareWork(char*& buf, MPI_Status* status);
417 
419  void masterBalanceHubs();
420 
422  // NOTE: comm is hubComm or MPI_COMM_WORLD.
423  void masterUpdateSysStatus(char*& buf, MPI_Status* status, MPI_Comm comm);
424 
426  void refreshSysStatus();
427 
429  void refreshClusterStatus();
430 
432  // NOTE: comm is clusterComm_ or MPI_COMM_WORLD.
433  void workerReportStatus(int tag, MPI_Comm comm);
435 
436  //------------------------------------------------------
437 
443  void workerAskIndices();
444 
446  void workerRecvIndices(char *&bufLarge);
447 
449  void masterSendIndices(char *&bufLarge);
451 
452  //------------------------------------------------------
453 
459  void broadcastModel(const int id, const int source);
460 
462  void sendIncumbent();
463 
466  bool unpackSetIncumbent(char*& buf, MPI_Status* status);
467 
469  void collectBestSolution(int destination);
470 
473  void tellMasterRecv();
474 
477  // Not used
478  void tellHubRecv();
479 
484  void packEncoded(AlpsEncoded* enc,
485  char*& buf,
486  int& size,
487  int& position,
488  MPI_Comm comm);
489 
491  AlpsEncoded* unpackEncoded(char*& buf,
492  int& position,
493  MPI_Comm comm,
494  int size = -1);
495 
498  // NOTE: comm is hubComm_ or clusterComm_
499  void receiveSizeBuf(char*& buf,
500  int sender,
501  int tag,
502  MPI_Comm comm,
503  MPI_Status* status);
504 
507  // NOTE: comm is hubComm_ or clusterComm_
508  void receiveRampUpNode(int sender,
509  MPI_Comm comm,
510  MPI_Status* status);
511 
514  void receiveSubTree(char*& buf, int sender, MPI_Status* status);
515 
517  // NOTE: comm is hubComm_ or clusterComm_.
518  void sendSizeBuf(char*& buf,
519  int size,
520  int position,
521  const int target,
522  const int tag,
523  MPI_Comm comm);
524 
527  // NOTE: comm is hubComm_ or clusterComm_.
528  void sendRampUpNode(const int target, MPI_Comm comm);
529 
532  void sendNodeModelGen(int receiver, int doUnitWork);
533 
535  bool sendSubTree(const int target, AlpsSubTree*& st, int tag);
536 
538  // NOTE: comm is hubComm_ or clusterComm_.
539  void sendFinishInit(const int target, MPI_Comm comm);
541 
543  void deleteSubTrees();
544 
545 
546  void forwardModelKnowledge();
547 
549  // NOTE: comm is hubComm_ or MPI_COMM_WORLD.
550  void sendModelKnowledge(MPI_Comm comm, int receiver=-1);
551 
553  // NOTE: comm is hubComm_ or MPI_COMM_WORLD.
554  void receiveModelKnowledge(MPI_Comm comm);
555 
560  void incSendCount(const char* how, int s = 1);
562  void decSendCount(const char* how, int s = 1);
564  void incRecvCount(const char* how, int s = 1);
566  void decRecvCount(const char* how, int s = 1);
568 
570  void masterForceHubTerm();
571 
573  void hubForceWorkerTerm();
574 
576  void changeWorkingSubTree(double & changeWorkThreshold);
577 
579  void sendErrorCodeToMaster(int errorCode);
580 
582  void recvErrorCode(char *& bufLarge);
583 
585  void spiralRecvProcessNode();
586 
588  void spiralDonateNode();
589 
590  public:
591 
595  :
597  {
598  init();
599  }
600 
603  char* argv[],
604  AlpsModel& model,
605  bool showBanner = true)
606  :
608  {
609  init();
610  initializeSearch(argc, argv, model, showBanner);
611  }
612 
615 
617  virtual int getProcRank() const { return globalRank_; }
618 
620  virtual int getMasterRank() const { return masterRank_; }
621 
623  virtual AlpsProcessType getProcType() const { return processType_; }
624 
637  void initializeSearch(int argc,
638  char* argv[],
639  AlpsModel& model,
640  bool showBanner = true);
641 
643  void search(AlpsModel *model);
644 
652  void rootSearch(AlpsTreeNode* root);
653 
657  virtual double getIncumbentValue() const {
658  double bestObj = ALPS_OBJ_MAX;
661  if (incumbentValue_ > bestObj) {
662  return bestObj;
663  }
664  }
665  return incumbentValue_;
666  }
667 
669  //todo(aykut) why not this returns to incumbentValue_
670  virtual double getBestQuality() const {
671  if (globalRank_ == masterRank_) {
674  }
675  else {
676  return ALPS_OBJ_MAX;
677  }
678  }
679  else {
680  return ALPS_OBJ_MAX;
681  }
682  }
683 
685  virtual double getBestEstimateQuality() { return systemWorkQuality_; }
686 
688  virtual void printBestSolution(char* outputFile = 0) const;
689 
691  virtual void searchLog();
693 
694  //------------------------------------------------------
695 
701  int sender,
702  int receiver,
703  char *& msgBuffer,
704  int msgSize,
705  int msgTag,
706  MPI_Comm comm,
707  bool blocking);
708 
711  int sender,
712  int receiver,
713  char *& msgBuffer,
714  int msgSize,
715  int msgTag,
716  MPI_Comm comm,
717  MPI_Status* status,
718  bool blocking);
719 
722  int sender,
723  int receiver,
724  char *& msgBuffer,
725  int msgSize,
726  int msgTag,
727  MPI_Comm comm,
728  bool blocking);
730 
731 };
732 #endif
733 
734 //#############################################################################
AlpsKnowledgeBrokerMPI::decSendCount
void decSendCount(const char *how, int s=1)
Decrement the number of sent message.
AlpsKnowledgeBrokerMPI::smallBuffer_
char * smallBuffer_
Small message buffer.
Definition: AlpsKnowledgeBrokerMPI.h:295
AlpsKnowledgeBrokerMPI::masterIndexBatch_
int masterIndexBatch_
Definition: AlpsKnowledgeBrokerMPI.h:238
AlpsKnowledgeBrokerMPI::blockHubReport_
bool blockHubReport_
Indicate whether a hub need to report state to master.
Definition: AlpsKnowledgeBrokerMPI.h:277
AlpsKnowledgeBrokerMPI::initializeSearch
void initializeSearch(int argc, char *argv[], AlpsModel &model, bool showBanner=true)
This function.
AlpsKnowledgeBrokerMPI::clusterNodeProcessed_
int clusterNodeProcessed_
To record how many nodes by a cluster.
Definition: AlpsKnowledgeBrokerMPI.h:203
AlpsKnowledgeBrokerMPI::forwardRequestR_
MPI_Request forwardRequestR_
Definition: AlpsKnowledgeBrokerMPI.h:127
AlpsKnowledgeBrokerMPI::workerAskIndices
void workerAskIndices()
A worker ask for node index from master.
AlpsKnowledgeBrokerMPI::incSendCount
void incSendCount(const char *how, int s=1)
Increment the number of sent message.
AlpsKnowledgeBrokerMPI::processNum_
int processNum_
The Number of processes launched.
Definition: AlpsKnowledgeBrokerMPI.h:70
AlpsKnowledgeBrokerMPI::processType_
AlpsProcessType processType_
The AlpsProcessType of this process.
Definition: AlpsKnowledgeBrokerMPI.h:106
AlpsKnowledge.h
AlpsKnowledgeBrokerMPI::receiveKnowledge
void receiveKnowledge(AlpsKnowledgeType type, int sender, int receiver, char *&msgBuffer, int msgSize, int msgTag, MPI_Comm comm, MPI_Status *status, bool blocking)
Receive knowlege.
AlpsKnowledgeBrokerMPI::hubMain
void hubMain()
Hub generates subtrees and sends them to workers in Round-Robin way.
AlpsKnowledgeBrokerMPI::spiralDonateNode
void spiralDonateNode()
Unpack msg and donate a node.
AlpsKnowledgeBrokerMPI::systemWorkQuantity_
double systemWorkQuantity_
The workload quantity of the whole system.
Definition: AlpsKnowledgeBrokerMPI.h:172
AlpsModel
AlpsModel is a base class for user application problem data.
Definition: AlpsModel.h:132
AlpsKnowledgeBrokerMPI::incumbentValue_
double incumbentValue_
Incumbent value.
Definition: AlpsKnowledgeBrokerMPI.h:135
AlpsKnowledgeBrokerMPI::init
void init()
Initialize member data.
AlpsKnowledgeBrokerMPI::sendIncumbent
void sendIncumbent()
Sent the incumbent value and rank to its two child if eixt.
AlpsKnowledgeBrokerMPI::receiveSizeBuf
void receiveSizeBuf(char *&buf, int sender, int tag, MPI_Comm comm, MPI_Status *status)
Receive the size of buffer, allocate memory for buffer, then receive the message and put it in buffer...
AlpsTimer
Definition: AlpsTime.h:64
AlpsKnowledgeBrokerMPI::hubNum_
int hubNum_
The Number of hubs.
Definition: AlpsKnowledgeBrokerMPI.h:73
AlpsKnowledgeBrokerMPI::deleteSubTrees
void deleteSubTrees()
Delete subTrees in pools and the active subtree.
AlpsKnowledgeBrokerMPI::rampDownTime_
double rampDownTime_
The time spent in ramp down.
Definition: AlpsKnowledgeBrokerMPI.h:258
AlpsKnowledgeBrokerMPI::hubForceWorkerTerm
void hubForceWorkerTerm()
Hub tell workers to terminate due to reaching limits or other reason.
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:261
AlpsKnowledgeBrokerMPI::~AlpsKnowledgeBrokerMPI
~AlpsKnowledgeBrokerMPI()
Destructor.
AlpsKnowledgeBroker.h
AlpsKnowledgeBrokerMPI::AlpsKnowledgeBrokerMPI
AlpsKnowledgeBrokerMPI()
Default construtor.
Definition: AlpsKnowledgeBrokerMPI.h:594
AlpsKnowledgeBrokerMPI::incRecvCount
void incRecvCount(const char *how, int s=1)
Increment the number of received message.
AlpsKnowledgeBrokerMPI::workerMain
void workerMain()
Worker first receive subtrees, then start to explore them.
AlpsKnowledgeBrokerMPI::blockWorkerReport_
bool blockWorkerReport_
Indicate whether a worker need to report state to its hub.
Definition: AlpsKnowledgeBrokerMPI.h:280
AlpsKnowledgeBrokerMPI::hubWork_
bool hubWork_
Whether hub should also work as a worker.
Definition: AlpsKnowledgeBrokerMPI.h:112
AlpsKnowledgeBrokerMPI::hubReported_
bool * hubReported_
Indicate which hub has been reported its work.
Definition: AlpsKnowledgeBrokerMPI.h:188
AlpsKnowledgeBrokerMPI::hubBalanceWorkers
void hubBalanceWorkers()
Hub balances the workloads of its workers.
AlpsKnowledgeBrokerMPI::sendNodeModelGen
void sendNodeModelGen(int receiver, int doUnitWork)
Send a node from rampUpSubTree's node pool and generated model knowledge.
AlpsKnowledgeBrokerMPI::tellMasterRecv
void tellMasterRecv()
Inform master that a proc has received workload during a load balance initialized by master.
AlpsKnowledgeBrokerMPI::solRequestL_
MPI_Request solRequestL_
Send model knoledge request.
Definition: AlpsKnowledgeBrokerMPI.h:118
AlpsKnowledgeBrokerMPI::hubRanks_
int * hubRanks_
The global ranks of the hubs.
Definition: AlpsKnowledgeBrokerMPI.h:97
AlpsKnowledgeBrokerMPI::workerWorkQualities_
double * workerWorkQualities_
The workload qualities of workers in the cluster to which this proces belongs.
Definition: AlpsKnowledgeBrokerMPI.h:163
AlpsKnowledgeBrokerMPI::masterTimer_
AlpsTimer masterTimer_
Master timer.
Definition: AlpsKnowledgeBrokerMPI.h:246
AlpsKnowledgeBrokerMPI::sendFinishInit
void sendFinishInit(const int target, MPI_Comm comm)
Send finish initialization signal to the target process.
AlpsKnowledgeBrokerMPI::masterDoBalance_
int masterDoBalance_
Whether master do load balance.
Definition: AlpsKnowledgeBrokerMPI.h:194
AlpsKnowledgeBroker::getNumKnowledges
virtual int getNumKnowledges(AlpsKnowledgeType kt) const
Query the number of knowledge in the given type of a knowledge pool.
AlpsKnowledgeBrokerMPI::msgTime_
double msgTime_
The time spent processing messages (include idle).
Definition: AlpsKnowledgeBrokerMPI.h:264
AlpsKnowledgeBrokerMPI::masterMain
void masterMain(AlpsTreeNode *root)
Master generates subtrees and sends them to hubs in Round-Robin way.
AlpsEncoded
Definition: AlpsEncoded.h:64
AlpsKnowledgeBrokerMPI::forceTerminate_
bool forceTerminate_
Terminate due to reaching limits (time and node) or other reason.
Definition: AlpsKnowledgeBrokerMPI.h:271
AlpsKnowledgeBrokerMPI::largeBuffer2_
char * largeBuffer2_
Large message buffer.
Definition: AlpsKnowledgeBrokerMPI.h:292
AlpsKnowledgeBrokerMPI::search
void search(AlpsModel *model)
Search best solution for a given model.
AlpsKnowledgeBrokerMPI::hubTimer_
AlpsTimer hubTimer_
Hub timer.
Definition: AlpsKnowledgeBrokerMPI.h:249
AlpsKnowledgeBrokerMPI::masterBalanceHubs
void masterBalanceHubs()
Master balance the workload of hubs.
AlpsProcessType
AlpsProcessType
This enumerative constant describes the various process types.
Definition: AlpsEnumProcessT.h:34
AlpsKnowledgeBrokerMPI::largeBuffer_
char * largeBuffer_
Large message buffer.
Definition: AlpsKnowledgeBrokerMPI.h:289
AlpsKnowledgeBrokerMPI::donateWork
void donateWork(char *&buf, int tag, MPI_Status *status, int recvID=-1, double recvWL=0.0)
A worker donate its workload to the specified worker.
AlpsKnowledgeBrokerMPI::AlpsKnowledgeBrokerMPI
AlpsKnowledgeBrokerMPI(int argc, char *argv[], AlpsModel &model, bool showBanner=true)
Useful construtor.
Definition: AlpsKnowledgeBrokerMPI.h:602
AlpsKnowledgeBrokerMPI::sendKnowledge
void sendKnowledge(AlpsKnowledgeType type, int sender, int receiver, char *&msgBuffer, int msgSize, int msgTag, MPI_Comm comm, bool blocking)
Set knowlege.
AlpsKnowledgeBrokerMPI::masterForceHubTerm
void masterForceHubTerm()
Master tell hubs to terminate due to reaching limits or other reason.
AlpsKnowledgeBrokerMPI::getMasterRank
virtual int getMasterRank() const
Query the global rank of the Master.
Definition: AlpsKnowledgeBrokerMPI.h:620
AlpsKnowledgeBrokerMPI::masterAskHubDonate
void masterAskHubDonate(int donorID, int receiverID, double receiverWorkload)
Master asks a hub to donate its workload to another hub.
AlpsKnowledgeBrokerMPI::unitWorkNodes_
int unitWorkNodes_
Number of nodes in one unit of work.
Definition: AlpsKnowledgeBrokerMPI.h:315
AlpsKnowledgeBrokerMPI::clusterRecvCount_
int clusterRecvCount_
The number of new messages received by the processes in clusterComm_ after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:225
AlpsKnowledgeBrokerMPI::spiralWorker
void spiralWorker()
AlpsKnowledgeBrokerMPI::spiralRecvProcessNode
void spiralRecvProcessNode()
Unpack the node, explore it and send load info to master.
AlpsKnowledgeBrokerMPI::getBestEstimateQuality
virtual double getBestEstimateQuality()
Get best estimalted quality in system.
Definition: AlpsKnowledgeBrokerMPI.h:685
AlpsKnowledgeBrokerMPI::broadcastModel
void broadcastModel(const int id, const int source)
Broadcast the model from source to other processes.
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:52
AlpsKnowledgeBrokerMPI::hubsShareWork
void hubsShareWork(char *&buf, MPI_Status *status)
Two hubs share their workload.
AlpsKnowledgeBrokerMPI::printBestSolution
virtual void printBestSolution(char *outputFile=0) const
Master prints out the best solution that it knows.
AlpsKnowledgeBrokerMPI::blockTermCheck_
bool blockTermCheck_
Indicate whether do termination check.
Definition: AlpsKnowledgeBrokerMPI.h:274
AlpsKnowledgeBrokerMPI::globalRank_
int globalRank_
The rank of the process in MPI_COMM_WORLD.
Definition: AlpsKnowledgeBrokerMPI.h:76
AlpsKnowledgeBrokerMPI::hubComm_
MPI_Comm hubComm_
Communicator consists of all hubs.
Definition: AlpsKnowledgeBrokerMPI.h:82
AlpsKnowledgeBrokerMPI::workerTimer_
AlpsTimer workerTimer_
Worker timer.
Definition: AlpsKnowledgeBrokerMPI.h:252
AlpsKnowledgeBrokerMPI::sendCount_
int sendCount_
The number of new messages sent by the process after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:214
AlpsKnowledgeBrokerMPI::getIncumbentValue
virtual double getIncumbentValue() const
The process queries the quality of the incumbent this process stores.
Definition: AlpsKnowledgeBrokerMPI.h:657
AlpsKnowledgeBrokerMPI::clusterWorkQuantity_
double clusterWorkQuantity_
The workload quantity of the cluster to which the process belongs.
Definition: AlpsKnowledgeBrokerMPI.h:169
AlpsKnowledgeBrokerMPI::workQuantity_
double workQuantity_
The workload quantity of the workload on the process.
Definition: AlpsKnowledgeBrokerMPI.h:166
AlpsKnowledgeBrokerMPI::getBestQuality
virtual double getBestQuality() const
The master queries the quality of the best solution it knowns.
Definition: AlpsKnowledgeBrokerMPI.h:670
AlpsKnowledgeBrokerMPI::recvCount_
int recvCount_
The number of new messages received by the process after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:217
AlpsKnowledgeBrokerMPI::hubUpdateCluStatus
void hubUpdateCluStatus(char *&buf, MPI_Status *status, MPI_Comm comm)
A hub unpacks the status of a worker from buffer.
AlpsKnowledgeBrokerMPI::processMessages
void processMessages(char *&buffer, MPI_Status &status, MPI_Request &request)
Processing messages.
AlpsKnowledgeBrokerMPI::workerReportStatus
void workerReportStatus(int tag, MPI_Comm comm)
A worker report its status (workload and msg counts) to its hub.
AlpsKnowledgeBrokerMPI::workerNodeProcesseds_
int * workerNodeProcesseds_
To record how many nodes processed for each worker in a cluster.
Definition: AlpsKnowledgeBrokerMPI.h:200
AlpsKnowledgeBrokerMPI::masterBalancePeriod_
double masterBalancePeriod_
The period that master do load balancing.
Definition: AlpsKnowledgeBrokerMPI.h:299
AlpsKnowledgeBrokerMPI::operator=
AlpsKnowledgeBrokerMPI & operator=(const AlpsKnowledgeBrokerMPI &)
AlpsKnowledgeBrokerMPI::getProcRank
virtual int getProcRank() const
Query the global rank of the process.
Definition: AlpsKnowledgeBrokerMPI.h:617
AlpsKnowledgeBrokerMPI::workQuality_
double workQuality_
The workload quality of the process.
Definition: AlpsKnowledgeBrokerMPI.h:150
AlpsKnowledgeBrokerMPI::haltSearch_
int haltSearch_
Temporily halt search.
Definition: AlpsKnowledgeBrokerMPI.h:318
AlpsKnowledgeBrokerMPI::processTypeList_
AlpsProcessType * processTypeList_
The AlpsProcessType of all process.
Definition: AlpsKnowledgeBrokerMPI.h:109
AlpsKnowledgeBrokerMPI::refreshClusterStatus
void refreshClusterStatus()
A hub adds its status to the cluster's status.
AlpsKnowledgeBrokerMPI::updateWorkloadInfo
void updateWorkloadInfo()
Calculate the work quality and quantity on this process.
AlpsKnowledgeBrokerMPI::rootInitHub
void rootInitHub()
AlpsKnowledgeBrokerMPI::hubWorkQuantities_
double * hubWorkQuantities_
The workload quantities of all clusters/hubs.
Definition: AlpsKnowledgeBrokerMPI.h:178
AlpsKnowledgeBrokerMPI::idleTime_
double idleTime_
The time spent waiting for work.
Definition: AlpsKnowledgeBrokerMPI.h:261
AlpsKnowledgeType
AlpsKnowledgeType
Type of knowledge like solution, node, cut...
Definition: Alps.h:223
AlpsKnowledgeBrokerMPI::receiveRampUpNode
void receiveRampUpNode(int sender, MPI_Comm comm, MPI_Status *status)
First receive the size and the contend of a node, then construct a subtree with this received node.
AlpsKnowledgeBrokerMPI::refreshSysStatus
void refreshSysStatus()
The master re-calculate the system status.
AlpsKnowledgeBrokerMPI::searchLog
virtual void searchLog()
Log search statistics.
AlpsKnowledgeBrokerMPI::hubGroup_
MPI_Group hubGroup_
MPI_Group consists of all hubs.
Definition: AlpsKnowledgeBrokerMPI.h:85
AlpsKnowledgeBrokerMPI::receiveSubTree
void receiveSubTree(char *&buf, int sender, MPI_Status *status)
Receive a subtree from the sender process and add it into the subtree pool.
AlpsExitStatus
AlpsExitStatus
Definition: Alps.h:244
AlpsKnowledgeBrokerMPI::collectBestSolution
void collectBestSolution(int destination)
Send the best solution from the process having it to destination.
ALPS_OBJ_MAX
#define ALPS_OBJ_MAX
Definition: Alps.h:288
AlpsKnowledgeBroker
The base class of knowledge broker class.
Definition: AlpsKnowledgeBroker.h:52
AlpsKnowledgeBrokerMPI::doOneUnitWork
AlpsReturnStatus doOneUnitWork(int unitWork, double unitTime, AlpsExitStatus &exitStatus, int &numNodesProcessed, int &numNodesBranched, int &numNodesDiscarded, int &numNodesPartial, int &depth, bool &betterSolution)
Explore a subtree from subtree pool for certain units of work/time.
AlpsKnowledgeBrokerMPI::packEncoded
void packEncoded(AlpsEncoded *enc, char *&buf, int &size, int &position, MPI_Comm comm)
Pack an AlpsEncoded instance into buf.
AlpsKnowledgeBrokerMPI::clusterSize_
int clusterSize_
The actual size of the cluster to which the process belongs.
Definition: AlpsKnowledgeBrokerMPI.h:88
AlpsKnowledgeBrokerMPI::rootSearch
void rootSearch(AlpsTreeNode *root)
This function.
AlpsKnowledgeBrokerMPI::systemRecvCount_
int systemRecvCount_
The total number of messages sent by the all processes.
Definition: AlpsKnowledgeBrokerMPI.h:231
AlpsKnowledgeBrokerMPI::rootInitWorker
void rootInitWorker()
AlpsKnowledgeBrokerMPI::subTreeRequest_
MPI_Request subTreeRequest_
Send subtree request.
Definition: AlpsKnowledgeBrokerMPI.h:115
AlpsKnowledgeBrokerMPI::masterUpdateSysStatus
void masterUpdateSysStatus(char *&buf, MPI_Status *status, MPI_Comm comm)
Master unpack the status of a hub from buf and update system status.
AlpsKnowledgeBrokerMPI::sendModelKnowledge
void sendModelKnowledge(MPI_Comm comm, int receiver=-1)
Set generated knowlege (related to model) to receiver.
AlpsKnowledgeBrokerMPI::systemWorkQuality_
double systemWorkQuality_
The workload quality of the whole system.
Definition: AlpsKnowledgeBrokerMPI.h:156
AlpsKnowledgeBrokerMPI::systemWorkQuantityForce_
double systemWorkQuantityForce_
The workload quantity of the whole system before forcing termination.
Definition: AlpsKnowledgeBrokerMPI.h:175
AlpsKnowledgeBrokerMPI::workerReported_
bool * workerReported_
Indicate which worker has been reported its work.
Definition: AlpsKnowledgeBrokerMPI.h:185
AlpsKnowledgeBrokerMPI::recvErrorCode
void recvErrorCode(char *&bufLarge)
Receive error code and set solution status.
AlpsKnowledgeBrokerMPI::userClusterSize_
int userClusterSize_
The user reqested size of a cluster.
Definition: AlpsKnowledgeBrokerMPI.h:91
AlpsKnowledgeBrokerMPI::masterRank_
int masterRank_
The global rank of the master.
Definition: AlpsKnowledgeBrokerMPI.h:103
AlpsKnowledgeBrokerMPI::modelGenPos_
int modelGenPos_
Size of the shared knowledge.
Definition: AlpsKnowledgeBrokerMPI.h:309
AlpsKnowledgeBrokerMPI::workerRecvIndices
void workerRecvIndices(char *&bufLarge)
A worker receive node index from master.
AlpsEnumProcessT.h
ALPS_PS_STATS
Definition: Alps.h:322
AlpsKnowledgeBrokerMPI::masterSendIndices
void masterSendIndices(char *&bufLarge)
Master send a batch of node indices to the receiving worker.
AlpsKnowledgeBrokerMPI::modelKnowRequestR_
MPI_Request modelKnowRequestR_
Definition: AlpsKnowledgeBrokerMPI.h:123
AlpsKnowledgeBrokerMPI::workerWorkQuantities_
double * workerWorkQuantities_
The workload quantities of workers in the cluster to which this proces belongs.
Definition: AlpsKnowledgeBrokerMPI.h:182
AlpsKnowledgeBrokerMPI::hubReportStatus
void hubReportStatus(int tag, MPI_Comm comm)
A hub reports its status (workload and msg counts) to the master.
AlpsKnowledgeBrokerMPI::clusterComm_
MPI_Comm clusterComm_
Communicator of the cluster to which the process belongs.
Definition: AlpsKnowledgeBrokerMPI.h:79
AlpsKnowledgeBrokerMPI::systemSendCount_
int systemSendCount_
The total number of messages sent by the all processes.
Definition: AlpsKnowledgeBrokerMPI.h:228
AlpsKnowledgeBrokerMPI::rampUpTime_
double rampUpTime_
The time spent in ramp up.
Definition: AlpsKnowledgeBrokerMPI.h:255
AlpsKnowledgeBrokerMPI::myHubRank_
int myHubRank_
The global rank of its hub for a worker.
Definition: AlpsKnowledgeBrokerMPI.h:100
AlpsKnowledgeBrokerMPI::forwardRequestL_
MPI_Request forwardRequestL_
Forward model knoledge request.
Definition: AlpsKnowledgeBrokerMPI.h:126
AlpsKnowledgeBrokerMPI::spiralHub
void spiralHub()
AlpsKnowledgeBrokerMPI::incumbentID_
int incumbentID_
The process id that store the incumbent.
Definition: AlpsKnowledgeBrokerMPI.h:138
AlpsKnowledgeBrokerMPI::tellHubRecv
void tellHubRecv()
Inform hub that a proc has received workload during a load balance initialized by a hub.
AlpsKnowledgeBrokerMPI::hubWorkQualities_
double * hubWorkQualities_
The workload qualities of hubs.
Definition: AlpsKnowledgeBrokerMPI.h:159
AlpsKnowledgeBrokerMPI::forwardModelKnowledge
void forwardModelKnowledge()
AlpsKnowledgeBrokerMPI::rampUpSubTree_
AlpsSubTree * rampUpSubTree_
A subtree used in during up.
Definition: AlpsKnowledgeBrokerMPI.h:312
AlpsKnowledgeBrokerMPI::hubAllocateDonation
void hubAllocateDonation(char *&buf, MPI_Status *status)
Hub allocates the donated workload to its workers.
AlpsKnowledgeBrokerMPI::clusterSendCount_
int clusterSendCount_
The number of new messages sent by the processes in clusterComm_ after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:221
AlpsKnowledgeBrokerMPI::decRecvCount
void decRecvCount(const char *how, int s=1)
Decrement the number of sent message.
AlpsKnowledgeBrokerMPI::hubAskWorkerDonate
void hubAskWorkerDonate(int donorID, int receiverID, double receiverWorkload)
Hub asks a worker to donate its workload to another worker.
AlpsKnowledgeBrokerMPI::hubNodeProcesseds_
int * hubNodeProcesseds_
To record how many nodes processed for each hub.
Definition: AlpsKnowledgeBrokerMPI.h:206
AlpsSubTree
This class contains the data pertaining to a particular subtree in the search tree.
Definition: AlpsSubTree.h:51
AlpsKnowledgeBrokerMPI::modelKnowRequestL_
MPI_Request modelKnowRequestL_
Send model knoledge request.
Definition: AlpsKnowledgeBrokerMPI.h:122
AlpsKnowledgeBrokerMPI::spiralMaster
void spiralMaster(AlpsTreeNode *root)
Static load balancing: spiral.
AlpsKnowledgeBrokerMPI::clusterWorkQuality_
double clusterWorkQuality_
The workload quality of the cluster to which the process belong.
Definition: AlpsKnowledgeBrokerMPI.h:153
AlpsKnowledgeBrokerMPI::unpackSetIncumbent
bool unpackSetIncumbent(char *&buf, MPI_Status *status)
unpack the incumbent value, then store it and the id of the process having the incumbent in AlpsDataP...
AlpsParams.h
AlpsKnowledgeBrokerMPI::getNumNodeLeftSystem
virtual int getNumNodeLeftSystem()
Definition: AlpsKnowledgeBrokerMPI.h:388
AlpsKnowledgeBrokerMPI::sendSizeBuf
void sendSizeBuf(char *&buf, int size, int position, const int target, const int tag, MPI_Comm comm)
Send the size and content of a buffer to the target process.
AlpsKnowledgeBrokerMPI::psStats_
AlpsPsStats psStats_
More statistics.
Definition: AlpsKnowledgeBrokerMPI.h:267
AlpsKnowledgeBrokerMPI::attachBuffer_
char * attachBuffer_
Buffer attached to MPI when sharing generated knowledge.
Definition: AlpsKnowledgeBrokerMPI.h:286
AlpsKnowledgeBrokerMPI::hubSatisfyWorkerRequest
void hubSatisfyWorkerRequest(char *&buf, MPI_Status *status)
Hub satisfies the workload rquest from a worker.
AlpsKnowledgeBrokerMPI::changeWorkingSubTree
void changeWorkingSubTree(double &changeWorkThreshold)
Change subtree to be explored if it is too worse.
AlpsKnowledgeBrokerMPI::sendSubTree
bool sendSubTree(const int target, AlpsSubTree *&st, int tag)
Send a given subtree to the target process.
AlpsKnowledgeBrokerMPI::sendRampUpNode
void sendRampUpNode(const int target, MPI_Comm comm)
Send the size and the content of the best node of a given subtree to the target process.
AlpsKnowledgeBrokerMPI::solRequestR_
MPI_Request solRequestR_
Definition: AlpsKnowledgeBrokerMPI.h:119
AlpsKnowledgeBrokerMPI::modelGenID_
int modelGenID_
The global rank of the process that share generated model knowledge.
Definition: AlpsKnowledgeBrokerMPI.h:306
AlpsKnowledgeBrokerMPI::unpackEncoded
AlpsEncoded * unpackEncoded(char *&buf, int &position, MPI_Comm comm, int size=-1)
Unpack the given buffer into an AlpsEncoded instance.
AlpsKnowledgeBrokerMPI::updateIncumbent_
bool updateIncumbent_
Indicate whether the incumbent value is updated between two checking point.
Definition: AlpsKnowledgeBrokerMPI.h:142
AlpsKnowledgeBrokerMPI::hubReportPeriod_
double hubReportPeriod_
The period that a hub load balancing and report cluster status.
Definition: AlpsKnowledgeBrokerMPI.h:303
AlpsKnowledgeBroker::hasKnowledge
virtual bool hasKnowledge(AlpsKnowledgeType kt) const
Query whether there are knowledges in the given type of knowledge pools.
Definition: AlpsKnowledgeBroker.h:311
AlpsKnowledgeBrokerMPI::hubDoBalance_
int hubDoBalance_
Whether a hub do load balance.
Definition: AlpsKnowledgeBrokerMPI.h:197
AlpsKnowledgeBrokerMPI::clusterRank_
int clusterRank_
The local rank of the process in clusterComm_.
Definition: AlpsKnowledgeBrokerMPI.h:94
AlpsKnowledgeBrokerMPI::receiveModelKnowledge
void receiveModelKnowledge(MPI_Comm comm)
Receive generated knowlege (related to model) from sender.
AlpsKnowledgeTypeSolution
@ AlpsKnowledgeTypeSolution
Definition: Alps.h:228
AlpsKnowledgeBrokerMPI::sendErrorCodeToMaster
void sendErrorCodeToMaster(int errorCode)
Send error code to master.
AlpsKnowledgeBrokerMPI::allHubReported_
bool allHubReported_
Indicate whether all hubs have reported status to master at least once.
Definition: AlpsKnowledgeBrokerMPI.h:191
AlpsKnowledgeBrokerMPI::requestKnowledge
void requestKnowledge(AlpsKnowledgeType type, int sender, int receiver, char *&msgBuffer, int msgSize, int msgTag, MPI_Comm comm, bool blocking)
Request knowlege.
AlpsKnowledgeBroker::getBestKnowledge
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge(AlpsKnowledgeType kt) const
Get the best knowledge in the given type of knowledge pools.
AlpsKnowledgeBrokerMPI::rootInitMaster
void rootInitMaster(AlpsTreeNode *root)
Static load balancing: Root Initialization.
AlpsKnowledgeBrokerMPI::getProcType
virtual AlpsProcessType getProcType() const
Query the type (master, hub, or worker) of the process.
Definition: AlpsKnowledgeBrokerMPI.h:623
AlpsKnowledgeBrokerMPI::blockAskForWork_
bool blockAskForWork_
Indicate whether a worker need to as for work from its hub.
Definition: AlpsKnowledgeBrokerMPI.h:283
AlpsKnowledgeBrokerMPI
MPI implementation of AlpsKnowledgeBroker interface.
Definition: AlpsKnowledgeBrokerMPI.h:56