63 UGS::UgsParaCommMpi *inCommUgs,
69 bool *inRacingSolversExist,
85 initialNodesGenerated(false),
86 firstCollectingModeState(-1),
87 isCollectingModeRestarted(false),
89 nReplaceToBetterNode(0),
91 winnerSolverNodesCollected(false),
93 restartingRacing(false),
95 statEmptyNodePoolTime(DBL_MAX),
96 minDepthInWinnerSolverNodes(INT_MAX),
97 maxDepthInWinnerSolverNodes(-1),
99 nBoundChangesOfBestNode(0),
104 nCollectedSolvers(0),
105 previousTabularOutputTime(0.0),
106 averageDualBoundGain(0.0),
107 nAverageDualBoundGain(0),
108 averageLastSeveralDualBoundGains(0.0),
110 hugeImbalanceTime(-1.0),
111 paraNodePoolToRestart(0),
112 paraNodePoolBufferToRestart(0),
113 paraNodePoolBufferToGenerateCPF(0),
114 paraNodeToKeepCheckpointFileNodes(0),
115 unprocessedParaNodes(0),
116 selfSplitFinisedSolvers(0),
117 osTabularSolvingStatus(0),
119 allCompInfeasibleAfterSolution(false),
120 minmalDualBoundNormalTermSolvers(DBL_MAX),
121 warmStartNodeTransferring(false),
122 hugeImbalance(false),
123 isHeaderPrinted(false),
124 givenGapIsReached(false),
125 aSolverTerminatedWithOptimality(false),
191 std::cout <<
"EnhancedCheckpointStartTime mast be greater than 1.0. " << std::endl;
197 std::cout <<
"EnhancedCheckpointStartTime mast be less than FinalCheckpointGeneratingTime. " << std::endl;
204 std::cout <<
"FinalCheckpointNSolvers mast be less equal than the number of solvers. " << std::endl;
206 std::cout <<
"The number of solvers = " << (
paraComm->
getSize() - 1) << std::endl;
213 std::cout <<
"** FinalCheckpointGeneratingTime is specified, then TimeLimit is omitted. ** " << std::endl;
219 std::cout <<
"LC is working with normal ramp-up." << std::endl;
223 std::cout <<
"LC is working with racing ramp-up." << std::endl;
227 std::cout <<
"LC is working with racing ramp-up and with rebuilding tree after racing." << std::endl;
231 std::cout <<
"LC is working with self-split ramp-up." << std::endl;
238 <<
" LC" <<
" INITIAL_PRIMAL_VALUE " 240 dynamic_cast<BbParaSolution *>(dynamic_cast<BbParaInitiator *>(
paraInitiator)->getGlobalBestIncumbentSolution())->getObjectiveFunctionValue()
247 std::ostringstream s;
252 << commUgs->getMySolverName() <<
"_" 267 std::cout <<
"Sub tree info. log file cannot open : file name = " << s.str() << std::endl;
282 std::ostringstream s;
287 << commUgs->getMySolverName() <<
"_" 302 std::cout <<
"Tabular solving status file cannot open : file name = " << s.str() << std::endl;
321 if( paraParams->getBoolParamValue(
CleanUp) )
363 std::cout <<
"** MergeNodesAtRestart = " << paraParams->getBoolParamValue(
UG::MergeNodesAtRestart) << std::endl;
364 std::cout <<
"** DualBoundGainTest = " << paraParams->getBoolParamValue(
UG::DualBoundGainTest) << std::endl;
365 std::cout <<
"** GenerateReducedCheckpointFiles is specified, then this solver shuld be executed with" 366 <<
"-w option and MergeNodesAtRestart = TRUE and DualBoundGainTest = FALSE ** " << std::endl;
411 std::ostringstream s;
412 s <<
"[ERROR RETURN form termination message handler]:" << __FILE__ <<
"] func = " 413 << __func__ <<
", line = " << __LINE__ <<
" - " 414 <<
"process tag = " << tag << std::endl;
424 if( commUgs ) checkAndReadIncumbent();
450 updateCheckpointFiles();
457 updateCheckpointFiles();
464 int nKeepingNodes = 0;
465 int nNoProcessedNodes = 0;
490 << (nKeepingNodes + nNoProcessedNodes) <<
" nodes remained" << std::endl;
495 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool) )
539 updateCheckpointFiles();
566 <<
" initially keeping nodes by the run-time parameter." 572 <<
" nodes." << std::endl;
580 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool) )
625 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool) )
681 ABORT_LOGICAL_ERROR1(
"Computation is interrupted in racing stage, but no paraRacingSolverPool");
686 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool) )
706 *
osTabularSolvingStatus <<
"* Warning: the number of nodes (total) including nodes solved by interrupted Solvers is " 721 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getTotalNodesSolved() != dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesSolvedInSolvers() )
741 std::cout <<
lcts.
runningTime <<
" BbParaLoadCoordinator_TERMINATED" << std::endl;
765 <<
" active racing ramp-up solvers exist." << std::endl;
766 *osStatisticsFinalRun << dynamic_cast<BbParaRacingSolverPool *>(
paraRacingSolverPool)->getStrActiveSolerNumbers() << std::endl;
797 int exitSolverRequest = 0;
845 #ifdef UG_DEBUG_SOLUTION 846 #ifdef UG_DEBUG_SOLUTION_OPT_PATH 958 double globalBestDualBoundValueLocal =
982 #ifdef UG_DEBUG_SOLUTION 985 throw "Optimal solution going to be killed.";
1022 <<
" S." << source <<
" R.SOL " 1045 <<
" S." << source <<
" I.SOL " 1052 <<
" S." << source <<
" I.SOL " 1054 paraInitiator->getGlobalBestIncumbentSolution()->getObjectiveFunctionValue()
1069 snprintf(solutionFileNameTemp,
MaxStrLen,
"%s%s_after_checkpointing_solution_t.gz",
1072 paraInitiator->writeCheckpointSolution(std::string(solutionFileNameTemp));
1073 snprintf(solutionFileName,
MaxStrLen,
"%s%s_after_checkpointing_solution.gz",
1076 if ( rename(solutionFileNameTemp, solutionFileName) )
1078 std::cout <<
"after checkpointing solution file cannot be renamed: errno = " << strerror(errno) << std::endl;
1104 double globalBestDualBoundValue = -DBL_MAX;
1105 double globalBestDualBoundValueLocal = -DBL_MAX;
1121 globalBestDualBoundValueLocal = globalBestDualBoundValue =
1123 std::min( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getGlobalBestDualBoundValue(),
1131 <<
" S." << source <<
" | " 1157 <<
" ) ] ** R" << std::endl;
1163 <<
" S." << source <<
" | " 1170 std::cout <<
" ( Inf )";
1177 globalBestDualBoundValue =
1179 std::cout <<
" ** G.B.: " <<
paraInitiator->convertToExternalValue(globalBestDualBoundValue);
1183 std::cout <<
" ( Inf ) ";
1187 std::cout <<
" ( " <<
paraInitiator->getGap(globalBestDualBoundValue) * 100 <<
"% ) ";
1191 <<
" ) ] ** RR" << std::endl;
1196 if( !dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isSolverActive(source) )
1204 assert( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getCurrentTask(source) != 0 );
1205 double solverDualBoundGain = 0.0;
1207 if(dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNumOfNodesSolved(source) == 0
1218 <<
", g:" << solverDualBoundGain;
1219 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isDualBounGainTesting(source) )
1258 globalBestDualBoundValueLocal =
1261 std::min( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getGlobalBestDualBoundValue(),
1268 globalBestDualBoundValue = globalBestDualBoundValueLocal =
1280 globalBestDualBoundValueLocal = globalBestDualBoundValue =
1284 dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getGlobalBestDualBoundValue() ),
1291 globalBestDualBoundValueLocal = globalBestDualBoundValue =
1300 globalBestDualBoundValueLocal = globalBestDualBoundValue =
1312 <<
" S." << source <<
" | " 1340 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isInCollectingMode() )
1343 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isSolverInCollectingMode(source) )
1365 *osLogSolvingStatus << dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesSolvedInSolvers()
1378 *osLogSolvingStatus << dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesSolvedInSolvers()
1402 <<
" S." << source <<
" | " 1409 std::cout <<
" ( Inf )";
1416 globalBestDualBoundValue =
1420 std::cout <<
" ** G.B.: " <<
paraInitiator->convertToExternalValue(globalBestDualBoundValue);
1424 std::cout <<
" ( Inf ) ";
1428 std::cout <<
" ( " <<
paraInitiator->getGap(globalBestDualBoundValue) * 100 <<
"% ) ";
1434 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isInCollectingMode() )
1437 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isSolverInCollectingMode(source) )
1447 std::cout << std::endl;
1474 bbParaInitiator->
getGap(globalBestDualBoundValue) < bbParaInitiator->
getGapValue() )
1536 globalBestDualBoundValueLocal
1607 "Limit number of collecting mode solvers extends to " <<
1632 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isInCollectingMode() )
1643 globalBestDualBoundValueLocal
1668 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNumOfNodesLeftInBestSolver()
1685 if( ( ( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getGlobalBestDualBoundValue()
1712 (signed)dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesInSolvers()
1771 switch ( calcTerminationState )
1850 switch ( calcTerminationState )
1855 <<
" S." << source <<
" >";
1862 <<
" S." << source <<
" >(INTERRUPTED_BY_ANOTHER_NODE)";
1868 <<
" S." << source <<
" >(INTERRUPTED)";
1874 <<
" S." << source <<
" >(TERMINATED_IN_RACING_STAGE)";
1880 <<
" S." << source <<
" >(INTERRUPTED_IN_RACING_STAGE)";
1895 std::cout << std::endl;
1898 switch ( calcTerminationState )
1937 <<
" Nodes generated by S." << source <<
" from " << solvingNode->
toSimpleString() <<
" are collected to LC." << std::endl;
1955 updateCheckpointFiles();
1961 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isSolverInCollectingMode(source) )
1975 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isSolverActive(source) )
2104 <<
" Nodes generated by S." << source <<
" from " << solvingNode->
toSimpleString() <<
" are collected to LC." << std::endl;
2119 updateCheckpointFiles();
2183 source <<
" is terminated in racing stage #########" << std::endl;
2200 minmalDualBoundNormalTermSolvers < calcState->getDualBoundValue() )
2265 <<
" Nodes generated by S." << source <<
" from " << solvingNode->
toSimpleString() <<
" are collected to LC." << std::endl;
2283 updateCheckpointFiles();
2341 if( dynamic_cast<BbParaRacingSolverPool *>(
paraRacingSolverPool)->getNumInactiveSolvers() == 0 )
2362 updateCheckpointFiles();
2524 if( dynamic_cast<BbParaSolverPool *>(
paraSolverPool)->isInterruptRequested(source)
2536 #ifndef _COMM_MPI_WORLD 2575 double bestDualBoundValue;
2595 if( !paraNode )
break;
2596 if( ( bbParaInitiator->getGlobalBestIncumbentSolution() &&
2597 paraNode->
getDualBoundValue() < bbParaInitiator->getGlobalBestIncumbentSolution()->getObjectiveFunctionValue() ) ||
2598 !( bbParaInitiator->getGlobalBestIncumbentSolution() ) )
2604 #ifdef UG_DEBUG_SOLUTION 2607 throw "Optimal solution going to be killed.";
2617 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isSolverActive(source) &&
2633 double globalBestDualBoundValueLocal =
2646 <<
" S." << source <<
" <(ANOTHER_NODE) " 2647 << bbParaInitiator->convertToExternalValue(
2649 if( bbParaInitiator->getGlobalBestIncumbentSolution() )
2664 <<
" S." << source <<
" <(ANOTHER_NODE) " 2671 std::cout <<
" ( Inf )";
2678 std::cout << std::endl;
2724 double tightenedBound;
2739 if( static_cast<int>(i) != source )
2764 double tightenedBound;
2779 if( static_cast<int>(i) != source )
2907 (!dynamic_cast<BbParaSolverPool *>(
paraSolverPool)->isSolverActive(source) ) )
3012 switch ( calcTerminationState )
3079 switch ( calcTerminationState )
3185 <<
" Nodes generated by S." << source <<
" from " << solvingNode->
toSimpleString() <<
" are collected to LC." << std::endl;
3191 nodes = nodes->
next;
3227 updateCheckpointFiles();
3239 nodes = nodes->
next;
3283 updateCheckpointFiles();
3294 assert( !(dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->extractCurrentNodeAndInactivate(source,
paraNodePool))->getAncestor() );
3299 nodes = nodes->
next;
3329 nodes = nodes->
next;
3378 <<
" Nodes generated by S." << source <<
" from " << solvingNode->
toSimpleString() <<
" are collected to LC." << std::endl;
3384 nodes = nodes->
next;
3404 updateCheckpointFiles();
3416 nodes = nodes->
next;
3440 updateCheckpointFiles();
3471 assert( !(dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->extractCurrentNodeAndInactivate(source,
paraNodePool))->getAncestor() );
3476 nodes = nodes->
next;
3507 nodes = nodes->
next;
3554 nodes = nodes->
next;
3578 updateCheckpointFiles();
3611 assert( !(dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->extractCurrentNodeAndInactivate(source,
paraNodePool))->getAncestor() );
3616 nodes = nodes->
next;
3647 nodes = nodes->
next;
3817 *osTabularSolvingStatus << std::setw(15) << std::right << dynamic_cast<BbParaRacingSolverPool *>(
paraRacingSolverPool)->getNnodesSolvedInBestSolver();
3827 *osTabularSolvingStatus << std::setw(12) << std::right << dynamic_cast<BbParaRacingSolverPool *>(
paraRacingSolverPool)->getNnodesLeftInBestSolver();
3841 if( dynamic_cast<BbParaRacingSolverPool *>(
paraRacingSolverPool)->getNnodesSolvedInBestSolver() == 0 )
3929 *osTabularSolvingStatus << std::setw(15) << std::right << dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesSolvedInSolvers();
3932 *osTabularSolvingStatus << std::setw(12) << std::right << ( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesInSolvers()
3938 *osTabularSolvingStatus << std::setw(12) << std::right << ( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesInSolvers()
3944 *osTabularSolvingStatus << std::setw(12) << std::right << ( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getNnodesInSolvers()
4054 bbParaInitiator->
getGap( globalBestDualBound ) * 100 <<
"%";
4089 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getGlobalBestDualBoundValue() >= -1e+10 )
4105 bbParaInitiator->
getGap( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->getGlobalBestDualBoundValue() ) * 100 <<
"%";
4181 updateCheckpointFiles();
4215 updateCheckpointFiles();
4219 std::cout <<
"### REACHED TO THE SPECIFIED NUMBER OF IDLER SOLVERS, then EXIT ###" << std::endl;
4278 std::ostringstream s;
4279 s <<
"[ERROR RETURN form Message Hander]:" << __FILE__ <<
"] func = " 4280 << __func__ <<
", line = " << __LINE__ <<
" - " 4281 <<
"process tag = " << tag << std::endl;
4291 if( commUgs ) checkAndReadIncumbent();
4366 double globalBestDualBoundValueLocal =
4372 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isActive() &&
4387 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isActive() &&
4406 double globalBestDualBoundValueLocal =
4410 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isActive() &&
4481 restartInRampDownPhase();
4554 updateCheckpointFiles();
4564 BbParaLoadCoordinator::restartInRampDownPhase(
4567 updateCheckpointFiles();
4586 <<
" Interrupt all solvers to restart" 4591 "Interrupt all solvers to restart after " 4629 std::ostringstream s;
4630 s <<
"[ERROR RETURN form Message Hander]:" << __FILE__ <<
"] func = " 4631 << __func__ <<
", line = " << __LINE__ <<
" - " 4632 <<
"process tag = " << tag << std::endl;
4642 if( commUgs ) checkAndReadIncumbent();
4654 std::cout <<
"Logical error occurred during restart in ramp-down phase." << std::endl;
4655 std::cout <<
"You can restart from the chakepoint file." << std::endl;
4721 bool sentNode =
false;
4742 if( !paraNode )
break;
4798 #ifdef UG_DEBUG_SOLUTION 4801 throw "Optimal solution going to be killed.";
4830 #ifdef UG_DEBUG_SOLUTION 4833 throw "Optimal solution going to be killed.";
4879 double globalBestDualBoundValueLocal =
4886 if( destination < 0 )
4914 <<
" S." << destination <<
" < " 4940 std::cout <<
"node id = " << (paraNode->
getTaskId()).toString() << std::endl;
4957 <<
" S." << destination <<
" < " 4964 std::cout <<
" ( Inf )";
4978 std::cout << std::endl;
4992 BbParaLoadCoordinator::updateCheckpointFiles(
5018 ctime_s(timeStr, bufsize, &timer);
5020 ctime_r(&timer, timeStr);
5022 for(
int i = 0; timeStr[i] !=
'\0' && i < 26; i++ )
5024 if( timeStr[i] ==
' ') timeStr[i] =
'_';
5025 if( timeStr[i] ==
'\n' ) timeStr[i] =
'\0';
5027 char *newCheckpointTimeStr = &timeStr[4];
5032 int l = strlen(newCheckpointTimeStr);
5033 newCheckpointTimeStr[l] =
'a';
5034 newCheckpointTimeStr[l+1] =
'\0';
5039 snprintf(nodesFileName,
MaxStrLen,
"%s%s_%s_nodes_LC%d.gz",
5042 gzstream::ogzstream checkpointNodesStream;
5043 checkpointNodesStream.open(nodesFileName, std::ios::out | std::ios::binary);
5044 if( !checkpointNodesStream )
5046 std::cout <<
"Checkpoint file for ParaNodes cannot open. file name = " << nodesFileName << std::endl;
5057 n +=
paraNodePool->writeBbParaNodesToCheckpointFile(checkpointNodesStream);
5060 int nUnprocessedNodes =
unprocessedParaNodes->writeBbParaNodesToCheckpointFile(checkpointNodesStream);
5073 n += nUnprocessedNodes;
5075 checkpointNodesStream.close();
5079 <<
" Checkpoint: " << n <<
" ParaNodes were saved" << std::endl;
5083 <<
" Checkpoint: " << n <<
" ParaNodes were saved" << std::endl;
5089 "Storing check-point data after " <<
5091 n <<
" nodes were saved." << std::endl;
5098 snprintf(solutionFileName,
MaxStrLen,
"%s%s_%s_solution.gz",
5101 paraInitiator->writeCheckpointSolution(std::string(solutionFileName));
5105 char solverStatisticsFileName[
MaxStrLen];
5106 snprintf(solverStatisticsFileName,
MaxStrLen,
"%s%s_%s_solverStatistics_LC%d.gz",
5109 gzstream::ogzstream checkpointSolverStatisticsStream;
5110 checkpointSolverStatisticsStream.open(solverStatisticsFileName, std::ios::out | std::ios::binary);
5111 if( !checkpointSolverStatisticsStream )
5113 std::cout <<
"Checkpoint file for SolverStatistics cannot open. file name = " << solverStatisticsFileName << std::endl;
5117 checkpointSolverStatisticsStream.close();
5120 char loadCoordinatorStatisticsFileName[
MaxStrLen];
5121 snprintf(loadCoordinatorStatisticsFileName,
MaxStrLen,
"%s%s_%s_loadCoordinatorStatistics_LC%d.gz",
5124 gzstream::ogzstream loadCoordinatorStatisticsStream;
5125 loadCoordinatorStatisticsStream.open(loadCoordinatorStatisticsFileName, std::ios::out | std::ios::binary);
5126 if( !loadCoordinatorStatisticsStream )
5128 std::cout <<
"Checkpoint file for SolverStatistics cannot open. file name = " << loadCoordinatorStatisticsFileName << std::endl;
5136 writeLoadCoordinatorStatisticsToCheckpointFile(loadCoordinatorStatisticsStream, nSolverInfo,
5138 loadCoordinatorStatisticsStream.close();
5147 snprintf(racingWinnerParamsName,
MaxStrLen,
"%s%s_racing_winner_params.gz",
5150 gzstream::ogzstream racingWinnerParamsStream;
5151 racingWinnerParamsStream.open(racingWinnerParamsName, std::ios::out | std::ios::binary);
5152 if( !racingWinnerParamsStream )
5154 std::cout <<
"Racing winner parameter file cannot open. file name = " << racingWinnerParamsName << std::endl;
5158 racingWinnerParamsStream.close();
5164 snprintf(nodesFileName,
MaxStrLen,
"%s%s_%s_nodes_LC%d.gz",
5169 snprintf(solutionFileName,
MaxStrLen,
"%s%s_%s_solution.gz",
5173 snprintf(solverStatisticsFileName,
MaxStrLen,
"%s%s_%s_solverStatistics_LC%d.gz",
5176 snprintf(loadCoordinatorStatisticsFileName,
MaxStrLen,
"%s%s_%s_loadCoordinatorStatistics_LC%d.gz",
5179 if(
remove(nodesFileName) )
5181 std::cout <<
"checkpoint nodes file cannot be removed: errno = " << strerror(errno) << std::endl;
5184 if (
remove(solutionFileName) )
5186 std::cout <<
"checkpoint solution file cannot be removed: errno = " << strerror(errno) << std::endl;
5189 if (
remove(solverStatisticsFileName) )
5191 std::cout <<
"checkpoint SolverStatistics file cannot be removed: errno = " << strerror(errno) << std::endl;
5194 if (
remove(loadCoordinatorStatisticsFileName) )
5196 std::cout <<
"checkpoint LoadCoordinatorStatistics file cannot be removed: errno = " << strerror(errno) << std::endl;
5201 char afterCheckpointingSolutionFileName[
MaxStrLen];
5202 snprintf(afterCheckpointingSolutionFileName,
MaxStrLen,
"%s%s_after_checkpointing_solution.gz",
5205 gzstream::igzstream afterCheckpointingSolutionStream;
5206 afterCheckpointingSolutionStream.open(afterCheckpointingSolutionFileName, std::ios::in | std::ios::binary);
5207 if( afterCheckpointingSolutionStream )
5210 afterCheckpointingSolutionStream.close();
5211 if (
remove(afterCheckpointingSolutionFileName) )
5213 std::cout <<
"after checkpointing solution file cannot be removed: errno = " << strerror(errno) << std::endl;
5223 BbParaLoadCoordinator::writeLoadCoordinatorStatisticsToCheckpointFile(
5224 gzstream::ogzstream &loadCoordinatorStatisticsStream,
5226 double globalBestDualBoundValue,
5227 double externalGlobalBestDualBoundValue
5230 loadCoordinatorStatisticsStream.write((
char *)&nSolverInfo,
sizeof(
int));
5253 lcts.write(loadCoordinatorStatisticsStream);
5257 BbParaLoadCoordinator::warmStart(
5267 std::cout <<
"*** When warm start with racing is specified, you should specify CollectOnce = TRUE ***" << std::endl;
5270 std::cout <<
"*** When warm start with racing is specified, you cannot specify MergeNodesAtRestart = TRUE ***" << std::endl;
5276 std::cout <<
"*** When warm start with racing is specified, you cannot specify MergeNodesAtRestart = TRUE ***" << std::endl;
5279 std::cout <<
"*** Warm start with racing ramp-up ***" << std::endl;
5287 std::cout <<
"*** Warm start with normal ramp-up ***" << std::endl;
5293 writePreviousStatisticsInformation();
5299 snprintf(racingWinnerParamsName,
MaxStrLen,
"%s%s_racing_winner_params.gz",
5302 gzstream::igzstream racingWinnerParamsStream;
5303 racingWinnerParamsStream.open(racingWinnerParamsName, std::ios::in | std::ios::binary);
5304 if( racingWinnerParamsStream )
5309 racingWinnerParamsStream.close();
5317 std::cout <<
"*** winner parameter is read from " << racingWinnerParamsName <<
"***" << std::endl;
5324 char afterCheckpointingSolutionFileName[
MaxStrLen];
5325 snprintf(afterCheckpointingSolutionFileName,
MaxStrLen,
"%s%s_after_checkpointing_solution.gz",
5328 double incumbentValue =
paraInitiator->readSolutionFromCheckpointFile(afterCheckpointingSolutionFileName);
5331 bbParaInitiator->
writeSolution(
"[Warm started from "+std::string(bbParaInitiator->
getPrefixWarm())+
" : the solution from the checkpoint file]");
5336 bool onlyBoundChanges =
false;
5339 onlyBoundChanges =
true;
5352 paraNode = bbParaInitiator->readParaNodeFromCheckpointFile(onlyBoundChanges);
5356 #ifdef UG_DEBUG_SOLUTION 5357 #ifdef UG_DEBUG_SOLUTION_OPT_PATH 5369 std::cout <<
"Checkpoint node has ancestor: " << paraNode->
toString() << std::endl;
5370 std::cout <<
"Something wrong for this checkpoint file." << std::endl;
5379 tempParaNodePool.insert(paraNode);
5392 std::cout <<
"### NNodesToKeepInCheckpointFile is specified to " 5394 <<
" and also NEagerToSolveAtRestart is specified to " 5396 <<
". The both values should not greater than 0 together." << std::endl;
5401 std::cout <<
"### NNodesToKeepInCheckpointFile is specified to " 5403 <<
" and also MergeNodesAtRestart = TRUE is specified. This combination is not allowed." << std::endl;
5409 ", but the number of nodes in checkpoint file is " << tempParaNodePool.getNumOfNodes() <<
". ###" << std::endl;
5414 std::cout <<
"### NEagerToSolveAtRestart is specified to " 5416 <<
", but RampUpPhaseProcess != 0 is specified. This combination is not allowed." << std::endl;
5422 BbParaNode *tempParaNode = tempParaNodePool.extractNode();
5425 while( tempParaNodePool.getNumOfNodes() > 0 )
5427 BbParaNode *tempParaNode = tempParaNodePool.extractNode();
5430 std::cout <<
"### NNodesToKeepInCheckpointFile is specified to " 5432 <<
" ###" << std::endl;
5434 <<
" ###" << std::endl;
5436 <<
" ###" << std::endl;
5444 ", but the number of nodes in checkpoint file is " << tempParaNodePool.getNumOfNodes() <<
". ###" << std::endl;
5449 std::cout <<
"### NEagerToSolveAtRestart is specified to " 5451 <<
" and also MergeNodesAtRestart = TRUE is specified. This combination is not allowed." << std::endl;
5456 std::cout <<
"### NEagerToSolveAtRestart is specified to " 5458 <<
", but RampUpPhaseProcess != 0 is specified. This combination is not allowed." << std::endl;
5464 BbParaNode *tempParaNode = tempParaNodePool.extractNode();
5467 while( tempParaNodePool.getNumOfNodes() > 0 )
5469 BbParaNode *tempParaNode = tempParaNodePool.extractNode();
5472 std::cout <<
"### NEagerToSolveAtRestart is specified to " 5474 <<
" ###" << std::endl;
5476 <<
" ###" << std::endl;
5485 while( ( tempNode = tempParaNodePool.extractNode() ) )
5521 <<
" Warm started from " 5523 <<
" : " << n <<
" ParaNodes read. Current incumbent value = " 5531 <<
" Warm started from " 5533 <<
" : " << n <<
" ParaNodes read. No solution is generated." << std::endl;
5538 <<
" Warm started from " 5540 <<
" : " << n <<
" ParaNodes read. Current incumbent value = " 5542 paraInitiator->getGlobalBestIncumbentSolution()->getObjectiveFunctionValue() )
5565 warmStartNodeTransferring =
false;
5573 double globalBestDualBoundValueLocal =
5663 racingRampUpParams[i-1]->send(
paraComm, i)
5676 racingRampUpParams[i-1]->send(
paraComm, i)
5699 if( racingRampUpParams[i-1] )
delete racingRampUpParams[i-1];
5721 if( racingRampUpParams[i-1] )
delete racingRampUpParams[i-1];
5724 delete [] racingRampUpParams;
5731 BbParaLoadCoordinator::writePreviousStatisticsInformation(
5735 char loadCoordinatorStatisticsFileName[
MaxStrLen];
5737 gzstream::igzstream loadCoordinatorStatisticsStream;
5738 loadCoordinatorStatisticsStream.open(loadCoordinatorStatisticsFileName, std::ios::in | std::ios::binary);
5739 if( !loadCoordinatorStatisticsStream )
5741 std::cout <<
"checkpoint LoadCoordinatorStatistics file cannot open: file name = " << loadCoordinatorStatisticsFileName << std::endl;
5744 int nSolverStatistics;
5745 loadCoordinatorStatisticsStream.read((
char *)&nSolverStatistics,
sizeof(
int));
5747 if( !prevLcts->read(
paraComm, loadCoordinatorStatisticsStream) )
5749 std::cout <<
"checkpoint LoadCoordinatorStatistics file cannot read: file name = " << loadCoordinatorStatisticsFileName << std::endl;
5752 loadCoordinatorStatisticsStream.close();
5755 char solverStatisticsFileName[
MaxStrLen];
5757 gzstream::igzstream solverStatisticsStream;
5758 solverStatisticsStream.open(solverStatisticsFileName, std::ios::in | std::ios::binary);
5759 if( !solverStatisticsStream )
5761 std::cout <<
"checkpoint SolverStatistics file cannot open: file name = " << solverStatisticsFileName << std::endl;
5766 char previousStatisticsFileName[
MaxStrLen];
5767 snprintf(previousStatisticsFileName,
MaxStrLen,
"%s_statistics_w%05lld_LC0",
5770 std::ofstream ofsStatistics;
5771 ofsStatistics.open(previousStatisticsFileName);
5772 if( !ofsStatistics )
5774 std::cout <<
"previous statistics file cannot open : file name = " << previousStatisticsFileName << std::endl;
5779 for(
int i = 0; i < nSolverStatistics; i++ )
5782 if( !psts->read(
paraComm, solverStatisticsStream) )
5784 std::cout <<
"checkpoint SolverStatistics file cannot read: file name = " << solverStatisticsFileName << std::endl;
5792 ofsStatistics << prevLcts->
toString();
5801 solverStatisticsStream.close();
5802 ofsStatistics.close();
5805 #endif // End of UG_WITH_ZLIB 5819 double globalBestDualBoundValueLocal =
5827 dynamic_cast<BbParaNode *>(paraNode),
5856 <<
" S." << destination <<
" < " 5858 dynamic_cast<BbParaNode *>(paraNode)->getDualBoundValue() );
5867 *
osLogSolvingStatus <<
" ( " << bbParaInitiator->
getGap(dynamic_cast<BbParaNode *>(paraNode)->getDualBoundValue()) * 100 <<
"% )";
5881 <<
" S." << destination <<
" > " 5883 paraNode->getDualBoundValue() );
5888 std::cout <<
" ( Inf )";
5892 std::cout <<
" ( " <<
paraInitiator->getGap(paraNode->getDualBoundValue()) * 100 <<
"% )";
5902 std::cout << std::endl;
5912 paraNode = bbParaComm->createParaNode(
5917 dynamic_cast<BbParaNode *>(paraNode),
5926 <<
" S." << destination <<
" < " 5928 dynamic_cast<BbParaNode *>(paraNode)->getDualBoundValue() );
5937 *
osLogSolvingStatus <<
" ( " << bbParaInitiator->
getGap(dynamic_cast<BbParaNode *>(paraNode)->getDualBoundValue()) * 100 <<
"% )";
5996 <<
" S." << source <<
" | " 5997 << bbParaInitiator->convertToExternalValue(
6000 if( !bbParaInitiator->getGlobalBestIncumbentSolution() ||
6016 *
osLogSolvingStatus <<
" ** G.B.: " << bbParaInitiator->convertToExternalValue(globalBestDualBoundValue);
6017 if( !bbParaInitiator->getGlobalBestIncumbentSolution() ||
6024 *
osLogSolvingStatus <<
" ( " << bbParaInitiator->getGap(globalBestDualBoundValue) * 100 <<
"% ) ";
6032 <<
" S." << source <<
" | " 6033 << bbParaInitiator->convertToExternalValue(
6036 if( !bbParaInitiator->getGlobalBestIncumbentSolution() ||
6040 std::cout <<
" ( Inf )";
6048 std::cout <<
" ** G.B.: " <<
paraInitiator->convertToExternalValue(globalBestDualBoundValue);
6049 if( !bbParaInitiator->getGlobalBestIncumbentSolution() ||
6052 std::cout <<
" ( Inf ) ";
6056 std::cout <<
" ( " << bbParaInitiator->getGap(globalBestDualBoundValue) * 100 <<
"% ) ";
6059 <<
" ] ** RR" << std::endl;
6067 if( bbParaInitiator->getGlobalBestIncumbentSolution() &&
6068 bbParaInitiator->getGlobalBestIncumbentSolution()->getObjectiveFunctionValue()
6071 bbParaInitiator->getGlobalBestIncumbentSolution()->send(
paraComm, source);
6080 bbParaInitiator->getAbsgapValue() ||
6082 bbParaInitiator->getGapValue()
6193 <<
" S." << source <<
" >(TERMINATED_IN_RACING_STAGE)";
6200 <<
" S." << source <<
" >(INTERRUPTED_BY_TIME_LIMIT or INTERRUPTED_BY_SOME_SOLVER_TERMINATED_IN_RACING_STAGE)";
6206 std::cout << std::endl;
6216 source <<
" is terminated in racing stage #########" << std::endl;
6219 if( (dynamic_cast<UG::BbParaInitiator *>(
paraInitiator)->getNSolutions() >=
6237 minmalDualBoundNormalTermSolvers < calcState->getDualBoundValue() )
6373 #ifndef _COMM_MPI_WORLD 6420 bbParaRacingSolverPool->
activate(dynamic_cast<BbParaNode *>(paraNode));
6445 <<
" All Solvers starts racing " 6447 dynamic_cast<BbParaNode *>(paraNode)->getDualBoundValue() )
6453 <<
" All Solvers starts racing " 6455 paraNode->getDualBoundValue() )
6476 std::ostringstream s;
6477 s <<
"[ERROR RETURN form Racing Ramp-up Message Hander]:" << __FILE__ <<
"] func = " 6478 << __func__ <<
", line = " << __LINE__ <<
" - " 6479 <<
"process tag = " << tag << std::endl;
6489 if( commUgs ) checkAndReadIncumbent();
6586 std::cout <<
"** Program is still in racing stage. FinalCheckpointGeneratingTime is sppecifid, but the checkpoint files would not be generated." << std::endl;
6641 std::cout <<
"Warning: Ramp-Up Phase Process is switched to 1. CollectOnce, MergeNodesAtRestart and RacingStatBranching are switched to FALSE." << std::endl;
6642 std::cout <<
"You should check the following parameter values: StopRacingNumberOfNodesLeft, StopRacingNumberOfNodesLeftMultiplier, ProhibitCollectOnceMultiplier" << std::endl;
6678 if( racingRampUpParams[i - 1] )
6695 <<
"." << std::endl;
6701 <<
"." << std::endl;
6706 "Racing ramp-up finished after " <<
6753 int exitSolverRequest = 0;
6765 "Start collecting the final check-point data after " <<
6772 if( bestSolverRank > 0 )
6777 exitSolverRequest = 1;
6784 <<
" S." << bestSolverRank <<
" TagInterruptRequest with collecting is sent" 6793 <<
" S." << bestSolverRank <<
" TagInterruptRequest with collecting could not be sent (No best solvers)" 6803 <<
" S." << 0 <<
" TagInterruptRequest with collecting could not be sent (No active solvers)" 6945 if( i != receivedRank )
6976 if( i != receivedRank )
7009 if( dynamic_cast<BbParaSolverPoolForMinimization *>(
paraSolverPool)->isSolverInCollectingMode(rank) )
7109 <<
" Racing Ramp-up restarted." << std::endl;
7167 bbParaRacingSolverPool->
reset();
7168 bbParaRacingSolverPool->activate(paraNode);
7191 <<
" All Solvers starts racing " 7193 dynamic_cast<BbParaNode *>(paraNode)->getDualBoundValue() )
7199 <<
" All Solvers starts racing " 7242 BbParaLoadCoordinator::checkAndReadIncumbent(
7250 while( commUgs->iProbe(&source, &tag) )
7252 if( source == 0 && tag == UGS::TagUpdateIncumbent )
7254 if(
paraInitiator->readUgsIncumbentSolution(commUgs, source) )
7256 double globalBestIncumbentValue =
paraInitiator->getGlobalBestIncumbentSolution()->getObjectiveFunctionValue();
7287 <<
" S." << source <<
" I.SOL " 7289 paraInitiator->getGlobalBestIncumbentSolution()->getObjectiveFunctionValue()
7294 <<
" S." << source <<
" I.SOL " 7296 paraInitiator->getGlobalBestIncumbentSolution()->getObjectiveFunctionValue()
7311 snprintf(solutionFileNameTemp,
MaxStrLen,
"%s%s_after_checkpointing_solution_t.gz",
7314 paraInitiator->writeCheckpointSolution(std::string(solutionFileNameTemp));
7315 snprintf(solutionFileName,
MaxStrLen,
"%s%s_after_checkpointing_solution.gz",
7318 if ( rename(solutionFileNameTemp, solutionFileName) )
7320 std::cout <<
"after checkpointing solution file cannot be renamed: errno = " << strerror(errno) << std::endl;
virtual void inactivateRacingSolverPool(int rank)
inactivate racing solver pool
static const int RestartInRampDownThresholdTime
std::ostream * osTabularSolvingStatus
ostream for solving status in tabular form to switch output location
virtual ParaSolution * clone(ParaComm *comm)=0
create clone of this object
virtual void generateRacingRampUpParameterSets(int nParamSets, ParaRacingRampUpParamSet **racingRampUpParamSets)=0
generate racing ramp-up parameter sets TODO: this function may be in inherited class ...
#define DEF_BB_PARA_COMM(para_comm, comm)
MessageHandlerFunctionPointer * messageHandler
message handlers table for primary phase
static const int MultiplierForBreakingTargetBound
double generateMergeNodesCandidatesTime
time when merge ParaNode candidates are generated
BbParaNodePool * paraNodePoolBufferToGenerateCPF
This is used for GenerateReducedCheckpointFiles.
void terminateAllSolvers()
terminate all solvers
std::string toString()
stringfy ParaCalculationState
double averageDualBoundGain
average dual bound gain: could be negative value at restart
static const int NNodesTransferLogging
void regenerateMergeNodesCandidates(BbParaNode *node, ParaComm *paraComm, ParaInitiator *paraInitiator)
regenerate merge nodes candidates
virtual void send(ParaComm *comm, int destination)=0
send solution data
virtual BbParaDiffSubproblem * makeRootNodeDiffSubproblem()=0
make DiffSubproblem object for root node
representative node for merging
static const int TagNotificationId
bool memoryLimitIsReached
indicate if memory limit is reached or not in a solver, when base solver has memory management featur...
initial nodes were generated
virtual int restartRacing()
restart racing
static const int NCollectOnce
static const int CompTerminatedByInterruptRequest
#define THROW_LOGICAL_ERROR4(msg1, msg2, msg3, msg4)
ParaTimer * paraTimer
Timers for LoadCoordinator.
static const int TagReassignSelfSplitSubtreeRootNode
std::ostream * osStatisticsFinalRun
ostream for statistics of the final run
std::deque< double > lastSeveralDualBoundGains
keep last several dual bound gains
virtual ParaSolverTerminationState * createParaSolverTerminationState()=0
create ParaSolverTerminationState object by default constructor
virtual void outputTabularSolvingStatus(char incumbent)
output solving status in tabular form
static const int TagNewSubtreeRootNode
ParaSolverPool * paraSolverPool
Pools in LoadCorrdinator.
std::ostream * osStatisticsRacingRampUp
ostream for statistics for racing solvers to switch output location
static const int CompTerminatedByTimeLimit
static const int TagIncumbentValue
virtual std::string toString(ParaInitiator *initiator)=0
stringfy ParaSolverTerminationState object
virtual double getCutOffValue()
get cutoff value
virtual ParaTask * getCurrentTask(int rank)=0
get current solving ParaTask in the Solver specified by rank
virtual void interruptRequested(int rank)=0
set the Solver specified by rank is interrupt requested
static const int FinalCheckpointNSolvers
static const int LogSolvingStatusFilePath
void collectsNodes()
set all nodes are collected TODO: this function has to be investigated
static const int TagCutOffValue
static const int GenerateReducedCheckpointFiles
static const double displayInfOverThisValue
if gap is over this value, Inf is displayed at gap TODO: this would move to inherited class ...
int nMergedNodes
the number of merged nodes with this node.
int breakingSolverId
all nodes collecting solver Id: -1: no collecting
int mergeNodes(BbParaNode *node, BbParaNodePool *paraNodePool)
make a merge node
virtual BbParaSolution * getGlobalBestIncumbentSolution()=0
get global best incumbent solution
BbParaMergeNodeInfo * getMergeNodeInfo()
get merge node information struct
int getInterruptedMode()
getter of interrupted flag
virtual int processTagAllowToBeInCollectingMode(int source, int tag)
function to process TagAllowToBeInCollectingMode message
#define DEFAULT_NUM_EPSILON
long long nSolvedInInterruptedRacingSolvers
number of tasks solved of the winner solver in the racing solvers
enum UG::BbParaMergeNodeInfo_::@0 status
status of this ParaMargeNodeInfo
Class for LoadCoordinator termination state which contains calculation state in a ParaLoadCoordinator...
virtual void writeTransferLogInRacing(int rank, ParaCalculationState *state)
write transfer log in racing
virtual int processTagLbBoundTightened(int source, int tag)
function to process TagLbBoundTightened message
size_t nCollectedSolvers
counter to check if all solvers are terminated or not
static const int FinalCheckpointGeneratingTime
int racingWinner
racing winner information
static const int CompTerminatedByMemoryLimit
static const int CollectOnce
BbParaNodePool * paraNodePool
Pools in LoadCorrdinator.
static const int HugeImbalanceThresholdTime
static const int ProhibitCollectOnceMultiplier
virtual double getElapsedTime()=0
get elapsed time
static const int CompInterruptedInMerging
bool isBreakingFinised
indicate that breaking is finished or not if bootstrap ramp-up is not specified, this flag should be ...
virtual double getEpsilon()=0
get epsilon specified
double tNodesOutputLog
keep time for next logging of the number of transferred ParaNodes
int nAverageDualBoundGain
number of nodes whose dual bound gain are counted
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...
void setBoolParamValue(int param, bool value)
set bool parameter value
static const int TagTerminateRequest
bool restarted
indicates that this run is restarted from checkpoint files
static const int InitialNodesGeneration
static const int NumberOfInitialNodes
unsigned long long nSentBackImmediately
Counters related to this ParaLoadCoordinator TODO: The numbers should be classified depending on solv...
static const int DeterministicTabularSolvingStatus
BbParaNodePool * paraNodeToKeepCheckpointFileNodes
The first n nodes may always keep in checkpoint file, that is, the n nodes are not processed in this ...
void setDiffSubproblem(BbParaDiffSubproblem *inDiffSubproblem)
setter of diffSubproblem */
virtual void setInitialStatOnDiffSubproblem(int minDepth, int maxDepth, BbParaDiffSubproblem *diffSubproblem)
set initial status on DiffSubproblem
double getSolverLocalBestDualBoundValue()
gettter of best dual bound value
static const int CompTerminatedByAnotherTask
double getRegenerateMergeNodesCandidatesTime()
getter of regenerateMergeNodesCandidatesTime
int(UG::ParaLoadCoordinator::* MessageHandlerFunctionPointer)(int, int)
virtual int processTagSelfSplitTermStateForInterruption(int source, int tag)
function to process TagSelfSplitTermStateForInterruption message
unsigned long long nDeletedInLc
number of ParaNodes deleted in LC
static const int EnhancedCheckpointStartTime
static const int RatioToApplyLightWeightRootProcess
virtual bool tryToSetIncumbentSolution(BbParaSolution *sol, bool checksol)=0
try to set incumbent solution
double getDeterministicTime()
getter of deterministic time
double regenerateMergeNodesCandidatesTime
time when merge ParaNode candidates are regenerated
virtual ParaRacingRampUpParamSet * createParaRacingRampUpParamSet()=0
create ParaRacingRampUpParamSet object
#define ABORT_LOGICAL_ERROR1(msg1)
virtual bool isSolverActive(int rank)=0
check if the Solver specified by rank is active or not
std::size_t getNSolvers()
get number of Solvers in this Solver pool
static const int TagSubtreeRootNodeToBeRemoved
virtual int processTagAnotherNodeRequest(int source, int tag)
function to process TagAnotherNodeRequest message
virtual int removeBoundedNodes(double incumbentValue)=0
remove bounded BbParaNodes by given incumbnet value
virtual int bcast(ParaComm *comm, int rank, int method)=0
broadcast function to all solvers
ParaInitiator * paraInitiator
initiator
static const int BgapStopSolvingMode
Base class of Calculation state in a ParaSolver.
static const int TagHardTimeLimit
int nSolvedRacingTermination
number of tasks solved at the racing termination solver
unsigned long long nFailedToSendBackAnotherNode
number of ParaNodes failed to send back after AnotherNode request
virtual void insert(BbParaNodePtr node)=0
insert BbParaNode to this pool
static const int NSolverNodesStartBreaking
std::ostream * osLogSolvingStatus
ostram for solving status to switch output location
virtual int bcast(ParaComm *comm, int root)=0
broadcast this object
double addingNodeToMergeStructTime
time when a ParaNode is added to merge struct
static const int NChangeIntoCollectingModeNSolvers
virtual double getAbsgap(double dualBoundValue)=0
get absolute gap of dual bound value
size_t getMaxUsageOfPool()
get maximum usage of this pool
double runningTime
this ParaLoadCoordinator running time
bool interruptedFromControlTerminal
interrupted from control terminal
bool isRootTask()
check if root task or not
static const int NNodesToKeepInCheckpointFile
long long nTasksLeftInInterruptedRacingSolvers
number of of tasks remains of the the winner solver in the racing solvers
static const int TagLCBestBoundValue
unsigned long long nNodesOutputLog
count for next logging of the number of transferred ParaNodes
bool isSameParetntTaskSubtaskIdAs(const TaskId &inTaskId)
check if this task's parent subtree id is the same as that of argument ParaTask's task id ...
Base class of Calculation state in a ParaSolver.
static const int Checkpoint
virtual void setNumberOfNodesSolved(long long n)=0
set number of nodes solved
virtual int receiveSubtreeRootNodeId(ParaComm *comm, int source, int tag)=0
receive this object node Id
double getNSelfSplitNodesLeft()
getter of the number of self-split nodes left
static const int LightWeightRootNodeProcess
bool outputTabularSolvingStatusFlag
output streams and flags which indicate the output is specified or not
static const int NChangeIntoCollectingMode
bool aSolverTerminatedWithOptimality
indicate if a solver terminated with proving optimality of the problem
virtual void sendInterruptRequest()
send interrupt request to all solvers
double externalGlobalBestDualBoundValue
global best dual bound value (external value)
int minDepthInWinnerSolverNodes
racing winner information
virtual const std::string toSimpleString()
stringfy ParaTask as simple string
static const int TagGivenGapIsReached
static const int CompInterruptedInRacingStage
virtual ParaSolverState * createParaSolverState()=0
create ParaSolverState object by default constructor
virtual int send(ParaComm *comm, int destination)=0
send this object
virtual int processTagTerminated(int source, int tag)
function to process TagTerminated message
virtual int receiveNewSubtreeRoot(ParaComm *comm, int source)=0
receive this object
int getTerminationState()
getter of the termination state for solving the subproblem
virtual void receive(ParaComm *comm, int source, int tag)=0
receive this object
int maxDepthInWinnerSolverNodes
maximum depth of open nodes in the winner solver tree
bool hugeImbalance
indicate that a huge imbalance in solvers is detected
int nBoundChangesOfBestNode
the number of fixed variables of the best node The followings are used temporary to generate merge no...
virtual bool isSolverActive(int rank)=0
check if the specified Solver is active or not
bool * racingSolversExist
indicate if racing solver exits or not, true: exists
class BbParaRacingSolverPool (Racing Solver Pool)
virtual std::size_t getNumActiveSolvers()=0
get number of active Solvers
BbParaNodePool * paraNodePoolBufferToRestart
ParaNode pool for buffering ParaNodes in huge imbalance situation.
unsigned long long nNodesInNodePool
number of nodes in ParaNodePool
virtual int reInit(int nRestartedRacing)=0
reinitizalie initiator TODO: this function should be in inherited class
double getAddingNodeToMergeStructTime()
getter of addingNodeToMergeStructTime
virtual void deleteCurrentSubtreeRootNode(int rank)
delete current self-split subtree root node from the active solver with the specified rank ...
virtual double getBestDualBoundValue()=0
get best dual bound value of BbParaNode object in this pool
ParaRacingSolverPool * paraRacingSolverPool
racing solver pool
ParaDeterministicTimer * paraDetTimer
deterministic timer used in case of deterministic mode this timer need to be created in case of deter...
double getDualBoundValue()
getter of the final dual bound value
static const int TagLbBoundTightenedBound
double starvingTime
start time of starving active solvers
double globalBestDualBoundValue
global best dual bound value (internal value)
class for deterministic timer
bool logSubtreeInfoFlag
indicate if subtree info. is logged or not
virtual std::size_t getNumActiveSolvers()=0
get number of active Solvers
static const int TransferLocalCuts
requested subproblem was solved
static const int ParaUNSIGNED
Base class for initial statistics collecting class.
virtual void resetCountersInSolver(int rank, long long numOfNodesSolved, int numOfSelfSplitNodesLeft, BbParaNodePool *paraNodePool)
reset counters in the Solver specified by rank
class BbParaSolverPool (Solver Pool base class)
bool warmStartNodeTransferring
indicate that the first node transferring at warm start (restart)
void setGlobalSubtaskId(int lcId, int subtaskId)
setter of global subtask id
double getAverageDualBoundGain()
getter of average dual bound gain received
double previousCheckpointTime
For checkpoint.
virtual const char * getProbName()=0
get problem name
virtual void addTotalNodesSolved(unsigned long long num)
add number of nodes solved in all Solvers
static const int TimeToIncreaseCMS
#define PARA_COMM_CALL(paracommcall)
virtual void receive(ParaComm *comm, int source, int tag)=0
send this object to destination
bool isCheckpointState
indicate if this state is at checkpoint or not
static const int Deterministic
virtual int getRank()=0
get rank of this process or this thread depending on run-time environment
virtual void setDualBound(double bound)=0
set final dual bound
int(UG::BbParaLoadCoordinator::* BbMessageHandlerFunctionPointer)(int, int)
static const int StopRacingNumberOfNodesLeftMultiplier
virtual ~BbParaLoadCoordinator()
destructor
static const int TagCollectAllNodes
int getNSent()
getter of the number of nodes transferred from the subproblem solving
static const int TagSelfSlpitNodeCalcuationState
BbParaNodePool * paraNodePoolToRestart
ParaNode pool to restart in ramp-down phase.
static const int TagRestart
virtual int processRacingRampUpTagSolverState(int source, int tag)
message handlers specialized for racing ramp-up
unsigned long long nFailedToSendBack
number of ParaNodes failed to send back
double getRootTime()
getter of root node computing time
virtual void receive(ParaComm *comm, int source, int tag)=0
receive this object
int getWinner()
get winner Solver rank
virtual double convertToExternalValue(double internalValue)=0
convert objective function value to external value TODO: this function may be in inherited class ...
TaskId getTaskId()
getter of task id
static const int ParaDOUBLE
BbParaNode * next
this pointer is used in case of self-split ramp-up in LC this field is not transferred ...
int nNormalSelection
number of normal node selection to a random node selection
virtual double getElapsedTime()=0
getter of the deterministic time
int getNNodesLeft()
getter of number of nodes left by the notification Solver
static const int EnhancedFinalCheckpoint
int getNSolvedWithNoPreprocesses()
getter of the number of solved nodes in the case that a node is solved without presolving. This is an experimental routine only used for SCIP parallelization
virtual int processTagReassignSelfSplitSubtreeRootNode(int source, int tag)
function to process TagReassignSelfSplitSubtreeRootNode message
static const int NStopBreaking
void generateMergeNodesCandidates(ParaComm *paraComm, ParaInitiator *paraInitiator)
generate merge nodes candidates
virtual bool sendParaTasksToIdleSolvers()
send ParaNodes to idle solvers
static const int NMergingNodesAtRestart
virtual void updateDualBoundsForSavingNodes()=0
update dual bound values for saving BbParaNodes to checkpoint file
static const int CheckEffectOfRootNodePreprocesses
BbParaLoadCoordinatorTerminationState lcts
LoadCoordinatorTerminationState: counters and times.
static const int TagTaskReceived
virtual void reset()
reset racing solver pool
virtual void activate(BbParaNode *node)
activate racing ramp-up Solver pool with root BbParaNode object
virtual void changeSearchStrategyOfAllSolversToOriginalSearch()
change search strategy of all solvers to original search strategy
virtual void receive(ParaComm *comm, int source)=0
receive solution data
double getRealParamValue(int param)
for real parameters
unsigned long long nMaxUsageOfNodePool
maximum number of ParaNodes in ParaNodePool
static const int TagSolverState
virtual void outputFinalSolverStatistics(std::ostream *os, double time)=0
output final solver statistics
unsigned long long nSent
number of ParaTasks sent from LC
static const int RandomNodeSelectionRatio
BbParaDiffSubproblem * origDiffSubproblem
original DiffSubproblem */
bool interruptIsRequested
indicate that all solver interrupt message is requested or not
virtual void sendIncumbentValue(int receivedRank)
send incumbent value
static const int NEagerToSolveAtRestart
bool allCompInfeasibleAfterSolution
indicate that all computations are infeasible after a feasible solution
std::ofstream ofsTabularSolvingStatus
ofstream for solving status in tabular form
static const int TagTermStateForInterruption
static const int TagSolution
virtual std::size_t getNumInactiveSolvers()=0
get number of inactive Solvers
ParaParamSet * paraParams
UG parameter set.
virtual int processTagTermStateForInterruption(int source, int tag)
function to process TagTermStateForInterruption message
double getInitialDualBoundValue()
getter of initial dual bound value
virtual size_t getNumOfNodes()=0
get number of BbParaNodes in this pool
virtual int bcast(ParaComm *comm, int root)=0
broadcast this object
bool restartingRacing
indicate that racing ramp-up is restarting
std::set< int > * selfSplitFinisedSolvers
indicate selfSplit finished solvers
static const int TNodesTransferLogging
virtual double getAbsgapValue()=0
get absgap value specified
virtual int processTagToken(int source, int tag)
function to process TagToken message
virtual void writeSubtreeInfo(int source, ParaCalculationState *calcState)
write subtree info.
static const int NoUpperBoundTransferInRacing
hard time limit is reached
bool merging
for merging nodes
virtual unsigned long long getTotalNodesSolved()
get number of nodes solved in all Solvers: updated at termination of subtree computation ...
virtual void terminateRequested(int rank)=0
set the Solver specified by rank is terminate requested
static const int TagToken
int createNewGlobalSubtreeId()
create a new global subtree Id
double getAverageNodeCompTimeExcpetRoot()
getter of average computing time of a node except root node
double idleTime
idle time of this LoadCoordinator
virtual int processTagTask(int source, int tag)
Message handlers.
unsigned int getNotificaionId()
getter of notification id
static const int OmitInfeasibleTerminationInRacing
void addNodeToMergeNodeStructs(BbParaNode *node)
add a node to nodes merger
virtual void setSwichOutTime(double time)
set time of switching out collecting mode
int firstCollectingModeState
status of first collecting mode -1 : have not been in collecting mode 0 : once in collecting mode 1 :...
bool givenGapIsReached
shows if specified gap is reached or not
virtual bool isSolverInCollectingMode(int rank)
get collecting mode of the Solver specified by rank
const char * getPrefixWarm()
get prefix of warm start (restart) files
static const int TagGlobalBestDualBoundValueAtWarmStart
static const int TagAnotherNodeRequest
static const int ABgapForSwitchingToBestSolver
static const int DualBoundGainBranchRatio
virtual void sendCutOffValue(int receivedRank)
send cut off value
given gap is reached for the computation
static const int LightWeightNodePenartyInCollecting
class ParaSolverTerminationState (Solver termination state in a ParaSolver)
virtual int processTagHardTimeLimit(int source, int tag)
function to process TagHardTimeLimit message
virtual int processTagSolution(int source, int tag)
function to process TagSolution message
virtual void outputTabularSolvingStatusHeader()
output tabular solving status header
virtual void setFinalSolverStatus(FinalSolverState status)=0
set final solver status
virtual int receive(void *bufer, int count, const int datatypeId, int source, const int tag)=0
receive function for standard ParaData types
Class for the difference between instance and subproblem.
static const int TagUbBoundTightenedIndex
#define ABORT_LOGICAL_ERROR3(msg1, msg2, msg3)
static const int MergeNodesAtRestart
static const int TagRetryRampUp
virtual void run()
run function to start main process
static const int TagBreaking
virtual ParaSolution * createParaSolution()=0
create ParaSolution object by default constructor
ParaComm * paraComm
communicator used
memory limit is reached in a solver
static const int TransferConflictCuts
virtual BbParaNodePtr extractNodeRandomly()=0
extract a BbParaNode object randomly from this pool
void setMergingStatus(int status)
set merging status
bool logTasksTransferFlag
indicate if task transfer info. is logged or not
BbParaDiffSubproblem * mergedDiffSubproblem
merged DiffSubproblem, in case this node is merged and this is the head */
double mergeNodeTime
time when ParaNode is merged
int getNRestarts()
getter of the number of restart occurred in solving a subproblem
const std::string toString()
stringfy BbParaNode
virtual double getGapValue()=0
get gap value specified
std::ostream * osLogTasksTransfer
ostream for task transfer info. to switch output location
int getDepth()
getter of depth
static const int TagAllowToBeInCollectingMode
void setMergeNodeInfo(BbParaMergeNodeInfo *mNode)
set merge node information to this BbParaNode object
#define THROW_LOGICAL_ERROR5(msg1, msg2, msg3, msg4, msg5)
virtual int processTagSelfSlpitNodeCalcuationState(int source, int tag)
function to process TagSelfSlpitNodeCalcuationState message
const std::string toSimpleString()
stringfy BbParaNode as simple string
#define THROW_LOGICAL_ERROR2(msg1, msg2)
virtual bool isEmpty()=0
check if this pool is empty or not
static const int InstanceTransferMethod
static const int CompTerminatedNormally
unsigned long long nNodesLeftInAllSolvers
number of nodes left in all Solvers
computing was interrupted
static const int DistributeBestPrimalSolution
void setEstimatedValue(double inEstimatedValue)
setter of estimated value
Class for LoadCoordinator.
virtual ParaTask * createParaTask()=0
create ParaTask object by default constructor
const char * getStringParamValue(int param)
for char parameters
bool isRacingStage()
getter of isRacingStage
virtual int getNumNodesLeft(int rank)
get number of nodes left in the Solver specified by rank
class ParaTaskGenealogicalLocalPtr
static const int TagTerminateSolvingToRestart
static const int RestartInRampDownActiveSolverRatio
static const int HugeImbalanceActiveSolverRatio
static const int ParaBYTE
static const int TagTerminated
bool winnerSolverNodesCollected
indicate that all winner solver nodes has been collected
virtual ParaTask * getCurrentTask(int rank)
get current solving BbParaNode in the Solver specified by rank */
static const int CheckpointInterval
virtual int processTagSolverState(int source, int tag)
function to process TagSolverState message
bool computationIsInterrupted
indicate that current computation is interrupted or not
void setDualBoundValue(double inDualBoundValue)
setter of dual bound value
static const int OmitTerminationNSolutionsInRacing
static const int TagSelfSplitTermStateForInterruption
static const int BgapCollectingMode
termination phase, includes interrupting phase
virtual bool isTerminateRequested(int rank)=0
check if the Solver specified by rank is terminate requested or not
virtual void changeSearchStrategyOfAllSolversToBestBoundSearch()
change search strategy of all solvers to best bound bound search strategy
bool hardTimeLimitIsReached
indicate that hard time limit is reached or not
virtual unsigned int getNumOfGoodNodes(double globalBestBound)=0
get number of good (heavy) BbParaNodes in this pool
static const int TagNoNodes
virtual bool isWinnerDecided(bool feasibleSol)
check racing termination criteria
virtual void sendRetryRampUpToAllSolvers()
notify retry ramp-up to all solvers
bool racingTermination
racing termination information
static const int StopRacingNumberOfNodesLeft
double getDualBoundValue()
getter of dual bound value
BbParaDiffSubproblem * getDiffSubproblem()
getter of diffSubproblem
virtual bool isInterruptRequested(int rank)=0
check if the Solver specified by rank is interrupt requested or not
unsigned long long mMaxCollectingNodes
maximum multiplier for the number of collecting nodes
normal running phase (primary phase)
void setRealParamValue(int param, double value)
set real parameter value
unsigned long long nWarmStart
number of warm starts (restarts)
static const int OutputTabularSolvingStatus
unsigned long long nReceived
number of ParaTasks received from Solvers
RunningPhase runningPhase
status of LoadCoordinator
BbParaLoadCoordinator(int inNhanders, ParaComm *inComm, ParaParamSet *inParaParamSet, ParaInitiator *paraInitiator, bool *racingSolversExist, ParaTimer *paraTimer, ParaDeterministicTimer *detTimer)
constructor
static const int MultiplierForBgapCollectingMode
static const int RampUpPhaseProcess
virtual int processTagUbBoundTightened(int source, int tag)
function to process TagUbBoundTightened message
BbParaNodePool * unprocessedParaNodes
The last n nodes may always keep in checkpoint file, that is, the n nodes are not processed in this r...
virtual int processTagSubtreeRootNodeToBeRemoved(int source, int tag)
function to process TagSubtreeRootNodeToBeRemoved message
static const int TabularSolvingStatusInterval
static const int TagInterruptRequest
static const int RestartRacing
virtual int receive(ParaComm *comm, int source)=0
receive this object
virtual void writeTransferLog(int rank, ParaCalculationState *state)
write transfer log
int getNSolved()
geeter of the number of tasks solved in a subproblem
double getDeterministicTime()
getter of deterministic time
double minmalDualBoundNormalTermSolvers
minimal dual bound for normal termination solvers
virtual void activateSolver(int rank, BbParaNode *node, int nGoodNodesInNodePool, double averageDualBoundGain)
activate the Solver specified by rank with specified node which has been sent
void setAncestor(ParaTaskGenealogicalPtr *inAncestor)
setter of ancestor
MessageHandlerFunctionPointer * racingRampUpMessageHandler
message handlers table for racing stage
void addDescendant(ParaTaskGenealogicalPtr *inDescendant)
add a descendant
virtual std::string toSimpleString()=0
stringfy ParaCalculationState (simple string version)
static const int CommunicateTighterBoundsInRacing
double getMergeNodeTime()
getter of mergeNodeTime
virtual ParaCalculationState * createParaCalculationState()=0
transfer object factory
static const int WaitTerminationOfThreads
virtual BbParaNode * extractNode()
extract racing root BbParaNode
virtual int send(void *bufer, int count, const int datatypeId, int dest, const int tag)=0
send function for standard ParaData types
virtual void sendRampUpToAllSolvers()
notify ramp-up to all solvers
static const int TagLbBoundTightenedIndex
class BbParaNodePoolForCleanUp
ParaRacingRampUpParamSet * racingWinnerParams
racing winner parameter set
virtual double getObjectiveFunctionValue()=0
get objective function value
static const int TagSubtreeRootNodeStartComputation
static const int TagSelfSplitFinished
virtual int processTagSelfSplitFinished(int source, int tag)
function to process TagSelfSplitFinished message
virtual BbParaNodePtr extractNode()=0
extract a BbParaNode object from this pool
static const int TimeLimit
double getCompTime()
getter of computing time of a subproblem
virtual int getSize()=0
get number of UG processes or UG threads depending on run-time environment
static const int MaxStrLen
virtual std::size_t getNumInactiveSolvers()=0
get number of inactive Solvers
virtual int send(ParaComm *comm, int destination)=0
send ParaRacingRampUpParamSet
static const int RacingStatBranching
static const int TagUbBoundTightenedBound
virtual void inactivateSolver(int rank)
inactivate the Solver specified by rank
bool logSolvingStatusFlag
output streams and flags which indicate the output is specified or not
virtual double getSwichOutTime()
the following functions are to omit rebooting collecting mode process
static const int LogSubtreeInfo
virtual int processRacingRampUpTagCompletionOfCalculation(int source, int tag)
function to process TagCompletionOfCalculation message in racing ramp-up stage
unsigned long long nInitialP
initial p value, which indicates the number of good ParaNodes try to keep in LC
virtual ParaInstance * getParaInstance()=0
get instance object
static const int TagKeepRacing
std::ofstream ofsLogSubtreeInfo
ofstream for subtree info.
virtual int getStrategy()=0
get strategy
long long getNNodesSolved()
getter of number of nodes solved by the notification Solver
Merge node information struct.
virtual void writeSolution(const std::string &message)=0
write solution
bool isCollectingModeRestarted
this flag indicate if a collecting mode is restarted or not
virtual void newRacing()
start a new racing
double statEmptyNodePoolTime
To measure how long does node pool stay in empty situation.
static const int StatisticsToStdout
virtual int processTagNewSubtreeRootNode(int source, int tag)
function to process TagNewSubtreeRootNode message
double averageLastSeveralDualBoundGains
average dual bound gains of last several ones
double getGlobalBestPrimalBoundValue()
get global best primal bound value that the notification Solver has
virtual bool isRacingStage()
check if current stage is in racing or not
int getIntParamValue(int param)
for int parameters
bool isHeaderPrinted
indicate if heeader is printed or not
static const int CompTerminatedInRacingStage
BbParaMergeNodeInfo * mergedTo
pointer to merge node info to which this node is merged */
int nHandlers
number of valid handlers
bool terminationIssued
indicate termination request is issued
unsigned long long nSentBackImmediatelyAnotherNode
number of ParaNodes sent back immediately after AnotherNode request from LC
static const int MultiplierForCollectingMode
virtual bool updateSolution(BbParaSolution *)
update incumbent solution
std::size_t getNSolvers()
get number of Solvers in this Solver pool
size_t nTerminated
counter to check if all solvers are terminated or not
virtual void update(double value)=0
update function of the deterministic time. the deterministic time is a kind of counter ...
virtual bool canGenerateSpecialCutOffValue()
check if solver can generate special cut off value or not
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
static const int NTransferLimitForBreaking
bool areNodesCollected()
check if nodes are collected or not
double getGenerateMergeNodesCandidatesTime()
getter of generateMergeNodesCandidatesTime
static const int NBoundChangesOfMergeNode
static const int TagCompletionOfCalculation
static const int DualBoundGainTest
void deleteMergeNodeInfo(BbParaMergeNodeInfo *mNode)
delete merge node info
void setInitialDualBoundValue(double inTrueDualBoundValue)
setter of initial dual bound value
virtual double getGap(double dualBoundValue)=0
get relative gap of dual bound value
class BbParaSolverState (ParaSolver state object for notification message)
class BbParaSolverTerminationState (Solver termination state in a ParaSolver)
static const int EnhancedCheckpointInterval
BbParaNodesMerger * nodesMerger
pointer to nodes merger object, which merges nodes
virtual BbParaNode * getSelfSplitSubtreeRootNodes(int rank)
get self-split subtree root node from the active solver with the specified rank
char lastCheckpointTimeStr[26]
lastCheckpointTimeStr[0] == ' ' means no checkpoint
void setIntParamValue(int param, int value)
set int parameter value
Base class of communicator object.
bool primalUpdated
indicate that primal solution was updated or not
virtual int processTagCompletionOfCalculation(int source, int tag)
function to process TagCompletionOfCalculation message
virtual bool isObjIntegral()
check if objective function value is always integral or not
virtual void switchOutCollectingMode()
switch out collecting mode
static const int NIdleSolversToTerminate
double previousTabularOutputTime
to keep tabular solving status output time
std::ostream * osLogSubtreeInfo
ostram for subtree info. to switch output location
static const int TagWinner
#define THROW_LOGICAL_ERROR3(msg1, msg2, msg3)
bool initialNodesGenerated
indicates that initial nodes have been generated
static const int TagAckCompletion
virtual void switchInCollectingMode(BbParaNodePool *paraNodePool)=0
switch in collecting mode
ParaTaskGenealogicalPtr * getAncestor()
getter of ancestor
bool getBoolParamValue(int param)
for bool parameters
double hugeImbalanceTime
start time of huge imbalance situation
virtual int processTagSubtreeRootNodeStartComputation(int source, int tag)
function to process TagSubtreeRootNodeStartComputation message
int nRestartedRacing
number of racing stages restarted
static const int CheckpointFilePath