← Documentation
ADS-IDAC Engine 5.0.0
BranchRecord.h
Go to the documentation of this file.
1#pragma once
2
18
19#include <iostream>
20#include <typeinfo>
21
22#include "BranchCluster.h"
23#include "BranchGoal.h"
24#include "BranchStrategy.h"
25#include "BranchSubGoal.h"
26#include "BranchDiagnosis.h"
28#include "BranchActionPack.h"
29#include "BranchAction.h"
35#include "BranchProcedureStep.h"
37#include "BranchSystemAction.h"
39#include "BranchUnit.h"
40#include "BranchEndState.h"
49#include "../Global/TermConversions.h"
50#include "../Scheduler/AnalysisInfoContainer.h"
51#include <boost/serialization/export.hpp>
52
53#include <memory>
54#include <boost/archive/text_oarchive.hpp>
55#include <boost/archive/text_iarchive.hpp>
56#include <boost/serialization/access.hpp>
57#include <boost/serialization/vector.hpp>
58#include <boost/serialization/unique_ptr.hpp>
59
60
61typedef std::vector<std::unique_ptr<BranchSystemAction>> VHWReliabilityUnit;
62typedef std::vector<std::unique_ptr<VHWReliabilityUnit>> MHWReliabilityUnit;
63typedef std::vector<std::unique_ptr<BranchSupportSystemAction>> VSSReliabilityUnit;
64typedef std::vector<std::unique_ptr<VSSReliabilityUnit>> MSSReliabilityUnit;
65
67 public:
72 virtual ~BranchRecord();
82 void addGoal(int, BranchGoal *);
83 void addStrategy(int, BranchStrategy *);
84 void addSubGoal(int, BranchSubGoal *);
85 void addDiagnosis(int, BranchDiagnosis *);
88 void addAction(int, BranchAction *);
127 void clearBranches();
148 void applyBranchProbabilityFloor(double floor);
186// void calculateBranchProbability();
188 void setIDOfRecentGeneratedES(int);
195// void addABranchCluster();
206 int getSizeOfSubFolder();
207 void setSizeOfSubFolder(int);
217 void setIDOfMotherCluster(int);
219 void setIDOfMotherBranch(int);
221 int getTypeOfODMBranch();
222 int getTypeOfOATBranch();
223 int getTypeOfOCTBranch();
224 int getNumOfODMBranch();
225 int getNumOfOATBranch();
226 int getNumOfOCTBranch();
237 void endSimulation();
252 void saveBranchRecordToFile(std::ofstream &);
259 void retrieveBranchRecordFromFile(std::ifstream &);
263 void saveRecentBranchClusterToFile(std::ofstream &);
266 void retrieveRecentBranchClusterFromFile(std::ifstream &);
275 void saveNumOfBranchInRecentBranchClusterToFile(std::ofstream &);
278 void setTempESMessage(std::string);
281 std::string getTempESMessage();
284 std::vector<std::unique_ptr<BranchCluster>> branch_cluster;
286 std::vector<std::unique_ptr<BranchEndState>> end_state;
294 std::vector<std::unique_ptr<BranchSystemAlarmState>> system_branch;
299 template<class Archive>
300 void serialize(Archive & ar, const unsigned int version) {
301// std::cout << "Serializing class: " << typeid(*this).name() << std::endl;
302 // Basic types
314 ar & temp_es_message;
316
317 // Vectors of pointers
318 ar & branch_cluster;
319 ar & end_state;
320
321 // Custom objects
322 ar & ODM_branch;
323 ar & OAT_branch;
324 ar & OCT_branch;
325
326 // Vectors of vectors
329
330 ar & system_branch;
331
332 // Custom objects
336
337 // Basic types
343 }
344 private:
345 int type_of_ODM_branch, type_of_OAT_branch, type_of_OCT_branch;//GOAL, STRATEGY, DIAGNOSIS...
347 int ID_of_recent_generated_branch;//number to be used as PE_N; started from zero including the branch following IE
354 std::string temp_es_message;
356};
357
358
359BOOST_CLASS_EXPORT_KEY(BranchRecord)
A branching point in the DET, holding its branch alternatives.
std::vector< std::unique_ptr< BranchSystemAction > > VHWReliabilityUnit
Definition: BranchRecord.h:61
std::vector< std::unique_ptr< BranchSupportSystemAction > > VSSReliabilityUnit
Definition: BranchRecord.h:63
std::vector< std::unique_ptr< VSSReliabilityUnit > > MSSReliabilityUnit
Definition: BranchRecord.h:64
std::vector< std::unique_ptr< VHWReliabilityUnit > > MHWReliabilityUnit
Definition: BranchRecord.h:62
A single branch alternative — holds all crew/system state deltas for one branch.
Consequence
Definition: SimConstants.h:27
The end state (ES node) that terminates one sequence of the DET.
Table of procedure actions that branch on the control value they set.
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)
int type_of_ODM_branch
Definition: BranchRecord.h:345
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.
Definition: BranchRecord.h:294
void addSSContentToExpandedBranch(MSSReliabilityUnit &, BranchCluster &, int, int)
Support system counterpart of addHWContentToExpandedBranch().
int size_of_subfolder
Definition: BranchRecord.h:353
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).
Definition: BranchRecord.h:292
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
Definition: BranchRecord.h:348
Consequence getTempTypeOfConsequence()
void addProcedureStep(int, BranchProcedureStep *)
std::string temp_es_message
Definition: BranchRecord.h:354
void saveBranchRecordToFile(std::ofstream &)
Writes the whole record (scalars, clusters, end states, pending forks and the three branch definition...
void addComponentState(int, BranchExpectedComponentState *)
int num_of_ODM_branch
Definition: BranchRecord.h:298
void generateRestartFileForRELAP5()
Declared only; there is no definition.
BranchUnit OCT_branch
Definition: BranchRecord.h:288
int getTypeOfODMBranch()
Consequence temp_type_of_consequence
Definition: BranchRecord.h:355
virtual ~BranchRecord()
void clearBranchRecordForRestart()
Clears the pending forks only (same as clearBranches()).
double getRecentUnconditionalBranchProbability()
int num_of_OCT_branch
Definition: BranchRecord.h:298
void addInstinctiveResponseProcedure(int, BranchProcedureStep *)
int getTotalNumberOfBranches()
void saveAESNodeToFile(BranchEndState *)
Declared only; there is no definition. ES nodes are written by BranchEndState::saveInfoToFile().
int getTypeOfOATBranch()
void addParameterTrend(int, BranchExpectedParameterTrend *)
void clearBranches()
Drops every pending fork and system alarm and resets the pending branch types and counts....
int getSizeOfSubFolder()
int getIDOfMotherBranch()
BranchProcedureAtionTime source_of_procedure_time_branches
Definition: BranchRecord.h:295
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.
Definition: BranchRecord.h:288
void saveNumOfBranchInRecentBranchClusterToFile(std::ofstream &)
Writes the alternative count of the most recent cluster (0 with no cluster).
int num_of_SSReliability_branch
Definition: BranchRecord.h:298
void applyBranchProbabilityFloor(double floor)
Applies the minimum branch probability to every pending fork.
BranchUnit OAT_branch
Definition: BranchRecord.h:288
int checkAndAddBranchCluster()
Expands the pending forks into a new BranchCluster.
int getIDOfRecentGeneratedBranchCluster()
void addSubGoal(int, BranchSubGoal *)
int type_of_OCT_branch
Definition: BranchRecord.h:345
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...
int getNumOfOCTBranch()
void addSSReliabilityBranch(BranchSupportSystemAction *, BranchSupportSystemAction *)
Registers a support system reliability fork with two alternatives (index 0 first)....
int ID_of_recent_generated_branch_cluster
Definition: BranchRecord.h:349
void setSizeOfSubFolder(int)
double recent_unconditional_branch_probability
Definition: BranchRecord.h:352
void calculateTotalNumberOfBranch()
Sets the total branch count to the product of the nonzero pending counts (ODM, OAT,...
int ID_of_recent_generated_branch
Definition: BranchRecord.h:347
void appendEndStateSummary()
Appends the most recent end state to ES_summary.txt, writing the header first when the file does not ...
int type_of_OAT_branch
Definition: BranchRecord.h:345
std::vector< std::unique_ptr< BranchEndState > > end_state
End states of the finished sequences held by this record.
Definition: BranchRecord.h:286
void serialize(Archive &ar, const unsigned int version)
Definition: BranchRecord.h:300
int getNumOfHWReliabilityBranch()
int getNumOfOATBranch()
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).
Definition: BranchRecord.h:290
int ID_of_mother_cluster
Definition: BranchRecord.h:350
int getIDOfRecentGeneratedBranch()
int getNumOfODMBranch()
void addDiagnosis(int, BranchDiagnosis *)
void setRecentUnconditionalBranchProbability(double)
BranchMentalProcedureActivationTime mental_procedure_activation_branches
Definition: BranchRecord.h:296
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 savePENodeOfABranchClusterToFile(BranchCluster *)
Declared only; there is no definition. PE nodes are written by BranchCluster::savePENodeToFile().
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
Definition: BranchRecord.h:298
std::vector< std::unique_ptr< BranchCluster > > branch_cluster
All branching points generated so far, in creation order.
Definition: BranchRecord.h:284
int total_number_of_branches
Definition: BranchRecord.h:346
int getTypeOfOCTBranch()
BranchProcedureControlValue control_value_branches
Definition: BranchRecord.h:297
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...
int ID_of_mother_branch
Definition: BranchRecord.h:351
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 num_of_OAT_branch
Definition: BranchRecord.h:298
int getIDOfMotherCluster()
void setIDOfMotherCluster(int)