Scippy

UG

Ubiquity Generator framework

bbParaSolver.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and software framework */
4 /* UG --- Ubquity Generator Framework */
5 /* */
6 /* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7 /* Copyright (C) 2021 by Zuse Institute Berlin, */
8 /* licensed under LGPL version 3 or later. */
9 /* Commercial licenses are available through <licenses@zib.de> */
10 /* */
11 /* This code is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public License */
13 /* as published by the Free Software Foundation; either version 3 */
14 /* of the License, or (at your option) any later version. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 /* */
24 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25 
26 /**@file paraSolver.cpp
27  * @brief Base class for solver: Generic parallelized solver.
28  * @author Yuji Shinano
29  *
30  *
31  *
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 
37 #include <cstdlib>
38 #include <cfloat>
39 #include <climits>
40 #include <cassert>
41 #include <algorithm>
42 #include "ug/paraComm.h"
43 #include "ug/paraTask.h"
44 #include "ug/paraInstance.h"
45 #include "ug/paraSolution.h"
47 #include "bbParaCalculationState.h"
48 #include "bbParaSolverState.h"
49 #include "bbParaSolver.h"
50 #include "bbParaComm.h"
51 #include "bbParaNodePool.h"
52 
53 using namespace UG;
54 
56  int argc,
57  char **argv,
58  int inNHandlers,
59  ParaComm *comm,
60  ParaParamSet *inParaParamSet,
61  ParaInstance *inParaInstance,
62  ParaDeterministicTimer *inParaDetTimer
63  )
64  : ParaSolver(argc, argv, inNHandlers, comm, inParaParamSet, inParaInstance, inParaDetTimer),
65  globalBestDualBoundValueAtWarmStart(-DBL_MAX),
66  globalBestCutOffValue(DBL_MAX),
67  lcBestDualBoundValue(-DBL_MAX),
68  collectingMode(false),
69  aggressiveCollecting(false),
70  nSendInCollectingMode(0),
71  nCollectOnce(0),
72  collectingManyNodes(false),
73  collectingInterrupt(false),
74  anotherNodeIsRequested(false),
75  lightWeightRootNodeComputation(false),
76  onceBreak(false),
77  rootNodeTime(0.0),
78  totalRootNodeTime(0.0),
79  minRootNodeTime(DBL_MAX),
80  maxRootNodeTime(-DBL_MAX),
81  nSolved(0),
82  nSent(0),
83  nSolvedWithNoPreprocesses(0),
84  totalNSolved(0),
85  minNSolved(INT_MAX),
86  maxNSolved(INT_MIN),
87  nTransferredLocalCutsFromSolver(0),
88  minTransferredLocalCutsFromSolver(INT_MAX),
89  maxTransferredLocalCutsFromSolver(INT_MIN),
90  nTransferredBendersCutsFromSolver(0),
91  minTransferredBendersCutsFromSolver(INT_MAX),
92  maxTransferredBendersCutsFromSolver(INT_MIN),
93  nTotalRestarts(0),
94  minRestarts(INT_MAX),
95  maxRestarts(INT_MIN),
96  totalNSent(0),
97  totalNImprovedIncumbent(0),
98  nParaNodesSolvedAtRoot(0),
99  nParaNodesSolvedAtPreCheck(0),
100  nSimplexIterRoot(0),
101  nTransferredLocalCuts(0),
102  minTransferredLocalCuts(INT_MAX),
103  maxTransferredLocalCuts(INT_MIN),
104  nTransferredBendersCuts(0),
105  minTransferredBendersCuts(INT_MAX),
106  maxTransferredBendersCuts(INT_MIN),
107  nTightened(0),
108  nTightenedInt(0),
109  minIisum(DBL_MAX),
110  maxIisum(0.0),
111  minNii(INT_MAX),
112  maxNii(0),
113  targetBound(-DBL_MAX),
114  nTransferLimit(-1),
115  nTransferredNodes(-1),
116  solverDualBound(-DBL_MAX),
117  averageDualBoundGain(0.0),
118  enoughGainObtained(true),
119  givenGapIsReached(false),
120  testDualBoundGain(false),
121  noWaitModeSend(false),
122  keepRacing(false),
123  restartingRacing(false),
124  localIncumbentIsChecked(false),
125  selfSplitNodePool(0)
126 {
127  /** create timer for this BbParaSolver */
128 
129  BbMessageHandlerFunctionPointer *bbMessageHandler = reinterpret_cast<BbMessageHandlerFunctionPointer *>(messageHandler);
130 
131  bbMessageHandler[TagTask] = &UG::BbParaSolver::processTagTask;
134  bbMessageHandler[TagNoNodes] = &UG::BbParaSolver::processTagNoNodes;
146  bbMessageHandler[TagRestart] = &UG::BbParaSolver::processTagRestart;
150  {
153  }
157 
159  {
161  }
162 
164  {
165  paraParams->setIntParamValue(RampUpPhaseProcess, 0); // it should work with normal ramp-up
166  }
167 
168  if( paraParams->getIntParamValue(RampUpPhaseProcess) == 3 ) // self-split ramp-up
169  {
171  }
172 }
173 
174 void
176  )
177 {
178  double stopTime = paraTimer->getElapsedTime();
182 
183  double detTime = -1.0;
184 
185  DEF_BB_PARA_COMM(bbParaComm, paraComm);
186 
187  BbParaSolverTerminationState *paraSolverTerminationState = dynamic_cast<BbParaSolverTerminationState *>(bbParaComm->createParaSolverTerminationState(
188  interrupted,
189  paraComm->getRank(),
190  totalNSolved,
191  minNSolved,
192  maxNSolved,
193  totalNSent,
206  minRestarts,
207  maxRestarts,
208  nTightened,
209  calcTermState,
211  stopTime,
221  detTime ));
222  paraSolverTerminationState->send(paraComm, 0, TagTerminated);
223  delete paraSolverTerminationState;
224 
225 }
226 
227 void
229  )
230 {
231  // PARA_COMM_CALL(
232  // paraComm->receive( NULL, 0, ParaBYTE, 0, TagSelfSplitFinished )
233  // );
234  // Node で
235  // 貰ったルートの一つ下
237  paraComm->send( NULL, 0, ParaBYTE, 0, TagSelfSplitFinished )
238  );
239  return;
240 }
241 
242 
243 int
245  int source,
246  int tag
247  )
248 {
249 
250  DEF_BB_PARA_COMM(bbParaComm, paraComm);
251 
252  if( currentTask )
253  {
254  newTask = bbParaComm->createParaTask();
255  newTask->receive(bbParaComm, source);
256  if( dynamic_cast<BbParaNode *>(newTask)->getMergingStatus() == 3 ) // This means, the received node is separated
257  {
258  dynamic_cast<BbParaNode *>(newTask)->setMergingStatus(-1);
259  }
260  }
261  else
262  {
263  currentTask = bbParaComm->createParaTask();
264  currentTask->receive(bbParaComm, source);
265  if( dynamic_cast<BbParaNode *>(currentTask)->getMergingStatus() == 3 ) // This means, the received node is separated
266  {
267  dynamic_cast<BbParaNode *>(currentTask)->setMergingStatus(-1);
268  }
269  }
270  anotherNodeIsRequested = false;
272  if( keepRacing )
273  {
274  assert(!winnerRacingParams);
275  }
276  return 0;
277 }
278 
279 int
281  int source,
282  int tag
283  )
284 {
286  paraComm->receive( NULL, 0, ParaBYTE, source, TagTaskReceived )
287  );
288  return 0;
289 }
290 
291 int
293  int source,
294  int tag
295  )
296 {
298  paraComm->receive( NULL, 0, ParaBYTE, source, TagRampUp)
299  );
300  // if( isRacingStage() )
301  // {
302  // assert(!racingWinner);
303  // }
304  rampUp = true;
305  // testDualBoundGain = false;
306  enoughGainObtained = true;
307 
308 #ifdef _DEBUG_CHECK_RECEIVE
309  std::cout << paraTimer->getElapsedTime() << " Solver" << paraComm->getRank() << " received TagRampUp" << std::endl;
310 #endif
311 
314  racingWinner )
315  {
316  return 0;
317  }
318 
319  // if( racingWinner ) // when the winner solver switches to normal ramp up without collecting nodes, this is necessary
320  // {
321  // setOriginalNodeSelectionStrategy();
322  // }
324  collectingManyNodes = false;
325  collectingMode = false;
326  aggressiveCollecting = false;
328  noWaitModeSend = false;
329  return 0;
330 }
331 
332 int
334  int source,
335  int tag
336  )
337 {
339  sol->receive(paraComm, source);
341  // sometime it is necessary to save the solution in solver side
342  // updateGlobalBestIncumbentValue( sol->getObjectiveFuntionValue() ) ) // DO NOT UPDATE!!
343  // The timing of the update depends on solver used
344  {
345  if( pendingSolution )
346  {
347  delete pendingSolution;
348  }
349  pendingSolution = sol;
351  }
352  else
353  {
354  delete sol;
355  }
356  return 0;
357 }
358 
359 int
361  int source,
362  int tag
363  )
364 {
365  double incumbent;
367  paraComm->receive( &incumbent, 1, ParaDOUBLE, source, TagIncumbentValue)
368  );
370  {
371  if( incumbent < globalBestIncumbentValue && incumbent < pendingIncumbentValue )
372  {
373  pendingIncumbentValue = incumbent;
374  }
375  }
376  else
377  {
379  }
380 
381  //
382  // should not do as follows: LC does not know which nodes were removed
383  //
384  // if( selfSplitNodePool )
385  // {
386  // selfSplitNodePool->removeBoundedNodes(incumbent);
387  // }
388  return 0;
389 }
390 
391 int
393  int source,
394  int tag
395  )
396 {
397  assert(notificationProcessed);
398  unsigned int notificationId;
400  paraComm->receive( &notificationId, 1, ParaUNSIGNED, source, TagNotificationId)
401  );
402  if( notificationId == notificationIdGenerator) notificationProcessed = false;
403  else {
404  THROW_LOGICAL_ERROR4("notificationId received is ", notificationId, ", but generator value is ", notificationIdGenerator);
405  }
406  return 0;
407 }
408 
409 int
411  int source,
412  int tag
413  )
414 {
416  paraComm->receive( NULL, 0, ParaBYTE, source, TagTerminateRequest)
417  );
418 // std::cout << "Solver" << paraComm->getRank() << " received exitSolverRequest" << std::endl;
420  stayAliveAfterInterrupt = false;
421  return 0;
422 }
423 
424 int
426  int source,
427  int tag
428  )
429 {
430  /* received racing parameter set is always winner one,
431  * because the initail racing parameter set is broadcasted. */
435  );
437  if( isRacingStage() )
438  {
439  assert(!racingWinner);
440  racingIsInterrupted = true;
441  }
442 #ifdef _DEBUG_CHECK_RECEIVE
443  std::cout << paraTimer->getElapsedTime() << " Solver" << paraComm->getRank() << " received racing winner params" << std::endl;
444 #endif
445  return 0;
446 }
447 
448 int
450  int source,
451  int tag
452  )
453 {
455  paraComm->receive( NULL, 0, ParaBYTE, source, TagWinner)
456  );
457  racingWinner = true;
458  assert(!winnerRacingParams);
459  winnerRacingParams = racingParams; // LC does not send racing param to winner
460  racingParams = 0; // No racing stage now
461  return 0;
462 }
463 
464 int
466  int source,
467  int tag
468  )
469 {
471  int token[2];
473  paraComm->receive( token, 2, ParaINT, source, TagToken )
474  );
475  paraComm->setToken(paraComm->getRank(), token);
476  return 0;
477 }
478 
479 int
481  int source,
482  int tag
483  )
484 {
486  paraComm->receive( NULL, 0, ParaBYTE, source, TagRetryRampUp)
487  );
488  rampUp = false;
489  /* RetryRampUp did not work for rmine10 44th run */
490  /* Then, added the following four lines */
491  collectingMode = false;
492  aggressiveCollecting = false;
494  noWaitModeSend = false;
495  /* end of the four lines */
496  return 0;
497 }
498 
499 int
501  int source,
502  int tag
503  )
504 {
507  );
508  return 0;
509 }
510 
511 int
513  int source,
514  int tag
515  )
516 {
518  paraComm->receive( NULL, 0, ParaBYTE, source, TagNoNodes)
519  );
520  anotherNodeIsRequested = false;
521  return 0;
522 }
523 
524 int
526  int source,
527  int tag
528  )
529 {
532  );
533  if( nSendInCollectingMode < 0 )
534  {
536  aggressiveCollecting = true;
537  }
538  collectingMode = true;
539 
541  {
542  if( selfSplitNodePool->getNumOfNodes() >= 2 ||
543  ( selfSplitNodePool->getNumOfNodes() > 0 && getNNodesLeft() > 0 ) )
544  {
547  // std::cout << "Trans NODE (inCollecting): " << node->toSimpleString() << std::endl;
548  delete node;
549  if( selfSplitNodePool->isEmpty() )
550  {
551  // DO NOT delete below, since it shows that current solving node is generated by self-split ramp-up
552 // delete selfSplitNodePool;
553 // selfSplitNodePool = 0;
554  }
555  }
556  }
557 
558  return 0;
559 }
560 
561 int
563  int source,
564  int tag
565  )
566 {
569  );
570  collectingManyNodes = true;
571  noWaitModeSend = true;
572  return 0;
573 }
574 
575 int
577  int source,
578  int tag
579  )
580 {
582  paraComm->receive( NULL, 0, ParaBYTE, source, TagOutCollectingMode)
583  );
585  {
586  // if this solver is in Ttermination mode, the following function cannot be called
588  }
589  collectingMode = false;
590  aggressiveCollecting = false;
592  noWaitModeSend = false;
593  return 0;
594 }
595 
596 int
598  int source,
599  int tag
600  )
601 {
604  );
605  return 0;
606 }
607 
608 int
610  int source,
611  int tag
612  )
613 {
614 // std::cout << paraTimer->getElapsedTime() << " Solver" << paraComm->getRank() << " received TagInterruptRequest" << std::endl;
615 
616  int exitSolverRequest;
618  paraComm->receive( &exitSolverRequest, 1, ParaINT, source, TagInterruptRequest)
619  );
620 
623 
624 // std::cout << "Solver" << paraComm->getRank() << " received TagInterruptRequest with exitSolverRequest = " << exitSolverRequest << std::endl;
625 
626  if( exitSolverRequest == 1 )
627  {
628  collectingInterrupt = true;
631  noWaitModeSend = true;
632  }
633  else
634  {
635  if( exitSolverRequest == 2 )
636  {
638  }
639  else
640  {
641  stayAliveAfterInterrupt = false;
642  }
643  }
644 
645  if( keepRacing )
646  {
648  }
649 
650  if( selfSplitNodePool )
651  {
652  while( !selfSplitNodePool->isEmpty() )
653  {
655  delete node;
656  }
657  }
658 
659  return 0;
660 }
661 
662 int
664  int source,
665  int tag
666  )
667 {
670  );
673  return 0;
674 }
675 
676 int
678  int source,
679  int tag
680  )
681 {
684  );
687  );
688  nTransferredNodes = 0;
689  collectingManyNodes = true;
690  return 0;
691 }
692 
693 int
695  int source,
696  int tag
697  )
698 {
700  paraComm->receive( NULL, 0, ParaBYTE, source, TagGivenGapIsReached )
701  );
703  stayAliveAfterInterrupt = false;
704  givenGapIsReached = true;
705  return 0;
706 }
707 
708 int
710  int source,
711  int tag
712  )
713 {
716  );
717  testDualBoundGain = true;
718  enoughGainObtained = true;
719  return 0;
720 }
721 
722 int
724  int source,
725  int tag
726  )
727 {
729  paraComm->receive( NULL, 0, ParaBYTE, source, TagNoTestDualBoundGain )
730  );
731  testDualBoundGain = false;
732  enoughGainObtained = true;
733  return 0;
734 }
735 
736 int
738  int source,
739  int tag
740  )
741 {
743  paraComm->receive( NULL, 0, ParaBYTE, source, TagNoWaitModeSend )
744  );
745  noWaitModeSend = true;
746  return 0;
747 }
748 
749 int
751  int source,
752  int tag
753  )
754 {
756  paraComm->receive( NULL, 0, ParaBYTE, source, TagRestart )
757  );
758  stayAliveAfterInterrupt = false;
760  rampUp = false;
761  return 0;
762 }
763 
764 int
766  int source,
767  int tag
768  )
769 {
770  return lbBoundTightened(source, tag);
771 }
772 
773 int
775  int source,
776  int tag
777  )
778 {
779  return ubBoundTightened(source, tag);
780 }
781 
782 int
784  int source,
785  int tag
786  )
787 {
788  double cutOffValue;
790  paraComm->receive( &cutOffValue, 1, ParaDOUBLE, source, TagCutOffValue)
791  );
792  updateGlobalBestCutOffValue(cutOffValue);
793  return 0;
794 }
795 
796 int
798  int source,
799  int tag
800  )
801 {
802  int keep = 0;
804  paraComm->receive( &keep, 1, ParaINT, source, TagKeepRacing )
805  );
806  if( keep == 1 )
807  {
808  keepRacing = true;
809  }
810  else
811  {
812  keepRacing = false;
813  }
814  return 0;
815 }
816 
817 
818 
819 int
821  int source,
822  int tag
823  )
824 {
827  );
828  assert(isRacingStage());
829  restartingRacing = true;
830  racingIsInterrupted = true;
831  return 0;
832 }
833 
834 void
836  )
837 {
838  for(;;)
839  {
840  /***************************************************
841  * Wait a new ParaNode from ParaLoadCoordinator *
842  * If Termination message is received, then break *
843  ***************************************************/
844  if( !currentTask )
845  {
846  if( receiveNewTaskAndReactivate() == false )
847  {
848  break;
849  }
850  }
851 
852  if( winnerRacingParams ) // winner racing parameter set is received
853  {
854  if( racingParams )
855  {
856  delete racingParams;
857  racingParams = 0;
858  }
861  // delete winnerRacingParams;
862  // winnerRacingParams = 0;
863  }
864 
867  nParaTasksReceived >= 2 ) // after racing, parameters should be set to default values
868  {
870  if( winnerRacingParams )
871  {
872  delete winnerRacingParams;
873  winnerRacingParams = 0;
874  }
876  racingWinner = false;
877  }
878 
879  /** set collecting mode */
880  collectingMode = false; /* begin with out-collecting mode: NOTE: LC clear collecting mode for new solver */
882  aggressiveCollecting = false;
883  collectingManyNodes = false;
884  nCollectOnce = 0;
885  resetBreakingInfo(); // set false on collectingManyNodes in the resetBreakingInfo
886  onceBreak = false;
887  noWaitModeSend = false;
888 
889  /** set start time and ilde times */
891  if( previousStopTime < 0.0 )
892  {
894  }
895  else
896  {
898  }
899 
900  /****************************************************
901  * create subproblem into target solver environment *
902  ***************************************************/
903  subproblemFreed = false;
907  {
909  }
911 
912  /******************
913  * start solving *
914  ******************/
915  assert(!newTask);
916  // std::cout << "R." << paraComm->getRank() << " starts solving" << std::endl;
917  solve();
918  // std::cout << "R." << paraComm->getRank() << " solved a ParaNode" << std::endl;
919  /*****************************************************
920  * notify completion of a calculation of a ParaNode *
921  *****************************************************/
923  double compTime = previousStopTime - paraTaskStartTime;
925 
926  nSolved += getNNodesSolved(); // In case of self-split, the number of nodes solved needs to be added for root node
927 
929  {
931  }
932 
933  /****************************************************************************
934  * send completion of calculation and update counters and accumulation time *
935  ****************************************************************************/
937  {
938  do
939  {
941  } while ( !waitToken(paraComm->getRank()) );
942  }
943  iReceiveMessages(); /** Before sending completion state, receiving message should be checked.
944  * When subproblem terminated with no branch, solver lost a timing for receiving new node */
945 
946  if( currentTask ) // When a solver is reserved for multi-threaded parallel solver, currentTaks can be deleted by user routine
947  {
948  if( !selfSplitNodePool )
949  {
950  // std::cout << "Solver (!selfSplitNodePool) Rank = " << paraComm->getRank() << ", node = " << dynamic_cast<BbParaNode *>(currentTask)->toSimpleString() << std::endl;
953  {
955  // if( hasToken() ) passToken();
956  paraDetTimer->update(1.0);
958  #ifdef _DEBUG_DET
959  std::cout << previousCommTime << " run2 R." << paraComm->getRank() << ": token passed" << std::endl;
960  #endif
962  }
963  }
964  else
965  {
966  // std::cout << "Solver Rank = " << paraComm->getRank() << ", node = " << dynamic_cast<BbParaNode *>(currentTask)->toSimpleString() << std::endl;
967  // dynamic_cast<BbParaNode *>(currentTask)->sendSubtreeRootNodeId(paraComm, 0, TagSubtreeRootNodeToBeRemoved);
969  // std::cout << "*** Rank" << paraComm->getRank() << ", num in selfSplit node pool = " << selfSplitNodePool->getNumOfNodes() <<", " << currentTask->toSimpleString() << std::endl;
971  {
973  // if( hasToken() ) passToken();
974  paraDetTimer->update(1.0);
976  #ifdef _DEBUG_DET
977  std::cout << previousCommTime << " run2 R." << paraComm->getRank() << ": token passed" << std::endl;
978  #endif
979  // passToken(paraComm->getRank());
980  }
981  if( selfSplitNodePool->isEmpty() )
982  {
983  delete selfSplitNodePool;
984  selfSplitNodePool = 0;
985  // std::cout << "Rank" << paraComm->getRank() << ", SELFSPLIT NODE POOL NULL" << std::endl;
987  {
989  }
990  }
991  if( dynamic_cast<BbParaNode *>(currentTask)->isRootTask() )
992  {
994  }
995  }
996  }
997 
998  /*******************************************
999  * free solving environment for subproblem *
1000  ********************************************/
1001  if( !subproblemFreed )
1002  {
1003  freeSubproblem();
1004  }
1005 
1006  /* if light wait root node computation is applied, rest it */
1008  {
1011  }
1012 
1013  /**************************
1014  * update current ParaNode *
1015  ***************************/
1016  // assert( currentTask );
1017  if( currentTask ) // When a solver is reserved for multi-threaded parallel solver, currentTaks can be deleted by user routine
1018  {
1019  delete currentTask;
1020  }
1021  if( newTask )
1022  {
1023  currentTask = newTask;
1024  newTask = 0;
1025  }
1026  else
1027  {
1028  currentTask = 0;
1029  }
1031  {
1032  break;
1033  }
1034 
1036  {
1037 
1038  assert(!currentTask);
1040  {
1042  if( dynamic_cast<BbParaNode *>(currentTask)->getInitialDualBoundValue() > globalBestIncumbentValue )
1043  {
1044  dynamic_cast<BbParaNode *>(currentTask)->sendSubtreeRootNodeId(paraComm, 0, TagSubtreeRootNodeStartComputation);
1045  if( selfSplitNodePool->getNumOfNodes() > 0 )
1046  {
1048  }
1049  else
1050  {
1051  // Now self-split node pool becomes empty
1053  delete selfSplitNodePool;
1054  selfSplitNodePool = 0;
1055  }
1056  delete currentTask;
1057  currentTask = 0;
1059  {
1061  // if( hasToken() ) passToken();
1062  paraDetTimer->update(1.0);
1064 #ifdef _DEBUG_DET
1065  std::cout << previousCommTime << " run2 R." << paraComm->getRank() << ": token passed" << std::endl;
1066 #endif
1067  // passToken(paraComm->getRank());
1068  }
1069  }
1070  }
1071 
1073  {
1075  }
1076 
1077  if( selfSplitNodePool && currentTask ) // NOTE: if selfplitNodePool != NULL, new node could receive in waitAckCompletion in case of deterministic
1078  {
1079  // std::cout << "new NODE: " << currentTask->toSimpleString();
1080  // if( dynamic_cast<BbParaNode *>(currentTask)->getDiffSubproblem() )
1081  // {
1082  // std::cout
1083  // << ", "
1084  //// << dynamic_cast<BbParaDiffSubproblem *>(dynamic_cast<BbParaNode *>(currentTask)->getDiffSubproblem())->getNBoundChanges()
1085  // << dynamic_cast<BbParaDiffSubproblem *>(dynamic_cast<BbParaNode *>(currentTask)->getDiffSubproblem())->toStringStat();
1086  // }
1087  // std::cout << std::endl;
1088  dynamic_cast<BbParaNode *>(currentTask)->sendSubtreeRootNodeId(paraComm, 0, TagSubtreeRootNodeStartComputation);
1089  if( selfSplitNodePool->isEmpty() )
1090  {
1091  // DO NOT delete below, since it shows that current solving node is generated by self-split ramp-up
1092  // delete selfSplitNodePool;
1093  // selfSplitNodePool = 0;
1094  }
1095  else
1096  {
1098  {
1101  // std::cout << "Trans NODE (run): " << node->toSimpleString() << std::endl;
1102  // if( dynamic_cast<BbParaNode *>(node)->getDiffSubproblem() )
1103  // {
1104  // std::cout
1105  // << ", "
1106  //// << dynamic_cast<BbParaDiffSubproblem *>(dynamic_cast<BbParaNode *>(node)->getDiffSubproblem())->getNBoundChanges()
1107  // << dynamic_cast<BbParaDiffSubproblem *>(dynamic_cast<BbParaNode *>(node)->getDiffSubproblem())->toStringStat();
1108  // }
1109  // std::cout << std::endl;
1110  delete node;
1111  if( selfSplitNodePool->isEmpty() )
1112  {
1113  // DO NOT delete below, since it shows that current solving node is generated by self-split ramp-up
1114  // delete selfSplitNodePool;
1115  // selfSplitNodePool = 0;
1116  }
1117  }
1118  }
1119  }
1120  }
1121  }
1122  return;
1123 }
1124 
1125 bool
1127 {
1128  for(;;)
1129  {
1130  int source;
1131  int tag;
1132  int status;
1133  /*******************************************
1134  * waiting for any message form anywhere *
1135  *******************************************/
1137  {
1138  do
1139  {
1140  iReceiveMessages();
1141  } while( !waitToken(paraComm->getRank()) );
1142  iReceiveMessages();
1143  paraDetTimer->update(1.0);
1145 #ifdef _DEBUG_DET
1146  std::cout << previousCommTime << " receiveNewNodeAndReactivate R." << paraComm->getRank() << ": token passed" << std::endl;
1147 #endif
1149  }
1150  else
1151  {
1152  (void)paraComm->probe(&source, &tag);
1153  if( messageHandler[tag] )
1154  {
1155  status = (this->*messageHandler[tag])(source, tag);
1156  if( status )
1157  {
1158  std::ostringstream s;
1159  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
1160  << __func__ << ", line = " << __LINE__ << " - "
1161  << "process tag = " << tag << std::endl;
1162  abort();
1163  }
1164  }
1165  else
1166  {
1167  THROW_LOGICAL_ERROR3( "No message hander for ", tag, " is not registered" );
1168  }
1169  }
1170  if( currentTask )
1171  {
1173  {
1175  }
1176  else
1177  {
1179  }
1180  return true;
1181  }
1182  if( terminationMode && !stayAliveAfterInterrupt ) break;
1183  }
1184  return false;
1185 }
1186 
1187 void
1189  )
1190 {
1191 #ifdef _DEBUG_CHECK_RECEIVE
1192  static double previousRreceiveCheckTime = DBL_MAX;
1193  double currentTime = paraTimer->getElapsedTime();
1194  if( ( currentTime - previousRreceiveCheckTime ) < -1.0 )
1195  {
1196  std::cout << currentTime << " Solver" << paraComm->getRank() << " No check receiving message over 500 (sec.) is logging." << std::endl;
1197  }
1198  if( ( currentTime - previousRreceiveCheckTime ) > 500.0 )
1199  {
1200  std::cout << currentTime << " Solver" << paraComm->getRank() << " did not check receiving message over 500 (sec.)" << std::endl;
1201  writeSubproblem();
1202  }
1203  previousRreceiveCheckTime = currentTime;
1204 #endif
1205  /************************************************************************
1206  * This fucntion is called from a callback routine of the target solver *
1207  * **********************************************************************/
1208  int source;
1209  int tag = TagAny;
1210  int status;
1211  /************************************
1212  * check if there are some messages *
1213  ************************************/
1214  while( paraComm->iProbe(&source, &tag) )
1215  {
1216  if( messageHandler[tag] )
1217  {
1218  status = (this->*messageHandler[tag])(source, tag);
1219  if( status )
1220  {
1221  std::ostringstream s;
1222  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
1223  << __func__ << ", line = " << __LINE__ << " - "
1224  << "process tag = " << tag << std::endl;
1225  abort();
1226  }
1227  }
1228  else
1229  {
1231  {
1232  //
1233  // receive the notification Id message
1234  //
1236  paraComm->receive( NULL, 0, ParaBYTE, 0, TagAckCompletion)
1237  );
1238  continue;
1239  }
1240  THROW_LOGICAL_ERROR3( "No message hander for ", tag, " is not registered" );
1241  }
1242  }
1243 }
1244 
1245 void
1247  )
1248 {
1251  {
1253  }
1255  {
1257  }
1258 }
1259 
1260 void
1262  double compTime,
1263  int tag, ///< message Tag
1264  int nSelfSplitNodesLeft ///< number of self-split nodes left
1265  )
1266 {
1267  int terminationState = CompTerminatedNormally;
1268  bool needToResetMaximalDualBound = racingIsInterrupted;
1269 
1270  if( givenGapIsReached )
1271  {
1272  if( isRacingStage() )
1273  {
1274  terminationState = CompTerminatedInRacingStage;
1275  }
1276  else
1277  {
1278  terminationState = CompTerminatedByInterruptRequest;
1279  }
1280  }
1281  else if( memoryLimitIsReached )
1282  {
1283  terminationState = CompTerminatedByMemoryLimit;
1284  }
1285  else
1286  {
1288  {
1289  terminationState = CompTerminatedByInterruptRequest;
1290  }
1291  else
1292  {
1294  {
1295  terminationState = CompTerminatedByTimeLimit;
1296  }
1297  else
1298  {
1299  if ( newTask )
1300  {
1301  terminationState = CompTerminatedByAnotherTask;
1302  }
1303  else
1304  {
1306  {
1307  for(;;)
1308  {
1309  int source;
1310  int ttag;
1311  int status;
1312  /*******************************************
1313  * waiting for any message from anywhere *
1314  *******************************************/
1315  (void)paraComm->probe(&source, &ttag);
1316  if( messageHandler[ttag] )
1317  {
1318  status = (this->*messageHandler[ttag])(source, ttag);
1319  if( status )
1320  {
1321  std::ostringstream s;
1322  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
1323  << __func__ << ", line = " << __LINE__ << " - "
1324  << "process tag = " << ttag << std::endl;
1325  abort();
1326  }
1327  }
1328  else
1329  {
1330  THROW_LOGICAL_ERROR3( "No message hander for ", ttag, " is not registered" );
1331  }
1332  if( newTask )
1333  {
1334  terminationState = CompTerminatedByAnotherTask;
1335  break;
1336  }
1337  if( !anotherNodeIsRequested ) break;
1338  }
1339  }
1340  if( dynamic_cast<BbParaNode *>(currentTask) ) // may not be BbParaNode
1341  {
1342  if( dynamic_cast<BbParaNode *>(currentTask)->getMergingStatus() == 3 )
1343  {
1344  terminationState = CompInterruptedInMerging;
1345  }
1346  }
1347  }
1348 
1349  if( isRacingStage() &&
1350  !newTask && !racingWinner)
1351  {
1353  {
1354  // assert(getNNodesLeft() == 0); // hard time limit case, this happned.
1355  /* CompTerminatedInRacingStage means computation is finished, so terminates all solvers */
1356  terminationState = CompTerminatedInRacingStage;
1357  }
1358  else
1359  {
1360  /* CompInterruptedInRacingStage means computation is interrupted by termination of the other solvers */
1361  terminationState = CompInterruptedInRacingStage; // even if a racing solver terminated badly, just keep running.
1363  racingIsInterrupted = false;
1364  }
1365 
1366  }
1367  else
1368  {
1369  if( !wasTerminatedNormally() )
1370  {
1371  THROW_LOGICAL_ERROR3( "BbParaSolver", paraComm->getRank(), " was terminated abnormally." );
1372  }
1373  }
1374  }
1375  }
1376 
1377  }
1378 
1379  double averageSimplexIter = 0.0;
1380 
1381  if( nSolved <= 1 )
1382  {
1383  /** nSolved > 1 is set within callback routine */
1384  setRootNodeTime();
1386  }
1387  else
1388  {
1389  averageSimplexIter = static_cast<double>( ( getSimplexIter() - nSimplexIterRoot )/(nSolved - 1) );
1390  }
1391 
1392  DEF_BB_PARA_COMM(bbParaComm, paraComm);
1393 
1394  if( terminationState == CompTerminatedByInterruptRequest
1395  && nSolved <= 1 // current solving node is interrupted
1396  && collectingManyNodes // collect all nodes
1397  && nCollectOnce == -1 // collect all nodes
1398  )
1399  {
1400  if( dynamic_cast<BbParaNode *>(currentTask) ) // may not be BbParaNode
1401  {
1402  dynamic_cast<BbParaNode *>(currentTask)->send(bbParaComm, 0); // current solving node has to be collected
1403  }
1404  }
1405 
1407  {
1409  }
1410 
1411  BbParaCalculationState *paraCalculationState = dynamic_cast<BbParaCalculationState *>(bbParaComm->createParaCalculationState(
1413  nSimplexIterRoot, averageSimplexIter,
1416  getNRestarts(), minIisum, maxIisum, minNii, maxNii, solverDualBound, nSelfSplitNodesLeft ));
1417  paraCalculationState->send(paraComm, 0, tag);
1418  delete paraCalculationState;
1419 
1420  /*******************
1421  * update counters *
1422  *******************/
1423  if( nSolved < minNSolved )
1424  {
1425  minNSolved = nSolved;
1426  }
1427  if( nSolved > maxNSolved )
1428  {
1429  maxNSolved = nSolved;
1430  }
1431  totalNSolved += nSolved;
1432 
1433  totalNSent += nSent;
1435  nParaTasksSolved++;
1436  if( nSolved == 1)
1437  {
1439  }
1440 
1443  {
1445  }
1447  {
1449  }
1450 
1453  {
1455  }
1457  {
1459  }
1460 
1462  if( minRestarts > getNRestarts() )
1463  {
1465  }
1466  if( maxRestarts < getNRestarts() )
1467  {
1469  }
1470 
1471  nSolved = 0;
1472  nSent = 0;
1473  nImprovedIncumbent = 0;
1476  minTransferredLocalCuts = INT_MAX;
1477  maxTransferredLocalCuts = INT_MIN;
1479  minTransferredBendersCuts = INT_MAX;
1480  maxTransferredBendersCuts = INT_MIN;
1481  /**********************************
1482  * accumulate total root node time *
1483  ***********************************/
1485  rootNodeTime = 0.0;
1486 
1487  minIisum = DBL_MAX;
1488  maxIisum = 0.0;
1489  minNii = INT_MAX;
1490  maxNii = 0;
1491 
1492  double detTime = -1.0;
1494  {
1495  detTime = paraDetTimer->getElapsedTime();
1496  }
1497  double stopTime = paraTimer->getElapsedTime();
1498  if( isRacingStage() )
1499  {
1500 // if( newNode )
1501 // {
1502 // nParaNodesReceived--;
1503 // }
1504 
1505  // if( !keepRacing )
1506  // {
1507  /** Transfer SolverTermination state during racing ramp-up */
1508  BbParaSolverTerminationState *paraSolverTerminationState = dynamic_cast<BbParaSolverTerminationState *>(bbParaComm->createParaSolverTerminationState(
1509  3, /** interupted flag == 3 means the information for racing ramp-up */
1510  paraComm->getRank(),
1511  totalNSolved,
1512  minNSolved,
1513  maxNSolved,
1514  totalNSent,
1527  minRestarts,
1528  maxRestarts,
1529  getNTightened(),
1530  getNTightenedInt(),
1531  terminationState,
1532  stopTime,
1535  0.0,
1542  detTime
1543  ));
1544  assert( tag == TagCompletionOfCalculation );
1545  paraSolverTerminationState->send(paraComm, 0, TagTermStateForInterruption);
1546  delete paraSolverTerminationState;
1547  assert(! racingWinner);
1548  /** re-initialize all counters, winner counts on current counters */
1549  minNSolved = INT_MAX;
1550  maxNSolved = INT_MIN;
1551  totalNSolved = 0;
1552  totalNSent = 0;
1553  totalNImprovedIncumbent = 0;
1554 // if( newNode )
1555 // nParaNodesReceived = 1;
1556 // else
1557 // nParaNodesReceived = 0;
1558  nParaTasksSolved = 0;
1559  nParaNodesSolvedAtRoot = 0;
1560  nParaNodesSolvedAtPreCheck = 0;
1561  totalRootNodeTime = 0.0;
1562  minRootNodeTime = DBL_MAX;
1563  maxRootNodeTime = -DBL_MAX;
1564 
1565  if( restartingRacing || keepRacing )
1566  {
1567  restartRacing();
1568  }
1569  else
1570  {
1571  terminateRacing();
1572  }
1573 
1574  // }
1575  }
1576  else
1577  {
1578  /** Transfer SolverTermination state to save statistic information for checkpoint */
1579  BbParaSolverTerminationState *paraSolverTerminationState = dynamic_cast<BbParaSolverTerminationState *>(bbParaComm->createParaSolverTerminationState(
1580  2, /** interupted flag == 2 means the information for checkpoint */
1581  paraComm->getRank(),
1582  totalNSolved,
1583  minNSolved,
1584  maxNSolved,
1585  totalNSent,
1598  minRestarts,
1599  maxRestarts,
1600  getNTightened(),
1601  getNTightenedInt(),
1602  terminationState,
1603  stopTime,
1606  0.0,
1613  detTime
1614  ));
1615  if( tag == TagCompletionOfCalculation )
1616  {
1617  paraSolverTerminationState->send(paraComm, 0, TagTermStateForInterruption);
1618  }
1619  else
1620  {
1621  paraSolverTerminationState->send(paraComm, 0, TagSelfSplitTermStateForInterruption);
1622  }
1623  delete paraSolverTerminationState;
1624  }
1626  if( needToResetMaximalDualBound ) solverDualBound = -DBL_MAX;
1627  givenGapIsReached = false;
1628  // keepRacing = false;
1629 }
1630 
1631 void
1633  double compTime,
1634  int tag, ///< message Tag
1635  int nSelfSplitNodesLeft ///< number of self-split nodes left
1636  )
1637 {
1638  int terminationState = CompTerminatedNormally;
1639  bool needToResetMaximalDualBound = racingIsInterrupted;
1640 
1641  double dualBound = DBL_MAX;
1642 
1644  {
1645  dualBound = std::min(solverDualBound, selfSplitNodePool->getBestDualBoundValue() );
1646  }
1647 
1648  DEF_BB_PARA_COMM(bbParaComm, paraComm);
1649 
1650  BbParaCalculationState *paraCalculationState = dynamic_cast<BbParaCalculationState *>(bbParaComm->createParaCalculationState(
1651  compTime, 0, 0 , 0, 0, terminationState, 0,
1652  0, 0.0,
1653  0, 0, 0,
1654  0, 0, 0,
1655  0, 0, 0, 0, 0, dualBound, nSelfSplitNodesLeft ));
1656  paraCalculationState->send(paraComm, 0, tag);
1657  delete paraCalculationState;
1658 
1659  /**********************
1660  * No update counters *
1661  **********************/
1662 
1663  double detTime = -1.0;
1665  {
1666  detTime = paraDetTimer->getElapsedTime();
1667  }
1668  double stopTime = paraTimer->getElapsedTime();
1669  /** Transfer SolverTermination state to save statistic information for checkpoint */
1670  BbParaSolverTerminationState *paraSolverTerminationState = dynamic_cast<BbParaSolverTerminationState *>(bbParaComm->createParaSolverTerminationState(
1671  2, /** interupted flag == 2 means the information for checkpoint */
1672  paraComm->getRank(),
1673  totalNSolved,
1674  minNSolved,
1675  maxNSolved,
1676  totalNSent,
1689  minRestarts,
1690  maxRestarts,
1691  getNTightened(),
1692  getNTightenedInt(),
1693  terminationState,
1694  stopTime,
1697  0.0,
1704  detTime
1705  ));
1706  paraSolverTerminationState->send(paraComm, 0, TagSelfSplitTermStateForInterruption);
1707  delete paraSolverTerminationState;
1709  if( needToResetMaximalDualBound ) solverDualBound = -DBL_MAX;
1710  givenGapIsReached = false;
1711  // keepRacing = false;
1712 }
1713 
1714 
1715 void
1717  )
1718 {
1719  if( localIncumbentSolution && (!notificationProcessed) ) // if solution is sent in notification is processed,
1720  // dead lock may be occurred depending of MPI system buffer size
1721  {
1723  {
1726  }
1727  else
1728  {
1730  // NOTE: globalBestIncumbnetValue may be an objective function value of localIncumbentSolution
1731  {
1735  }
1736  else
1737  {
1738  delete localIncumbentSolution;
1739  }
1740  }
1742  }
1743 }
1744 
1745 bool
1747  )
1748 {
1749  // if( paraParams->getBoolParamValue(Deterministic) )
1750  // {
1751  // return true; // always true, in case of deterministic run
1752  // }
1753 
1756  {
1758  }
1759 
1760  if( !rampUp )
1761  {
1762  if( isRacingStage() )
1763  {
1765  {
1766  return true;
1767  }
1768  else
1769  {
1771  {
1774  {
1775  return true;
1776  }
1777  else
1778  {
1779  return false;
1780  }
1781  }
1782  else
1783  {
1786  {
1787  return true;
1788  }
1789  else
1790  {
1791  return false;
1792  }
1793  }
1794  }
1795  }
1796  else
1797  { // normal ramp-up phase
1798  return true;
1799  }
1800  }
1801  else
1802  {
1804  {
1805  if( noWaitModeSend )
1806  {
1808  {
1811  {
1812  return true;
1813  }
1814  else
1815  {
1816  return false;
1817  }
1818  }
1819  else
1820  {
1823  {
1824  return true;
1825  }
1826  else
1827  {
1828  return false;
1829  }
1830  }
1831  }
1832  else
1833  {
1834  return true;
1835  }
1836  }
1838  {
1841  {
1842  return true;
1843  }
1844  else
1845  {
1846  return false;
1847  }
1848  }
1849  else
1850  {
1853  {
1854  return true;
1855  }
1856  else
1857  {
1858  return false;
1859  }
1860  }
1861  }
1862 }
1863 
1864 void
1866  long long nNodesSolved,
1867  int nNodesLeft,
1868  double bestDualBoundValue,
1869  double detTime
1870  )
1871 {
1873  {
1874  int racingStage = 0; /** assume not racing stage */
1875  if( isRacingStage() )
1876  {
1877  racingStage = 1;
1878  }
1879  double tempGlobalBestPrimalBound = DBL_MAX;
1881  {
1882  tempGlobalBestPrimalBound = globalBestIncumbentSolution->getObjectiveFunctionValue();
1883  }
1884 
1885  DEF_BB_PARA_COMM(bbParaComm, paraComm);
1886  double dualBound = std::min( std::max( bestDualBoundValue,dynamic_cast<BbParaNode *>(currentTask)->getDualBoundValue()), tempGlobalBestPrimalBound );
1888  {
1889  nNodesLeft += selfSplitNodePool->getNumOfNodes();
1890  dualBound = std::min(dualBound, selfSplitNodePool->getBestDualBoundValue());
1891  }
1892  BbParaSolverState *solverState = dynamic_cast<BbParaSolverState *>(bbParaComm->createParaSolverState(
1893  racingStage,
1896  nNodesSolved, nNodesLeft, dualBound,
1897  tempGlobalBestPrimalBound,
1898  detTime,
1900  ));
1901  solverState->send(paraComm, 0, TagSolverState);
1902  delete solverState;
1904  {
1906  }
1907  else
1908  {
1910  }
1911  notificationProcessed = true;
1912  }
1913 }
1914 
1915 int
1917  int nNodes /**< number of processed nodes, including the focus node */
1918  )
1919 {
1921  {
1922  return 10;
1923  }
1924 
1926  double meanRootNodeTime = ( totalRootNodeTime + rootNodeTime )/(nParaTasksSolved + 1); // +1 is this ParaNode
1927  double meanNodeTime = -1.0; // unrealiable
1928  if( ( compTime - (totalRootNodeTime + rootNodeTime ) ) > 10.0 // less equal than 10.0 sec. treats as unreliable
1929  && meanRootNodeTime > 0.0001 ) // meanRootNode time less equal than 0.0001 sec. treats as unreliable
1930  {
1931  meanNodeTime = ( compTime - (totalRootNodeTime + rootNodeTime ) ) / (totalNSolved + nNodes - nParaTasksSolved);
1932  // compute mean node comp. time except root nodes(nParaNodesSolved+1) and the focus node(-1)
1933  if( meanNodeTime < 0.0 ) meanNodeTime = 0.0;
1934  }
1935 
1936  int n;
1937  if( meanNodeTime < 0.000001 )
1938  { // heuristic initial value setting
1939  n = ( rootNodeTime < 0.01 ) ? 100 : ( ( rootNodeTime < 0.1 ) ? 50 : ( (rootNodeTime < 1.0) ? 10 : 5 ) );
1940  }
1941  else
1942  {
1943  if( ( meanRootNodeTime / meanNodeTime ) > 5.0 )
1944  { // base value at least 5.0
1945  n = (int) (
1947  * ( meanRootNodeTime / meanNodeTime ) );
1948  if( n > 100 )
1949  {
1950  if( meanNodeTime > 1.0 )
1951  {
1952  n = 3;
1953  }
1954  else
1955  {
1956  n = 100;
1957  }
1958  }
1959  }
1960  else
1961  { // heuristic value setting
1962  n = ( rootNodeTime < 0.01 ) ? 100 : ( ( rootNodeTime < 0.1 ) ? 50 : ( (rootNodeTime < 1.0) ? 10 : 5 ) );
1963  }
1964  }
1966  if( n < 2 ) n = 2;
1967  return n;
1968 }
1969 
1970 void
1972  long long n,
1973  int depth,
1974  double dualBound,
1975  double estimateValue,
1976  ParaDiffSubproblem *diffSubproblem
1977  )
1978 {
1979  DEF_BB_PARA_COMM(bbParaComm, paraComm );
1980 
1981  BbParaNode *node = dynamic_cast<BbParaNode *>(bbParaComm->createParaNode(
1984  paraComm->getRank() ),
1985  -1), // sequentail number is not set
1987  dynamic_cast<BbParaNode *>(currentTask)->getDepth() + depth,
1988  std::max( dualBound, dynamic_cast<BbParaNode *>(currentTask)->getDualBoundValue() ),
1989  dualBound,
1990  estimateValue,
1991  diffSubproblem
1992  ));
1993  double inIdleTime = paraTimer->getElapsedTime();
1994  node->send(paraComm, 0);
1995  delete node;
1996  int tag;
1997  int status;
1998  if( nSendInCollectingMode <= 0 || !noWaitModeSend )
1999  {
2000  waitingSpecificMessage = true;
2001  for(;;)
2002  {
2004  idleTimeToWaitNotificationId += ( paraTimer->getElapsedTime() - inIdleTime );
2005  if( tag == TagTaskReceived )
2006  {
2007  break;
2008  }
2009  status = (this->*messageHandler[tag])(0, tag);
2010  if( status )
2011  {
2012  std::ostringstream s;
2013  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
2014  << __func__ << ", line = " << __LINE__ << " - "
2015  << "process tag = " << tag << std::endl;
2016  abort();
2017  }
2018  inIdleTime = paraTimer->getElapsedTime();
2019  }
2020  idleTimeToWaitNotificationId += ( paraTimer->getElapsedTime() - inIdleTime );
2021  //
2022  // receive the NULL message for TagNodeReceived
2023  //
2024  status = (this->*messageHandler[tag])(0, tag);
2025  if( status )
2026  {
2027  std::ostringstream s;
2028  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
2029  << __func__ << ", line = " << __LINE__ << " - "
2030  << "process tag = " << tag << std::endl;
2031  abort();
2032  }
2033  waitingSpecificMessage = false;
2034  }
2035  nSent++;
2037  if( nCollectOnce > 0 ) nCollectOnce--;
2040  if( isBreaking() ) nTransferredNodes++;
2041 }
2042 
2043 void
2045  long long n,
2046  int depth,
2047  double dualBound,
2048  double estimateValue,
2049  ParaDiffSubproblem *diffSubproblem
2050  )
2051 {
2052  DEF_BB_PARA_COMM(bbParaComm, paraComm );
2053 
2054  BbParaNode *node = dynamic_cast<BbParaNode *>(bbParaComm->createParaNode(
2057  paraComm->getRank() ),
2058  -1), // sequentail number is not set
2060  dynamic_cast<BbParaNode *>(currentTask)->getDepth() + depth,
2061  std::max( dualBound, dynamic_cast<BbParaNode *>(currentTask)->getDualBoundValue() ),
2062  dualBound,
2063  estimateValue,
2064  diffSubproblem
2065  ));
2066  // double inIdleTime = paraTimer->getElapsedTime();
2067  node->sendNewSubtreeRoot(paraComm, 0);
2068  selfSplitNodePool->insert(node);
2069 }
2070 
2071 void
2073  double bestDualBoundValue
2074  )
2075 {
2076  if( anotherNodeIsRequested ) return;
2077  if( selfSplitNodePool && (!selfSplitNodePool->isEmpty()) ) return;
2078  if( givenGapIsReached ) return;
2080  paraComm->send( &bestDualBoundValue, 1, ParaDOUBLE, 0, TagAnotherNodeRequest)
2081  );
2082  anotherNodeIsRequested = true;
2083 
2084 }
2085 
2086 bool
2088  double newValue
2089  )
2090 {
2091  if( newValue < globalBestCutOffValue ){
2092  globalBestCutOffValue = newValue;
2093  return true;
2094  } else {
2095  return false;
2096  }
2097 }
2098 
2099 void
2101  )
2102 {
2104  !rampUp ||
2106  {
2108  }
2109 }
2110 
2111 void
2113  )
2114 {
2115  assert( !paraInstance );
2116 
2117  freeSubproblem();
2118  subproblemFreed = true;
2119 
2120  // paraInstance = paraComm->createParaInstance();
2121  // paraInstance->bcast(paraComm, 0, paraParams->getIntParamValue(InstanceTransferMethod));
2122  reinitialize();
2123 
2124  if( !keepRacing )
2125  {
2126  assert(newTask == 0);
2129  newTask->bcast(paraComm, 0)
2130  );
2131 
2133  }
2134  racingIsInterrupted = false;
2135  restartingRacing = false;
2137 }
2138 
2139 /*** sendIfImprovedSolutionWasFound routine should be removed in the future **/
2140 bool
2142  ParaSolution *sol
2143  )
2144 {
2148  {
2151  assert( localIncumbentSolution == 0 );
2152  sol->send(paraComm, 0);
2153  delete sol;
2154  //
2155  // shoul not do as follows. LC does not know which nodes were removed
2156  //
2157  // if( selfSplitNodePool )
2158  // {
2159  // selfSplitNodePool->removeBoundedNodes(globalBestIncumbentValue);
2160  // }
2162  return true;
2163  }
2164  else
2165  {
2166  delete sol;
2167  return false;
2168  }
2169 }
2170 
2171 bool
2173  ParaSolution *sol
2174  )
2175 {
2176  if( EPSLT( sol->getObjectiveFunctionValue(), globalBestIncumbentValue, eps ) ) // compare to globalBestIncumbentValue
2177  { // no solution sending is accepted!!!
2178  // globalBestIncumbentValue = sol->getObjectiveFuntionValue(); // should not update globalBestIncumbentValue and flag
2179  // globalIncumbnetValueUpdateFlag = true; // thease are updated only when the value comes from outside
2181  {
2183  {
2184  // there is a possibility to be updated several times
2185  delete localIncumbentSolution;
2186  localIncumbentSolution = sol;
2188  localIncumbentIsChecked = false;
2189  return true;
2190  }
2191  else
2192  {
2194  {
2195  delete localIncumbentSolution;
2197  localIncumbentIsChecked = false;
2198  return false;
2199  }
2200  else
2201  {
2202  // could check an identical solution
2203  localIncumbentIsChecked = true;
2204  return true;
2205  }
2206  }
2207  }
2208  else
2209  {
2210  localIncumbentSolution = sol;
2212  localIncumbentIsChecked = false;
2213  return true;
2214  }
2215  }
2216  else
2217  {
2218  delete sol;
2219  return false;
2220  }
2221 }
2222 
2223 bool
2225  double newValue
2226  )
2227 {
2228  if( newValue < globalBestIncumbentValue ){
2229  globalBestIncumbentValue = newValue;
2231  return true;
2232  } else {
2233  return false;
2234  }
2235 }
2236 
2237 bool
2239  ParaSolution *sol
2240  )
2241 {
2243  {
2245  {
2246  if( sol != globalBestIncumbentSolution ) // can have the same pointer address
2247  {
2250  }
2252  {
2255  }
2256  return true;
2257  }
2258  else
2259  {
2260  return false;
2261  }
2262  }
2263  else
2264  {
2267  {
2270  // std::cout << "R." << paraComm->getRank() << ", pendingIncumbentValue = " << pendingIncumbentValue << std::endl;
2271  }
2272  return true;
2273  }
2274 }
2275 
2276 void
2278  )
2279 {
2280  double inIdleTime = paraTimer->getElapsedTime();
2281  int tag;
2282  int status;
2283  waitingSpecificMessage = true;
2284  for(;;)
2285  {
2287  idleTimeToWaitNotificationId += ( paraTimer->getElapsedTime() - inIdleTime );
2288  if( tag == TagNotificationId )
2289  {
2290  break;
2291  }
2292  status = (this->*messageHandler[tag])(0, tag);
2293  if( status )
2294  {
2295  std::ostringstream s;
2296  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
2297  << __func__ << ", line = " << __LINE__ << " - "
2298  << "process tag = " << tag << std::endl;
2299  abort();
2300  }
2301  inIdleTime = paraTimer->getElapsedTime();
2302  }
2303  idleTimeToWaitNotificationId += ( paraTimer->getElapsedTime() - inIdleTime );
2304  //
2305  // receive the notification Id message
2306  //
2307  // status = (this->*messageHandler[tag])(0, tag);
2308  status = processTagNotificationId(0,tag);
2309  if( status )
2310  {
2311  std::ostringstream s;
2312  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
2313  << __func__ << ", line = " << __LINE__ << " - "
2314  << "process tag = " << tag << std::endl;
2315  abort();
2316  }
2317  waitingSpecificMessage = false;
2318 }
2319 
2320 void
2322  )
2323 {
2324  double inIdleTime = paraTimer->getElapsedTime();
2325  int tag;
2326  int hstatus;
2327  waitingSpecificMessage = true;
2328  for(;;)
2329  {
2331  idleTimeToWaitAckCompletion += ( paraTimer->getElapsedTime() - inIdleTime );
2332  if( tag == TagAckCompletion )
2333  {
2334  break;
2335  }
2336  hstatus = (this->*messageHandler[tag])(0, tag);
2337  if( hstatus )
2338  {
2339  std::ostringstream s;
2340  s << "[ERROR RETURN form Message Hander]:" << __FILE__ << "] func = "
2341  << __func__ << ", line = " << __LINE__ << " - "
2342  << "process tag = " << tag << std::endl;
2343  abort();
2344  }
2345  if( terminationMode == NormalTerminationMode ) break;
2346  inIdleTime = paraTimer->getElapsedTime();
2347  }
2348  double current = paraTimer->getElapsedTime();
2349  double idleTime = current - inIdleTime;
2350  idleTimeToWaitAckCompletion += idleTime;
2353  idleTime > 1.0 )
2354  {
2357  }
2358  if( tag == TagAckCompletion )
2359  {
2360  //
2361  // receive the notification Id message
2362  //
2364  paraComm->receive( NULL, 0, ParaBYTE, 0, TagAckCompletion)
2365  );
2366  }
2367  waitingSpecificMessage = false;
2368 }
2369 
int minNii
minimum number of integer infeasibility
Definition: bbParaSolver.h:130
#define DEF_BB_PARA_COMM(para_comm, comm)
int minTransferredBendersCutsFromSolver
minimum number of benders cuts transferred from this Solver
Definition: bbParaSolver.h:109
double rootNodeTime
Times.
Definition: bbParaSolver.h:87
virtual void send(ParaComm *comm, int destination)=0
send solution data
virtual void createSubproblem()=0
create subproblem
double minIisum
minimum sum of integer infeasibility
Definition: bbParaSolver.h:128
static const int TagNotificationId
Definition: paraTagDef.h:55
int nTransferredBendersCuts
number of benders cuts transferred from a ParaNode
Definition: bbParaSolver.h:123
static const int CompTerminatedByInterruptRequest
Definition: paraDef.h:184
#define THROW_LOGICAL_ERROR4(msg1, msg2, msg3, msg4)
Definition: paraDef.h:103
bool notificationProcessed
if true, notification is issued but not receive the corresponding LCB
Definition: paraSolver.h:140
static const int TagReassignSelfSplitSubtreeRootNode
Definition: bbParaTagDef.h:75
int nImprovedIncumbent
Counters related to the current ParaTask.
Definition: paraSolver.h:130
double idleTimeToFirstParaTask
idle time to start solving the first ParaTask
Definition: paraSolver.h:118
static const int CompTerminatedByTimeLimit
Definition: paraDef.h:188
int getGlobalSubtaskIdInLc()
getter of global subtask id in Solvers managed by LoadCoordinator
Definition: paraTask.h:752
static const int TagIncumbentValue
Definition: paraTagDef.h:52
virtual int processTagSolution(int source, int tag)
process TagSolution
static const int TagCutOffValue
Definition: bbParaTagDef.h:66
bool isBreaking()
check if Solver is in racing stage or not
static ScipParaCommTh * comm
Definition: fscip.cpp:73
virtual int processTagNoNodes(int source, int tag)
process TagNoNodes
ParaSolution * pendingSolution
solution which is pending to update in case of deterministic runs
Definition: paraSolver.h:94
virtual int processTagTerminateSolvingToRestart(int source, int tag)
process TagTerminateSolvingToRestart
bool stayAliveAfterInterrupt
indicate that stay alive this solver after interrupt request
Definition: paraSolver.h:149
#define DEFAULT_NUM_EPSILON
Definition: paraDef.h:49
bool memoryLimitIsReached
indicate if memory limit is reached or not, when base solver has memory management feature ...
Definition: paraSolver.h:109
bool collectingInterrupt
when the solver is interrupted, all nodes are collected to LC
Definition: bbParaSolver.h:78
bool racingInterruptIsRequested
indicate a racing interrupt is requested
Definition: paraSolver.h:105
static const int FinalCheckpointGeneratingTime
Definition: paraParamSet.h:108
static const int CompTerminatedByMemoryLimit
Definition: paraDef.h:189
virtual void restartRacing()
restart racing
void terminateRacing()
check if Solver is in racing stage or not
Definition: paraSolver.h:677
virtual double getElapsedTime()=0
get elapsed time
static const int CompInterruptedInMerging
Definition: paraDef.h:187
virtual void waitNotificationIdMessage()
wait notification id message to synchronized with LoadCoordinator
virtual bool probe(int *source, int *tag)=0
No need to take action for fault tolerant, when the functions return. So, they do not rerun status va...
static const int TagTerminateRequest
Definition: paraTagDef.h:56
int nParaTasksSolved
number of ParaTasks solved ( received ) in this ParaSolver
Definition: paraSolver.h:136
ParaParamSet * paraParams
ParaParamSet object.
Definition: paraSolver.h:83
virtual int sendSubtreeRootNodeId(ParaComm *comm, int destination, int tag)=0
send subtree root to be removed
virtual double getDualBoundValue()=0
get dual bound value
static const int CompTerminatedByAnotherTask
Definition: paraDef.h:183
static const int NoTransferThresholdReductionRatio
static const int TagLightWeightRootNodeProcess
Definition: bbParaTagDef.h:54
int nParaNodesSolvedAtRoot
number of ParaNodes solved at root node
Definition: bbParaSolver.h:116
static const int EnhancedCheckpointStartTime
int nTotalRestarts
number of total restarts
Definition: bbParaSolver.h:111
int maxRestarts
maximum number of restarts
Definition: bbParaSolver.h:113
virtual ParaRacingRampUpParamSet * createParaRacingRampUpParamSet()=0
create ParaRacingRampUpParamSet object
virtual int processTagUbBoundTightened(int source, int tag)
process TagUbBoundTightened
virtual int processTagWinnerRacingRampUpParamSet(int source, int tag)
process TagWinnerRacingRampUpParamSet
static const int TagRampUp
Definition: paraTagDef.h:50
static const int TagAny
Definition: paraTagDef.h:44
static const int NormalTerminationMode
Definition: paraSolver.h:61
static const int TagNoTestDualBoundGain
Definition: bbParaTagDef.h:59
Base class for ParaTask.
void setRootNodeSimplexIter(int iter)
set number of simplex iteration at root node
static const int InterruptedTerminationMode
Definition: paraSolver.h:62
virtual void setToken(int rank, int *token)
set received token to this communicator
Definition: paraComm.h:221
virtual void sendCompletionOfCalculation(double stopTime)
send completion of calculation
Definition: bbParaSolver.h:438
Base class of Calculation state in a ParaSolver.
int minTransferredBendersCuts
minimum number of benders cuts transferred from a ParaNode
Definition: bbParaSolver.h:124
int maxTransferredLocalCuts
maximum number of local cuts (including conflict cuts) transferred from a ParaNode ...
Definition: bbParaSolver.h:122
virtual void insert(BbParaNodePtr node)=0
insert BbParaNode to this pool
double globalBestIncumbentValue
global best incumbent value
Definition: paraSolver.h:91
virtual int bcast(ParaComm *comm, int root)=0
broadcast this object
ParaRacingRampUpParamSet * racingParams
ParaRacingRampUpParamSet object. This is also a flag to indicate running with racing ramp-up...
Definition: paraSolver.h:84
ParaDeterministicTimer * paraDetTimer
deterministic timer for this ParaSolver
Definition: paraSolver.h:89
SubtaskId subtaskId
subtree id
Definition: paraTask.h:227
double globalBestDualBoundValueAtWarmStart
global best dual bound value which is set when system warm starts
Definition: bbParaSolver.h:70
static const int TagLCBestBoundValue
Definition: bbParaTagDef.h:53
virtual int getNRestarts()
get number of restarts (Derived class for SCIP should override this function)
bool lightWeightRootNodeComputation
indicate that fast root node computation is required
Definition: bbParaSolver.h:80
virtual int processTagTestDualBoundGain(int source, int tag)
process TagTestDualBoundGain
double previousIdleTimeToWaitToken
previous idle time to wait token
Definition: paraSolver.h:124
virtual int processTagNoWaitModeSend(int source, int tag)
process TagNoWaitModeSend
virtual int sendNewSubtreeRoot(ParaComm *comm, int destination)=0
send new subtree root node
BbParaNodePool * selfSplitNodePool
Pool in Solver.
Definition: bbParaSolver.h:152
static const int TagGivenGapIsReached
Definition: bbParaTagDef.h:56
static const int CompInterruptedInRacingStage
Definition: paraDef.h:186
virtual int processTagRampUp(int source, int tag)
process TagRampUp
int nTightenedInt
the number of tightened integral variable bounds in racing
Definition: bbParaSolver.h:127
virtual int processTagNotificationId(int source, int tag)
process TagNotificationId
virtual int send(ParaComm *comm, int destination)=0
send this object
virtual void issueInterruptSolve()
issue interrupt to solve
int totalNSolved
Counters related to this BbParaSolver.
Definition: bbParaSolver.h:102
int nSent
number of ParaNodes sent from this subtree rooted from the current ParaNode
Definition: bbParaSolver.h:96
int lcId
LoadCoordinator ID.
Definition: paraTask.h:63
virtual void iReceiveMessages()
non-blocking receive messages
virtual long long getSimplexIter()=0
get number of simplex iterations
bool isRacingStage()
check if Solver is in racing stage or not
int maxTransferredLocalCutsFromSolver
maximum number of local cuts transferred from this Solver
Definition: bbParaSolver.h:107
int maxNii
maximum number of integer infeasibility
Definition: bbParaSolver.h:131
int nSendInCollectingMode
number of nodes need to send in collecting mode
Definition: bbParaSolver.h:75
virtual void setRootNodeTime()
set root node computing time
bool subproblemFreed
indicate that subproblem is already freed or not
Definition: paraSolver.h:147
double pendingIncumbentValue
incumbent value which is pending to update in case of deterministic runs
Definition: paraSolver.h:95
virtual double getBestDualBoundValue()=0
get best dual bound value of BbParaNode object in this pool
TaskId class.
Definition: paraTask.h:222
static const int TimeLimitTerminationMode
Definition: paraSolver.h:63
class for deterministic timer
bool anotherNodeIsRequested
indicate that another node is requested or not
Definition: bbParaSolver.h:79
virtual int processTagCutOffValue(int source, int tag)
process TagCutOffValue
static const int ParaUNSIGNED
Definition: paraComm.h:72
virtual void waitAckCompletion()
wait ack completion to synchronized with LoadCoordinator
virtual void sendAnotherNodeRequest(double bestDualBoundValue)
send another node request
ParaSolution * localIncumbentSolution
incumbent solution generated in local solver
Definition: paraSolver.h:93
virtual int processTagLCBestBoundValue(int source, int tag)
process TagLCBestBoundValue
#define PARA_COMM_CALL(paracommcall)
Definition: paraComm.h:47
static const int Deterministic
Definition: paraParamSet.h:76
virtual int getRank()=0
get rank of this process or this thread depending on run-time environment
int nTightened
the number of tightened variable bounds in racing
Definition: bbParaSolver.h:126
static const int TagCollectAllNodes
Definition: bbParaTagDef.h:51
int globalSubtaskIdInLc
Global Subtask ID in Solvers managed by LoadCoordinator.
Definition: paraTask.h:64
static const int TagSelfSlpitNodeCalcuationState
Definition: bbParaTagDef.h:76
virtual int getNTightened()
get number of tightened variables during racing
Definition: bbParaSolver.h:568
virtual int processTagKeepRacing(int source, int tag)
process TagKeepRacing
static const int TagRestart
Definition: bbParaTagDef.h:61
virtual void tryNewSolution(ParaSolution *sol)=0
try to enter solution to base solver environment
bool rampUp
indicate whether if ramp-up phase is finished or not: true - finish
Definition: paraSolver.h:104
virtual long long getNNodesSolved()=0
get number of nodes solved
int nTransferredNodes
keep track number of transferred nodes for breaking
Definition: bbParaSolver.h:135
static const int ParaDOUBLE
Definition: paraComm.h:76
static const int TagInCollectingMode
Definition: bbParaTagDef.h:50
static bool interrupted
Definition: fscip.cpp:78
double averageDualBoundGain
average dual bound gain
Definition: bbParaSolver.h:139
virtual double getElapsedTime()=0
getter of the deterministic time
int nSolved
Counters related to the current ParaNode.
Definition: bbParaSolver.h:95
double globalBestCutOffValue
global best cut off value
Definition: bbParaSolver.h:71
static const int EnhancedFinalCheckpoint
bool waitingSpecificMessage
indicate that this solver is waiting for a specific message
Definition: paraSolver.h:108
void passToken(int rank)
pass token to the next process
bool testDualBoundGain
indicate that the dual bound gain needs to test or not
Definition: bbParaSolver.h:143
virtual bool updateGlobalBestCutOffValue(double newValue)
update global best cutoff value
virtual int processTagInCollectingMode(int source, int tag)
process TagInCollectingMode
virtual void writeSubproblem()=0
write subproblem
static const int CheckEffectOfRootNodePreprocesses
double targetBound
target bound value for breaking
Definition: bbParaSolver.h:133
static const int TagTaskReceived
Definition: paraTagDef.h:48
double solverDualBound
dual bound value achieved for a subproblem
Definition: bbParaSolver.h:137
virtual void receive(ParaComm *comm, int source)=0
receive solution data
double getRealParamValue(int param)
for real parameters
static const int TagSolverState
Definition: paraTagDef.h:53
virtual int processTagGlobalBestDualBoundValueAtWarmStart(int source, int tag)
process TagGlobalBestDualBoundValueAtWarmStart
virtual int processTagLightWeightRootNodeProcess(int source, int tag)
process TagLightWeightRootNodeProcess
int nParaNodesSolvedAtPreCheck
number of ParaNodes solved at pre-checking of root node solvability
Definition: bbParaSolver.h:117
static const int TagTermStateForInterruption
Definition: bbParaTagDef.h:77
int nParaTasksReceived
Counters related to this ParaSolver.
Definition: paraSolver.h:135
virtual void sendCompletionOfCalculationWithoutSolving(double stopTime, int tag, int nSelfSplitNodesLeft)
send completion of calculation with arguments
virtual int processTagToken(int source, int tag)
process TagToken
int nTransferredBendersCutsFromSolver
number of benders cuts transferred from this Solver
Definition: bbParaSolver.h:108
virtual size_t getNumOfNodes()=0
get number of BbParaNodes in this pool
int minRestarts
minimum number of restarts
Definition: bbParaSolver.h:112
virtual void setOriginalRootNodeProcess()
set original root node process
int nSolvedWithNoPreprocesses
number of nodes solved when it is solved with no preprocesses
Definition: bbParaSolver.h:97
double previousStopTime
Idle Times.
Definition: paraSolver.h:117
virtual int processTagCollectAllNodes(int source, int tag)
process TagCollectAllNodes
virtual int receive(ParaComm *comm, int source)=0
receive this object
static const int TagToken
Definition: paraTagDef.h:63
double idleTimeAfterLastParaTask
idle time after the last ParaTask was solved
Definition: paraSolver.h:120
virtual void freeSubproblem()=0
free subproblem
virtual int processTagTerminateRequest(int source, int tag)
process TagTerminateRequest
int terminationMode
indicate that termination mode 0: no termination mode 1: normal termination mode 2: interrupted termi...
Definition: paraSolver.h:99
virtual void waitMessageIfNecessary()
wait a notification id message if it is needed to synchronize with LoadCoordinaor ...
virtual int processTagRetryRampUp(int source, int tag)
process TagRetryRampUp
virtual int getNNodesLeft()=0
get number of nodes left
Base class of communicator for UG Framework.
virtual void sendLocalSolution()
send solution found in this Solver
static const int TagGlobalBestDualBoundValueAtWarmStart
Definition: bbParaTagDef.h:47
static const int TagAnotherNodeRequest
Definition: bbParaTagDef.h:48
int maxTransferredBendersCuts
maximum number of benders cuts transferred from a ParaNode
Definition: bbParaSolver.h:125
virtual int processTagNoTestDualBoundGain(int source, int tag)
process TagNoTestDualBoundGain
int maxNSolved
maximum number of subtree nodes rooted from ParaNode
Definition: bbParaSolver.h:104
ParaTimer * paraTimer
timer for this ParaSolver
Definition: paraSolver.h:88
virtual void send(ParaComm *comm, int destination, int tag)=0
send this object
virtual int processTagTaskReceived(int source, int tag)
process TagTaskReceived
void resetBreakingInfo()
reset breaking information
class BbParaNodePoolForMinimization
bool enoughGainObtained
indicate that the root node process improved dual bound enough or not
Definition: bbParaSolver.h:140
#define EPSLT(x, y, eps)
Definition: paraDef.h:167
virtual void send(ParaComm *comm, int destination, int tag)=0
send this object
double eps
absolute values smaller than this are considered zero esp should be set in the constructor of the der...
Definition: paraSolver.h:142
virtual void solve()=0
solve (sub)problem
virtual int receive(void *bufer, int count, const int datatypeId, int source, const int tag)=0
receive function for standard ParaData types
Base class for instance data.
static const int TagUbBoundTightenedIndex
Definition: bbParaTagDef.h:64
virtual int processTagBreaking(int source, int tag)
process TagBreaking
static const int TagRetryRampUp
Definition: bbParaTagDef.h:46
static const int TagBreaking
Definition: bbParaTagDef.h:55
double previousCommTime
previous communication time for deterministic execution
Definition: paraSolver.h:145
static const int TagTestDualBoundGain
Definition: bbParaTagDef.h:58
virtual ParaSolution * createParaSolution()=0
create ParaSolution object by default constructor
virtual bool updateGlobalBestIncumbentValue(double newValue)
update global best incumbent value
class ParaParamSet
Definition: paraParamSet.h:850
double maxIisum
maximum sum of integer infeasibility
Definition: bbParaSolver.h:129
class for instance data
Definition: paraInstance.h:50
bool globalIncumbnetValueUpdateFlag
indicate that global incumbent value is updated in iReceiveMessages() routine
Definition: paraSolver.h:139
virtual void setOriginalNodeSelectionStrategy()=0
set original node selection strategy
ParaSolution * globalBestIncumbentSolution
global best solution. However, this is not always feasible for the current sub-MIP ...
Definition: paraSolver.h:92
double idleTimeBetweenParaTasks
idle time between ParaTasks processing
Definition: paraSolver.h:119
Class for the difference between instance and subproblem.
virtual int ubBoundTightened(int source, int tag)
upper bound of variable tightened
Definition: bbParaSolver.h:557
int nTransferredLocalCuts
number of local cuts (including conflict cuts) transferred from a ParaNode
Definition: bbParaSolver.h:120
double minRootNodeTime
minimum time consumed by root node process
Definition: bbParaSolver.h:89
static const int NotificationSynchronization
Definition: paraParamSet.h:88
virtual bool isEmpty()=0
check if this pool is empty or not
virtual bool saveIfImprovedSolutionWasFound(ParaSolution *sol)
save improved solution if it was found in this Solver
static const int CompTerminatedNormally
Definition: paraDef.h:182
BbParaSolver()
constructor
Definition: bbParaSolver.h:631
virtual ParaTask * createParaTask()=0
create ParaTask object by default constructor
virtual bool updateGlobalBestIncumbentSolution(ParaSolution *sol)
update global best incumbent solution
virtual int getThresholdValue(int nNodes)
get threshold value to send ParaNodes to LoadCoordinator
static const int TagTerminateSolvingToRestart
Definition: bbParaTagDef.h:70
ParaTask * currentTask
solving task
Definition: paraSolver.h:97
static const int ParaBYTE
Definition: paraComm.h:79
static const int MultiplierToDetermineThresholdValue
static const int TagTerminated
Definition: paraTagDef.h:58
virtual int processTagOutCollectingMode(int source, int tag)
process TagOutCollectingMode
int getLcId()
getter of LoadCoordinator id
Definition: paraTask.h:742
bool givenGapIsReached
indicate that the given gap is reached or not
Definition: bbParaSolver.h:142
virtual bool wasTerminatedNormally()=0
check if Solver was terminated normally or not
class BbParaNode
Definition: bbParaNode.h:61
static const int CheckpointInterval
Definition: paraParamSet.h:107
virtual bool iProbe(int *source, int *tag)=0
iProbe function which checks if a new message is arrived or not
static const int TagSelfSplitTermStateForInterruption
Definition: bbParaTagDef.h:78
static const int BgapCollectingMode
static const int SetAllDefaultsAfterRacing
double idleTimeToWaitToken
idle time to wait token
Definition: paraSolver.h:123
static const int NotificationInterval
Definition: paraParamSet.h:105
static const int NoTerminationMode
termination mode
Definition: paraSolver.h:60
static const int TagNoNodes
Definition: bbParaTagDef.h:49
virtual void keepParaNode(long long n, int depth, double dualBound, double estimateValue, ParaDiffSubproblem *diffSubproblem)
keep a branch-and-bound node as ParaNode to LoadCoordinator
double maxRootNodeTime
maximum time consumed by root node process
Definition: bbParaSolver.h:90
virtual void updatePendingSolution()
update pending solution
Definition: paraSolver.h:759
bool collectingManyNodes
indicate that many nodes collecting is requested by LC
Definition: bbParaSolver.h:77
void setRealParamValue(int param, double value)
set real parameter value
virtual void notifySelfSplitFinished()
notify Self-Split finished
virtual void send(ParaComm *comm, int destination, int tag)=0
send this object to destination
int nTransferLimit
limit number of transferring nodes for breaking
Definition: bbParaSolver.h:134
double idleTimeToWaitNotificationId
idle time to wait a message within collecting mode
Definition: paraSolver.h:121
static const int RampUpPhaseProcess
static const int TagInterruptRequest
Definition: paraTagDef.h:57
virtual bool notificationIsNecessary()
check if a notification message needs to send or not
bool aggressiveCollecting
indicate that if this solver has two nodes, this solver sends one to LC
Definition: bbParaSolver.h:74
SubtaskId class.
Definition: paraTask.h:60
ParaRacingRampUpParamSet * winnerRacingParams
Winner ParaRacingRampUpParamSet object.
Definition: paraSolver.h:86
virtual bool receiveNewTaskAndReactivate()
wait for receiving a new node and reactivate solver
static const int CommunicateTighterBoundsInRacing
virtual int send(void *bufer, int count, const int datatypeId, int dest, const int tag)=0
send function for standard ParaData types
bool racingIsInterrupted
indicate whether if racing phases is interrupted or not: true - interrupted
Definition: paraSolver.h:106
static const int TagLbBoundTightenedIndex
Definition: bbParaTagDef.h:62
virtual void setWinnerRacingParams(ParaRacingRampUpParamSet *racingParms)=0
set winner racing parameters
virtual int receive(ParaComm *comm, int source)=0
receive ParaRacingRampUpParamSet
void setSendBackAllNodes()
set counter and flag to indicate that all nodes are sent to LoadCooordinator
virtual void run()
static const int TagSubtreeRootNodeStartComputation
Definition: bbParaTagDef.h:73
static const int TagSelfSplitFinished
Definition: bbParaTagDef.h:71
#define EPSLE(x, y, eps)
Definition: paraDef.h:168
virtual BbParaNodePtr extractNode()=0
extract a BbParaNode object from this pool
int maxTransferredBendersCutsFromSolver
maximum number of benders cuts transferred from this Solver
Definition: bbParaSolver.h:110
double paraTaskStartTime
start time of current ParaTask
Definition: paraSolver.h:112
static const int TimeLimit
Definition: paraParamSet.h:106
virtual void reinitialize()
re-initialized instance
Definition: paraSolver.h:378
static const int TagNoWaitModeSend
Definition: bbParaTagDef.h:60
unsigned int notificationIdGenerator
Definition: paraSolver.h:80
ParaTask * newTask
new task to solve
Definition: paraSolver.h:98
double previousNotificationTime
previous notification time
Definition: paraSolver.h:111
static const int TagTask
Definition: paraTagDef.h:47
static const int TagKeepRacing
Definition: bbParaTagDef.h:69
bool isWarmStarted()
check if current execution is warm start (restart) or not
Definition: paraSolver.h:428
static const int ParaINT
Definition: paraComm.h:66
bool waitToken(int rank)
wait token for deterministic mode
ParaInstance * paraInstance
root problem instance
Definition: paraSolver.h:96
static const int DynamicAdjustNotificationInterval
Definition: paraParamSet.h:78
double lcBestDualBoundValue
LoadCoordinator best dual bound value.
Definition: bbParaSolver.h:72
virtual int processTagWinner(int source, int tag)
process TagWinner
int totalNImprovedIncumbent
accumulated number of improvements of incumbent value in this BbParaSolver
Definition: bbParaSolver.h:115
int getIntParamValue(int param)
for int parameters
ParaComm * paraComm
ParaCommunicator object.
Definition: paraSolver.h:82
virtual int processTagRestart(int source, int tag)
process TagRestart
static const int CompTerminatedInRacingStage
Definition: paraDef.h:185
virtual void setLightWeightRootNodeProcess()
set light weight root node process
virtual int processTagLbBoundTightened(int source, int tag)
process TagLbBoundTightened
virtual void sendSolverState(long long nNodesSolved, int nNodesLeft, double bestDualBoundValue, double detTime)
send Solver state to LoadCoordinator
double totalRootNodeTime
accumulated root node process time solved by this solver so far
Definition: bbParaSolver.h:88
int nCollectOnce
number of nodes need to collect once
Definition: bbParaSolver.h:76
int minTransferredLocalCuts
minimum number of local cuts (including conflict cuts) transferred from a ParaNode ...
Definition: bbParaSolver.h:121
virtual bool sendIfImprovedSolutionWasFound(ParaSolution *sol)
send improved solution if it was found in this Solver
TaskId taskId
solving task information
Definition: paraTask.h:549
int(BbParaSolver::* BbMessageHandlerFunctionPointer)(int, int)
Definition: bbParaSolver.h:68
int totalNSent
accumulated number of nodes sent from this BbParaSolver
Definition: bbParaSolver.h:114
virtual void update(double value)=0
update function of the deterministic time. the deterministic time is a kind of counter ...
virtual void sendParaNode(long long n, int depth, double dualBound, double estimateValue, ParaDiffSubproblem *diffSubproblem)
send a branch-and-bound node as ParaNode to LoadCoordinator
int nSimplexIterRoot
number of simplex iteration at root node
Definition: bbParaSolver.h:119
int minTransferredLocalCutsFromSolver
minimum number of local cuts transferred from this Solver
Definition: bbParaSolver.h:106
virtual int processTagTask(int source, int tag)
Message handlers
bool localIncumbentIsChecked
indicate if a local incumbent solution is checked or not
Definition: bbParaSolver.h:147
MessageHandlerFunctionPointer * messageHandler
table for message handlers
Definition: paraSolver.h:78
class ParaSolver
Definition: paraSolver.h:70
static const int TagCompletionOfCalculation
Definition: paraTagDef.h:54
class BbParaSolverState (ParaSolver state object for notification message)
class BbParaSolverTerminationState (Solver termination state in a ParaSolver)
virtual int processTagGivenGapIsReached(int source, int tag)
process TagGivenGapIsReached
virtual double getObjectiveFunctionValue()=0
get objective function value
virtual void sendSolverTerminationState()
send Solver termination state
virtual void solveToCheckEffectOfRootNodePreprocesses()
solve to check effect of root node preprocesses
Definition: bbParaSolver.h:535
bool noWaitModeSend
indicate that no wait mode sending is applied
Definition: bbParaSolver.h:144
void setIntParamValue(int param, int value)
set int parameter value
Base class of communicator object.
Definition: paraComm.h:101
bool keepRacing
indicate if Solver needs to do racing ramp-up repeatedly in case of warm start
Definition: bbParaSolver.h:145
virtual int processTagInterruptRequest(int source, int tag)
process TagInterruptRequest
bool racingWinner
indicate racing ramp-up winner or not: true - winner
Definition: paraSolver.h:107
class for solution
Definition: paraSolution.h:53
double idleTimeToWaitAckCompletion
idle time to wait acknowledgment of completion
Definition: paraSolver.h:122
static const int TagOutCollectingMode
Definition: bbParaTagDef.h:52
Base class for solution.
virtual int lbBoundTightened(int source, int tag)
lower bound of variable tightened
Definition: bbParaSolver.h:545
bool collectingMode
indicate whether if this solver is in collecting mode or not
Definition: bbParaSolver.h:73
int minNSolved
minimum number of subtree nodes rooted from ParaNode
Definition: bbParaSolver.h:103
virtual int processTagIncumbentValue(int source, int tag)
process TagIncumbentValue
int nTransferredLocalCutsFromSolver
number of local cuts transferred from this Solver
Definition: bbParaSolver.h:105
virtual int getNTightenedInt()
get number of tightened integral variables during racing
Definition: bbParaSolver.h:577
virtual void waitSpecTagFromSpecSource(const int source, const int tag, int *receivedTag)=0
wait function for a specific tag from a specific source coming from
static const int TagWinner
Definition: paraTagDef.h:60
#define THROW_LOGICAL_ERROR3(msg1, msg2, msg3)
Definition: paraDef.h:86
bool onceBreak
indicate that the sub-MIP is broken down once
Definition: bbParaSolver.h:82
static const int TagAckCompletion
Definition: paraTagDef.h:62
bool getBoolParamValue(int param)
for bool parameters
bool restartingRacing
indicate that this solver is restarting racing
Definition: bbParaSolver.h:146