Scippy

UG

Ubiquity Generator framework

BbParaCommPth Class Reference

Communicator object for pthreads thread communications. More...

#include <bbParaCommPth.h>

+ Inheritance diagram for BbParaCommPth:

Public Member Functions

 BbParaCommPth ()
 constructor of BbParaCommPth More...
 
virtual ~BbParaCommPth ()
 destructor of this communicator More...
 
virtual ParaCalculationStatecreateParaCalculationState ()
 create ParaCalculationState object by default constructor More...
 
virtual ParaCalculationStatecreateParaCalculationState (double compTime, double rootTime, int nSolved, int nSent, int nImprovedIncumbent, int terminationState, int nSolvedWithNoPreprocesses, int nSimplexIterRoot, double averageSimplexIter, int nTransferredLocalCuts, int minTransferredLocalCuts, int maxTransferredLocalCuts, int nTransferredBendersCuts, int minTransferredBendersCuts, int maxTransferredBendersCuts, int nRestarts, double minIisum, double maxIisum, int minNii, int maxNii, double dualBound, int nSelfSplitNodesLeft)
 create ParaCalculationState object More...
 
virtual ParaTaskcreateParaTask ()
 create ParaNode object by default constructor More...
 
virtual ParaTaskcreateParaNode (TaskId inNodeId, TaskId inGeneratorNodeId, int inDepth, double inDualBoundValue, double inOriginalDualBoundValue, double inEstimatedValue, ParaDiffSubproblem *inDiffSubproblem)
 create ParaNode object More...
 
virtual ParaSolverStatecreateParaSolverState ()
 create ParaSolverState object by default constructor More...
 
virtual ParaSolverStatecreateParaSolverState (int racingStage, unsigned int notificationId, int lcId, int globalSubtreeId, long long nodesSolved, int nodesLeft, double bestDualBoundValue, double globalBestPrimalBoundValue, double detTime, double averageDualBoundGain)
 create ParaSolverState object More...
 
virtual ParaSolverTerminationStatecreateParaSolverTerminationState ()
 create ParaSolverTerminationState object by default constructor More...
 
virtual ParaSolverTerminationStatecreateParaSolverTerminationState (int interrupted, int rank, int totalNSolved, int minNSolved, int maxNSolved, int totalNSent, int totalNImprovedIncumbent, int nParaNodesReceived, int nParaNodesSolved, int nParaNodesSolvedAtRoot, int nParaNodesSolvedAtPreCheck, int nTransferredLocalCutsFromSolver, int minTransferredLocalCutsFromSolver, int maxTransferredLocalCutsFromSolver, int nTransferredBendersCutsFromSolver, int minTransferredBendersCutsFromSolver, int maxTransferredBendersCutsFromSolver, int nTotalRestarts, int minRestarts, int maxRestarts, int nTightened, int nTightenedInt, int calcTerminationState, double runningTime, double idleTimeToFirstParaNode, double idleTimeBetweenParaNodes, double iddleTimeAfterLastParaNode, double idleTimeToWaitNotificationId, double idleTimeToWaitAckCompletion, double idleTimeToWaitToken, double totalRootNodeTime, double minRootNodeTime, double maxRootNodeTime, double detTime)
 create ParaSolverTerminationState object More...
 
virtual ParaRacingRampUpParamSetcreateParaRacingRampUpParamSet ()
 create ParaRacingRampUpParamSet object by default constructor More...
 
- Public Member Functions inherited from ParaCommPth
 ParaCommPth ()
 constructor of ParaCommPth More...
 
virtual ~ParaCommPth ()
 destructor of this communicator More...
 
virtual void init (int argc, char **argv)
 initializer of this communicator More...
 
double getStartTime ()
 get start time of this communicator (should not be used) More...
 
int getRank ()
 get rank of caller's thread More...
 
int getSize ()
 get size of this communicator, which indicates how many threads in a UG process More...
 
int getNumOfMessagesWaitingToSend (int dest=-1)
 get size of the messageQueueTable More...
 
void lcInit (ParaParamSet *paraParamSet)
 initializer for LoadCoordinator More...
 
