← Documentation
ADS-IDAC Engine 5.0.0
BranchCluster Class Reference

#include <BranchCluster.h>

Inheritance diagram for BranchCluster:
[legend]
Collaboration diagram for BranchCluster:
[legend]

Public Member Functions

 BranchCluster ()
 Constructs an empty cluster: mother branch and mother cluster IDs 0, cluster ID, current branch number and RELAP5 restart count -1. More...
 
virtual ~BranchCluster ()
 
void setCurrentBranchNum (int)
 Sets the index (within all_branch) of the most recently started alternative. Alternatives with a larger index have not been started yet; the tree traversal restarts a cluster while this index is below all_branch.size() - 1. More...
 
int getCurrentBranchNum ()
 
void calBranchProbability ()
 Recomputes the conditional probability of every alternative (BranchProbability::calculateProbability on each element of all_branch). More...
 
void setIDOfTheMotherBranch (int)
 Sets the ID of the branch (PE node) this cluster hangs from. More...
 
int getIDOfTheMotherBranch ()
 
void saveInfoToFile ()
 Declared only; there is no definition. Use savePENodeToFile(). More...
 
void retrieveInfoFromFile (std::ifstream &)
 Does nothing; the stream is not read. More...
 
void setIDOfThisBranchCluster (int)
 
int getIDOfThisBranchCluster ()
 
void clearBranchCluster ()
 Destroys all alternatives held in all_branch. More...
 
void setNCountForRestartRELAP5 (long)
 Stores the RELAP5 restart count (r5pars_.cncount) recorded at this branching point. More...
 
int getNCountForRestartRELAP5 ()
 
BranchProbability * findBranch (int)
 Finds the alternative with the given branch ID, searching from the last alternative. More...
 
void copyBranchCluster (BranchCluster &)
 Deep-copies the alternatives and all scalar fields of another cluster. The copies are appended to all_branch; call it on an empty cluster. More...
 
void saveBranchClusterToFile (std::ofstream &)
 Writes the cluster as text: the five ID fields, the alternative count, every alternative, then the Time and Probability base parts. More...
 
void retrieveBranchClusterFromFile (std::ifstream &)
 Reads the text layout written by saveBranchClusterToFile and appends the alternatives it reads to all_branch. More...
 
void setIDOfMotherCluster (int)
 Sets the ID of the cluster that contains the mother branch. More...
 
int getIDOfMotherCluster ()
 
void savePENodeToFile ()
 Writes the PE nodes of this cluster under the scheduler's PE directory (Scheduler::getPEDirectory()). More...
 
void savePENodeToFile (std::string strDirName)
 Writes one PE node per alternative of this cluster. More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
- Public Member Functions inherited from Time
 Time ()
 
virtual ~Time ()
 
double getTimeAtWhichThisEventHappen () const
 
void setTimeAtWhichThisEventHappen (double)
 
void copyTime (Time &)
 
void saveTimeToFile (std::ofstream &)
 
void retrieveTimeFromFile (std::ifstream &)
 
- Public Member Functions inherited from Probability
double calculateProbability ()
 
double calculateSurvivalProbability (double)
 
double gamma_log (double)
 
double beta_cdf_inv (double, double, double)
 
double beta_cdf (double, double, double)
 
double beta_pdf (double, double, double)
 
double beta_inc (double, double, double)
 
double beta (double, double)
 
double r8_huge ()
 
double r8_epsilon (void)
 
 Probability ()
 
virtual ~Probability ()
 
void setProbability (double)
 
double getProbability ()
 
void setAlpha_Parameter (double)
 
double getAlpha_Parameter ()
 
void setBeta_Parameter (double)
 
double getBeta_Parameter ()
 
void copyProbability (Probability &)
 
void saveProbabilityToFile (std::ofstream &)
 
void retrieveProbabilityFromFile (std::ifstream &)
 
double getFailureRate () const
 
void setFailureRate (double failure_rate)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Public Attributes

std::vector< std::unique_ptr< BranchProbability > > all_branch
 The alternatives of this branching point; index 0 is the one the generating sequence continues on. More...
 

Private Attributes

int ID_of_the_mother_branch
 
int ID_of_the_mother_cluster
 
int Current_branch_num
 
int ID_of_this_branch_cluster
 
long n_count_for_restart_RELAP5
 

Friends

class boost::serialization::access
 

Detailed Description

Definition at line 33 of file BranchCluster.h.

Constructor & Destructor Documentation

◆ BranchCluster()

BranchCluster::BranchCluster ( )

Constructs an empty cluster: mother branch and mother cluster IDs 0, cluster ID, current branch number and RELAP5 restart count -1.

Definition at line 32 of file BranchCluster.cpp.

References Current_branch_num, ID_of_the_mother_branch, ID_of_the_mother_cluster, ID_of_this_branch_cluster, and n_count_for_restart_RELAP5.

