- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 * Ted Ralphs, Lehigh University *
11 * *
12 * Conceptual Design: *
13 * *
14 * Yan Xu, Lehigh University *
15 * Ted Ralphs, Lehigh University *
16 * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17 * Matthew Saltzman, Clemson University *
18 * *
19 * *
20 * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21 *===========================================================================*/
22
23 #ifndef AlpsKnowledgeBrokerMPI_h_
24 #define AlpsKnowledgeBrokerMPI_h_
25
26 #include <cmath>
27 #include <iosfwd>
28
29 #undef SEEK_SET
30 #undef SEEK_END
31 #undef SEEK_CUR
32 #include "mpi.h"
33
34 #include "AlpsEnumProcessT.h"
35 #include "AlpsKnowledge.h"
36 #include "AlpsKnowledgeBroker.h"
37 #include "AlpsParams.h"
38
39 //#############################################################################
40
41 class AlpsKnowledgeBrokerMPI : public AlpsKnowledgeBroker {
42
43 private:
45 AlpsKnowledgeBrokerMPI(const AlpsKnowledgeBrokerMPI&);
46 AlpsKnowledgeBrokerMPI& operator=(const AlpsKnowledgeBrokerMPI&);
47
48 protected:
49
55 int processNum_;
56
58 int hubNum_;
59
61 int globalRank_;
62
64 MPI_Comm clusterComm_;
65
67 MPI_Comm hubComm_;
68
70 MPI_Group hubGroup_;
71
73 int clusterSize_;
74
76 int userClusterSize_;
77
79 int clusterRank_;
80
82 int* hubRanks_;
83
85 int myHubRank_;
86
88 int masterRank_;
89
91 AlpsProcessType processType_;
92
94 AlpsProcessType* processTypeList_;
95
97 bool hubWork_;
98
100 MPI_Request subTreeRequest_;
101
103 MPI_Request solRequestL_;
104 MPI_Request solRequestR_;
105
107 MPI_Request modelKnowRequestL_;
108 MPI_Request modelKnowRequestR_;
109
111 MPI_Request forwardRequestL_;
112 MPI_Request forwardRequestR_;
114
120 double incumbentValue_;
121
123 int incumbentID_;
124
127 bool updateIncumbent_;
129
135 double workQuality_;
136
138 double clusterWorkQuality_;
139
141 double systemWorkQuality_;
142
144 double* hubWorkQualities_;
145
148 double* workerWorkQualities_;
149
151 double workQuantity_;
152
154 double clusterWorkQuantity_;
155
157 double systemWorkQuantity_;
158
160 double systemWorkQuantityForce_;
161
163 double* hubWorkQuantities_;
164
167 double* workerWorkQuantities_;
168
170 bool* workerReported_;
171
173 bool* hubReported_;
174
176 bool allHubReported_;
177
179 int masterDoBalance_;
180
182 int hubDoBalance_;
183
185 int* workerNodeProcesseds_;
186
188 int clusterNodeProcessed_;
189
191 int* hubNodeProcesseds_;
193
199 int sendCount_;
200
202 int recvCount_;
203
206 int clusterSendCount_;
207
210 int clusterRecvCount_;
211
213 int systemSendCount_;
214
216 int systemRecvCount_;
218
223 int masterIndexBatch_;
225
231 AlpsTimer masterTimer_;
232
234 AlpsTimer hubTimer_;
235
237 AlpsTimer workerTimer_;
238
240 double rampUpTime_;
241
243 double rampDownTime_;
244
246 double idleTime_;
247
249 double msgTime_;
250
252 AlpsPsStats psStats_;
254
256 bool forceTerminate_;
257
259 bool blockTermCheck_;
260
262 bool blockHubReport_;
263
265 bool blockWorkerReport_;
266
268 bool blockAskForWork_;
269
271 char *attachBuffer_;
272
274 char *largeBuffer_;
275
277 char *largeBuffer2_;
278
280 char *smallBuffer_;
281
284 double masterBalancePeriod_;
285
288 double hubReportPeriod_;
289
291 int modelGenID_;
292
294 int modelGenPos_;
295
297 AlpsSubTree* rampUpSubTree_;
298
300 int unitWorkNodes_;
301
303 int haltSearch_;
304
305 protected:
306
308 void init();
309
316 void masterMain(AlpsTreeNode* root);
317
320 void hubMain();
321
324 void workerMain();
326
328 // The same subtree will be explored next time if it still have
329 // unexplored nodes.
330 AlpsReturnStatus doOneUnitWork(int unitWork,
331 double unitTime,
332 AlpsExitStatus & exitStatus,
333 int & numNodesProcessed,
334 int & numNodesBranched,
335 int & numNodesDiscarded,
336 int & numNodesPartial,
337 int & depth,
338 bool & betterSolution);
339
341 void processMessages(char *&buffer,
342 MPI_Status &status,
343 MPI_Request &request);
344
346 void rootInitMaster(AlpsTreeNode* root);
347 void rootInitHub();
348 void rootInitWorker();
349
351 void spiralMaster(AlpsTreeNode* root);
352 void spiralHub();
353 void spiralWorker();
354
355 //------------------------------------------------------
356
361 void masterAskHubDonate(int donorID,
362 int receiverID,
363 double receiverWorkload);
364
366 void hubAskWorkerDonate(int donorID,
367 int receiverID,
368 double receiverWorkload);
369
371 void updateWorkloadInfo();
372
373 virtual int getNumNodeLeftSystem()
374 { return static_cast<int>(systemWorkQuantity_); }
375
377 void donateWork(char*& buf,
378 int tag,
379 MPI_Status* status,
380 int recvID = -1,
381 double recvWL = 0.0);
382
384 void hubAllocateDonation(char*& buf, MPI_Status* status);
385
387 void hubBalanceWorkers();
388
390 void hubSatisfyWorkerRequest(char*& buf, MPI_Status* status);
391
393 // NOTE: comm is hubComm_ or MPI_COMM_WORLD.
394 void hubReportStatus(int tag, MPI_Comm comm);
395
397 // NOTE: comm is clusterComm_ or MPI_COMM_WORLD.
398 void hubUpdateCluStatus(char*& buf, MPI_Status* status, MPI_Comm comm);
399
401 void hubsShareWork(char*& buf, MPI_Status* status);
402
404 void masterBalanceHubs();
405
407 // NOTE: comm is hubComm or MPI_COMM_WORLD.
408 void masterUpdateSysStatus(char*& buf, MPI_Status* status, MPI_Comm comm);
409
411 void refreshSysStatus();
412
414 void refreshClusterStatus();
415
417 // NOTE: comm is clusterComm_ or MPI_COMM_WORLD.
418 void workerReportStatus(int tag, MPI_Comm comm);
420
421 //------------------------------------------------------
422
428 void workerAskIndices();
429
431 void workerRecvIndices(char *&bufLarge);
432
434 void masterSendIndices(char *&bufLarge);
436
437 //------------------------------------------------------
438
444 void broadcastModel(const int id, const int source);
445
447 void sendIncumbent();
448
451 bool unpackSetIncumbent(char*& buf, MPI_Status* status);
452
454 void collectBestSolution(int destination);
455
458 void tellMasterRecv();
459
462 // Not used
463 void tellHubRecv();
464
469 void packEncoded(AlpsEncoded* enc,
470 char*& buf,
471 int& size,
472 int& position,
473 MPI_Comm comm);
474
476 AlpsEncoded* unpackEncoded(char*& buf,
477 int& position,
478 MPI_Comm comm,
479 int size = -1);
480
483 // NOTE: comm is hubComm_ or clusterComm_
484 void receiveSizeBuf(char*& buf,
485 int sender,
486 int tag,
487 MPI_Comm comm,
488 MPI_Status* status);
489
492 // NOTE: comm is hubComm_ or clusterComm_
493 void receiveRampUpNode(int sender,
494 MPI_Comm comm,
495 MPI_Status* status);
496
499 void receiveSubTree(char*& buf, int sender, MPI_Status* status);
500
502 // NOTE: comm is hubComm_ or clusterComm_.
503 void sendSizeBuf(char*& buf,
504 int size,
505 int position,
506 const int target,
507 const int tag,
508 MPI_Comm comm);
509
512 // NOTE: comm is hubComm_ or clusterComm_.
513 void sendRampUpNode(const int target, MPI_Comm comm);
514
517 void sendNodeModelGen(int receiver, int doUnitWork);
518
520 bool sendSubTree(const int target, AlpsSubTree*& st, int tag);
521
523 // NOTE: comm is hubComm_ or clusterComm_.
524 void sendFinishInit(const int target, MPI_Comm comm);
526
528 void deleteSubTrees();
529
530
531 void forwardModelKnowledge();
532
534 // NOTE: comm is hubComm_ or MPI_COMM_WORLD.
535 void sendModelKnowledge(MPI_Comm comm, int receiver=-1);
536
538 // NOTE: comm is hubComm_ or MPI_COMM_WORLD.
539 void receiveModelKnowledge(MPI_Comm comm);
540
545 void incSendCount(const char* how, int s = 1);
547 void decSendCount(const char* how, int s = 1);
549 void incRecvCount(const char* how, int s = 1);
551 void decRecvCount(const char* how, int s = 1);
553
555 void masterForceHubTerm();
556
558 void hubForceWorkerTerm();
559
561 void changeWorkingSubTree(double & changeWorkThreshold);
562
564 void sendErrorCodeToMaster(int errorCode);
565
567 void recvErrorCode(char *& bufLarge);
568
570 void spiralRecvProcessNode();
571
573 void spiralDonateNode();
574
575 public:
576
579 AlpsKnowledgeBrokerMPI()
580 :
581 AlpsKnowledgeBroker()
582 {
583 init();
584 }
585
587 AlpsKnowledgeBrokerMPI(int argc,
588 char* argv[],
589 AlpsModel& model)
590 :
591 AlpsKnowledgeBroker()
592 {
593 init();
594 initializeSearch(argc, argv, model);
595 }
596
598 ~AlpsKnowledgeBrokerMPI();
599
601 virtual int getProcRank() const { return globalRank_; }
602
604 virtual int getMasterRank() const { return masterRank_; }
605
607 virtual AlpsProcessType getProcType() const { return processType_; }
608
621 void initializeSearch(int argc, char* argv[], AlpsModel& model);
622
624 void search(AlpsModel *model);
625
633 void rootSearch(AlpsTreeNode* root);
634
638 virtual double getIncumbentValue() const {
639 double bestObj = ALPS_OBJ_MAX;
640 if (AlpsKnowledgeBroker::hasKnowledge(AlpsKnowledgeTypeSolution)) {
641 bestObj = getBestKnowledge(AlpsKnowledgeTypeSolution).second;
642 if (incumbentValue_ > bestObj) {
643 return bestObj;
644 }
645 }
646 return incumbentValue_;
647 }
648
650 virtual double getBestQuality() const {
651 if (globalRank_ == masterRank_) {
652 if (getNumKnowledges(AlpsKnowledgeTypeSolution) > 0) {
653 return getBestKnowledge(AlpsKnowledgeTypeSolution).second;
654 }
655 else {
656 return ALPS_OBJ_MAX;
657 }
658 }
659 else {
660 return ALPS_OBJ_MAX;
661 }
662 }
663
665 virtual double getBestEstimateQuality() { return systemWorkQuality_; }
666
668 virtual void printBestSolution(char* outputFile = 0) const;
669
671 virtual void searchLog();
673
674 //------------------------------------------------------
675
680 void sendKnowledge(AlpsKnowledgeType type,
681 int sender,
682 int receiver,
683 char *& msgBuffer,
684 int msgSize,
685 int msgTag,
686 MPI_Comm comm,
687 bool blocking);
688
690 void receiveKnowledge(AlpsKnowledgeType type,
691 int sender,
692 int receiver,
693 char *& msgBuffer,
694 int msgSize,
695 int msgTag,
696 MPI_Comm comm,
697 MPI_Status* status,
698 bool blocking);
699
701 void requestKnowledge(AlpsKnowledgeType type,
702 int sender,
703 int receiver,
704 char *& msgBuffer,
705 int msgSize,
706 int msgTag,
707 MPI_Comm comm,
708 bool blocking);
710
711 };
712 #endif
713
714 //#############################################################################
AlpsKnowledgeBrokerMPI::masterTimer_
AlpsTimer masterTimer_
Master timer.
Definition: AlpsKnowledgeBrokerMPI.h:231
AlpsKnowledgeBrokerMPI::workerWorkQualities_
double * workerWorkQualities_
The workload qualities of workers in the cluster to which this proces belongs.
Definition: AlpsKnowledgeBrokerMPI.h:148
AlpsKnowledgeBrokerMPI::init
void init()
Initialize member data.
AlpsKnowledgeBrokerMPI::masterBalanceHubs
void masterBalanceHubs()
Master balance the workload of hubs.
AlpsKnowledgeBroker
The base class of knowledge broker class.
Definition: AlpsKnowledgeBroker.h:48
AlpsKnowledgeBrokerMPI::tellMasterRecv
void tellMasterRecv()
Inform master that a proc has received workload during a load balance initialized by master...
AlpsKnowledgeBrokerMPI::initializeSearch
void initializeSearch(int argc, char *argv[], AlpsModel &model)
This function.
AlpsKnowledgeBrokerMPI::workerMain
void workerMain()
Worker first receive subtrees, then start to explore them.
AlpsKnowledgeBrokerMPI::allHubReported_
bool allHubReported_
Indicate whether all hubs have reported status to master at least once.
Definition: AlpsKnowledgeBrokerMPI.h:176
AlpsKnowledgeBrokerMPI::clusterWorkQuantity_
double clusterWorkQuantity_
The workload quantity of the cluster to which the process belongs.
Definition: AlpsKnowledgeBrokerMPI.h:154
AlpsKnowledgeBrokerMPI::sendSubTree
bool sendSubTree(const int target, AlpsSubTree *&st, int tag)
Send a given subtree to the target process.
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::requestKnowledge
void requestKnowledge(AlpsKnowledgeType type, int sender, int receiver, char *&msgBuffer, int msgSize, int msgTag, MPI_Comm comm, bool blocking)
Request knowlege.
AlpsKnowledgeBrokerMPI::getNumNodeLeftSystem
virtual int getNumNodeLeftSystem()
Master asks a hub to donate its workload to another hub.
Definition: AlpsKnowledgeBrokerMPI.h:373
AlpsKnowledgeBrokerMPI::workerNodeProcesseds_
int * workerNodeProcesseds_
To record how many nodes processed for each worker in a cluster.
Definition: AlpsKnowledgeBrokerMPI.h:185
AlpsKnowledgeBrokerMPI::clusterSendCount_
int clusterSendCount_
The number of new messages sent by the processes in clusterComm_ after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:206
AlpsKnowledgeBrokerMPI::msgTime_
double msgTime_
The time spent processing messages (include idle).
Definition: AlpsKnowledgeBrokerMPI.h:249
AlpsKnowledgeBrokerMPI::hubReportPeriod_
double hubReportPeriod_
The period that a hub load balancing and report cluster status.
Definition: AlpsKnowledgeBrokerMPI.h:288
AlpsKnowledgeBrokerMPI::sendKnowledge
void sendKnowledge(AlpsKnowledgeType type, int sender, int receiver, char *&msgBuffer, int msgSize, int msgTag, MPI_Comm comm, bool blocking)
Set knowlege.
AlpsKnowledgeBrokerMPI::hubMain
void hubMain()
Hub generates subtrees and sends them to workers in Round-Robin way.
AlpsKnowledgeBrokerMPI::hubUpdateCluStatus
void hubUpdateCluStatus(char *&buf, MPI_Status *status, MPI_Comm comm)
A hub unpacks the status of a worker from buffer.
AlpsKnowledgeBrokerMPI::tellHubRecv
void tellHubRecv()
Inform hub that a proc has received workload during a load balance initialized by a hub...
ALPS_PS_STATS
Definition: Alps.h:179
AlpsKnowledgeBrokerMPI::blockWorkerReport_
bool blockWorkerReport_
Indicate whether a worker need to report state to its hub.
Definition: AlpsKnowledgeBrokerMPI.h:265
AlpsKnowledgeBrokerMPI::AlpsKnowledgeBrokerMPI
AlpsKnowledgeBrokerMPI()
Default construtor.
Definition: AlpsKnowledgeBrokerMPI.h:579
AlpsKnowledgeBrokerMPI::largeBuffer_
char * largeBuffer_
Large message buffer.
Definition: AlpsKnowledgeBrokerMPI.h:274
AlpsKnowledgeBrokerMPI::attachBuffer_
char * attachBuffer_
Buffer attached to MPI when sharing generated knowledge.
Definition: AlpsKnowledgeBrokerMPI.h:271
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.
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:118
AlpsKnowledgeBrokerMPI::getProcType
virtual AlpsProcessType getProcType() const
Query the type (master, hub, or worker) of the process.
Definition: AlpsKnowledgeBrokerMPI.h:607
AlpsKnowledgeBrokerMPI::clusterNodeProcessed_
int clusterNodeProcessed_
To record how many nodes by a cluster.
Definition: AlpsKnowledgeBrokerMPI.h:188
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...
AlpsKnowledgeBrokerMPI::clusterRank_
int clusterRank_
The local rank of the process in clusterComm_.
Definition: AlpsKnowledgeBrokerMPI.h:79
AlpsKnowledgeBrokerMPI::processType_
AlpsProcessType processType_
The AlpsProcessType of this process.
Definition: AlpsKnowledgeBrokerMPI.h:91
AlpsKnowledgeBrokerMPI::hubForceWorkerTerm
void hubForceWorkerTerm()
Hub tell workers to terminate due to reaching limits or other reason.
AlpsKnowledgeBrokerMPI::sendErrorCodeToMaster
void sendErrorCodeToMaster(int errorCode)
Send error code to master.
AlpsKnowledgeBrokerMPI::masterForceHubTerm
void masterForceHubTerm()
Master tell hubs to terminate due to reaching limits or other reason.
AlpsKnowledgeBrokerMPI::blockAskForWork_
bool blockAskForWork_
Indicate whether a worker need to as for work from its hub.
Definition: AlpsKnowledgeBrokerMPI.h:268
AlpsKnowledgeBrokerMPI::recvCount_
int recvCount_
The number of new messages received by the process after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:202
AlpsKnowledgeBrokerMPI::processNum_
int processNum_
The Number of processes launched.
Definition: AlpsKnowledgeBrokerMPI.h:55
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::search
void search(AlpsModel *model)
Search best solution for a given model.
AlpsKnowledgeBrokerMPI::clusterWorkQuality_
double clusterWorkQuality_
The workload quality of the cluster to which the process belong.
Definition: AlpsKnowledgeBrokerMPI.h:138
AlpsModel
Definition: AlpsModel.h:36
AlpsSubTree
This class contains the data pertaining to a particular subtree in the search tree.
Definition: AlpsSubTree.h:47
AlpsParams.h
AlpsEnumProcessT.h
AlpsKnowledgeBrokerMPI::hubAllocateDonation
void hubAllocateDonation(char *&buf, MPI_Status *status)
Hub allocates the donated workload to its workers.
AlpsKnowledgeBrokerMPI::smallBuffer_
char * smallBuffer_
Small message buffer.
Definition: AlpsKnowledgeBrokerMPI.h:280
AlpsKnowledgeBrokerMPI::receiveModelKnowledge
void receiveModelKnowledge(MPI_Comm comm)
Receive generated knowlege (related to model) from sender.
AlpsKnowledgeBrokerMPI::unpackEncoded
AlpsEncoded * unpackEncoded(char *&buf, int &position, MPI_Comm comm, int size=-1)
Unpack the given buffer into an AlpsEncoded instance.
AlpsKnowledgeBrokerMPI::systemWorkQuantityForce_
double systemWorkQuantityForce_
The workload quantity of the whole system before forcing termination.
Definition: AlpsKnowledgeBrokerMPI.h:160
AlpsKnowledgeBrokerMPI::masterIndexBatch_
int masterIndexBatch_
Definition: AlpsKnowledgeBrokerMPI.h:223
AlpsKnowledgeBrokerMPI::incumbentValue_
double incumbentValue_
Incumbent value.
Definition: AlpsKnowledgeBrokerMPI.h:120
AlpsKnowledgeBrokerMPI::solRequestL_
MPI_Request solRequestL_
Send model knoledge request.
Definition: AlpsKnowledgeBrokerMPI.h:103
AlpsKnowledgeBrokerMPI::hubSatisfyWorkerRequest
void hubSatisfyWorkerRequest(char *&buf, MPI_Status *status)
Hub satisfies the workload rquest from a worker.
AlpsKnowledgeBrokerMPI::decSendCount
void decSendCount(const char *how, int s=1)
Decrement the number of sent message.
AlpsKnowledgeBrokerMPI::changeWorkingSubTree
void changeWorkingSubTree(double &changeWorkThreshold)
Change subtree to be explored if it is too worse.
AlpsKnowledgeBrokerMPI::systemWorkQuality_
double systemWorkQuality_
The workload quality of the whole system.
Definition: AlpsKnowledgeBrokerMPI.h:141
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
AlpsKnowledgeBrokerMPI::rootInitWorker
void rootInitWorker()
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::modelKnowRequestR_
MPI_Request modelKnowRequestR_
The Number of processes launched.
Definition: AlpsKnowledgeBrokerMPI.h:108
AlpsKnowledgeBrokerMPI::largeBuffer2_
char * largeBuffer2_
Large message buffer.
Definition: AlpsKnowledgeBrokerMPI.h:277
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.
AlpsKnowledgeBrokerMPI::clusterSize_
int clusterSize_
The actual size of the cluster to which the process belongs.
Definition: AlpsKnowledgeBrokerMPI.h:73
AlpsKnowledgeBrokerMPI::modelKnowRequestL_
MPI_Request modelKnowRequestL_
Send model knoledge request.
Definition: AlpsKnowledgeBrokerMPI.h:107
AlpsKnowledgeBrokerMPI::masterSendIndices
void masterSendIndices(char *&bufLarge)
Master send a batch of node indices to the receiving worker.
AlpsKnowledgeBrokerMPI::spiralMaster
void spiralMaster(AlpsTreeNode *root)
Static load balancing: spiral.
AlpsKnowledgeBrokerMPI::masterRank_
int masterRank_
The global rank of the master.
Definition: AlpsKnowledgeBrokerMPI.h:88
AlpsKnowledgeBrokerMPI::hubDoBalance_
int hubDoBalance_
Whether a hub do load balance.
Definition: AlpsKnowledgeBrokerMPI.h:182
AlpsKnowledgeBrokerMPI::blockHubReport_
bool blockHubReport_
Indicate whether a hub need to report state to master.
Definition: AlpsKnowledgeBrokerMPI.h:262
AlpsKnowledgeBrokerMPI::sendFinishInit
void sendFinishInit(const int target, MPI_Comm comm)
Send finish initialization signal to the target process.
AlpsKnowledgeBrokerMPI::rampUpSubTree_
AlpsSubTree * rampUpSubTree_
A subtree used in during up.
Definition: AlpsKnowledgeBrokerMPI.h:297
AlpsKnowledgeBrokerMPI::decRecvCount
void decRecvCount(const char *how, int s=1)
Decrement the number of sent message.
AlpsKnowledgeBrokerMPI::rampUpTime_
double rampUpTime_
The time spent in ramp up.
Definition: AlpsKnowledgeBrokerMPI.h:240
AlpsKnowledgeBrokerMPI::hubBalanceWorkers
void hubBalanceWorkers()
Hub balances the workloads of its workers.
AlpsKnowledgeBrokerMPI::subTreeRequest_
MPI_Request subTreeRequest_
Send subtree request.
Definition: AlpsKnowledgeBrokerMPI.h:100
AlpsKnowledgeBrokerMPI::clusterComm_
MPI_Comm clusterComm_
Communicator of the cluster to which the process belongs.
Definition: AlpsKnowledgeBrokerMPI.h:64
AlpsKnowledgeBrokerMPI::systemSendCount_
int systemSendCount_
The total number of messages sent by the all processes.
Definition: AlpsKnowledgeBrokerMPI.h:213
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::AlpsKnowledgeBrokerMPI
AlpsKnowledgeBrokerMPI(int argc, char *argv[], AlpsModel &model)
Useful construtor.
Definition: AlpsKnowledgeBrokerMPI.h:587
AlpsProcessType
AlpsProcessType
This enumerative constant describes the various process types.
Definition: AlpsEnumProcessT.h:31
AlpsKnowledgeBrokerMPI::modelGenPos_
int modelGenPos_
Size of the shared knowledge.
Definition: AlpsKnowledgeBrokerMPI.h:294
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50
AlpsKnowledgeBrokerMPI::getMasterRank
virtual int getMasterRank() const
Query the global rank of the Master.
Definition: AlpsKnowledgeBrokerMPI.h:604
AlpsKnowledgeBrokerMPI::hubAskWorkerDonate
void hubAskWorkerDonate(int donorID, int receiverID, double receiverWorkload)
Hub asks a worker to donate its workload to another worker.
AlpsKnowledgeType
AlpsKnowledgeType
Definition: Alps.h:88
AlpsKnowledgeBrokerMPI::rootInitHub
void rootInitHub()
AlpsKnowledgeBrokerMPI::modelGenID_
int modelGenID_
The global rank of the process that share generated model knowledge.
Definition: AlpsKnowledgeBrokerMPI.h:291
AlpsKnowledgeBrokerMPI::workerReported_
bool * workerReported_
Indicate which worker has been reported its work.
Definition: AlpsKnowledgeBrokerMPI.h:170
AlpsKnowledgeBrokerMPI::forwardModelKnowledge
void forwardModelKnowledge()
AlpsKnowledgeBrokerMPI::broadcastModel
void broadcastModel(const int id, const int source)
Broadcast the model from source to other processes.
AlpsKnowledgeBrokerMPI
Definition: AlpsKnowledgeBrokerMPI.h:41
AlpsExitStatus
AlpsExitStatus
Definition: Alps.h:101
AlpsKnowledgeBrokerMPI::hubWorkQualities_
double * hubWorkQualities_
The workload qualities of hubs.
Definition: AlpsKnowledgeBrokerMPI.h:144
AlpsKnowledgeBrokerMPI::haltSearch_
int haltSearch_
Temporily halt search.
Definition: AlpsKnowledgeBrokerMPI.h:303
AlpsKnowledgeBrokerMPI::processTypeList_
AlpsProcessType * processTypeList_
The AlpsProcessType of all process.
Definition: AlpsKnowledgeBrokerMPI.h:94
AlpsKnowledgeBrokerMPI::hubReportStatus
void hubReportStatus(int tag, MPI_Comm comm)
A hub reports its status (workload and msg counts) to the master.
AlpsKnowledgeBrokerMPI::workerWorkQuantities_
double * workerWorkQuantities_
The workload quantities of workers in the cluster to which this proces belongs.
Definition: AlpsKnowledgeBrokerMPI.h:167
AlpsKnowledgeBrokerMPI::systemRecvCount_
int systemRecvCount_
The total number of messages sent by the all processes.
Definition: AlpsKnowledgeBrokerMPI.h:216
AlpsKnowledgeBrokerMPI::rootInitMaster
void rootInitMaster(AlpsTreeNode *root)
Static load balancing: Root Initialization.
AlpsKnowledgeBrokerMPI::collectBestSolution
void collectBestSolution(int destination)
Send the best solution from the process having it to destination.
AlpsKnowledgeBrokerMPI::myHubRank_
int myHubRank_
The global rank of its hub for a worker.
Definition: AlpsKnowledgeBrokerMPI.h:85
AlpsKnowledgeBrokerMPI::psStats_
AlpsPsStats psStats_
More statistics.
Definition: AlpsKnowledgeBrokerMPI.h:252
ALPS_OBJ_MAX
#define ALPS_OBJ_MAX
Definition: Alps.h:145
AlpsKnowledgeBrokerMPI::workQuantity_
double workQuantity_
The workload quantity of the workload on the process.
Definition: AlpsKnowledgeBrokerMPI.h:151
AlpsKnowledgeBrokerMPI::recvErrorCode
void recvErrorCode(char *&bufLarge)
Receive error code and set solution status.
AlpsKnowledgeBrokerMPI::sendCount_
int sendCount_
The number of new messages sent by the process after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:199
AlpsKnowledgeBrokerMPI::searchLog
virtual void searchLog()
Log search statistics.
AlpsKnowledgeBrokerMPI::workerRecvIndices
void workerRecvIndices(char *&bufLarge)
A worker receive node index from master.
AlpsKnowledge.h
AlpsKnowledgeBrokerMPI::incumbentID_
int incumbentID_
The process id that store the incumbent.
Definition: AlpsKnowledgeBrokerMPI.h:123
AlpsKnowledgeBrokerMPI::solRequestR_
MPI_Request solRequestR_
The Number of processes launched.
Definition: AlpsKnowledgeBrokerMPI.h:104
AlpsKnowledgeBrokerMPI::masterDoBalance_
int masterDoBalance_
Whether master do load balance.
Definition: AlpsKnowledgeBrokerMPI.h:179
AlpsKnowledgeBrokerMPI::hubGroup_
MPI_Group hubGroup_
MPI_Group consists of all hubs.
Definition: AlpsKnowledgeBrokerMPI.h:70
AlpsKnowledgeBrokerMPI::sendModelKnowledge
void sendModelKnowledge(MPI_Comm comm, int receiver=-1)
Set generated knowlege (related to model) to receiver.
AlpsKnowledgeBrokerMPI::spiralHub
void spiralHub()
AlpsKnowledgeBrokerMPI::packEncoded
void packEncoded(AlpsEncoded *enc, char *&buf, int &size, int &position, MPI_Comm comm)
Pack an AlpsEncoded instance into buf.
AlpsKnowledgeBrokerMPI::refreshSysStatus
void refreshSysStatus()
The master re-calculate the system status.
AlpsKnowledgeBrokerMPI::workQuality_
double workQuality_
The workload quality of the process.
Definition: AlpsKnowledgeBrokerMPI.h:135
AlpsKnowledgeBrokerMPI::userClusterSize_
int userClusterSize_
The user reqested size of a cluster.
Definition: AlpsKnowledgeBrokerMPI.h:76
AlpsKnowledgeBrokerMPI::workerTimer_
AlpsTimer workerTimer_
Worker timer.
Definition: AlpsKnowledgeBrokerMPI.h:237
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...
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::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::hubNodeProcesseds_
int * hubNodeProcesseds_
To record how many nodes processed for each hub.
Definition: AlpsKnowledgeBrokerMPI.h:191
AlpsKnowledgeBroker::getBestKnowledge
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge(AlpsKnowledgeType kt) const
Get the best knowledge in the given type of knowledge pools.
AlpsKnowledgeBrokerMPI::hubTimer_
AlpsTimer hubTimer_
Hub timer.
Definition: AlpsKnowledgeBrokerMPI.h:234
AlpsKnowledgeBrokerMPI::updateIncumbent_
bool updateIncumbent_
Indicate whether the incumbent value is updated between two checking point.
Definition: AlpsKnowledgeBrokerMPI.h:127
AlpsTimer
Definition: AlpsTime.h:75
AlpsKnowledgeBroker.h
AlpsKnowledgeBrokerMPI::masterAskHubDonate
void masterAskHubDonate(int donorID, int receiverID, double receiverWorkload)
Master asks a hub to donate its workload to another hub.
AlpsKnowledgeBrokerMPI::operator=
AlpsKnowledgeBrokerMPI & operator=(const AlpsKnowledgeBrokerMPI &)
AlpsKnowledgeBrokerMPI::sendNodeModelGen
void sendNodeModelGen(int receiver, int doUnitWork)
Send a node from rampUpSubTree&#39;s node pool and generated model knowledge.
AlpsKnowledgeBrokerMPI::printBestSolution
virtual void printBestSolution(char *outputFile=0) const
Master prints out the best solution that it knows.
AlpsKnowledgeBrokerMPI::hubReported_
bool * hubReported_
Indicate which hub has been reported its work.
Definition: AlpsKnowledgeBrokerMPI.h:173
AlpsKnowledgeBrokerMPI::getProcRank
virtual int getProcRank() const
Query the global rank of the process.
Definition: AlpsKnowledgeBrokerMPI.h:601
AlpsKnowledgeBrokerMPI::hubComm_
MPI_Comm hubComm_
Communicator consists of all hubs.
Definition: AlpsKnowledgeBrokerMPI.h:67
AlpsKnowledgeBrokerMPI::updateWorkloadInfo
void updateWorkloadInfo()
Calculate the work quality and quantity on this process.
AlpsKnowledgeBrokerMPI::hubWorkQuantities_
double * hubWorkQuantities_
The workload quantities of all clusters/hubs.
Definition: AlpsKnowledgeBrokerMPI.h:163
AlpsKnowledgeBrokerMPI::forceTerminate_
bool forceTerminate_
Terminate due to reaching limits (time and node) or other reason.
Definition: AlpsKnowledgeBrokerMPI.h:256
AlpsKnowledgeBrokerMPI::idleTime_
double idleTime_
The time spent waiting for work.
Definition: AlpsKnowledgeBrokerMPI.h:246
AlpsKnowledgeBrokerMPI::hubsShareWork
void hubsShareWork(char *&buf, MPI_Status *status)
Two hubs share their workload.
AlpsKnowledgeBrokerMPI::forwardRequestL_
MPI_Request forwardRequestL_
Forward model knoledge request.
Definition: AlpsKnowledgeBrokerMPI.h:111
AlpsKnowledgeBrokerMPI::sendIncumbent
void sendIncumbent()
Sent the incumbent value and rank to its two child if eixt.
AlpsKnowledgeBrokerMPI::getBestQuality
virtual double getBestQuality() const
The master queries the quality of the best solution it knowns.
Definition: AlpsKnowledgeBrokerMPI.h:650
AlpsKnowledgeBroker::hasKnowledge
virtual bool hasKnowledge(AlpsKnowledgeType kt) const
Query whether there are knowledges in the given type of knowledge pools.
Definition: AlpsKnowledgeBroker.h:363
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::hubWork_
bool hubWork_
Whether hub should also work as a worker.
Definition: AlpsKnowledgeBrokerMPI.h:97
AlpsKnowledgeBrokerMPI::clusterRecvCount_
int clusterRecvCount_
The number of new messages received by the processes in clusterComm_ after last survey.
Definition: AlpsKnowledgeBrokerMPI.h:210
AlpsKnowledgeBrokerMPI::spiralDonateNode
void spiralDonateNode()
Unpack msg and donate a node.
AlpsKnowledgeBrokerMPI::globalRank_
int globalRank_
The rank of the process in MPI_COMM_WORLD.
Definition: AlpsKnowledgeBrokerMPI.h:61
AlpsKnowledgeBrokerMPI::rootSearch
void rootSearch(AlpsTreeNode *root)
This function.
AlpsKnowledgeBrokerMPI::blockTermCheck_
bool blockTermCheck_
Indicate whether do termination check.
Definition: AlpsKnowledgeBrokerMPI.h:259
AlpsKnowledgeBrokerMPI::incRecvCount
void incRecvCount(const char *how, int s=1)
Increment the number of received message.
AlpsKnowledgeTypeSolution
Definition: Alps.h:92
AlpsKnowledgeBrokerMPI::forwardRequestR_
MPI_Request forwardRequestR_
The Number of processes launched.
Definition: AlpsKnowledgeBrokerMPI.h:112
AlpsKnowledgeBrokerMPI::rampDownTime_
double rampDownTime_
The time spent in ramp down.
Definition: AlpsKnowledgeBrokerMPI.h:243
AlpsKnowledgeBrokerMPI::hubNum_
int hubNum_
The Number of hubs.
Definition: AlpsKnowledgeBrokerMPI.h:58
AlpsKnowledgeBrokerMPI::refreshClusterStatus
void refreshClusterStatus()
A hub adds its status to the cluster&#39;s status.
AlpsKnowledgeBrokerMPI::deleteSubTrees
void deleteSubTrees()
Delete subTrees in pools and the active subtree.
AlpsKnowledgeBrokerMPI::masterMain
void masterMain(AlpsTreeNode *root)
Master generates subtrees and sends them to hubs in Round-Robin way.
AlpsKnowledgeBrokerMPI::getBestEstimateQuality
virtual double getBestEstimateQuality()
Get best estimalted quality in system.
Definition: AlpsKnowledgeBrokerMPI.h:665
AlpsKnowledgeBrokerMPI::getIncumbentValue
virtual double getIncumbentValue() const
The process queries the quality of the incumbent this process stores.
Definition: AlpsKnowledgeBrokerMPI.h:638
AlpsKnowledgeBroker::getNumKnowledges
virtual int getNumKnowledges(AlpsKnowledgeType kt) const
Query the number of knowledge in the given type of a knowledge pool.
AlpsKnowledgeBrokerMPI::~AlpsKnowledgeBrokerMPI
~AlpsKnowledgeBrokerMPI()
Destructor.
AlpsKnowledgeBrokerMPI::processMessages
void processMessages(char *&buffer, MPI_Status &status, MPI_Request &request)
Processing messages.
AlpsKnowledgeBrokerMPI::unitWorkNodes_
int unitWorkNodes_
Number of nodes in one unit of work.
Definition: AlpsKnowledgeBrokerMPI.h:300
AlpsKnowledgeBrokerMPI::spiralWorker
void spiralWorker()
AlpsKnowledgeBrokerMPI::spiralRecvProcessNode
void spiralRecvProcessNode()
Unpack the node, explore it and send load info to master.
AlpsKnowledgeBrokerMPI::masterBalancePeriod_
double masterBalancePeriod_
The period that master do load balancing.
Definition: AlpsKnowledgeBrokerMPI.h:284
AlpsKnowledgeBrokerMPI::systemWorkQuantity_
double systemWorkQuantity_
The workload quantity of the whole system.
Definition: AlpsKnowledgeBrokerMPI.h:157
AlpsKnowledgeBrokerMPI::hubRanks_
int * hubRanks_
The global ranks of the hubs.
Definition: AlpsKnowledgeBrokerMPI.h:82
AlpsKnowledgeBrokerMPI::workerReportStatus
void workerReportStatus(int tag, MPI_Comm comm)
A worker report its status (workload and msg counts) to its hub.