void solverInit (ParaParamSet *paraParamSet)
 initializer for Solvers More...
 
void solverInit (int rank, ParaParamSet *paraParamSet)
 initializer for a specific Solver More...
 
void solverReInit (int rank, ParaParamSet *paraParamSet)
 reinitializer of a specific Solver More...
 
void solverDel (int rank)
 delete Solver from this communicator More...
 
void abort ()
 abort. How it works sometimes depends on communicator used More...
 
bool waitTerminatedMessage ()
 function to wait Terminated message (This function is not used currently) More...
 
bool waitToken (int rank)
 wait token when UG runs with deterministic mode More...
 
void passToken (int rank)
 pass token to from the rank to the next More...
 
bool passTermToken (int rank)
 pass termination token from the rank to the next More...
 
void setToken (int rank, int *inToken)
 set received token to this communicator More...
 
void waitUntilRegistered ()
 wait until thread id is registered to thread table More...
 
void registedAllSolvers ()
 notify that all solvers are registered More...
 
std::ostream * getOstream ()
 get ostream pointer More...
 
void lockApp ()
 lock UG application to synchronize with other threads More...
 
void unlockApp ()
 unlock UG application to synchronize with other threads More...
 
void lockRank ()
 lock rank More...
 
void unlockRank ()
 unlock rank More...
 
void lockApp (char const *f, int l)
 lock UG application to synchronize with other threads (for debugging) More...
 
void lockRank (char const *f, int l)
 lock rank (for debugging) More...
 
void unlockRank (char const *f, int l)
 unlock rank (for debugging) More...
 
ParaTimercreateParaTimer ()
 create ParaTimer object More...
 
int bcast (void *buffer, int count, const int datatypeId, int root)
 broadcast function for standard ParaData types More...
 
int send (void *bufer, int count, const int datatypeId, int dest, const int tag)
 send function for standard ParaData types More...
 
int receive (void *bufer, int count, const int datatypeId, int source, const int tag)
 receive function for standard ParaData types More...
 
void waitSpecTagFromSpecSource (const int source, const int tag, int *receivedTag)
 wait function for a specific tag from a specific source coming from More...
 
bool probe (int *source, int *tag)
 probe function which waits a new message More...
 
bool iProbe (int *source, int *tag)
 iProbe function which checks if a new message is arrived or not More...
 
int uTypeSend (void *bufer, const int datatypeId, int dest, int tag)
 User type send for created data type. More...
 
int uTypeReceive (void **bufer, const int datatypeId, int source, int tag)
 User type receive for created data type. More...
 
- Public Member Functions inherited from ParaComm
 ParaComm ()
 default constructor of ParaComm More...
 
virtual ~ParaComm ()
 destructor of ParaComm More...
 
virtual void setLocalRank (int inRank)
 
virtual void unlockApp (char const *f, int l)
 unlock UG application to synchronize with other threads (for debug) More...
 
virtual ParaParamSetcreateParaParamSet ()=0
 create ParaParamSet object More...
 
virtual ParaInstancecreateParaInstance ()=0
 create ParaInstance object by default constructor More...
 
virtual ParaSolutioncreateParaSolution ()=0
 create ParaSolution object by default constructor More...
 
virtual ParaDiffSubproblemcreateParaDiffSubproblem ()
 create ParaDiffSubproblem object by default constructor More...
 

Protected Member Functions

virtual bool tagStringTableIsSetUpCoorectly ()
 check if tag string table (for debugging) set up correctly More...
 
virtual const char * getTagString (int tag)
 get Tag string for debugging More...
 
- Protected Member Functions inherited from ParaCommPth
unsigned int hashCode (pthread_t tid)
 get hash code from thread id More...
 
void * allocateMemAndCopy (const void *buffer, int count, const int datatypeId)
 allocate memory and copy message More...
 
void copy (void *dest, const void *src, int count, int datatypeId)
 copy message More...
 
void freeMem (void *buffer, int count, const int datatypeId)
 free memory More...
 
bool freeStandardTypes (MessageQueueElement *elem)
 free memory More...
 

Static Protected Attributes

