6#include <boost/serialization/export.hpp>
12#include "../Global/SimulationContext.h"
13#include <boost/archive/binary_oarchive.hpp>
14#include <boost/archive/binary_iarchive.hpp>
366 auto container_pt = make_unique<VHWReliabilityUnit>();
367 container_pt->push_back(unique_ptr<BranchSystemAction>(_bp1));
368 container_pt->push_back(unique_ptr<BranchSystemAction>(_bp2));
376 auto container_pt = make_unique<VHWReliabilityUnit>();
377 container_pt->push_back(unique_ptr<BranchSystemAction>(_bp1));
385 auto container_pt = make_unique<VSSReliabilityUnit>();
386 container_pt->push_back(unique_ptr<BranchSupportSystemAction>(_bssa1));
387 container_pt->push_back(unique_ptr<BranchSupportSystemAction>(_bssa2));
395 auto container_pt = make_unique<VSSReliabilityUnit>();
396 container_pt->push_back(unique_ptr<BranchSupportSystemAction>(_bssa));
404 system_branch.push_back(unique_ptr<BranchSystemAlarmState>(_sap));
408 bool branch_generated =
false;
412 branch_generated =
true;
415 if (branch_generated) {
419 branch_generated =
true;
423 if (branch_generated) {
427 branch_generated =
true;
431 if (branch_generated) {
435 branch_generated =
true;
439 if (branch_generated) {
443 branch_generated =
true;
470double singleFloor(
double floor) {
471 static const double v = [] {
472 const char *s = std::getenv(
"ADS_BRANCH_FLOOR_SINGLE");
473 return s ? std::atof(s) : -1.0;
475 return v >= 0.0 ? v : floor;
487void foldBelowFloor(Vec &alternatives,
double floor) {
488 if (alternatives.empty())
return;
489 if (alternatives.size() == 1) {
490 double p = alternatives[0]->getProbability();
491 if (p < 1.0 && (1.0 - p) < singleFloor(floor)) alternatives[0]->setProbability(1.0);
495 for (
size_t k = alternatives.size(); k-- > 1;) {
496 double p = alternatives[k]->getProbability();
499 alternatives.erase(alternatives.begin() +
static_cast<long>(k));
502 if (folded > 0.0) alternatives[0]->setProbability(alternatives[0]->getProbability() + folded);
509int foldCrewFork(
BranchUnit &bu,
int type,
double floor) {
557 int i, j, k, n, section_size, section_size1, num_element_repeat, num_unit_repeat, num_element_repeat1,
559 static const double branch_floor = [] {
560 const char *v = std::getenv(
"ADS_BRANCH_FLOOR");
561 return v ? std::atof(v) : 0.0;
566 double bc_probability;
567 vector<unique_ptr<BranchSystemActionVector>> branch_system_action_matrix;
568 decltype(branch_system_action_matrix)::iterator bsam_itr;
569 vector<unique_ptr<BranchSupportSystemActionVector>> branch_support_system_action_matrix;
570 decltype(branch_support_system_action_matrix)::iterator bssam_itr;
576 auto bc_upt = make_unique<BranchCluster>();
577 auto *bc_pt = bc_upt.get();
578 bc_pt->setTimeAtWhichThisEventHappen(
r5pars_.timesno);
580 bc_pt->all_branch.push_back(make_unique<BranchProbability>());
587 section_size = num_element_repeat;
588 for (i = 1; i <= num_unit_repeat; i++) {
595 section_size = num_element_repeat;
596 for (i = 1; i <= num_unit_repeat; i++) {
603 section_size = num_element_repeat;
604 for (i = 1; i <= num_unit_repeat; i++) {
613 section_size = num_element_repeat;
614 for (i = 1; i <= num_unit_repeat; i++) {
620 branch_system_action_matrix.push_back(make_unique<BranchSystemActionVector>());
625 num_element_repeat1 = section_size1 / hw_container->size();
626 section_size1 = num_element_repeat1;
627 for (i = 1; i <= num_unit_repeat1; i++) {
629 for (
auto &bsa_src : *hw_container) {
631 for (j = 0; j < num_element_repeat1; j++) {
634 n = (i - 1) * (hw_container->size() * num_element_repeat1) + (k - 1) * num_element_repeat1 + j;
635 branch_system_action_matrix.at(n)->branch_system_action_vector.push_back(unique_ptr<BranchSystemAction>(bsa_pt));
642 section_size = num_element_repeat;
643 for (i = 1; i <= num_unit_repeat; i++) {
645 for (bsam_itr = branch_system_action_matrix.begin(); bsam_itr != branch_system_action_matrix.end();
648 for (j = 0; j < num_element_repeat; j++) {
649 n = (i - 1) * branch_system_action_matrix.size() + (k - 1) * num_element_repeat + j;
650 auto *bp_pt = bc_pt->all_branch.at(n).get();
651 for (
auto &bsa_src : (*bsam_itr)->branch_system_action_vector) {
654 bp_pt->HW_reliability.push_back(shared_ptr<BranchSystemAction>(bsa_pt));
660 branch_system_action_matrix.clear();
668 section_size = num_element_repeat;
669 for (i = 1; i <= num_unit_repeat; i++) {
674 branch_support_system_action_matrix.push_back(make_unique<BranchSupportSystemActionVector>());
679 num_element_repeat1 = section_size1 / ss_container->size();
680 section_size1 = num_element_repeat1;
681 for (i = 1; i <= num_unit_repeat1; i++) {
683 for (
auto &bssa_src : *ss_container) {
685 for (j = 0; j < num_element_repeat1; j++) {
688 n = (i - 1) * (ss_container->size() * num_element_repeat1) + (k - 1) * num_element_repeat1 + j;
689 branch_support_system_action_matrix.at(n)->branch_support_system_action_vector.push_back(unique_ptr<BranchSupportSystemAction>(bssa_pt));
696 section_size = num_element_repeat;
697 for (i = 1; i <= num_unit_repeat; i++) {
699 for (bssam_itr = branch_support_system_action_matrix.begin();
700 bssam_itr != branch_support_system_action_matrix.end();
703 for (j = 0; j < num_element_repeat; j++) {
704 n = (i - 1) * branch_support_system_action_matrix.size() + (k - 1) * num_element_repeat + j;
705 auto *bp_pt = bc_pt->all_branch.at(n).get();
706 for (
auto &bssa_src : (*bssam_itr)->branch_support_system_action_vector) {
709 bp_pt->SS_reliability.push_back(shared_ptr<BranchSupportSystemAction>(bssa_pt));
715 branch_support_system_action_matrix.clear();
723 spt->copyBranchSystemAlarmState(*sb_src);
724 bc_pt->all_branch.at(i)->new_alarm.push_back(shared_ptr<BranchSystemAlarmState>(spt));
729 bc_pt->setNCountForRestartRELAP5(
r5pars_.cncount);
740 bc_pt->setCurrentBranchNum(0);
744 if (getenv(
"ADSIDAC_BRANCH_DIAG"))
745 fprintf(stderr,
"[BRANCH-DIAG] t=%.4f branches=%zu CID=%d br0_id=%d mother_cid=%d mother_br=%d\n",
746 r5pars_.timesno, bc_pt->all_branch.size(),
759 bc_pt->setProbability(bc_probability);
761 bc_pt->setProbability(1.0);
763 n = bc_pt->getIDOfThisBranchCluster();
764 for (
auto &ab : bc_pt->all_branch) {
765 ab->setIDOfTheAssociatedBranchCluster(n);
766 ab->calculateProbability();
767 ab->calUnconditionalBranchProbability(bc_pt->getProbability());
775 auto num_branches = bc_pt->all_branch.size();
836 return bc_pt->all_branch.size();
840 bool found_branch_cluster =
false;
841 bool found_branch =
false;
845 found_branch_cluster =
true;
846 auto all_branch_itr = (*branch_cluster_ritr)->all_branch.begin();
847 while (all_branch_itr != (*branch_cluster_ritr)->all_branch.end() && !found_branch) {
860 (*all_branch_itr)->sendBranchInfoToCommandCenter((*all_branch_itr)->getIDOfThisBranch());
867 branch_cluster_ritr++;
869 if (!found_branch_cluster || !found_branch) {
870 ofstream fout(
"err messages.txt", ios::app);
871 cout <<
"BranchRecord::sendCurrentBranchCommandToCommandCenter Branch Cluster ID: "
874 fout <<
r5pars_.timesno <<
" BranchRecord::sendCurrentBranchCommandToCommandCenter Branch Cluster ID: "
890 bool found_branch =
false;
898 if (n_th_branch < (*branch_cluster_ritr)->all_branch.size()) {
899 all_branch_pt = (*branch_cluster_ritr)->all_branch.at(n_th_branch).get();
901 ofstream fout(
"err messages.txt", ios::app);
902 fout <<
"Restart Branch Cluster: " << (*branch_cluster_ritr)->getIDOfThisBranchCluster() <<
" Cluster Branch: "
903 << n_th_branch <<
" BranchID: " << all_branch_pt->
getIDOfThisBranch() <<
" Branch UnCondProbability: "
904 << (all_branch_pt)->getUnconditionalBranchProbability() <<
'\n';
919 ofstream fout(
"err messages.txt", ios::app);
920 cout <<
"BranchRecord:sendSpecifiedBranchCommandToCommandCenter n_th_branch: " << n_th_branch
921 <<
" exceeds the size of all_branch: " << (*branch_cluster_ritr)->all_branch.size() << endl;
922 fout <<
r5pars_.timesno <<
" BranchRecord:sendSpecifiedBranchCommandToCommandCenter n_th_branch: " << n_th_branch
923 <<
" exceeds the size of all_branch: " << (*branch_cluster_ritr)->all_branch.size() <<
'\n';
933 int num_of_single_element_repeat,
934 int nth_unit_appear) {
937 switch (type_of_branch) {
939 for (
auto &src : _bu.
goal) {
940 for (i = 0; i < num_of_single_element_repeat; i++) {
941 auto p = make_shared<BranchGoal>();
942 p->copyBranchGoal(*src);
943 k = (nth_unit_appear - 1) * _bu.
goal.size() + j * num_of_single_element_repeat + i;
944 bc_ref.
all_branch.at(k)->goal.push_back(std::move(p));
951 for (i = 0; i < num_of_single_element_repeat; i++) {
952 auto p = make_shared<BranchStrategy>();
953 p->copyBranchStrategy(*src);
954 k = (nth_unit_appear - 1) * _bu.
strategy.size() + j * num_of_single_element_repeat + i;
955 bc_ref.
all_branch.at(k)->strategy.push_back(std::move(p));
961 for (
auto &src : _bu.
subgoal) {
962 for (i = 0; i < num_of_single_element_repeat; i++) {
963 auto p = make_shared<BranchSubGoal>();
964 p->copyBranchSubGoal(*src);
965 k = (nth_unit_appear - 1) * _bu.
subgoal.size() + j * num_of_single_element_repeat + i;
966 bc_ref.
all_branch.at(k)->subgoal.push_back(std::move(p));
973 for (i = 0; i < num_of_single_element_repeat; i++) {
974 auto p = make_shared<BranchDiagnosis>();
975 p->copyBranchDiagnosis(*src);
976 k = (nth_unit_appear - 1) * _bu.
diagnosis.size() + j * num_of_single_element_repeat + i;
977 bc_ref.
all_branch.at(k)->diagnosis.push_back(std::move(p));
984 for (i = 0; i < num_of_single_element_repeat; i++) {
985 auto p = make_shared<BranchActionObjective>();
986 p->copyBranchActionObjective(*src);
987 k = (nth_unit_appear - 1) * _bu.
action_objective.size() + j * num_of_single_element_repeat + i;
988 bc_ref.
all_branch.at(k)->action_objective.push_back(std::move(p));
995 for (i = 0; i < num_of_single_element_repeat; i++) {
996 auto p = make_shared<BranchActionPack>();
997 p->copyBranchActionPack(*src);
998 k = (nth_unit_appear - 1) * _bu.
action_pack.size() + j * num_of_single_element_repeat + i;
999 bc_ref.
all_branch.at(k)->action_pack.push_back(std::move(p));
1005 for (
auto &src : _bu.
action) {
1006 for (i = 0; i < num_of_single_element_repeat; i++) {
1007 auto p = make_shared<BranchAction>();
1008 p->copyBranchAction(*src);
1009 k = (nth_unit_appear - 1) * _bu.
action.size() + j * num_of_single_element_repeat + i;
1010 bc_ref.
all_branch.at(k)->action.push_back(std::move(p));
1017 for (i = 0; i < num_of_single_element_repeat; i++) {
1018 auto p = make_shared<BranchExpectedAlarmState>();
1019 p->copyBranchExpectedAlarmState(*src);
1020 k = (nth_unit_appear - 1) * _bu.
alarm_state.size() + j * num_of_single_element_repeat + i;
1021 bc_ref.
all_branch.at(k)->alarm_state.push_back(std::move(p));
1028 for (i = 0; i < num_of_single_element_repeat; i++) {
1029 auto p = make_shared<BranchExpectedComponentState>();
1030 p->copyBranchExpectedComponentState(*src);
1031 k = (nth_unit_appear - 1) * _bu.
component_state.size() + j * num_of_single_element_repeat + i;
1032 bc_ref.
all_branch.at(k)->component_state.push_back(std::move(p));
1039 for (i = 0; i < num_of_single_element_repeat; i++) {
1040 auto p = make_shared<BranchExpectedSupportSystemState>();
1041 p->copyBranchExpectedSupportSystemState(*src);
1042 k = (nth_unit_appear - 1) * _bu.
support_system_state.size() + j * num_of_single_element_repeat + i;
1043 bc_ref.
all_branch.at(k)->support_system_state.push_back(std::move(p));
1050 for (i = 0; i < num_of_single_element_repeat; i++) {
1051 auto p = make_shared<BranchExpectedParameterTrend>();
1052 p->copyBranchExpectedParameterTrend(*src);
1053 k = (nth_unit_appear - 1) * _bu.
parameter_trend.size() + j * num_of_single_element_repeat + i;
1054 bc_ref.
all_branch.at(k)->parameter_trend.push_back(std::move(p));
1061 for (i = 0; i < num_of_single_element_repeat; i++) {
1062 auto p = make_shared<BranchExpectedParameterValue>();
1063 p->copyBranchExpectedParameterValue(*src);
1064 k = (nth_unit_appear - 1) * _bu.
parameter_value.size() + j * num_of_single_element_repeat + i;
1065 bc_ref.
all_branch.at(k)->parameter_value.push_back(std::move(p));
1073 for (i = 0; i < num_of_single_element_repeat; i++) {
1074 auto p = make_shared<BranchExpectedParameterDifference>();
1075 p->copyBranchExpectedParameterDifference(*src);
1076 k = (nth_unit_appear - 1) * _bu.
parameter_difference.size() + j * num_of_single_element_repeat + i;
1077 bc_ref.
all_branch.at(k)->parameter_difference.push_back(std::move(p));
1085 for (i = 0; i < num_of_single_element_repeat; i++) {
1086 auto p = make_shared<BranchProcedureStep>();
1087 p->copyBranchProcedureStep(*src);
1088 k = (nth_unit_appear - 1) * _bu.
procedure_step.size() + j * num_of_single_element_repeat + i;
1089 bc_ref.
all_branch.at(k)->procedure_step.push_back(std::move(p));
1096 for (i = 0; i < num_of_single_element_repeat; i++) {
1097 auto p = make_shared<BranchProcedureStep>();
1098 p->copyBranchProcedureStep(*src);
1100 bc_ref.
all_branch.at(k)->instinctive_response_procedure.push_back(std::move(p));
1107 for (i = 0; i < num_of_single_element_repeat; i++) {
1108 auto p = make_shared<BranchInfoGatherMode>();
1109 p->copyBranchInfoGatherMode(*src);
1110 k = (nth_unit_appear - 1) * _bu.
info_gather_mode.size() + j * num_of_single_element_repeat + i;
1111 bc_ref.
all_branch.at(k)->info_gather_mode.push_back(std::move(p));
1118 for (i = 0; i < num_of_single_element_repeat; i++) {
1119 auto p = make_shared<BranchExpectedMentalBelief>();
1120 p->copyBranchExpectedMentalBelief(*src);
1121 k = (nth_unit_appear - 1) * _bu.
mental_belief.size() + j * num_of_single_element_repeat + i;
1122 bc_ref.
all_branch.at(k)->mental_belief.push_back(std::move(p));
1130 for (i = 0; i < num_of_single_element_repeat; i++) {
1131 auto p = make_shared<BranchScannedParameter>();
1132 p->copyBranchScannedParameter(*src);
1133 k = (nth_unit_appear - 1) * _bu.
scanned_parameter.size() + j * num_of_single_element_repeat + i;
1134 bc_ref.
all_branch.at(k)->scanned_parameter.push_back(std::move(p));
1148 int num_of_single_element_repeat,
1149 int nth_unit_appear) {
1151 auto &first_unit = *_bu.begin();
1153 for (
auto &src : *first_unit) {
1154 for (i = 0; i < num_of_single_element_repeat; i++) {
1156 sa_pt->copyBranchSystemAction(*src);
1158 bc_ref.
all_branch.at(k)->HW_reliability.push_back(shared_ptr<BranchSystemAction>(sa_pt));
1165 int num_of_single_element_repeat,
1166 int nth_unit_appear) {
1168 auto &first_unit = *_bu.begin();
1170 for (
auto &src : *first_unit) {
1171 for (i = 0; i < num_of_single_element_repeat; i++) {
1173 ssa_pt->copyBranchSupportSystemAction(*src);
1175 bc_ref.
all_branch.at(k)->SS_reliability.push_back(shared_ptr<BranchSupportSystemAction>(ssa_pt));
1202 if (mother_bc_pt == 0) {
1234 this->
end_state.push_back(unique_ptr<BranchEndState>(_es));
1281 if ((*bc_ritr)->getIDOfThisBranchCluster() == _id) {
1283 bc_pt = bc_ritr->get();
1306 ofstream *fout = &fout_obj;
1307 bool first_branch =
true;
1308 string full_file_name, branch_name;
1311 full_file_name +=
"ES_summary.txt";
1314 fout->open(full_file_name.c_str(), ios::app);
1317 fout->open(full_file_name.c_str(), ios::out);
1318 *fout <<
"ES#\tProbability\tEnd_time\tConsequence#\tDescription\n";
1321 *fout << es->getIDOfThisEndState() <<
'\t'
1322 << es->getProbability() <<
'\t'
1323 << es->getTimeAtWhichThisEventHappen() <<
'\t'
1324 <<
static_cast<int>(es->getTypeOfConsequence()) <<
'\t'
1325 << es->getConsequenceDescription() <<
'\n';
1330 namespace fs = std::filesystem;
1332 bool needs_header = !fs::exists(path);
1333 ofstream fout(path.c_str(), ios::app);
1335 fout <<
"ES#\tProbability\tEnd_time\tConsequence#\tDescription\n";
1338 fout << es->getIDOfThisEndState() <<
'\t'
1339 << es->getProbability() <<
'\t'
1340 << es->getTimeAtWhichThisEventHappen() <<
'\t'
1341 <<
static_cast<int>(es->getTypeOfConsequence()) <<
'\t'
1342 << es->getConsequenceDescription() <<
'\n';
1351 int i, j, num, num1;
1352 fout <<
"BranchRecord\n"
1371 fout << num <<
'\n';
1372 for (i = 0; i < num; i++) {
1376 fout << num <<
'\n';
1377 for (i = 0; i < num; i++) {
1378 end_state.at(i)->saveBranchEndStateToFile(fout);
1384 fout << num <<
'\n';
1385 for (i = 0; i < num; i++) {
1387 fout << num1 <<
'\n';
1388 for (j = 0; j < num1; j++) {
1393 fout << num <<
'\n';
1394 for (i = 0; i < num; i++) {
1396 fout << num1 <<
'\n';
1397 for (j = 0; j < num1; j++) {
1402 fout << num <<
'\n';
1403 for (i = 0; i < num; i++) {
1404 system_branch.at(i)->saveBranchSystemAlarmStateToFile(fout);
1411 int i, j, num, num1;
1415 if (str !=
"BranchRecord") {
1416 ofstream fout(
"err messages.txt", ios::app);
1417 cout <<
"BranchRecord::retrieveBranchRecordFromFile File retrieval error in previous function" << endl;
1419 <<
" BranchRecord::retrieveBranchRecordFromFile File retrieval error in previous function\n";
1444 for (i = 0; i < num; i++) {
1445 auto p = make_unique<BranchCluster>();
1446 p->retrieveBranchClusterFromFile(fin);
1450 for (i = 0; i < num; i++) {
1451 auto p = make_unique<BranchEndState>();
1452 p->retrieveBranchEndStateFromFile(fin);
1459 for (i = 0; i < num; i++) {
1461 auto hw_pt = make_unique<VHWReliabilityUnit>();
1462 for (j = 0; i < num1; j++) {
1463 auto sa = make_unique<BranchSystemAction>();
1464 sa->retrieveBranchSystemActionFromFile(fin);
1465 hw_pt->push_back(std::move(sa));
1470 for (i = 0; i < num; i++) {
1472 auto ss_pt = make_unique<VSSReliabilityUnit>();
1473 for (j = 0; i < num1; j++) {
1474 auto ssa = make_unique<BranchSupportSystemAction>();
1475 ssa->retrieveBranchSupportSystemActionFromFile(fin);
1476 ss_pt->push_back(std::move(ssa));
1481 for (i = 0; i < num; i++) {
1482 auto sb = make_unique<BranchSystemAlarmState>();
1483 sb->retrieveBranchSystemAlarmStateFromFile(fin);
1493 fout <<
"BranchRecord 1 "
1511 (*bc_ritr)->saveBranchClusterToFile(fout);
1513 fout <<
"BranchRecord 0\n";
1523 n_branch = (*bc_ritr)->all_branch.size();
1524 fout << n_branch <<
'\n';
1533 fin >> str >> i_exist_bc;
1534 if (i_exist_bc == 1) {
1553 auto bc_pt = make_unique<BranchCluster>();
1554 bc_pt->retrieveBranchClusterFromFile(fin);
1556 }
else if (i_exist_bc == 0) {
1559 ofstream fout(
"err messages.txt", ios::app);
1560 cout <<
"BranchRecord::retrieveRecentBranchClusterFromFile: Data mismatch in file retrieval." << endl;
1562 <<
" BranchRecord::retrieveRecentBranchClusterFromFile: Data mismatch in file retrieval.\n";
1600 auto p = make_unique<BranchCluster>();
1601 p->copyBranchCluster(*src);
1605 auto p = make_unique<BranchEndState>();
1606 p->copyBranchEndState(*src);
1607 this->
end_state.push_back(std::move(p));
1610 auto hw_pt = make_unique<VHWReliabilityUnit>();
1611 for (
auto &bsa_src : *hw_src) {
1612 auto bsa_pt = make_unique<BranchSystemAction>();
1613 bsa_pt->copyBranchSystemAction(*bsa_src);
1614 hw_pt->push_back(std::move(bsa_pt));
1619 auto ss_pt = make_unique<VSSReliabilityUnit>();
1620 for (
auto &bssa_src : *ss_src) {
1621 auto bssa_pt = make_unique<BranchSupportSystemAction>();
1622 bssa_pt->copyBranchSupportSystemAction(*bssa_src);
1623 ss_pt->push_back(std::move(bssa_pt));
1628 auto sb_pt = make_unique<BranchSystemAlarmState>();
1629 sb_pt->copyBranchSystemAlarmState(*sb_src);
int nth_branch_muli_process
Central dynamic event tree data structure: the branch clusters, the end states and the forks that are...
std::vector< std::unique_ptr< VSSReliabilityUnit > > MSSReliabilityUnit
std::vector< std::unique_ptr< VHWReliabilityUnit > > MHWReliabilityUnit
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
BranchProbability * findBranch(int)
Finds the alternative with the given branch ID, searching from the last alternative.
std::vector< std::unique_ptr< BranchProbability > > all_branch
The alternatives of this branching point; index 0 is the one the generating sequence continues on.
The end state (ES node) that terminates one sequence of the DET.
void saveInfoToFile()
Writes this end state as an ES node file, overwriting any existing file.
void setIDOfThisEndState(int)
Sets the end state ID. It is also the sequence ID used in the ZESNode file name.
void setIDOfTheMotherBranch(int)
Sets the ID of the branch (PE node) this end state hangs from.
int getIDOfThisEndState()
void copyBranchMentalProcedureActivationTime(BranchMentalProcedureActivationTime &)
void clearBranchMentalProcedureActivationTime()
void saveBranchMentalProcedureActivationTimeToFile(std::ofstream &)
void retrieveBranchMentalProcedureActivationTimeFromFile(std::ifstream &)
One alternative of a BranchCluster, i.e. one PE node of the DET.
double getUnconditionalBranchProbability()
void setTypeOfChild(int)
Sets the kind of node that follows this alternative: sim::Branch::Branch (a child cluster) or sim::Br...
void setIDOfTheChildBranchCluster(int)
Sets the ID of the node that follows this alternative: the child cluster ID, or the end state ID when...
std::vector< int > child_IDs
void sendBranchInfoToCommandCenter(int)
Hands the content of this alternative to the command center (g_sim.Command_handler)....
void retrieveBranchProcedureAtionTimeFromFile(std::ifstream &)
void clearBranchProcedureAtionTime()
void saveBranchProcedureAtionTimeToFile(std::ofstream &)
void copyBranchProcedureAtionTime(BranchProcedureAtionTime &)
void copyBranchProcedureControlValue(BranchProcedureControlValue &)
Appends deep copies of the entries of another table. Existing entries are kept, so call it on an empt...
void saveBranchProcedureControlValueToFile(std::ofstream &)
Writes the label BranchProcedureControlValue, the entry count and every entry to a text restart strea...
void readInfoFromFile()
Loads ProcedureControlValueBranches.txt from the EOP directory (Scheduler::getEOPDirectory()) and app...
void retreiveBranchProcedureControlValueFromFile(std::ifstream &)
Reads the layout written by saveBranchProcedureControlValueToFile and appends the entries it reads.
void clearBranchProcedureControlValue()
Removes every entry.
void copyBranchRecord(BranchRecord &)
Deep-copies another record into this one. Clusters, end states and pending forks are appended,...
std::string getTempESMessage()
void addInfoGatherMode(int, BranchInfoGatherMode *)
void setIDOfRecentGeneratedES(int)
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
std::vector< std::unique_ptr< BranchSystemAlarmState > > system_branch
Pending system alarm states, copied onto every alternative of the next cluster.
void addSSContentToExpandedBranch(MSSReliabilityUnit &, BranchCluster &, int, int)
Support system counterpart of addHWContentToExpandedBranch().
void addAnEndState(BranchEndState *)
Closes the running sequence with an end state and takes ownership of it.
MSSReliabilityUnit SS_reliability_branch
Pending support system reliability forks (one inner vector per fork).
BranchRecord()
Constructs an empty record: no pending forks, recent branch, cluster and end state IDs -1,...
void retrieveRecentBranchClusterFromFile(std::ifstream &)
Reads the layout written by saveRecentBranchClusterToFile and appends the cluster it reads.
void addCrewContentToExpandedBranch(BranchUnit &, BranchCluster &, int, int, int)
Copies the alternatives of one crew fork into the expanded cluster.
void addAction(int, BranchAction *)
int ID_of_recent_generated_ES
Consequence getTempTypeOfConsequence()
void addProcedureStep(int, BranchProcedureStep *)
std::string temp_es_message
void saveBranchRecordToFile(std::ofstream &)
Writes the whole record (scalars, clusters, end states, pending forks and the three branch definition...
void addComponentState(int, BranchExpectedComponentState *)
Consequence temp_type_of_consequence
void clearBranchRecordForRestart()
Clears the pending forks only (same as clearBranches()).
double getRecentUnconditionalBranchProbability()
void addInstinctiveResponseProcedure(int, BranchProcedureStep *)
int getTotalNumberOfBranches()
void addParameterTrend(int, BranchExpectedParameterTrend *)
void clearBranches()
Drops every pending fork and system alarm and resets the pending branch types and counts....
int getIDOfMotherBranch()
BranchProcedureAtionTime source_of_procedure_time_branches
int getIDOfRecentGeneratedES()
void clearBranchRecordAll()
Resets the whole record: clusters, end states, pending forks, the three branch definition tables and ...
void addHWContentToExpandedBranch(MHWReliabilityUnit &, BranchCluster &, int, int)
Copies the alternatives of the first pending hardware fork into the expanded cluster (used when exact...
BranchUnit ODM_branch
Pending crew forks of the decision maker, action taker and consultant.
void saveNumOfBranchInRecentBranchClusterToFile(std::ofstream &)
Writes the alternative count of the most recent cluster (0 with no cluster).
int num_of_SSReliability_branch
void applyBranchProbabilityFloor(double floor)
Applies the minimum branch probability to every pending fork.
int checkAndAddBranchCluster()
Expands the pending forks into a new BranchCluster.
int getIDOfRecentGeneratedBranchCluster()
void addSubGoal(int, BranchSubGoal *)
void addActionPack(int, BranchActionPack *)
void setIDOfMotherBranch(int)
void setIDOfRecentGeneratedBranchCluster(int)
void addParameterValue(int, BranchExpectedParameterValue *)
void setIDOfRecentGeneratedBranch(int)
void sendSpecifiedBranchCommandToCommandCenter(int)
Sends the content of alternative n_th_branch (0-based) of the most recent cluster to the command cent...
void addSystemAlarms(BranchSystemAlarmState *)
Registers a system alarm state. It is not a fork: a copy is attached to every alternative of the next...
void addActionObjective(int, BranchActionObjective *)
void addScannedParameter(int, BranchScannedParameter *)
Crew fork registration for a scanned parameter; same contract as addGoal().
void addParameterDifference(int, BranchExpectedParameterDifference *)
void endSimulation()
Writes ES_summary.txt in the ES directory from the end_state vector: a header line ES# Probability En...
void addSSReliabilityBranch(BranchSupportSystemAction *, BranchSupportSystemAction *)
Registers a support system reliability fork with two alternatives (index 0 first)....
int ID_of_recent_generated_branch_cluster
void setSizeOfSubFolder(int)
double recent_unconditional_branch_probability
void calculateTotalNumberOfBranch()
Sets the total branch count to the product of the nonzero pending counts (ODM, OAT,...
int ID_of_recent_generated_branch
void appendEndStateSummary()
Appends the most recent end state to ES_summary.txt, writing the header first when the file does not ...
std::vector< std::unique_ptr< BranchEndState > > end_state
End states of the finished sequences held by this record.
int getNumOfHWReliabilityBranch()
void addHWReliabilityBranch(BranchSystemAction *, BranchSystemAction *)
Registers a hardware reliability fork with two alternatives (index 0 first). The record takes ownersh...
MHWReliabilityUnit HW_reliability_branch
Pending hardware reliability forks (one inner vector per fork).
int getIDOfRecentGeneratedBranch()
void addDiagnosis(int, BranchDiagnosis *)
void setRecentUnconditionalBranchProbability(double)
BranchMentalProcedureActivationTime mental_procedure_activation_branches
void addSupportSystemState(int, BranchExpectedSupportSystemState *)
BranchCluster * findBrnachCluster(int)
Finds a cluster by ID, searching from the most recent cluster.
void initiationForSimulation()
Loads the three branch definition tables: procedure action time branches, mental procedure activation...
void retrieveBranchRecordFromFile(std::ifstream &)
Reads the layout written by saveBranchRecordToFile and appends what it reads. A stream that does not ...
void addStrategy(int, BranchStrategy *)
void addMentalBelief(int, BranchExpectedMentalBelief *)
Crew fork registration for a mental belief; same contract as addGoal().
int num_of_HWReliability_branch
std::vector< std::unique_ptr< BranchCluster > > branch_cluster
All branching points generated so far, in creation order.
int total_number_of_branches
BranchProcedureControlValue control_value_branches
void sendCurrentBranchCommandToCommandCenter()
Sends the content of the running sequence's alternative of the most recent cluster to the command cen...
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
void addAlarmState(int, BranchExpectedAlarmState *)
void saveRecentBranchClusterToFile(std::ofstream &)
Writes the record scalars and the most recent cluster only (BranchRecord 1), or BranchRecord 0 when t...
void addGoal(int, BranchGoal *)
int getIDOfMotherCluster()
void setIDOfMotherCluster(int)
void copyBranchSupportSystemAction(BranchSupportSystemAction &)
void copyBranchSystemAction(BranchSystemAction &)
std::vector< std::shared_ptr< BranchSubGoal > > subgoal
void copyBranchUnit(BranchUnit &)
std::vector< std::shared_ptr< BranchExpectedParameterTrend > > parameter_trend
std::vector< std::shared_ptr< BranchInfoGatherMode > > info_gather_mode
std::vector< std::shared_ptr< BranchProcedureStep > > instinctive_response_procedure
std::vector< std::shared_ptr< BranchGoal > > goal
std::vector< std::shared_ptr< BranchActionPack > > action_pack
std::vector< std::shared_ptr< BranchExpectedSupportSystemState > > support_system_state
std::vector< std::shared_ptr< BranchExpectedParameterDifference > > parameter_difference
std::vector< std::shared_ptr< BranchDiagnosis > > diagnosis
std::vector< std::shared_ptr< BranchExpectedMentalBelief > > mental_belief
std::vector< std::shared_ptr< BranchExpectedParameterValue > > parameter_value
std::vector< std::shared_ptr< BranchScannedParameter > > scanned_parameter
std::vector< std::shared_ptr< BranchExpectedComponentState > > component_state
std::vector< std::shared_ptr< BranchStrategy > > strategy
void saveBranchUnitToFile(std::ofstream &)
std::vector< std::shared_ptr< BranchProcedureStep > > procedure_step
std::vector< std::shared_ptr< BranchExpectedAlarmState > > alarm_state
std::vector< std::shared_ptr< BranchAction > > action
std::vector< std::shared_ptr< BranchActionObjective > > action_objective
void retrieveBranchUnitFromFile(std::ifstream &)
void setProbability(double)
std::string getESDirectory()
void setStateOfActivation(int)
void setTimeAtWhichThisEventHappen(double)
constexpr int InfoGatherMode
constexpr int MentalBelief
constexpr int ParameterDifference
constexpr int ParameterTrend
constexpr int SupportSystemState
constexpr int ComponentState
constexpr int ParameterValue
constexpr int ParameterScan
constexpr int InstinctiveResponse
std::string resume_file
–resume checkpoint file as an absolute path (empty = fresh start)
bool resume_has_end_states
True if the BranchRecord restored by a serial resume held end states (checkpoint written by a serial ...
int is_mpi_environment
1 if OMPI_COMM_WORLD_SIZE or PMI_SIZE is set in the environment, 0 for serial
Scheduler SScheduler
Simulation scheduling, parses CLI options.
std::vector< std::pair< double, int > > current_seq_events
(branching_time, num_branches) pairs
BranchRecord Branch_center
Dynamic event tree state.