◆ ~BranchCluster()

BranchCluster::~BranchCluster ( )
virtual

Definition at line 43 of file BranchCluster.cpp.

References clearBranchCluster().

Here is the call graph for this function:

Member Function Documentation

◆ calBranchProbability()

void BranchCluster::calBranchProbability ( )

Recomputes the conditional probability of every alternative (BranchProbability::calculateProbability on each element of all_branch).

Definition at line 53 of file BranchCluster.cpp.

References all_branch.

◆ clearBranchCluster()

void BranchCluster::clearBranchCluster ( )

Destroys all alternatives held in all_branch.

Definition at line 47 of file BranchCluster.cpp.

References all_branch.

Referenced by ~BranchCluster().

Here is the caller graph for this function:

◆ copyBranchCluster()

void BranchCluster::copyBranchCluster ( BranchCluster &  _bc)

Deep-copies the alternatives and all scalar fields of another cluster. The copies are appended to all_branch; call it on an empty cluster.

Definition at line 313 of file BranchCluster.cpp.

References all_branch, Probability::copyProbability(), Time::copyTime(), Current_branch_num, getCurrentBranchNum(), getIDOfMotherCluster(), getIDOfTheMotherBranch(), getIDOfThisBranchCluster(), getNCountForRestartRELAP5(), ID_of_the_mother_branch, ID_of_the_mother_cluster, ID_of_this_branch_cluster, and n_count_for_restart_RELAP5.

Here is the call graph for this function:

◆ findBranch()

BranchProbability * BranchCluster::findBranch ( int  _id)

Finds the alternative with the given branch ID, searching from the last alternative.

Parameters
_idBranch (PE node) ID.
Returns
Pointer owned by this cluster, or a null pointer if no alternative has that ID. A miss is also logged to stdout and appended to "err messages.txt".

Definition at line 261 of file BranchCluster.cpp.

References all_branch, getIDOfThisBranchCluster(), and r5pars_.

Referenced by BranchRecord::addAnEndState(), BranchRecord::checkAndAddBranchCluster(), and AdsidacCallback::initiationForRestart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCurrentBranchNum()

int BranchCluster::getCurrentBranchNum ( )
Returns
Index of the most recently started alternative, or -1 if unset.

Definition at line 50 of file BranchCluster.cpp.

References Current_branch_num.

Referenced by copyBranchCluster(), AdsidacCallback::initiationForRestart(), and AdsidacCallback::restartForNewSequence().

Here is the caller graph for this function:

◆ getIDOfMotherCluster()

int BranchCluster::getIDOfMotherCluster ( )
Returns
ID of the cluster that contains the mother branch.

Definition at line 328 of file BranchCluster.cpp.

References ID_of_the_mother_cluster.

Referenced by compute_ancestry_path(), copyBranchCluster(), AdsidacCallback::initiationForRestart(), and log_seq_fingerprint_mpi().

Here is the caller graph for this function:

◆ getIDOfTheMotherBranch()

int BranchCluster::getIDOfTheMotherBranch ( )
Returns
ID of the branch (PE node) this cluster hangs from.

Definition at line 256 of file BranchCluster.cpp.

References ID_of_the_mother_branch.

Referenced by copyBranchCluster(), and AdsidacCallback::initiationForRestart().

Here is the caller graph for this function:

◆ getIDOfThisBranchCluster()

int BranchCluster::getIDOfThisBranchCluster ( )

Definition at line 258 of file BranchCluster.cpp.

References ID_of_this_branch_cluster.

Referenced by copyBranchCluster(), findBranch(), AdsidacCallback::initiationForRestart(), and AdsidacCallback::restartForNewSequence().

Here is the caller graph for this function:

◆ getNCountForRestartRELAP5()

int BranchCluster::getNCountForRestartRELAP5 ( )
Returns
The stored RELAP5 restart count, converted from long to int.

Definition at line 260 of file BranchCluster.cpp.

References n_count_for_restart_RELAP5.

Referenced by copyBranchCluster(), AdsidacCallback::onBranchingPoint(), Client::parallel_restartforanewsequence_(), and AdsidacCallback::restartForNewSequence().

Here is the caller graph for this function:

◆ retrieveBranchClusterFromFile()

void BranchCluster::retrieveBranchClusterFromFile ( std::ifstream &  )

Reads the text layout written by saveBranchClusterToFile and appends the alternatives it reads to all_branch.

Definition at line 297 of file BranchCluster.cpp.

References all_branch, Current_branch_num, ID_of_the_mother_branch, ID_of_the_mother_cluster, ID_of_this_branch_cluster, n_count_for_restart_RELAP5, Probability::retrieveProbabilityFromFile(), and Time::retrieveTimeFromFile().

