63#include "ugs/ugsDef.h"
64#include "ugs/ugsParaCommMpi.h"
124 std::cout << std::endl;
125 std::cout <<
"syntax: " <<
argv[0] <<
" fscip_param_file problem_file_name "
126 <<
"[-l <logfile>] [-q] [-sl <settings>] [-s <settings>] [-sr <root_settings>] [-w <prefix_warm>] [-sth <number>] [-fsol <solution_file>] [-isol <initial solution file]" << std::endl;
127 std::cout <<
" -l <logfile> : copy output into log file" << std::endl;
128 std::cout <<
" -q : suppress screen messages" << std::endl;
129 std::cout <<
" -sl <settings> : load parameter settings (.set) file for LC presolving" << std::endl;
130 std::cout <<
" -s <settings> : load parameter settings (.set) file for solvers" << std::endl;
131 std::cout <<
" -sr <root_settings> : load parameter settings (.set) file for root" << std::endl;
132 std::cout <<
" -w <prefix_warm> : warm start file prefix ( prefix_warm_nodes.gz and prefix_warm_solution.txt are read )" << std::endl;
133 std::cout <<
" -sth <number> : the number of solver threads used" << std::endl;
134 std::cout <<
" -fsol <solution file> : specify output solution file" << std::endl;
135 std::cout <<
" -qsol : quit to output solution file" << std::endl;
136 std::cout <<
" -isol <intial solution file> : specify initial solution file" << std::endl;
146 std::ofstream ofsParamsOutputFile;
147 std::ostringstream s;
158 ofsParamsOutputFile.open(s.str().c_str());
159 if( !ofsParamsOutputFile ){
160 std::cout <<
"Cannot open ParaParams output file: file name = " << s.str() << std::endl;
164 ofsParamsOutputFile.close();
175 std::ofstream ofsSolverParamsOutputFile;
176 std::ostringstream s;
187 ofsSolverParamsOutputFile.open(s.str().c_str());
188 if( !ofsSolverParamsOutputFile ){
189 std::cout <<
"Cannot open Solver parameters output file: file name = " << s.str() << std::endl;
193 ofsSolverParamsOutputFile.close();
210 printf(
"ULIBC_bind_pthread_thread( comm->getRank(): %d )\n",
comm->
getRank());
214#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
215 SCIPmessageSetDefaultHandler();
223 int ierr = placeme(1, PLACEME_SCHEME_DEFAULT, PLACEME_LEVEL_DEFAULT, 1,
"HLRN| ");
225 case PLACEME_SUCCESS:
226 fprintf(stdout,
"task %2d: pinning successful\n",
comm->
getRank());
228 case PLACEME_NOTDONE:
229 fprintf(stdout,
"task %2d: pinning not changed on request\n",
comm->
getRank());
232 fprintf(stdout,
"task %2d: pinning not successful, left unchanged\n",
comm->
getRank());
237 char **
argv = solverThreadData->
argv;
280 dynamic_cast<BbParaSolver *
>(paraSolver)->setKeepRacing(
false);
284 dynamic_cast<BbParaSolver *
>(paraSolver)->setKeepRacing(
true);
297 paraSolver->
run( racingRampUpParamSet );
318 delete solverThreadData;
320 if( detTimer )
delete detTimer;
366 static const int solverOrigin = 1;
368 bool racingSolversExist =
false;
371 char *configFileName = 0;
372 for(
int i = 1; i <
argc; ++i )
374 if ( strcmp(
argv[i],
"-ugsc") == 0 )
379 configFileName =
argv[i];
384 std::cerr <<
"missing file name after parameter '-ugsc" << std::endl;
390 UGS::UgsParaCommMpi *commUgs = 0;
398 commUgs =
new UGS::UgsParaCommMpi();
421 struct sigaction newaction;
425 newaction.sa_flags = SA_RESTART | SA_NODEFER | SA_RESETHAND;
426 (void)sigemptyset(&newaction.sa_mask);
429 (void)sigaction(SIGINT, &newaction, NULL);
438#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
439 SCIP_CALL_ABORT( SCIPcreateMesshdlrPThreads(
comm->
getSize()) );
440 SCIPmessageSetDefaultHandler();
448 int ierr = placeme(1, PLACEME_SCHEME_DEFAULT, PLACEME_LEVEL_DEFAULT, 1,
"HLRN| ");
450 case PLACEME_SUCCESS:
451 fprintf(stdout,
"task %2d: pinning successful\n",
comm->
getRank());
453 case PLACEME_NOTDONE:
454 fprintf(stdout,
"task %2d: pinning not changed on request\n",
comm->
getRank());
457 fprintf(stdout,
"task %2d: pinning not successful, left unchanged\n",
comm->
getRank());
469 ULIBC_set_affinity_policy(
nSolvers, SCATTER_MAPPING, THREAD_TO_CORE );
486 std::cout <<
"After Initiator initialized: " << paraTimer->
getElapsedTime() << std::endl;
505 std::thread *solverThreads =
new std::thread[
nSolvers];
510 solverThreadData->
argc = argc;
511 solverThreadData->
argv = argv;
513 solverThreadData->
rank = (i+1);
539 solverThreads[i].join();
542 delete [] solverThreads;
549 if( commUgs )
delete commUgs;
551 if( detTimer )
delete detTimer;
591 racingRampUpParams[i-solverOrigin]->send(
comm, i)
600 if( racingRampUpParams[i-solverOrigin] )
delete racingRampUpParams[i-solverOrigin];
602 delete [] racingRampUpParams;
614 solverThreads[i].join();
617 delete [] solverThreads;
621 std::cout <<
"*** FiberSCIP process is interrupted. ***" << std::endl;
627 if( detTimer )
delete detTimer;
631 if( commUgs )
delete commUgs;
634#ifndef SCIP_THREADSAFE_MESSAGEHDLRS
635 SCIPfreeMesshdlrPThreads();
Base class of initiator that maintains original problem and incumbent solution.
Base class for instance data.
BbParaNode extension for threads communication.
Parameter set for UG framework.
Base class for racing ramp-up parameter set.
UG::ParaRacingRampUpParamSet * createParaRacingRampUpParamSet()
UG::ParaInstance * createParaInstance()
UG::ParaParamSet * createParaParamSet()
void sendSolverInitializationMessage()
void outputFinalSolverStatistics(std::ostream *os, double time)
void generateRacingRampUpParameterSets(int nParamSets, UG::ParaRacingRampUpParamSet **racingRampUpParamSets)
void writeSolverParameters(std::ostream *os)
UG::BbParaDiffSubproblem * makeRootNodeDiffSubproblem()
UG::ParaInstance * getParaInstance()
virtual int init(UG::ParaParamSet *paraParams, int argc, char **argv)
Class for LoadCoordinator.
virtual ParaTask * createParaNode(TaskId inNodeId, TaskId inGeneratorNodeId, int inDepth, double inDualBoundValue, double inOriginalDualBoundValue, double inEstimatedValue, ParaDiffSubproblem *inDiffSubproblem)
create ParaNode object
virtual void run()
run function to start main process
virtual void warmStart()
warm start (restart)
void read(ParaComm *comm, const char *filename)
read ParaParams from file
virtual int receive(ParaComm *comm, int source)=0
receive BbParaRacingRampUpParamSet
virtual void solverInit(ParaParamSet *paraParamSet)
initializer for Solvers
virtual void lockApp()
lock UG application to synchronize with other threads
bool probe(int *source, int *tag)
probe function which waits a new message
int send(void *bufer, int count, const int datatypeId, int dest, const int tag)
send function for standard ParaData types
int receive(void *bufer, int count, const int datatypeId, int source, const int tag)
receive function for standard ParaData types
int getSize()
get size of this communicator, which indicates how many threads in a UG process
int getRank()
get rank of caller's thread
virtual void init(int argc, char **argv)
initializer of this communicator
ParaTimer * createParaTimer()
create ParaTimer object
virtual void unlockApp()
unlock UG application to synchronize with other threads
virtual void lcInit(ParaParamSet *paraParamSet)
initializer for LoadCoordinator
class for deterministic timer
const char * getPrefixWarm()
get prefix of warm start (restart) files
bool isWarmStarted()
check if the execution is warm started (restarted) or not
virtual int bcast(ParaComm *comm, int rank, int method)=0
broadcast function to all solvers
virtual const char * getProbName()=0
get problem name
virtual void interrupt()
interrupt from out side
bool getBoolParamValue(int param)
get bool parameter value
void write(std::ostream *os)
write ParaParams to output stream
int getIntParamValue(int param)
get int parameter value
const char * getStringParamValue(int param)
get string parameter value
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
virtual void init(ParaComm *paraComm)=0
initialize timer
virtual double getElapsedTime()=0
get elapsed time
static ScipParaCommTh * comm
void outputParaParamSet()
static ScipParaLoadCoordinator * paraLc
void outputSolverParams()
int main(int argc, char **argv)
struct SolverThreadData_t SolverThreadData
void * runSolverThread(void *threadData)
static ScipParaInitiator * paraInitiator
double memoryLimitOfSolverSCIP
static void interruptHandler(int signum)
void outputCommandLineMessages(char **argv)
void setUserPlugins(ParaInitiator *initiator)
static ScipParaParamSet * paraParamSet
long long virtualMemUsedAtLc
static const int OutputParaParams
static const int InstanceTransferMethod
static const int LogSolvingStatusFilePath
static const int TagTerminateRequest
static const int ParaBYTE
static const int Deterministic
static const int RampUpPhaseProcess
static const int TagKeepRacing
static const int StatisticsToStdout
#define PARA_COMM_CALL(paracommcall)
#define THROW_LOGICAL_ERROR2(msg1, msg2)
Time limit monitor thread class.
SCIP ParaComm extension for threads communication.
ParaDeterministicTimer extension for SCIP.
ParaInitiator extension for SCIP solver.
ParaInstance extenstion for SCIP solver.
ParaSolver extension for SCIP: Parallelized solver implementation for SCIP.