static const char * tagStringTable []
 tag name string table More...
 
- Static Protected Attributes inherited from ParaCommPth
static const char * tagStringTable []
 tag name string table More...
 
static ThreadsTableElementthreadsTable [HashTableSize]
 threads table: index is thread rank More...
 
static __thread int localRank = -1
 local thread rank More...
 

Additional Inherited Members

- Protected Attributes inherited from ParaCommPth
int comSize
 communicator size : number of threads joined in this system More...
 
bool tagTraceFlag
 indicate if tags are traced or not More...
 
int ** token
 index 0: token index 1: token color -1: green > 0: yellow ( termination origin solver number ) -2: red ( means the solver can terminate ) More...
 
ParaSysTimer timer
 system timer More...
 
MessageQueueTableElement ** messageQueueTable
 message queue table More...
 
bool * sentMessage
 sent message flag for synchronization More...
 
LockqueueLock
 Lock for synchronization. More...
 
ConditionVariablesentMsg
 Condition variable for synchronization. More...
 
LocktokenAccessLock
 lock to access token More...
 
Lock applicationLock
 lock for application More...
 
Lock rankLock
 lock to access rank More...
 

Detailed Description

Communicator object for pthreads thread communications.

Definition at line 78 of file bbParaCommPth.h.

Constructor & Destructor Documentation

◆ BbParaCommPth()

constructor of BbParaCommPth

Definition at line 105 of file bbParaCommPth.h.

◆ ~BbParaCommPth()

Member Function Documentation

◆ createParaCalculationState() [1/2]

ParaCalculationState * createParaCalculationState ( )
virtual

create ParaCalculationState object by default constructor

Returns
pointer to ParaCalculationState object

Implements ParaComm.

Definition at line 110 of file bbParaCommPth.cpp.

Referenced by BbParaCommPth::~BbParaCommPth().

◆ createParaCalculationState() [2/2]

ParaCalculationState * createParaCalculationState ( double  compTime,
double  rootTime,
int  nSolved,
int  nSent,
int  nImprovedIncumbent,
int  terminationState,
int  nSolvedWithNoPreprocesses,
int  nSimplexIterRoot,
double  averageSimplexIter,
int  nTransferredLocalCuts,
int  minTransferredLocalCuts,
int  maxTransferredLocalCuts,
int  nTransferredBendersCuts,
int  minTransferredBendersCuts,
int  maxTransferredBendersCuts,
int  nRestarts,
double  minIisum,
double  maxIisum,
int  minNii,
int  maxNii,
double  dualBound,
int  nSelfSplitNodesLeft 
)
virtual

create ParaCalculationState object

Returns
pointer to ParaCalculationState object
Parameters
compTimecomputation time of this ParaNode */
rootTimecomputation time of the root node */
nSolvedthe number of nodes solved */
nSentthe number of ParaNodes sent */
nImprovedIncumbentthe number of improved solution generated in this ParaSolver */
terminationStateindicate whether if this computation is terminationState or not. 0: no, 1: terminationState */
nSolvedWithNoPreprocessesnumber of nodes solved when it is solved with no preprocesses */
nSimplexIterRootnumber of simplex iteration at root node */
averageSimplexIteraverage number of simplex iteration except root node */
nTransferredLocalCutsnumber of local cuts transferred from a ParaNode */
minTransferredLocalCutsminimum number of local cuts transferred from a ParaNode */
maxTransferredLocalCutsmaximum number of local cuts transferred from a ParaNode */
nTransferredBendersCutsnumber of benders cuts transferred from a ParaNode */
minTransferredBendersCutsminimum number of benders cuts transferred from a ParaNode */
maxTransferredBendersCutsmaximum number of benders cuts transferred from a ParaNode */
nRestartsnumber of restarts */
minIisumminimum sum of integer infeasibility */
maxIisummaximum sum of integer infeasibility */
minNiiminimum number of integer infeasibility */
maxNiimaximum number of integer infeasibility */
dualBoundfinal dual bound value
nSelfSplitNodesLeftnumber of self-split nodes left

Definition at line 117 of file bbParaCommPth.cpp.

◆ createParaNode()

ParaTask * createParaNode ( TaskId  inNodeId,
TaskId  inGeneratorNodeId,
int  inDepth,
double  inDualBoundValue,
double  inOriginalDualBoundValue,
double  inEstimatedValue,
ParaDiffSubproblem inDiffSubproblem 
)
virtual

create ParaNode object

Returns
pointer to ParaNode object
Parameters
inNodeIdnode id
inGeneratorNodeIdgenerator node id
inDepthnode depth in global search tree
inDualBoundValuedual bound value
inOriginalDualBoundValueoriginal dual bound value
inEstimatedValueestimated value
inDiffSubproblemdiff subproblem info. from the original problem

Definition at line 176 of file bbParaCommPth.cpp.

Referenced by BbParaCommPth::~BbParaCommPth().

◆ createParaRacingRampUpParamSet()

virtual ParaRacingRampUpParamSet* createParaRacingRampUpParamSet ( )
virtual

create ParaRacingRampUpParamSet object by default constructor

Returns
pointer to ParaRacingRampUpParamSet object

Implements ParaComm.

Definition at line 253 of file bbParaCommPth.h.

References THROW_LOGICAL_ERROR1.

◆ createParaSolverState() [1/2]

ParaSolverState * createParaSolverState ( )
virtual

create ParaSolverState object by default constructor

Returns
pointer to ParaSolverState object

Implements ParaComm.

Definition at line 198 of file bbParaCommPth.cpp.

Referenced by BbParaCommPth::~BbParaCommPth().

◆ createParaSolverState() [2/2]

ParaSolverState * createParaSolverState ( int  racingStage,
unsigned int  notificationId,
int  lcId,
int  globalSubtreeId,
long long  nodesSolved,
int  nodesLeft,
double  bestDualBoundValue,
double  globalBestPrimalBoundValue,
double  detTime,
double  averageDualBoundGain 
)
virtual

create ParaSolverState object

Returns
pointer to ParaSolverState object
Parameters
racingStageif this value is 1, solver is in racing stage
notificationIdid for this notification
lcIdlc id of current ParaNode
globalSubtreeIdglobal subtree id of current ParaNode
nodesSolvednumber of nodes solved
nodesLeftnumber of remaining nodes
bestDualBoundValuebest dual bound value in that of remaining nodes
globalBestPrimalBoundValueglobal best primal bound value
detTimedeterministic time, -1: should be non-deterministic
averageDualBoundGainaverage dual bound gain received

Definition at line 205 of file bbParaCommPth.cpp.

◆ createParaSolverTerminationState() [1/2]

ParaSolverTerminationState * createParaSolverTerminationState ( )
virtual

create ParaSolverTerminationState object by default constructor

Returns
pointer to ParaSolverTerminationState object

Implements ParaComm.

Definition at line 233 of file bbParaCommPth.cpp.

Referenced by BbParaCommPth::~BbParaCommPth().

◆ createParaSolverTerminationState() [2/2]

ParaSolverTerminationState * createParaSolverTerminationState ( int  interrupted,
int  rank,
int  totalNSolved,
int  minNSolved,
int  maxNSolved,
int  totalNSent,
int  totalNImprovedIncumbent,
int  nParaNodesReceived,
int  nParaNodesSolved,
int  nParaNodesSolvedAtRoot,
int  nParaNodesSolvedAtPreCheck,
int  nTransferredLocalCutsFromSolver,
int  minTransferredLocalCutsFromSolver,
int  maxTransferredLocalCutsFromSolver,
int  nTransferredBendersCutsFromSolver,
int  minTransferredBendersCutsFromSolver,
int  maxTransferredBendersCutsFromSolver,
int  nTotalRestarts,
int  minRestarts,
int  maxRestarts,
int  nTightened,
int  nTightenedInt,
int  calcTerminationState,
double  runningTime,
double  idleTimeToFirstParaNode,
double  idleTimeBetweenParaNodes,
double  iddleTimeAfterLastParaNode,
double  idleTimeToWaitNotificationId,
double  idleTimeToWaitAckCompletion,
double  idleTimeToWaitToken,
double  totalRootNodeTime,
double  minRootNodeTime,
double  maxRootNodeTime,
double  detTime 
)
virtual