Here is the call graph for this function:

◆ retrieveInfoFromFile()

void BranchCluster::retrieveInfoFromFile ( std::ifstream &  )

Does nothing; the stream is not read.

Definition at line 253 of file BranchCluster.cpp.

◆ saveBranchClusterToFile()

void BranchCluster::saveBranchClusterToFile ( std::ofstream &  )

Writes the cluster as text: the five ID fields, the alternative count, every alternative, then the Time and Probability base parts.

Definition at line 282 of file BranchCluster.cpp.

References all_branch, Current_branch_num, ID_of_the_mother_branch, ID_of_the_mother_cluster, ID_of_this_branch_cluster, n_count_for_restart_RELAP5, Probability::saveProbabilityToFile(), and Time::saveTimeToFile().

Here is the call graph for this function:

◆ saveInfoToFile()

void BranchCluster::saveInfoToFile ( )

Declared only; there is no definition. Use savePENodeToFile().

◆ savePENodeToFile() [1/2]

void BranchCluster::savePENodeToFile ( )

Writes the PE nodes of this cluster under the scheduler's PE directory (Scheduler::getPEDirectory()).

Definition at line 182 of file BranchCluster.cpp.

References g_sim, Scheduler::getPEDirectory(), savePENodeToFile(), and SimulationContext::SScheduler.

Referenced by savePENodeToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ savePENodeToFile() [2/2]

void BranchCluster::savePENodeToFile ( std::string  strDirName)

Writes one PE node per alternative of this cluster.

Parameters
strDirNamePE output directory, with a trailing path separator.

Per-file layout (default): the node with identifier id is written to <strDirName>PEFolder_<id / subfolder size>/ZPENode_<id>.txt, where the subfolder size is BranchRecord::getSizeOfSubFolder(); the folder is created on demand and an existing file is overwritten. Aggregate layout (--aggregate-pe): the same bytes are appended as one #PE <id> <nbytes> record to the aggregate file in strDirName (see Global/PEOutput.h).

Node content: a header line PE_<id> <time> <id> <mother branch id> 0 <Branch type> <id> <cluster probability>, a line PE_BRANCH <alternative count> <index in cluster> <mother branch id> 0 <id of alternative 0>, then the child list (child types and child IDs; a single EndState child carries the end state ID). Only the node of alternative 0 also carries the conditional probabilities and the content (CommunicationPlace::saveInfoToFileAsBranchForADSV1) of every alternative; the other nodes write 0 for both lists.

A node whose bytes are identical to what this process last wrote for the same ID is skipped (size and hash are kept in g_sim.pe_file_state).

◆ serialize()

template<class Archive >
void BranchCluster::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

◆ setCurrentBranchNum()

void BranchCluster::setCurrentBranchNum ( int  n)

Sets the index (within all_branch) of the most recently started alternative. Alternatives with a larger index have not been started yet; the tree traversal restarts a cluster while this index is below all_branch.size() - 1.

Definition at line 51 of file BranchCluster.cpp.

References Current_branch_num.

Referenced by AdsidacCallback::initiationForRestart(), and Client::parallel_restartforanewsequence_().

Here is the caller graph for this function:

◆ setIDOfMotherCluster()

void BranchCluster::setIDOfMotherCluster ( int  n)

Sets the ID of the cluster that contains the mother branch.

Definition at line 327 of file BranchCluster.cpp.

References ID_of_the_mother_cluster.

◆ setIDOfTheMotherBranch()

void BranchCluster::setIDOfTheMotherBranch ( int  n)

Sets the ID of the branch (PE node) this cluster hangs from.

Definition at line 255 of file BranchCluster.cpp.

References ID_of_the_mother_branch.

◆ setIDOfThisBranchCluster()

void BranchCluster::setIDOfThisBranchCluster ( int  n)

Definition at line 257 of file BranchCluster.cpp.

References ID_of_this_branch_cluster.

◆ setNCountForRestartRELAP5()

void BranchCluster::setNCountForRestartRELAP5 ( long  n)

Stores the RELAP5 restart count (r5pars_.cncount) recorded at this branching point.

Definition at line 259 of file BranchCluster.cpp.

References n_count_for_restart_RELAP5.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 109 of file BranchCluster.h.

Member Data Documentation

◆ all_branch

◆ Current_branch_num

int BranchCluster::Current_branch_num
private

◆ ID_of_the_mother_branch

int BranchCluster::ID_of_the_mother_branch
private

◆ ID_of_the_mother_cluster

int BranchCluster::ID_of_the_mother_cluster
private

◆ ID_of_this_branch_cluster

int BranchCluster::ID_of_this_branch_cluster
private

◆ n_count_for_restart_RELAP5

long BranchCluster::n_count_for_restart_RELAP5
private

The documentation for this class was generated from the following files: