45#ifdef UG_DEBUG_SOLUTION
46#ifndef WITH_DEBUG_SOLUTION
47#define WITH_DEBUG_SOLUTION
49#include "scip/debug.h"
62#if ( defined(_COMM_PTH) || defined(_COMM_CPP11) )
66static int parseLine(
char* line){
70 while (*p <'0' || *p >
'9') p++;
76static long long getVmSize(){
77 FILE* file = fopen(
"/proc/self/status",
"r");
78 long long result = -1;
81 while (fgets(line, 128, file) != NULL){
82 if (strncmp(line,
"VmSize:", 7) == 0){
83 result = parseLine(line);
94ScipParaInitiator::addRootNodeCuts(
97 SCIP_Longint originalLimitsNodes;
98 SCIP_CALL_ABORT( SCIPgetLongintParam(
scip,
"limits/nodes", &originalLimitsNodes) );
99 SCIP_CALL_ABORT( SCIPsetLongintParam(
scip,
"limits/nodes", 1) );
105 SCIP_CALL_ABORT( SCIPsetRealParam(
scip,
"limits/time", timeRemains) );
107 SCIP_RETCODE ret = SCIPsolve(
scip);
108 if( ret != SCIP_OKAY )
110#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
111 SCIPprintError(ret, NULL);
119 SCIP_CALL_ABORT( SCIPresetParams(
scip) );
122 SCIP_CALL_ABORT( SCIPsetIntParam(
scip,
"presolving/maxrounds", 0));
133 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"misc/catchctrlc", FALSE) );
135 SCIP_STATUS status = SCIPgetStatus(
scip);
136 if( status == SCIP_STATUS_OPTIMAL )
142 if( status == SCIP_STATUS_MEMLIMIT )
144 std::cout << *
this <<
"Warning: SCIP was interrupted because the memory limit was reached" << std::endl;
159 cuts = SCIPgetPoolCuts(
scip);
160 ncuts = SCIPgetNPoolCuts(
scip);
161 for(
int c = 0; c < ncuts; ++c )
165 row = SCIPcutGetRow(cuts[c]);
166 assert(!SCIProwIsLocal(row));
167 assert(!SCIProwIsModifiable(row));
168 if( SCIPcutGetAge(cuts[c]) == 0 && SCIProwIsInLP(row) )
170 char name[SCIP_MAXSTRLEN];
178 cols = SCIProwGetCols(row);
179 ncols = SCIProwGetNNonz(row);
181 SCIP_CALL_ABORT( SCIPallocBufferArray(
scip, &vars, ncols) );
182 for( i = 0; i < ncols; ++i )
183 vars[i] = SCIPcolGetVar(cols[i]);
185 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN,
"%s_%d", SCIProwGetName(row), SCIPgetNRuns(
scip));
186 SCIP_CALL_ABORT( SCIPcreateConsLinear(
scip, &cons, name, ncols, vars, SCIProwGetVals(row),
187 SCIProwGetLhs(row) - SCIProwGetConstant(row), SCIProwGetRhs(row) - SCIProwGetConstant(row),
188 TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
189 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
190 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
192 SCIPfreeBufferArray(
scip, &vars);
211 std::string lognameinstance;
214#if ( defined(_COMM_PTH) || defined(_COMM_CPP11) )
215 bool noUpgrade =
false;
240 for( i = 3; i < argc; ++i )
243 if( strcmp(argv[i],
"-l") == 0 )
250 std::cerr <<
"missing log filename after parameter '-l'" << std::endl;
254 else if( strcmp(argv[i],
"-q") == 0 )
256 else if( strcmp(argv[i],
"-c") == 0 )
258 else if( strcmp(argv[i],
"-s") == 0 )
265 std::cerr <<
"missing settings filename after parameter '-s'" << std::endl;
269 else if( strcmp(argv[i],
"-sr") == 0 )
276 std::cerr <<
"missing settings filename after parameter '-sr'" << std::endl;
280 else if( strcmp(argv[i],
"-sl") == 0 )
287 std::cerr <<
"missing settings filename after parameter '-sl'" << std::endl;
291 else if( strcmp(argv[i],
"-w") == 0)
298 char nodesFileName[SCIP_MAXSTRLEN];
299 (void) SCIPsnprintf(nodesFileName, SCIP_MAXSTRLEN,
"%s_nodes_LC0.gz",
prefixWarm);
302 std::cerr <<
"ERROR: Opening file `" << nodesFileName <<
"' failed.\n";
308 std::cerr <<
"missing settings filename after parameter '-w'" << std::endl;
312 std::cerr <<
"Cannot work with parameter '-w' compiling without zlib" << std::endl;
316 else if( strcmp(argv[i],
"-racing") == 0 )
325 std::cerr <<
"missing settings filename after parameter '-racing'" << std::endl;
329 else if ( strcmp(argv[i],
"-isol") == 0 )
338 std::cerr <<
"missing settings filename after parameter '-isol'" << std::endl;
342 else if( strcmp(argv[i],
"-objlimit") == 0 )
351 std::cerr <<
"missing objective limit after parameter '-objlimit'" << std::endl;
355 else if ( strcmp(argv[i],
"-sth") == 0 )
359 else if ( strcmp(argv[i],
"-fsol" ) == 0 )
368 std::cerr <<
"missing solution filename after parameter '-fsol'" << std::endl;
372 else if ( strcmp(argv[i],
"-qsol" ) == 0 )
376 else if( strcmp(argv[i],
"-t" ) == 0 )
381 double timeLimit = atof(argv[i]);
386 std::cerr <<
"missing solution filename after parameter '-t'" << std::endl;
390 else if( strcmp(argv[i],
"-m" ) == 0 )
395 double memoryLimit = atof(argv[i]);
400 std::cerr <<
"missing solution filename after parameter '-m'" << std::endl;
404#if ( defined(_COMM_PTH) || defined(_COMM_CPP11) )
405 else if ( strcmp(argv[i],
"-nou" ) == 0 )
411 else if( strcmp(argv[i],
"-ugsc") == 0 )
416 else if ( strcmp(argv[i],
"-omit1" ) == 0 )
419 else if ( strcmp(argv[i],
"-omit2" ) == 0 )
431 std::ostringstream os;
433 lognameinstance = os.str();
436 (void)ParaInitiator::init(inParaParams, argc, argv);
442 SCIP_CALL( SCIPcreate(&
scip) );
447 SCIP_CALL_ABORT( SCIPsetIntParam(
scip,
"timing/clocktype", 2) );
451 SCIP_CALL_ABORT( SCIPsetRealParam(
scip,
"limits/time", timeRemains) );
458 SCIP_CALL( SCIPincludeDefaultPlugins(
scip) );
470 if( SCIPgetParam(
scip,
"constraints/orbisack/forceconscopy") != NULL )
472 SCIP_CALL( SCIPsetBoolParam(
scip,
"constraints/orbisack/forceconscopy", TRUE) );
474 if( SCIPgetParam(
scip,
"constraints/symresack/forceconscopy") != NULL )
476 SCIP_CALL( SCIPsetBoolParam(
scip,
"constraints/symresack/forceconscopy", TRUE) );
480 if( SCIPgetParam(
scip,
"constraints/orbitope/forceconscopy") != NULL )
482 SCIP_CALL( SCIPsetBoolParam(
scip,
"constraints/orbitope/forceconscopy", TRUE) );
484 if( SCIPgetParam(
scip,
"constraints/orbitope_full/forceconscopy") != NULL )
486 SCIP_CALL( SCIPsetBoolParam(
scip,
"constraints/orbitope_full/forceconscopy", TRUE) );
488 if( SCIPgetParam(
scip,
"constraints/orbitope_pp/forceconscopy") != NULL )
490 SCIP_CALL( SCIPsetBoolParam(
scip,
"constraints/orbitope_pp/forceconscopy", TRUE) );
500 SCIPmessagehdlrSetQuiet(SCIPgetMessagehdlr(
scip), TRUE);
505 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&
messagehdlr, objmessagehdlr, TRUE) );
506#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
507 SCIP_CALL_ABORT( SCIPsetMessagehdlr(
messagehdlr) );
510 SCIP_CALL_ABORT( SCIPmessagehdlrRelease(&
messagehdlr));
512 SCIPmessageSetErrorPrinting(ParaSCIP::scip_errorfunction, (
void*) objmessagehdlr);
516 if(
logname !=
nullptr || quiet )
520 logfile = fopen(lognameinstance.c_str(),
"a");
528 SCIP_CALL_ABORT( SCIPcreateObjMessagehdlr(&
messagehdlr, objmessagehdlr, TRUE) );
529#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
530 SCIP_CALL_ABORT( SCIPsetMessagehdlr(
messagehdlr) );
533 SCIP_CALL_ABORT( SCIPmessagehdlrRelease(&
messagehdlr));
535 SCIPmessageSetErrorPrinting(ParaSCIP::scip_errorfunction, (
void*) objmessagehdlr);
544#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
545 SCIPprintVersion(NULL);
547 SCIPprintVersion(
scip, NULL);
549 SCIPinfoMessage(
scip, NULL,
"\n");
558 SCIP_CALL( SCIPcreate(¶mScip) );
560 SCIP_CALL( SCIPincludeDefaultPlugins(paramScip) );
567 SCIP_CALL_ABORT( SCIPreadParams(paramScip,
settingsName) );
574 std::cout << *
this <<
"** RampUpPhaseProcess is switched to 1, since gap for solvers is specified" << std::endl;
586 std::cout << *
this <<
"** RampUpPhaseProcess is switched to 1, since gap for solvers is specified" << std::endl;
604 std::cout << *
this <<
"** RampUpPhaseProcess is switched to 1, since gap for root node is specified" << std::endl;
616 std::cout << *
this <<
"** RampUpPhaseProcess is switched to 1, since gap for root node is specified" << std::endl;
625 std::cout << *
this <<
"** applied absolute gap = " <<
getAbsgapValue() << std::endl;
626 std::cout << *
this <<
"** applied relative gap = " <<
getGapValue() << std::endl;
632 std::cout << *
this <<
"** RampUpPhaseProcess is switched to 1, since gap is specified" << std::endl;
640 SCIP_CALL_ABORT( SCIPfree(¶mScip) );
650 SCIP_RETCODE retcode = SCIPreadProb(
scip,
probname, NULL);
651 if( retcode != SCIP_OKAY )
653 std::cout << *
this <<
"error reading file <" <<
probname <<
">" << std::endl;
654 SCIP_CALL( SCIPfreeProb(
scip) );
659 SCIP_CALL_ABORT( SCIPtransformProb(
scip));
671 char *probNameFromFileName;
672 char *temp =
new char[strlen(
probname)+1];
674 SCIPsplitFilename(temp, NULL, &probNameFromFileName, NULL, NULL);
675 SCIP_CALL_ABORT( SCIPsetProbName(
scip, probNameFromFileName));
681 if( SCIPfindConshdlr(
scip,
"pseudoboolean") == NULL || SCIPconshdlrGetNConss(SCIPfindConshdlr(
scip,
"pseudoboolean")) == 0 )
683 SCIP_CALL_ABORT( SCIPsetIntParam(
scip,
"presolving/maxrounds", 0) );
684 std::cout << *
this <<
"No LC presolving is specified." << std::endl;
688 std::cout << *
this <<
"Default LC presolving (default)." << std::endl;
696 std::cout << *
this <<
"LC presolving settings file is specified." << std::endl;
701 std::cout << *
this <<
"Default LC presolving (default)." << std::endl;
708 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"misc/catchctrlc", FALSE) );
721 SCIP_Bool originalUpgradeKnapsack;
722 SCIP_Bool originalUpgradeLogicor;
723 SCIP_Bool originalUpgradeSetppc;
724 SCIP_Bool originalUpgradeVarbound;
726#ifdef _COMM_MPI_WORLD
727 if( onlyLinearConss )
729 std::cout <<
"** Original problem has only linear constraints" << std::endl;
733 std::cout <<
"** Original problem has non-linear constraints" << std::endl;
737 if( onlyLinearConss )
739 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", &originalUpgradeKnapsack));
740 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/logicor", &originalUpgradeLogicor));
741 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/setppc", &originalUpgradeSetppc));
742 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/varbound", &originalUpgradeVarbound));
743 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", FALSE));
744 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/logicor", FALSE));
745 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/setppc", FALSE));
746 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/varbound", FALSE));
752 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", &originalUpgradeKnapsack));
753 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/logicor", &originalUpgradeLogicor));
754 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/setppc", &originalUpgradeSetppc));
755 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/varbound", &originalUpgradeVarbound));
756 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", FALSE));
757 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/logicor", FALSE));
758 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/setppc", FALSE));
759 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/varbound", FALSE));
763#ifdef UG_DEBUG_SOLUTION
764 SCIPdebugSolDisable(
scip);
771 std::ostringstream os;
791#if defined(_COMM_PTH) || defined (_COMM_CPP11)
793 long long vmSizeBeforePresolving = getVmSize();
795 std::cout << *
this <<
"** Before presolving: virtualMemUsedAtLc = " <<
virtualMemUsedAtLc <<
", getVmSize() = " << getVmSize() <<
", SCIPgetMemUsed() = " << SCIPgetMemUsed(
scip) <<
", SCIPgetMemTotal() = " << SCIPgetMemTotal(
scip) <<
", SCIPgetMemExternEstim() = " << SCIPgetMemExternEstim(
scip) << std::endl;
798 std::cout << *
this <<
"** Before presolving: virtualMemUsedAtLc = " <<
virtualMemUsedAtLc <<
", SCIPgetMemUsed() = " << SCIPgetMemUsed(
scip) <<
", SCIPgetMemTotal() = " << SCIPgetMemTotal(
scip) <<
", SCIPgetMemExternEstim() = " << SCIPgetMemExternEstim(
scip) << std::endl;
808 SCIP_CALL_ABORT( SCIPsetIntParam(
scip,
"presolving/maxrounds", 0) );
809 std::cout << *
this <<
"** No LC presolving is applied, since memory limit becomes "
816 SCIP_CALL( SCIPpresolve(
scip) );
820 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
829 std::cout << *
this <<
"** set memory limit for presolving in LC and solvers to " <<
dynamic_cast<ScipParaParamSet *
>(
paraParams)->getRealParamValue(
MemoryLimit) <<
" for each SCIP **" << std::endl;
832#if SCIP_APIVERSION >= 101
833 SCIP_PARAM* milp_threads = SCIPgetParam(
scip,
"presolving/milp/threads");
834 if( milp_threads != NULL && SCIPparamGetIntMax(milp_threads) > 1 )
836#ifdef _COMM_MPI_WORLD
837 SCIP_CALL_ABORT( SCIPsetIntParam(
scip,
"presolving/milp/threads", 0) );
839 SCIP_CALL_ABORT( SCIPsetIntParam(
scip,
"presolving/milp/threads", (
paraComm->
getSize() - 1)) );
847 SCIP_CALL_ABORT( SCIPsetIntParam(
scip,
"timing/clocktype", 2) );
848 SCIP_CALL_ABORT( SCIPsetRealParam(
scip,
"limits/time", timeRemains) );
851 SCIP_CALL( SCIPpresolve(
scip) );
852 SCIP_STATUS scipStatus = SCIPgetStatus(
scip);
854 if( scipStatus == SCIP_STATUS_OPTIMAL ||
855 scipStatus == SCIP_STATUS_INFEASIBLE )
860 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
865 else if( scipStatus == SCIP_STATUS_MEMLIMIT )
870 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
877 if( scipStatus == SCIP_STATUS_TIMELIMIT )
882 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
897 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
910 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
920#if defined(_COMM_PTH) || defined (_COMM_CPP11)
923 long long vmSize = getVmSize();
924 long long vmSizeForSolver = (vmSize - vmSizeBeforePresolving)/
paraComm->
getSize() + vmSizeBeforePresolving;
926 std::cout << *
this <<
"** Estimated virtualMemUsedAtSolver = " <<
virtualMemUsedAtLc <<
", getVmSize() = " << vmSize <<
", SCIPgetMemUsed() = " << SCIPgetMemUsed(
scip) <<
", SCIPgetMemTotal() = " << SCIPgetMemTotal(
scip) <<
", SCIPgetMemExternEstim() = " << SCIPgetMemExternEstim(
scip) << std::endl;
929 std::cout << *
this <<
"** Estimated virtualMemUsedAtSolver = " <<
virtualMemUsedAtLc <<
", SCIPgetMemUsed() = " << SCIPgetMemUsed(
scip) <<
", SCIPgetMemTotal() = " << SCIPgetMemTotal(
scip) <<
", SCIPgetMemExternEstim() = " << SCIPgetMemExternEstim(
scip) << std::endl;
933 std::cout << *
this <<
"** set memory limit for solvers to " <<
memoryLimitOfSolverSCIP <<
" for each SCIP **" << std::endl;
939 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
947 int nNonLinearConsHdlrs = 0;
949#ifdef _COMM_MPI_WORLD
950 if( SCIPgetNActiveBenders(
scip) > 0 ) nNonLinearConsHdlrs++;
954 if( nNonLinearConsHdlrs > 0 )
961 if( SCIPgetNVars(
scip) == 0 )
963 SCIP_CALL( SCIPsolve(
scip) );
967 std::cout << *
this <<
"=== solved at Init ===" << std::endl;
974 SCIP_SOL *sol = SCIPgetBestSol(
scip);
980 if( ( SCIPgetObjsense(
scip) == SCIP_OBJSENSE_MINIMIZE && SCIPgetSolOrigObj(
scip, sol) <
objlimit ) ||
981 ( SCIPgetObjsense(
scip) == SCIP_OBJSENSE_MAXIMIZE && SCIPgetSolOrigObj(
scip, sol) >
objlimit ) )
983 int nVars = SCIPgetNVars(
scip);
984 SCIP_VAR **vars = SCIPgetVars(
scip);
985 SCIP_Real *vals =
new SCIP_Real[nVars];
986 SCIP_CALL_ABORT( SCIPgetSolVals(
scip, sol, nVars, vars, vals) );
987 solution = scipParaComm->createScipParaSolution(
989 SCIPgetSolTransObj(
scip, sol),
998 solution = scipParaComm->createScipParaSolution(
1000 ( (
objlimit / ( SCIPgetTransObjscale(
scip) * SCIPgetObjsense(
scip) ) ) - SCIPgetTransObjoffset(
scip) ),
1009 int nVars = SCIPgetNVars(
scip);
1010 SCIP_VAR **vars = SCIPgetVars(
scip);
1011 SCIP_Real *vals =
new SCIP_Real[nVars];
1012 SCIP_CALL_ABORT( SCIPgetSolVals(
scip, sol, nVars, vars, vals) );
1013 solution = scipParaComm->createScipParaSolution(
1015 SCIPgetSolTransObj(
scip, sol),
1027 solution = scipParaComm->createScipParaSolution(
1029 ( (
objlimit / ( SCIPgetTransObjscale(
scip) * SCIPgetObjsense(
scip) ) ) - SCIPgetTransObjoffset(
scip) ),
1040 #ifdef _COMM_MPI_WORLD
1061#ifdef _COMM_MPI_WORLD
1065 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", originalUpgradeKnapsack));
1066 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/logicor", originalUpgradeLogicor));
1067 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/setppc", originalUpgradeSetppc));
1068 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/varbound", originalUpgradeVarbound));
1073 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", originalUpgradeKnapsack));
1074 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/logicor", originalUpgradeLogicor));
1075 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/setppc", originalUpgradeSetppc));
1076 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/varbound", originalUpgradeVarbound));
1081 SCIP_CALL_ABORT( SCIPgetIntParam(
scip,
"presolving/maxrounds", &maxrounds));
1093 std::ostringstream os2;
1095 if( onlyLinearConss )
1103 SCIP_CALL_ABORT( SCIPwriteTransProblem(
scip, os2.str().c_str(), NULL, FALSE));
1108 std::cout << std::endl;
1109 std::cout <<
"syntax: " << argv[0] <<
" fscip_param_file problem_file_name "
1110 <<
"[-l <logfile>] [-q] [-sl <settings>] [-s <settings>] [-sr <root_settings>] [-w <prefix_warm>] [-sth <number>] [-fsol <solution_file>] [-isol <initial solution file]" << std::endl;
1111 std::cout <<
" -l <logfile> : copy output into log file" << std::endl;
1112 std::cout <<
" -q : suppress screen messages" << std::endl;
1113 std::cout <<
" -sl <settings> : load parameter settings (.set) file for LC presolving" << std::endl;
1114 std::cout <<
" -s <settings> : load parameter settings (.set) file for solvers" << std::endl;
1115 std::cout <<
" -sr <root_settings> : load parameter settings (.set) file for root" << std::endl;
1116 std::cout <<
" -w <prefix_warm> : warm start file prefix ( prefix_warm_nodes.gz and prefix_warm_solution.txt are read )" << std::endl;
1117 std::cout <<
" -sth <number> : the number of solver threads used" << std::endl;
1118 std::cout <<
" -fsol <solution file> : specify output solution file" << std::endl;
1119 std::cout <<
" -qsol : quit to output solution file" << std::endl;
1120 std::cout <<
" -isol <intial solution file> : specify initial solution file" << std::endl;
1142 int nRestartedRacing
1146 char initSolFileName[SCIP_MAXSTRLEN];
1150 (void) SCIPsnprintf(initSolFileName, SCIP_MAXSTRLEN,
"%s.%d",
isolname, nRestartedRacing);
1151 if( !rename(
isolname, initSolFileName ) )
1153 std::cout << *
this <<
"Warning: initial solution file name cannot rename: " <<
isolname <<
", " << nRestartedRacing <<
"'th restarted file." << std::endl;
1159 (void) SCIPsnprintf(initSolFileName, SCIP_MAXSTRLEN,
"%s",
isolname);
1168 (void) SCIPsnprintf(initSolFileName, SCIP_MAXSTRLEN,
"i_%s.sol",
instance->
getProbName());
1177 std::cout << *
this <<
"Could not open " <<
generatedIsolname <<
" file to reinitialize for restart." << std::endl;
1180 assert( SCIPgetBestSol(
scip) );
1181 SCIP_CALL_ABORT( SCIPprintBestSol(
scip, fp, FALSE) );
1185 SCIP_RETCODE retcode = SCIPreadProb(
scip,
probname, NULL);
1186 if( retcode != SCIP_OKAY )
1188 std::cout << *
this <<
"error reading file <" <<
probname <<
">" << std::endl;
1189 SCIP_CALL( SCIPfreeProb(
scip) );
1195 SCIP_CALL_ABORT( SCIPtransformProb(
scip));
1201 char *probNameFromFileName;
1202 char *temp =
new char[strlen(
probname)+1];
1204 SCIPsplitFilename(temp, NULL, &probNameFromFileName, NULL, NULL);
1205 SCIP_CALL_ABORT( SCIPsetProbName(
scip, probNameFromFileName));
1208#if ( defined(_COMM_PTH) || defined(_COMM_CPP11) )
1209 SCIP_CALL( SCIPsetBoolParam(
scip,
"misc/catchctrlc", FALSE) );
1212#ifdef _COMM_MPI_WORLD
1213 SCIP_Bool originalUpgradeKnapsack;
1214 SCIP_Bool originalUpgradeLogicor;
1215 SCIP_Bool originalUpgradeSetppc;
1216 SCIP_Bool originalUpgradeVarbound;
1218 if( onlyLinearConss )
1220 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", &originalUpgradeKnapsack));
1221 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/logicor", &originalUpgradeLogicor));
1222 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/setppc", &originalUpgradeSetppc));
1223 SCIP_CALL_ABORT( SCIPgetBoolParam(
scip,
"constraints/linear/upgrade/varbound", &originalUpgradeVarbound));
1224 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", FALSE));
1225 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/logicor", FALSE));
1226 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/setppc", FALSE));
1227 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/varbound", FALSE));
1231 SCIP_CALL( SCIPpresolve(
scip) );
1232 SCIP_STATUS scipStatus = SCIPgetStatus(
scip);
1235 int nNonLinearConsHdlrs = 0;
1238 if( scipStatus == SCIP_STATUS_OPTIMAL ||
1239 scipStatus == SCIP_STATUS_INFEASIBLE )
1244 std::cout << *
this <<
"=== solved at reInit ===" << std::endl;
1259 std::cout << *
this <<
"=== solved at reInit ===" << std::endl;
1267 if( SCIPgetNVars(
scip) == 0 )
1269 SCIP_CALL( SCIPsolve(
scip) );
1273 std::cout << *
this <<
"=== solved at reInit ===" << std::endl;
1281 SCIP_SOL *sol = SCIPgetBestSol(
scip);
1283 int nVars = SCIPgetNVars(
scip);
1284 SCIP_VAR **vars = SCIPgetVars(
scip);
1285 SCIP_Real *vals =
new SCIP_Real[nVars];
1286 SCIP_CALL_ABORT( SCIPgetSolVals(
scip, sol, nVars, vars, vals) );
1289 solution = scipParaComm->createScipParaSolution(
1291 SCIPgetSolTransObj(
scip, sol),
1319#ifdef _COMM_MPI_WORLD
1320 if( onlyLinearConss )
1323 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/knapsack", originalUpgradeKnapsack));
1324 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/logicor", originalUpgradeLogicor));
1325 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/setppc", originalUpgradeSetppc));
1326 SCIP_CALL_ABORT( SCIPsetBoolParam(
scip,
"constraints/linear/upgrade/varbound", originalUpgradeVarbound));
1352 if( checksol && SCIPgetNActiveBenders(
scip) > 0 )
1367 SCIP_VAR** vars = 0;
1383 if( checksol && SCIPgetNVars(
scip) > tempSol->
getNVars() )
1385 std::cout << *
this <<
"*** You should check the solution! ***" << std::endl;
1386 std::cout << *
this <<
"checksol = " << checksol << std::endl;
1387 std::cout << *
this <<
"SCIPgetNVars(scip) = " << SCIPgetNVars(
scip) <<
", " << tempSol->
getNVars() << std::endl;
1392 SCIP_CALL_ABORT( SCIPcreateSol(
scip, &newsol, 0) );
1393 vars = SCIPgetVars(
scip);
1399 int n = SCIPgetNVars(
scip);
1400 SCIP_Real *orgSolValues =
new SCIP_Real[tempSol->
getNVars()];
1404 for( i = 0; i < n; i++ )
1407 SCIP_CALL_ABORT( SCIPsetSolVal(
scip, newsol, vars[i], orgSolValues[i]) );
1418 delete [] orgSolValues;
1433 for( i = 0; i < tempSol->
getNVars(); i++ )
1483 bool primalValueUpdated =
false;
1490#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
1491 SCIP_CALL_ABORT( SCIPtrySolFree(
scip, &newsol, FALSE, TRUE, TRUE, TRUE, &success) );
1493 SCIP_CALL_ABORT( SCIPtrySolFree(
scip, &newsol, FALSE, TRUE, TRUE, TRUE, TRUE, &success) );
1498 if( SCIPisTransformed(
scip) && SCIPgetNSols(
scip) > 0 )
1500 double prevValue = SCIPgetPrimalbound(
scip);
1501 SCIP_CALL_ABORT( SCIPaddSolFree(
scip, &newsol, &success) );
1505 primalValueUpdated =
true;
1510 SCIP_CALL_ABORT( SCIPaddSolFree(
scip, &newsol, &success) );
1511 primalValueUpdated =
true;
1521 if( success && primalValueUpdated )
1540 std::cout << *
this <<
"*** A new solution generated in a Solver does not match with the upperbound in LC ***" << std::endl;
1541 std::cout << *
this <<
"SCIPgetUpperbound(scip) = " << SCIPgetUpperbound(
scip) << std::endl;
1544 <<
", SCIPfeastol(scip) = " << SCIPfeastol(
scip) << std::endl;
1552 SCIP_CALL_ABORT( SCIPcreateOrigSol(
scip, &newsol, 0) );
1553 vars = SCIPgetOrigVars(
scip);
1556 for( i = 0; i < tempSol->
getNVars(); i++ )
1561 if( probindex < 0 )
continue;
1565 SCIP_CALL_ABORT( SCIPsetSolVal(
scip, newsol, vars[probindex], tempSol->
getValues()[i]) );
1570 for( i = 0; i < tempSol->
getNVars(); i++ )
1573 SCIP_CALL_ABORT( SCIPsetSolVal(
scip, newsol, vars[i], tempSol->
getValues()[i]) );
1587#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
1588 SCIP_CALL_ABORT( SCIPtrySolFree(
scip, &newsol, FALSE, TRUE, TRUE, TRUE, &success) );
1590 SCIP_CALL_ABORT( SCIPtrySolFree(
scip, &newsol, FALSE, TRUE, TRUE, TRUE, TRUE, &success) );
1632#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
1633 SCIP_CALL_ABORT( SCIPtrySolFree(
scip, &newsol, FALSE, TRUE, TRUE, TRUE, &success) );
1635 SCIP_CALL_ABORT( SCIPtrySolFree(
scip, &newsol, FALSE, TRUE, TRUE, TRUE, TRUE, &success) );
1661 for( i = 0; i < tempSol->
getNVars(); i++ )
1666 if( probindex < 0 )
continue;
1668 assert(i == probindex);
1670 var = vars[probindex];
1672 if( SCIPvarGetType(var) == SCIP_VARTYPE_CONTINUOUS )
continue;
1681 SCIP_CALL_ABORT( SCIPsetSolVal(
scip, newsol, var, tempSol->
getValues()[i]) );
1684#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
1685 SCIP_CALL_ABORT( SCIPtrySol(
scip, newsol, FALSE, TRUE, TRUE, TRUE, &success) );
1687 SCIP_CALL_ABORT( SCIPtrySol(
scip, newsol, FALSE, TRUE, TRUE, TRUE, TRUE, &success) );
1692 SCIP_CALL_ABORT( SCIPfreeSol(
scip, &newsol) );
1723 std::cout << *
this <<
"Current scip primal value = " << SCIPgetPrimalbound(
scip) << std::endl;
1725 std::cout << *
this <<
"Initiator did not accept solution!" << std::endl;
1728 SCIP_CALL_ABORT( SCIPfreeSol(
scip, &newsol) );
1744 int warmStarted = 0;
1750 double incumbentValue;
1757 SCIP_SOL *sol = SCIPgetBestSol(
scip);
1760 int nVars = SCIPgetNVars(
scip);
1761 SCIP_VAR **vars = SCIPgetVars(
scip);
1762 SCIP_Real *vals =
new SCIP_Real[nVars];
1763 SCIP_CALL_ABORT( SCIPgetSolVals(
scip, sol, nVars, vars, vals) );
1765 solution = scipParaComm->createScipParaSolution(
1767 SCIPgetSolTransObj(
scip,sol),
1777 incumbentValue = DBL_MAX;
1784 int solutionExists = 0;
1793 int solutionExists = 0;
1829 double dualBoundValue
1835 return REALABS((primalbound - dualbound));
1841 double dualBoundValue
1848 if( SCIPisEQ(
scip, primalbound, dualbound) )
1850 else if( SCIPisZero(
scip, dualbound)
1851 || SCIPisZero(
scip, primalbound)
1854 || primalbound * dualbound < 0.0 )
1855 return SCIPinfinity(
scip);
1866 SCIP_CALL_ABORT( SCIPgetRealParam(
scip,
"numerics/epsilon", &epsilon));
1872 const std::string& message
1876 std::ostringstream osold;
1877 if( message ==
"Final Solution" )
1879#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
1882 SCIPmessageSetDefaultHandler();
1894 else if ( message ==
"Updated" )
1898 std::ostringstream os;
1912 if( rename(os.str().c_str(), osold.str().c_str()) )
1914 std::cerr <<
"Rename falied from " <<
"File Name: " << os.str().c_str() <<
" to " << osold.str().c_str() << std::endl;
1928 SCIP_SOL* sol = SCIPgetBestSol(
scip);
1937 if( SCIPsolGetOrigin(sol) != SCIP_SOLORIGIN_ORIGINAL )
1951 fprintf(
transSolutionFile,
"best solution is defined in original space - cannot print it as transformed solution\n");
1969 if ( message ==
"Updated" )
1971 remove(osold.str().c_str());
1977 const std::string& filename
1980 FILE *file = fopen(filename.c_str(),
"a");
1983 std::cout << *
this <<
"file : " << filename <<
"cannot open." << std::endl;
1989 SCIP_CALL_ABORT( SCIPprintOrigProblem(scipInstance->
getParaInstanceScip(), file,
"lp", FALSE) );
1993 SCIP_CALL_ABORT( SCIPprintTransProblem(
scip, file,
"lp", FALSE) );
2005 *os <<
"[ SCIP parameters for root Solver are all default values ]" << std::endl;
2009 *os <<
"[ Not default SCIP parameters for root Solver are as follows ]" << std::endl;
2015 *os <<
"[ SCIP parameters for NOT root Solvers are all default values ]" << std::endl;
2019 *os <<
"[ Not default SCIP parameters for NOT root Solvers are as follows ]" << std::endl;
2029 const std::string& filename
2032 gzstream::ogzstream checkpointSolutionStream;
2033 checkpointSolutionStream.open(filename.c_str(), std::ios::out | std::ios::binary);
2034 if( !checkpointSolutionStream )
2036 std::cout << *
this <<
"Checkpoint file for solution cannot open. file name = " << filename << std::endl;
2041 checkpointSolutionStream.close();
2048 char *afterCheckpointingSolutionFileName
2051 char tempSolutionFileName[SCIP_MAXSTRLEN];
2052 (void) SCIPsnprintf(tempSolutionFileName, SCIP_MAXSTRLEN,
"%s_solution.gz",
prefixWarm);
2053 gzstream::igzstream checkpointSolutionStream;
2054 checkpointSolutionStream.open(tempSolutionFileName, std::ios::in | std::ios::binary);
2055 if( !checkpointSolutionStream )
2057 std::cout << *
this <<
"checkpoint solution file cannot open: file name = " << tempSolutionFileName << std::endl;
2083 checkpointSolutionStream.close();
2086 checkpointSolutionStream.close();
2091 std::cout << *
this <<
"***** Given solution is wrong! ***************************" << std::endl;
2092 std::cout << *
this <<
"***** If the solution was given from checkpoint file, ***" << std::endl;
2093 std::cout << *
this <<
"***** it might be generated in original problem space **" << std::endl;
2094 std::cout << *
this <<
"***** Only primal value is used. *************************" << std::endl;
2095 std::cout << *
this <<
"***** You should better to use -isol option. ************" << std::endl;
2096 std::cout << *
this <<
"***** Or, better to use no distribute solution option. ***" << std::endl;
2101 checkpointSolutionStream.open(afterCheckpointingSolutionFileName, std::ios::in | std::ios::binary);
2102 if( checkpointSolutionStream )
2113 std::cout << *
this <<
"***** After checkpoint solution is RIGHT! ****************" << std::endl;
2124 std::cout << *
this <<
"***** After checkpoint solution is RIGHT! ****************" << std::endl;
2133 checkpointSolutionStream.close();
2160 for(
int n = 1; n < nParamSets + 1 ; n++ )
2162 std::ostringstream oss;
2165 << std::setfill(
'0') << std::setw(5)
2169 SCIP_CALL_ABORT( SCIPresetParams(
scip) );
2170 if( SCIPreadParams(
scip, oss.str().c_str()) != SCIP_OKAY )
2172 std::cout << *
this <<
"Cannot read racing parameter file = " << oss.str().c_str() << std::endl;
2176 racingScipDiffParamSet = scipParaComm->createScipDiffParamSet(
scip);
2177 racingRampUpParamSets[n-1] = scipParaComm->createScipParaRacingRampUpParamSet(
2184 racingScipDiffParamSet
2186 SCIP_CALL_ABORT( SCIPresetParams(
scip) );
2193 SCIP_CALL_ABORT( SCIPresetParams(
scip) );
2207#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
2220#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
2228 racingScipDiffParamSet = scipParaComm->createScipDiffParamSet(
scip);
2230 racingRampUpParamSets[n] = scipParaComm->createScipParaRacingRampUpParamSet(
2237 racingScipDiffParamSet
2242 if( n >= nParamSets )
return;
2247 SCIP_CALL_ABORT( SCIPresetParams(
scip) );
2257 SCIP_SOL* sol = SCIPgetBestSol(
scip);
2260 return std::string(
"solution found exist");
2264 return std::string(
"no solution");
2274#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
2275 SCIPprintVersion( NULL );
2277 SCIPprintVersion(
scip, NULL );
2280 SCIPprintExternalCodes(
scip, NULL);
2365 *os << *
this <<
"SCIP Status : ";
2371 *os <<
"initial nodes were generated" << std::endl;
2377 *os <<
"solving was interrupted [hard time limit reached]" << std::endl;
2380 *os <<
"solving was interrupted [memory limit reached]" << std::endl;
2383 *os <<
"solving was interrupted [given gap reached]" << std::endl;
2386 *os <<
"solving was interrupted" << std::endl;
2389 if( SCIPgetNSols(
scip) > 0 )
2390 *os <<
"problem is solved" << std::endl;
2392 *os <<
"problem is solved [infeasible]" << std::endl;
2395 *os <<
"requested subproblems are solved" << std::endl;
2401 *os << *
this <<
"Total Time : " << time << std::endl;
2402 *os << *
this <<
" solving : " << time << std::endl;
2403 *os << *
this <<
" presolving : " << SCIPgetPresolvingTime(
scip) <<
" (included in solving)" << std::endl;
2404 *os << *
this <<
"B&B Tree : " << std::endl;
2405 *os << *
this <<
" nodes (total) : " <<
nSolved << std::endl;
2406 *os << *
this <<
"Solution : " << std::endl;
2407 *os << *
this <<
" Solutions found : " << SCIPgetNSols(
scip) << std::endl;
2408 SCIP_Real primalbound = SCIPinfinity(
scip);
2414 if( SCIPgetNSols(
scip) != 0 )
2416 primalbound = SCIPgetPrimalbound(
scip);
2433 *os << *
this <<
" Primal Bound : ";
2436 *os <<
" -" << std::endl;
2440 (*os).setf(std::ios::showpos);
2441 *os << std::scientific << std::showpoint << std::setprecision(14) << primalbound << std::endl;
2442 (*os).unsetf(std::ios::showpos);
2446 SCIP_Real finalGap = 0.0;
2450 || SCIPisZero(
scip, primalbound)
2454 finalGap = SCIPinfinity(
scip);
2458#if SCIP_VERSION > 302 || ( SCIP_VERSION == 302 && SCIP_SUBVERSION == 1 )
2459 *os << *
this <<
" Dual Bound : ";
2461 *os << *
this <<
"Dual Bound : ";
2464 *os <<
" -" << std::endl;
2467 (*os).setf(std::ios::showpos);
2468 *os << std::scientific << std::showpoint << std::setprecision(14)
2470 (*os).unsetf(std::ios::showpos);
2472 *os << *
this <<
"Gap : ";
2473 if( SCIPgetNSols(
scip) == 0 )
2475 *os <<
" -" << std::endl;
2477 else if( SCIPisInfinity(
scip, finalGap ) )
2478 *os <<
" infinite" << std::endl;
2481 *os << std::fixed << std::setprecision(5) << 100.0 * finalGap <<
" %" << std::endl;
2483 if( finalGap > SCIPepsilon(
scip) && !SCIPisInfinity(
scip,
REALABS(primalbound) ) )
2485 *os << std::scientific << *
this <<
"* Warning: final gap: " << finalGap <<
" is greater than SCIPepsilon: " << SCIPepsilon(
scip) << std::endl;
2500 int *nNonLinearConsHdlrs
2503 std::cout << *
this <<
"Original Problem : " << std::endl;
2504 std::cout << *
this <<
" Problem name : " << SCIPgetProbName(
scip) << std::endl;
2505 std::cout << *
this <<
" Variables : " << SCIPgetNOrigVars(
scip)
2506 <<
" (" << SCIPgetNOrigBinVars(
scip) <<
" binary, "
2507 << SCIPgetNOrigIntVars(
scip) <<
" integer, "
2508 << SCIPgetNOrigImplVars(
scip) <<
" implicit integer, "
2509 << SCIPgetNOrigContVars(
scip) <<
" continuous)" << std::endl;
2510 std::cout << *
this <<
" Constraints : " << SCIPgetNOrigConss(
scip) << std::endl;
2511 std::cout << *
this <<
" Objective sense : " << (SCIPgetObjsense(
scip) == SCIP_OBJSENSE_MINIMIZE ?
"minimize" :
"maximize") << std::endl;
2512 std::cout << *
this <<
"Presolved Problem : " << std::endl;
2513 std::cout << *
this <<
" Variables : " << SCIPgetNVars(
scip)
2514 <<
" (" << SCIPgetNBinVars(
scip) <<
" binary, "
2515 << SCIPgetNIntVars(
scip) <<
" integer, "
2516 << SCIPgetNImplVars(
scip) <<
" implicit integer, "
2517 << SCIPgetNContVars(
scip) <<
" continuous)" << std::endl;
2518 std::cout << *
this <<
" Constraints : " << SCIPgetNConss(
scip) << std::endl;
2520 std::cout << *
this <<
"Constraints : Number" << std::endl;
2521 for(
int i = 0; i < SCIPgetNConshdlrs(
scip); ++i )
2523 SCIP_CONSHDLR* conshdlr;
2524 int startnactiveconss;
2525 int maxnactiveconss;
2526 conshdlr = SCIPgetConshdlrs(
scip)[i];
2527 startnactiveconss = SCIPconshdlrGetStartNActiveConss(conshdlr);
2528 maxnactiveconss = SCIPconshdlrGetMaxNActiveConss(conshdlr);
2529 if( startnactiveconss > 0 )
2531 std::cout << *
this <<
" " << std::setw(17) << std::left << SCIPconshdlrGetName(conshdlr) <<
": "
2532 << startnactiveconss << ( maxnactiveconss > startnactiveconss ?
'+' :
' ') << std::endl;
2533 if ( std::string(SCIPconshdlrGetName(conshdlr)) != std::string(
"linear") )
2535 *nNonLinearConsHdlrs += startnactiveconss;
2545 for(
int i = 0; i < SCIPgetNConss(
scip); ++i )
2547 SCIP_CONS** conss = SCIPgetConss(
scip);
2548 SCIP_CONSHDLR* conshdlr = SCIPconsGetHdlr(conss[i]);
2549 if( std::string(SCIPconshdlrGetName(conshdlr)) != std::string(
"linear") )
2568ScipParaInitiator::readUgsIncumbentSolution(
2569 UGS::UgsParaCommMpi *ugsComm,
2573 UGS::UgsUpdateIncumbent *updateIncumbent =
new UGS::UgsUpdateIncumbent();
2574 updateIncumbent->receive(ugsComm->getMyComm(), source);
2581 std::ostringstream s;
2582 s << ugsComm->getSolverName(updateIncumbent->getUpdatedSolverId()) <<
"-" << updateIncumbent->getSeqNumber() <<
".sol";
2584 SCIP_CALL_ABORT( SCIPcreateOrigSol(
scip, &origSol, NULL) );
2585 SCIP_Bool partial = FALSE;
2586 SCIP_Bool error = FALSE;
2587 SCIP_CALL_ABORT( SCIPreadSolFile(
scip, s.str().c_str(), origSol, FALSE, &partial, &error ) );
2594 if( (!partial) && (!error) )
2596 SCIP_Bool stored = FALSE;
2597 SCIP_CALL_ABORT( SCIPtrySol(
scip, origSol, FALSE, TRUE, TRUE, TRUE, FALSE, &stored) );
2603 SCIP_SOL *sol = SCIPgetBestSol(
scip);
2604 int nVars = SCIPgetNVars(
scip);
2605 SCIP_VAR **vars = SCIPgetVars(
scip);
2606 SCIP_Real *vals =
new SCIP_Real[nVars];
2607 SCIP_CALL_ABORT( SCIPgetSolVals(
scip, sol, nVars, vars, vals) );
2608 solution = scipParaComm->createScipParaSolution(
2610 SCIPgetSolTransObj(
scip, sol),
2619 solution = scipParaComm->createScipParaSolution(
2630 solution = scipParaComm->createScipParaSolution(
2639 SCIP_CALL_ABORT( SCIPfreeSol(
scip, &origSol) );
2641 delete updateIncumbent;
2648 delete updateIncumbent;
2655ScipParaInitiator::writeUgsIncumbentSolution(
2656 UGS::UgsParaCommMpi *ugsComm
2661 std::ostringstream s;
2662 s << ugsComm->getMySolverName() <<
"-" << seqNumber <<
".sol";
2663 FILE *fp = fopen(s.str().c_str(),
"w");
2666 fprintf (stderr,
"Cannot open solution file to write. File name = %s\n", s.str().c_str());
2670 SCIP_SOL* sol = SCIPgetBestSol(
scip);
2675 SCIP_CALL_ABORT( SCIPprintSol(
scip, sol, fp, TRUE) );
2680 uui->send(ugsComm->getMyComm(),0);
void setParametersInScip(SCIP *scip)
virtual int bcast(UG::ParaComm *comm, int root)=0
void addInitialBranchVarStats(int minDepth, int maxDepth, SCIP *scip)
void accumulateOn(SCIP *scip)
void sendSolverInitializationMessage()
bool tryToSetIncumbentSolution(UG::BbParaSolution *sol, bool checksol)
double convertToInternalValue(double externalValue)
void outputFinalSolverStatistics(std::ostream *os, double time)
void generateRacingRampUpParameterSets(int nParamSets, UG::ParaRacingRampUpParamSet **racingRampUpParamSets)
void writeSolverParameters(std::ostream *os)
void writeSolution(const std::string &message)
void writeCheckpointSolution(const std::string &filename)
char * racingSettingsName
SCIP_MESSAGEHDLR * messagehdlr
void setInitialStatOnDiffSubproblem(int minDepth, int maxDepth, UG::BbParaDiffSubproblem *diffSubproblem)
double getGap(double dualBoundValue)
double readSolutionFromCheckpointFile(char *afterCheckpointingSolutionFileName)
ScipDiffParamSet * scipDiffParamSet
void printSolverVersion(std::ostream *os)
double getAbsgap(double dualBoundValue)
double convertToExternalValue(double internalValue)
ScipUserPlugins * userPlugins
void writeParaInstance(const std::string &filename)
void setDualBound(double bound)
void setFinalSolverStatus(UG::FinalSolverState status)
virtual int init(UG::ParaParamSet *paraParams, int argc, char **argv)
void setUserPlugins(ScipUserPlugins *inUi)
void outputProblemInfo(int *nNonLinearConsHdlrs)
void setNumberOfNodesSolved(long long n)
void includeUserPlugins(SCIP *inScip, const char *inLogname, bool inQuiet, bool inComment)
ScipParaInstance * instance
int reInit(int nRestartedRacing)
ScipParaSolution * solution
void accumulateInitialStat(UG::ParaInitialStat *initialStat)
UG::FinalSolverState finalState
UG::ParaParamSet * paraParams
ScipDiffParamSet * scipDiffParamSetRoot
bool onlyLinearConsHandler()
double convertToInternalValue(double externalValue)
SCIP * getParaInstanceScip()
void getSolValuesForOriginalProblem(ScipParaSolution *sol, SCIP_Real *vals)
int getOrigProbIndex(int index)
double convertToExternalValue(double internalValue)
const char * getProbName()
bool isOriginalIndeciesMap()
void setObjectiveFuntionValue(SCIP_Real val)
int indexAmongSolvers(int index)
bool read(UG::ParaComm *comm, gzstream::igzstream &in)
void write(gzstream::ogzstream &out)
double getObjectiveFunctionValue()
void setValue(int i, SCIP_Real val)
virtual void writeUserSolution(SCIP *scip, int nSolvers, double dual)
Class for the difference between instance and subproblem.
bool solvedAtReInit
solved at reInit
double * tightenedVarUbs
array of tightened upper bound of variable
double * tightenedVarLbs
array of tightened lower bound of variable
bool solvedAtInit
solved at init
gzstream::igzstream checkpointTasksStream
gzstream for checkpoint tasks file
virtual void lockApp()=0
lock UG application to synchronize with other threads
virtual ParaSolution * createParaSolution()=0
create ParaSolution object by default constructor
virtual int getSize()=0
get number of UG processes or UG threads depending on run-time environment
virtual void unlockApp()=0
unlock UG application to synchronize with other threads
virtual int bcast(void *buffer, int count, const int datatypeId, int root)=0
Some action need to be taken for fault tolerant, when the functions return. So, they rerun status val...
virtual int getRank()=0
get rank of this process or this thread depending on run-time environment
class for initial statistics collecting after racing
ParaComm * paraComm
communicator used
bool comment
print comment messages
char * prefixWarm
prefix of warm start files
ParaTimer * timer
timer used
bool isWarmStarted()
check if the execution is warm started (restarted) or not
bool getBoolParamValue(int param)
get bool parameter value
void setIntParamValue(int param, int value)
set int parameter value
double getRealParamValue(int param)
get real parameter value
int getIntParamValue(int param)
get int parameter value
const char * getStringParamValue(int param)
get string parameter value
void setRealParamValue(int param, double value)
set real parameter value
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
virtual ParaSolution * clone(ParaComm *comm)=0
create clone of this object
virtual void bcast(ParaComm *comm, int root)=0
broadcast solution data
virtual double getElapsedTime()=0
get elapsed time
static const int MemoryLimit
static const int RacingParamsDirPath
static const int OutputPresolvedInstance
static const int TryNBranchingOrderInRacing
static const int NoUpperBoundTransferInRacing
static const int RacingRampUpTerminationCriteria
static const int NMaxRacingBaseParameters
static const int SolverSettingsExceptRootNode
static const int UseRootNodeCuts
static const int SolutionFilePath
static const int StopRacingTimeLimit
FinalSolverState
Final status of computation.
@ MemoryLimitIsReached
memory limit is reached in a solver
@ ComputingWasInterrupted
computing was interrupted
@ GivenGapIsReached
given gap is reached for the computation
@ ProblemWasSolved
problem was solved
@ HardTimeLimitIsReached
hard time limit is reached
@ RequestedSubProblemsWereSolved
requested subproblem was solved
@ InitialNodesGenerated
initial nodes were generated
static const int TryNVariablegOrderInRacing
static const int SolverSettingsForInitialPresolving
static const int InstanceTransferMethod
static const int MaxNRacingParamSetSeed
static const int CheckFeasibilityInLC
static const int LogSolvingStatusFilePath
static const int NoPreprocessingInLC
static const int TimeLimit
static const int SolverSettingsAtRacing
static const int RampUpPhaseProcess
static const int SolverSettingsAtRootNode
static const int DistributeBestPrimalSolution
static const int StopRacingNumberOfNodesLeft
static const int ParaDOUBLE
static const int CommunicateTighterBoundsInRacing
#define PARA_COMM_CALL(paracommcall)
#define THROW_LOGICAL_ERROR1(msg1)
#define THROW_LOGICAL_ERROR3(msg1, msg2, msg3)
#define DEF_SCIP_PARA_COMM(scip_para_comm, comm)
ParaInitialStat extension for SCIP solver.
double memoryLimitOfSolverSCIP
long long virtualMemUsedAtLc
ParaInitiator extension for SCIP solver.
ParaInstance extenstion for SCIP solver.
SCIP message handler for ParaSCIP and FiberSCIP.
#define SCIP_FIXED_MEMORY_FACTOR
#define SCIP_PRESOLVIG_MEMORY_FACTOR
#define SCIP_MEMORY_COPY_FACTOR