← Documentation
ADS-IDAC Engine 5.0.0
BranchProcedureControlValueUnit.cpp
Go to the documentation of this file.
1// BranchProcedureControlValueUnit.cpp: implementation of the BranchProcedureControlValueUnit class.
2//
4
6#include <boost/serialization/export.hpp>
7#include <boost/archive/binary_oarchive.hpp>
8#include <boost/archive/binary_iarchive.hpp>
9BOOST_CLASS_EXPORT_IMPLEMENT(BranchProcedureControlValueUnit)
10using namespace std;
11
13// Construction/Destruction
15
17{
18 procedure_name = "NONE";
19 step_name = "NONE";
20 action_name = "NONE";
22}
23
25{
27}
29{
30 this->control_values.clear();
31 this->probabilities.clear();
32}
41bool BranchProcedureControlValueUnit::checkIfControlValueBranchNeedsToBeGenerated(string _procedure, string _step, string _action)
42{
43 bool need_branch = false;
44 if (_procedure == procedure_name && _step == step_name && _action == action_name)
45 {
46 need_branch = true;
47 }
48 return need_branch;
49
50}
52{
53 string procedure, step, action, str;
54 int num_branches , i;
55 double cntrl_val, prob;
56 double total_probability = 0.0;
57 fin >> procedure
58 >> step
59 >> action
60 >> num_branches;
61 this->setProcedureName(procedure);
62 this->setStepName(step);
63 this->setActionName(action);
64 this->setNumberOfBranches(num_branches);
65 for (i = 0 ; i != num_branches ; i ++)
66 {
67 fin >> cntrl_val
68 >> prob;
69 total_probability += prob;
70 this->control_values.push_back(cntrl_val);
71 this->probabilities.push_back(prob);
72 }
73 if (total_probability > 1.0001 || total_probability < 0.9999)
74 {
75 // write error message that sum of all branch probabilities exceeds 1.0
76 cout << "Procedure Control Value Branch Probability: " << procedure << ' ' << step << ' ' << action
77 << " Probability Sum Does Not Equal 1.0" << '\n';
78 ofstream fout("err messages.txt", ios::app);
79 fout << r5pars_.timesno << "Procedure Control Value Branch Probability: " << procedure << ' ' << step << ' ' << action
80 << " Probability Sum Does Not Equal 1.0" << '\n';
81 fout.close();
82
83 }
84}
86{
87 vector<double >::iterator double_itr;
88 double x;
90 step_name = _bpcvu.getStepName();
91 action_name = _bpcvu.getActionName();
93 for(double_itr = _bpcvu.control_values.begin(); double_itr != _bpcvu.control_values.end() ; double_itr++)
94 {
95 x = *double_itr;
96 this->control_values.push_back(x);
97 }
98 for(double_itr = _bpcvu.probabilities.begin(); double_itr != _bpcvu.probabilities.end() ; double_itr++)
99 {
100 x = *double_itr;
101 this->probabilities.push_back(x);
102 }
103}
105{
106 vector<double>::iterator double_itr;
107 fout << procedure_name << ' '
108 << step_name << ' '
109 << action_name << ' '
110 << number_of_branches << ' '
111 << '\n';
112 for (double_itr = this->control_values.begin() ; double_itr!= this->control_values.end() ; double_itr++)
113 {
114 fout << *double_itr << ' ';
115 }
116 fout << '\n';
117 for (double_itr = this->probabilities.begin() ; double_itr!= this->probabilities.end() ; double_itr++)
118 {
119 fout << *double_itr << ' ';
120 }
121 fout << '\n';
122}
124{
125 int i;
126 double x;
127 fin >> procedure_name
128 >> step_name
129 >> action_name
131 for (i = 0 ; i != number_of_branches ; i ++)
132 {
133 fin >> x;
134 this->control_values.push_back(x);
135 }
136 for (i = 0 ; i != number_of_branches ; i ++)
137 {
138 fin >> x;
139 this->probabilities.push_back(x);
140 }
141}
bool checkIfControlValueBranchNeedsToBeGenerated(std::string, std::string, std::string)
void retrieveBranchProcedureControlValueUnitFromFile(std::ifstream &)
void copyBranchProcedureControlValueUnit(BranchProcedureControlValueUnit)
struct @0 r5pars_