create ParaSolverTerminationState object

Returns
pointer to ParaSolverTerminationState object
Parameters
interruptedindicate that this solver is interrupted or not. 0: not interrupted, 1: interrupted 2: checkpoint, 3: racing-ramp up
rankrank of this solver
totalNSolvedaccumulated number of nodes solved in this ParaSolver
minNSolvedminimum number of subtree nodes rooted from ParaNode
maxNSolvedmaximum number of subtree nodes rooted from ParaNode
totalNSentaccumulated number of nodes sent from this ParaSolver
totalNImprovedIncumbentaccumulated number of improvements of incumbent value in this ParaSolver
nParaNodesReceivednumber of ParaNodes received in this ParaSolver
nParaNodesSolvednumber of ParaNodes solved ( received ) in this ParaSolver
nParaNodesSolvedAtRootnumber of ParaNodes solved at root node before sending
nParaNodesSolvedAtPreChecknumber of ParaNodes solved at pre-checking of root node solvability
nTransferredLocalCutsFromSolvernumber of local cuts transferred from this Solver
minTransferredLocalCutsFromSolverminimum number of local cuts transferred from this Solver
maxTransferredLocalCutsFromSolvermaximum number of local cuts transferred from this Solver
nTransferredBendersCutsFromSolvernumber of benders cuts transferred from this Solver
minTransferredBendersCutsFromSolverminimum number of benders cuts transferred from this Solver
maxTransferredBendersCutsFromSolvermaximum number of benders cuts transferred from this Solver
nTotalRestartsnumber of total restarts
minRestartsminimum number of restarts
maxRestartsmaximum number of restarts
nTightenednumber of tightened variable bounds during racing stage
nTightenedIntnumber of tightened integral variable bounds during racing stage
calcTerminationStatetermination sate of a calculation in a Solver
runningTimethis solver running time
idleTimeToFirstParaNodeidle time to start solving the first ParaNode
idleTimeBetweenParaNodesidle time between ParaNodes processing
iddleTimeAfterLastParaNodeidle time after the last ParaNode was solved
idleTimeToWaitNotificationIdidle time to wait notification Id messages
idleTimeToWaitAckCompletionidle time to wait ack completion message
idleTimeToWaitTokenidle time to wait token
totalRootNodeTimetotal time consumed by root node processes
minRootNodeTimeminimum time consumed by root node processes
maxRootNodeTimemaximum time consumed by root node processes
detTimedeterministic time, -1: should be non-deterministic

Definition at line 240 of file bbParaCommPth.cpp.

◆ createParaTask()

ParaTask * createParaTask ( )
virtual

create ParaNode object by default constructor

Returns
pointer to ParaNode object

Implements ParaComm.

Definition at line 169 of file bbParaCommPth.cpp.

Referenced by BbParaCommPth::~BbParaCommPth().

◆ getTagString()

const char * getTagString ( int  tag)
protectedvirtual

get Tag string for debugging

Returns
string which shows Tag
Parameters
tagtag to be converted to string

Reimplemented from ParaCommPth.

Definition at line 94 of file bbParaCommPth.cpp.

References ParaCommPth::getTagString(), UG::TAG_BB_FIRST, and BbParaCommPth::tagStringTable.

◆ tagStringTableIsSetUpCoorectly()

bool tagStringTableIsSetUpCoorectly ( )
protectedvirtual

check if tag string table (for debugging) set up correctly

Returns
true if tag string table is set up correctly, false otherwise

Reimplemented from ParaCommPth.

Definition at line 84 of file bbParaCommPth.cpp.

References BbParaCommPth::tagStringTable, and ParaCommPth::tagStringTableIsSetUpCoorectly().

Member Data Documentation

◆ tagStringTable

const char * tagStringTable
staticprotected

tag name string table

Definition at line 83 of file bbParaCommPth.h.

Referenced by BbParaCommPth::getTagString(), and BbParaCommPth::tagStringTableIsSetUpCoorectly().