← Documentation
ADS-IDAC Engine 5.0.0
InfoChunk.cpp
Go to the documentation of this file.
1// InfoChunk.cpp: implementation of the InfoChunk class.
2//
4
5#include "InfoChunk.h"
6#include "../Branch/BranchRecord.h"
7#include <boost/serialization/export.hpp>
8#include "../Global/SimulationContext.h"
9#include <boost/archive/binary_oarchive.hpp>
10#include <boost/archive/binary_iarchive.hpp>
11BOOST_CLASS_EXPORT_IMPLEMENT(InfoChunk)
12using namespace std;
13
15// Construction/Destruction
17
19
20}
21
23}
25 goal.clear();
26 strategy.clear();
27 subgoal.clear();
28 diagnosis.clear();
29 action_objective.clear();
30 action_pack.clear();
31 action.clear();
32 procedure_step.clear();
34 perceived_alarms.clear();
39 mental_belief.clear();
40}
42 goal.clear();
43 strategy.clear();
44 subgoal.clear();
45 diagnosis.clear();
46 action_objective.clear();
47 action_pack.clear();
48 action.clear();
49 procedure_step.clear();
51 perceived_alarms.clear();
56 mental_belief.clear();
57}
59 int n;
61 + perceived_alarms.size();
62 return n;
63}
65 double x = 0.0;
66 auto alarm_itr = perceived_alarms.begin();
67 for (; alarm_itr != perceived_alarms.end(); alarm_itr++) {
68 x += (*alarm_itr)->getImportanceOfTheAlarm();
69 }
70 return x;
71}
73 return perceived_alarms.size();
74}
76 int r_n = 0;
77 for (auto diagnosis_itr = diagnosis.begin(); diagnosis_itr != diagnosis.end(); diagnosis_itr++) {
78 if ((*diagnosis_itr)->getAssessedState() == sim::State::Failed) { r_n++; }
79 }
80 return r_n;
81}
83 bool found_goal = false;
84 int current_goal = sim::None;
85 auto goal_itr = this->goal.rbegin();
86 while (goal_itr != this->goal.rend() && !found_goal) {
87 if ((*goal_itr)->getStateOfActivation() == sim::State::Active) {
88 current_goal = (*goal_itr)->getDecision();
89 found_goal = true;
90 } else {
91 goal_itr++;
92 }
93 }
94 return current_goal;
95}
96
98 bool found_strategy = false;
99 int current_strategy = sim::None;
100 auto strategy_itr = strategy.rbegin();
101 while (strategy_itr != strategy.rend() && !found_strategy) {
102 if ((*strategy_itr)->getStateOfActivation() == sim::State::Active) {
103 current_strategy = (*strategy_itr)->getDecision();
104 found_strategy = true;
105 } else {
106 strategy_itr++;
107 }
108 }
109 return current_strategy;
110}
112 bool found_subgoal = false;
113 int current_subgoal = sim::None;
114 auto subgoal_itr = subgoal.rbegin();
115 while (subgoal_itr != subgoal.rend() && !found_subgoal) {
116 if ((*subgoal_itr)->getStateOfActivation() == sim::State::Active) {
117 current_subgoal = (*subgoal_itr)->getDecision();
118 found_subgoal = true;
119 } else {
120 subgoal_itr++;
121 }
122 }
123 return current_subgoal;
124}
126 bool found_diagnosis = false;
127 string current_diagnosis = "NONE";
128 int i = 0;
129 auto diagnosis_itr = diagnosis.rbegin();
130 while (diagnosis_itr != diagnosis.rend() && !found_diagnosis) {
131 if ((*diagnosis_itr)->getStateOfActivation() == sim::State::Active) {
132 current_diagnosis = (*diagnosis_itr)->getDiagnosis();
133 found_diagnosis = true;
134 } else {
135 diagnosis_itr++;
136 }
137 }
138 return current_diagnosis;
139}
141 string str = "NO_PROCEDURE";
142 bool found = false;
143 decltype(procedure_step)::reverse_iterator procedure_step_ritr;
144 procedure_step_ritr = procedure_step.rbegin();
145 while (procedure_step_ritr != procedure_step.rend() && !found) {
146 if ((*procedure_step_ritr)->getStateOfActivation() == sim::State::Active) {
147 found = true;
148 str = (*procedure_step_ritr)->getProcedureName();
149 } else {
150 procedure_step_ritr++;
151 }
152 }
153 return str;
154}
156 string str = "NO_STEP";
157 bool found = false;
158 decltype(procedure_step)::reverse_iterator procedure_step_ritr;
159 procedure_step_ritr = procedure_step.rbegin();
160 while (procedure_step_ritr != procedure_step.rend() && !found) {
161 if ((*procedure_step_ritr)->getStateOfActivation() == sim::State::Active) {
162 found = true;
163 str = (*procedure_step_ritr)->getStepName();
164 } else {
165 procedure_step_ritr++;
166 }
167 }
168 return str;
169}
171 string str = "NO_PROCEDURE";
172 bool found = false;
173 decltype(procedure_step)::reverse_iterator procedure_step_ritr;
174 procedure_step_ritr = instinctive_response_procedure.rbegin();
175 while (procedure_step_ritr != instinctive_response_procedure.rend() && !found) {
176 if ((*procedure_step_ritr)->getStateOfActivation() == sim::State::Active) {
177 found = true;
178 str = (*procedure_step_ritr)->getProcedureName();
179 } else {
180 procedure_step_ritr++;
181 }
182 }
183 return str;
184}
186 string str = "NO_STEP";
187 bool found = false;
188 decltype(procedure_step)::reverse_iterator procedure_step_ritr;
189 procedure_step_ritr = instinctive_response_procedure.rbegin();
190 while (procedure_step_ritr != instinctive_response_procedure.rend() && !found) {
191 if ((*procedure_step_ritr)->getStateOfActivation() == sim::State::Active) {
192 found = true;
193 str = (*procedure_step_ritr)->getStepName();
194 } else {
195 procedure_step_ritr++;
196 }
197 }
198 return str;
199}
200
202 DecisionProcedureStep *r_ptr = nullptr;
203 bool found = false;
204 auto procedure_step_ritr = procedure_step.rbegin();
205 while (procedure_step_ritr != procedure_step.rend() && !found) {
206 if ((*procedure_step_ritr)->getStateOfActivation() == sim::State::Active) {
207 found = true;
208 r_ptr = procedure_step_ritr->get();
209 } else {
210 procedure_step_ritr++;
211 }
212 }
213 if (r_ptr == nullptr) {
214 procedure_step_ritr = procedure_step.rbegin();
215 while (procedure_step_ritr != procedure_step.rend() && !found) {
216 if ((*procedure_step_ritr)->getStateOfActivation() == sim::State::Pause) {
217 found = true;
218 //(*procedure_step_ritr)->setStateOfActivation(sim::State::Active);
219 r_ptr = procedure_step_ritr->get();
220 }
221 procedure_step_ritr++;
222 }
223 }
224 return r_ptr;
225}
227 DecisionProcedureStep *r_ptr = nullptr;
228 bool found = false;
229 auto procedure_step_ritr = instinctive_response_procedure.rbegin();
230 while (procedure_step_ritr != instinctive_response_procedure.rend() && !found) {
231 if ((*procedure_step_ritr)->getStateOfActivation() == sim::State::Active) {
232 found = true;
233 r_ptr = procedure_step_ritr->get();
234 }
235 procedure_step_ritr++;
236 }
237 return r_ptr;
238}
239
240void InfoChunk::addANewGoal(int _goal, int _active_state) {
241 auto goal_pt = make_shared<DecisionGoal>();
242 goal_pt->setDecision(_goal);
243 goal_pt->setStateOfActivation(_active_state);
244 goal.push_back(goal_pt);
245}
246void InfoChunk::addANewStrategy(int _strategy, int _active_state) {
247 auto strategy_pt = make_shared<DecisionStrategy>();
248 strategy_pt->setDecision(_strategy);
249 strategy_pt->setStateOfActivation(_active_state);
250 strategy.push_back(strategy_pt);
251}
252
253void InfoChunk::addANewDiagnosis(string _diagnosis, int _active_state) {
254 auto diagnosis_pt = make_shared<DecisionDiagnosis>();
255 diagnosis_pt->setDiagnosis(_diagnosis);
256 diagnosis_pt->setStateOfActivation(_active_state);
257 diagnosis.push_back(diagnosis_pt);
258}
259void InfoChunk::addANewSubGoal(int _subgoal, int _active_state) {
260 auto subgoal_pt = make_shared<DecisionSubGoal>();
261 subgoal_pt->setDecision(_subgoal);
262 subgoal_pt->setStateOfActivation(_active_state);
263 subgoal.push_back(subgoal_pt);
264}
265void InfoChunk::addNewProcedureStep(string _procedure, string _step, int _active_state) {
266 auto ps = make_shared<DecisionProcedureStep>();
267 ps->setProcedureName(_procedure);
268 ps->setStepName(_step);
269 ps->setStateOfActivation(_active_state);
270 procedure_step.push_back(ps);
271}
273 string _step,
274 int _priority,
275 int _active_state,
276 double _activation_time) {
277 DecisionProcedureStep *mental_procedure_pt = nullptr;
278 mental_procedure_pt = this->checkExistanceOfAnInstinctiveResponseProcedure(_procedure, _step);
279 if (mental_procedure_pt == nullptr) {
280 auto ps = make_shared<DecisionProcedureStep>();
281 ps->setProcedureName(_procedure);
282 ps->setStepName(_step);
283 ps->setStateOfActivation(_active_state);
284 ps->setActivationTime(_activation_time);
285 ps->setPriority(_priority);
286 instinctive_response_procedure.push_back(ps);
287 }
288}
290 bool found_goal = false;
291 int current_goal = sim::State::Unknown;
292 int i = 0;
293 auto goal_itr = goal.rbegin();
294 while (goal_itr != goal.rend() && !found_goal) {
295 if ((*goal_itr)->getStateOfActivation() == sim::State::Active) {
296 (*goal_itr)->setDecision(sim::State::Done);
297 found_goal = true;
298 }
299 goal_itr++;
300 }
301 found_goal = false;
302 goal_itr = goal.rbegin();
303 while (goal_itr != goal.rend() && !found_goal) {
304 if ((*goal_itr)->getStateOfActivation() == sim::State::Pause) {
305 (*goal_itr)->setDecision(sim::State::Active);
306 found_goal = true;
307 current_goal = (*goal_itr)->getDecision();
308 }
309 goal_itr++;
310 i++;
311 }
312 if (i == 0) {//no
313 ofstream fout("err messages.txt", ios::app);
314 cout << "InfoChunk::doneWithCurrentGoalAndGoForPreviousOne: no goal exist" << endl;
315 fout << r5pars_.timesno << " InfoChunk::doneWithCurrentGoalAndGoForPreviousOne: no goal exist\n";
316 fout.close();
317 r5pars_.sim_err = true;
318 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentGoalAndGoForPreviouslyPausedOne err.");
320 } else if (goal_itr == goal.rend()) {
321 ofstream fout("err messages.txt", ios::app);
322 cout << "InfoChunk::doneWithCurrentGoalAndGoForPreviousOne: could not find previousely paused goal" << endl;
323 fout << r5pars_.timesno
324 << " InfoChunk::doneWithCurrentGoalAndGoForPreviousOne: could not find previousely paused goal\n";
325 fout.close();
326 r5pars_.sim_err = true;
327 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentGoalAndGoForPreviouslyPausedOne err.");
329 } else {
330 }
331 return current_goal;
332}
334 bool found_strategy = false;
335 int current_strategy = sim::State::Unknown;
336 int i = 0;
337 auto strategy_itr = strategy.rbegin();
338 while (strategy_itr != strategy.rend() && !found_strategy) {
339 if ((*strategy_itr)->getStateOfActivation() == sim::State::Active) {
340 (*strategy_itr)->setDecision(sim::State::Done);
341 found_strategy = true;
342 }
343 strategy_itr++;
344 }
345 found_strategy = false;
346 strategy_itr = strategy.rbegin();
347 while (strategy_itr != strategy.rend() && !found_strategy) {
348 if ((*strategy_itr)->getStateOfActivation() == sim::State::Pause) {
349 (*strategy_itr)->setDecision(sim::State::Active);
350 found_strategy = true;
351 current_strategy = (*strategy_itr)->getDecision();
352 }
353 strategy_itr++;
354 i++;
355 }
356 if (i == 0) {//no
357 ofstream fout("err messages.txt", ios::app);
358 cout << "InfoChunk::doneWithCurrentStrategyAndGoForPreviousOne: no strategy exist" << endl;
359 fout << r5pars_.timesno << " InfoChunk::doneWithCurrentStrategyAndGoForPreviousOne: no strategy exist\n";
360 fout.close();
361 r5pars_.sim_err = true;
362 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentStrategyAndGoForPreviouslyPausedOne err.");
364 } else if (strategy_itr == strategy.rend()) {
365 ofstream fout("err messages.txt", ios::app);
366 cout << "InfoChunk::doneWithCurrentStrategyAndGoForPreviousOne: could not find previousely paused strategy" << endl;
367 fout << r5pars_.timesno
368 << " InfoChunk::doneWithCurrentStrategyAndGoForPreviousOne: could not find previousely paused strategy\n";
369 fout.close();
370 r5pars_.sim_err = true;
371 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentStrategyAndGoForPreviouslyPausedOne err.");
373 } else {
374 }
375 return current_strategy;
376}
378 bool found_diagnosis = false;
379 string current_diagnosis = "UNKNOWN";
380 int i = 0;
381 auto diagnosis_itr = diagnosis.rbegin();
382 while (diagnosis_itr != diagnosis.rend() && !found_diagnosis) {
383 if ((*diagnosis_itr)->getStateOfActivation() == sim::State::Active) {
384 (*diagnosis_itr)->setDecision(sim::State::Done);
385 found_diagnosis = true;
386 }
387 diagnosis_itr++;
388 }
389 found_diagnosis = false;
390 diagnosis_itr = diagnosis.rbegin();
391 while (diagnosis_itr != diagnosis.rend() && !found_diagnosis) {
392 if ((*diagnosis_itr)->getStateOfActivation() == sim::State::Pause) {
393 (*diagnosis_itr)->setDecision(sim::State::Active);
394 found_diagnosis = true;
395 current_diagnosis = (*diagnosis_itr)->getDiagnosis();
396 }
397 diagnosis_itr++;
398 i++;
399 }
400 if (i == 0) {//no
401 ofstream fout("err messages.txt", ios::app);
402 cout << "InfoChunk::doneWithCurrentDiagnosisAndGoForPreviousOne: no diagnosis exist" << endl;
403 fout << r5pars_.timesno << " InfoChunk::doneWithCurrentDiagnosisAndGoForPreviousOne: no diagnosis exist\n";
404 fout.close();
405 r5pars_.sim_err = true;
406 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentDiagnosisAndGoForPreviouslyPausedOne err.");
408 } else if (diagnosis_itr == diagnosis.rend()) {
409 ofstream fout("err messages.txt", ios::app);
410 cout << "InfoChunk::doneWithCurrentDiagnosisAndGoForPreviousOne: could not find previousely paused diagnosis"
411 << endl;
412 fout << r5pars_.timesno
413 << " InfoChunk::doneWithCurrentDiagnosisAndGoForPreviousOne: could not find previousely paused diagnosis\n";
414 fout.close();
415 r5pars_.sim_err = true;
416 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentDiagnosisAndGoForPreviouslyPausedOne err.");
418 } else {
419 }
420 return current_diagnosis;
421}
423 bool found_subgoal = false;
424 int current_subgoal = sim::State::Unknown;
425 int i = 0;
426 auto subgoal_itr = subgoal.rbegin();
427 while (subgoal_itr != subgoal.rend() && !found_subgoal) {
428 if ((*subgoal_itr)->getStateOfActivation() == sim::State::Active) {
429 (*subgoal_itr)->setDecision(sim::State::Done);
430 found_subgoal = true;
431 }
432 subgoal_itr++;
433 }
434 found_subgoal = false;
435 subgoal_itr = subgoal.rbegin();
436 while (subgoal_itr != subgoal.rend() && !found_subgoal) {
437 if ((*subgoal_itr)->getStateOfActivation() == sim::State::Pause) {
438 (*subgoal_itr)->setDecision(sim::State::Active);
439 found_subgoal = true;
440 current_subgoal = (*subgoal_itr)->getDecision();
441 }
442 subgoal_itr++;
443 i++;
444 }
445 if (i == 0) {//no
446 ofstream fout("err messages.txt", ios::app);
447 cout << "InfoChunk::doneWithCurrentSubgoalAndGoForPreviousOne: no subgoal exist" << endl;
448 fout << r5pars_.timesno << " InfoChunk::doneWithCurrentSubgoalAndGoForPreviousOne: no subgoal exist\n";
449 fout.close();
450 r5pars_.sim_err = true;
451 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentSubGoalAndGoForPreviouslyPausedOne err.");
453 } else if (subgoal_itr == subgoal.rend()) {
454 ofstream fout("err messages.txt", ios::app);
455 cout << "InfoChunk::doneWithCurrentSubgoalAndGoForPreviousOne: could not find previousely paused subgoal" << endl;
456 fout << r5pars_.timesno
457 << " InfoChunk::doneWithCurrentSubgoalAndGoForPreviousOne: could not find previousely paused subgoal\n";
458 fout.close();
459 r5pars_.sim_err = true;
460 g_sim.Branch_center.setTempESMessage("InfoChunk::doneWithCurrentSubGoalAndGoForPreviouslyPausedOne err.");
462 } else {
463 }
464 return current_subgoal;
465}
466
468 bool found_goal = false;
469 auto goal_itr = goal.rbegin();
470 while (goal_itr != goal.rend() && !found_goal) {
471 if ((*goal_itr)->getStateOfActivation() == sim::State::Active) {
472 (*goal_itr)->setStateOfActivation(sim::State::Pause);
473 found_goal = true;
474 }
475 goal_itr++;
476 }
478}
480 bool found_strategy = false;
481 auto strategy_itr = strategy.rbegin();
482 while (strategy_itr != strategy.rend() && !found_strategy) {
483 if ((*strategy_itr)->getStateOfActivation() == sim::State::Active) {
484 (*strategy_itr)->setStateOfActivation(sim::State::Pause);
485 found_strategy = true;
486 }
487 strategy_itr++;
488 }
490}
492 bool found_subgoal = false;
493 auto subgoal_itr = subgoal.rbegin();
494 while (subgoal_itr != subgoal.rend() && !found_subgoal) {
495 if ((*subgoal_itr)->getStateOfActivation() == sim::State::Active) {
496 (*subgoal_itr)->setStateOfActivation(sim::State::Pause);
497 found_subgoal = true;
498 }
499 subgoal_itr++;
500 }
502}
504 bool found_diagnosis = false;
505 auto diagnosis_itr = diagnosis.rbegin();
506 while (diagnosis_itr != diagnosis.rend() && !found_diagnosis) {
507 if ((*diagnosis_itr)->getStateOfActivation() == sim::State::Active) {
508 (*diagnosis_itr)->setStateOfActivation(sim::State::Pause);
509 found_diagnosis = true;
510 }
511 diagnosis_itr++;
512 }
514}
515bool InfoChunk::activateTheDiagnosis(string _diagnosis) {
516 bool found_diagnosis = false;
517 DecisionDiagnosis *diagnosis_pt = nullptr;
518 auto diagnosis_itr = diagnosis.rbegin();
519 while (diagnosis_itr != diagnosis.rend() && !found_diagnosis) {
520 if ((*diagnosis_itr)->getDiagnosis() == _diagnosis) {
521 found_diagnosis = true;
522 diagnosis_pt = diagnosis_itr->get();
523 }
524 diagnosis_itr++;
525 }
526 if (found_diagnosis) {
527 for (diagnosis_itr = diagnosis.rbegin(); diagnosis_itr != diagnosis.rend(); diagnosis_itr++) {
528 if ((*diagnosis_itr)->getStateOfActivation() == sim::State::Active) {
529 (*diagnosis_itr)->setStateOfActivation(sim::State::Pause);
530 }
531 }
533 }
534 return found_diagnosis;
535}
537 bool found_diagnosis = false;
538 auto diagnosis_itr = diagnosis.rbegin();
539 while (diagnosis_itr != diagnosis.rend() && !found_diagnosis) {
540 if ((*diagnosis_itr)->getStateOfActivation() == sim::State::Active) {
541 found_diagnosis = true;
542 }
543 diagnosis_itr++;
544 }
545 return found_diagnosis;
546}
548 string _in_use_step_name) {
549 bool found_mental_procedure = false;
550 bool procedure_in_use;
551 int state_of_activation = sim::State::Done;
552 int highest_priority = 999;
553 DecisionProcedureStep *dds_pt = nullptr;
554 auto instinctive_response_procedure_itr = instinctive_response_procedure.begin();
555 while (instinctive_response_procedure_itr != instinctive_response_procedure.end() && !found_mental_procedure) {
556 procedure_in_use = false;
557 state_of_activation = (*instinctive_response_procedure_itr)->getStateOfActivation();
558 if ((*instinctive_response_procedure_itr)->getProcedureName() == _in_use_procedure_name
559 && (*instinctive_response_procedure_itr)->getStepName() == _in_use_step_name) {
560 procedure_in_use = true;
561 }
562 if (state_of_activation == sim::State::Active && !procedure_in_use) {
563 found_mental_procedure = true;
564 dds_pt = instinctive_response_procedure_itr->get();
565 } else {
566 instinctive_response_procedure_itr++;
567 }
568 }
569 if (!found_mental_procedure) {
570 // check for previosuly paused procedures
571 instinctive_response_procedure_itr = instinctive_response_procedure.begin();
572 while (instinctive_response_procedure_itr != instinctive_response_procedure.end() && !found_mental_procedure) {
573 procedure_in_use = false;
574 state_of_activation = (*instinctive_response_procedure_itr)->getStateOfActivation();
575 if ((*instinctive_response_procedure_itr)->getProcedureName() == _in_use_procedure_name
576 && (*instinctive_response_procedure_itr)->getStepName() == _in_use_step_name) {
577 procedure_in_use = true;
578 }
579 if (state_of_activation == sim::State::Pause && !procedure_in_use) {
580 found_mental_procedure = true;
581 dds_pt = instinctive_response_procedure_itr->get();
582 } else {
583 instinctive_response_procedure_itr++;
584 }
585 }
586 }
587 if (!found_mental_procedure) {
588 // find highest priority waiting procedure
589 instinctive_response_procedure_itr = instinctive_response_procedure.begin();
590 while (instinctive_response_procedure_itr != instinctive_response_procedure.end()) {
591 procedure_in_use = false;
592 state_of_activation = (*instinctive_response_procedure_itr)->getStateOfActivation();
593 if ((*instinctive_response_procedure_itr)->getProcedureName() == _in_use_procedure_name
594 && (*instinctive_response_procedure_itr)->getStepName() == _in_use_step_name) {
595 procedure_in_use = true;
596 }
597 if (state_of_activation == sim::None && !procedure_in_use
598 && (*instinctive_response_procedure_itr)->getPriority() < highest_priority) {
599 highest_priority = (*instinctive_response_procedure_itr)->getPriority();
600 found_mental_procedure = true;
601 dds_pt = instinctive_response_procedure_itr->get();
602 }
603 instinctive_response_procedure_itr++;
604 }
605 }
606 return dds_pt;
607}
608bool InfoChunk::isThereMentalProcedureWaitingForExecution(string _procedure_name, string _step_name) {
609 bool found_mental_procedure = false;
610 bool procedure_in_use;
611 bool procedure_waiting;
612 int state_of_activation;
613 auto instinctive_response_procedure_itr = instinctive_response_procedure.begin();
614 while (instinctive_response_procedure_itr != instinctive_response_procedure.end() && !found_mental_procedure) {
615 procedure_in_use = false;
616 procedure_waiting = false;
617 state_of_activation = (*instinctive_response_procedure_itr)->getStateOfActivation();
618 //
619 // check if procedure is being used by another operator
620 if ((*instinctive_response_procedure_itr)->getProcedureName() == _procedure_name
621 && (*instinctive_response_procedure_itr)->getStepName() == _step_name) {
622 procedure_in_use = true;
623 }
624 //
625 // check to see if queued procedure can be activated
626 if ((*instinctive_response_procedure_itr)->getActivationTime() < r5pars_.timesno
627 && state_of_activation == sim::State::Waiting) {
628 state_of_activation = sim::None;
629 (*instinctive_response_procedure_itr)->setStateOfActivation(state_of_activation);
630 }
631 //
632 if (state_of_activation == sim::State::Active || state_of_activation == sim::None || state_of_activation == sim::State::Pause) {
633 procedure_waiting = true;
634 }
635 if (procedure_waiting && !procedure_in_use) {
636 found_mental_procedure = true;
637 } else {
638 instinctive_response_procedure_itr++;
639 }
640 }
641 return found_mental_procedure;
642}
644 if (this->getCurrentGoal() == sim::None) {
645 // Find the active goal shared_ptr in source and share it
646 bool found = false;
647 for (auto ritr = _perceived_info.goal.rbegin(); ritr != _perceived_info.goal.rend(); ritr++) {
648 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
649 this->goal.push_back(*ritr);
650 found = true;
651 break;
652 }
653 }
654 if (!found) {
655 ofstream fout("err messages.txt", ios::app);
656 cout << "InfoChunk::pointToAvtiveGoalAndStrategy: No active goal exists." << endl;
657 fout << r5pars_.timesno << " InfoChunk::pointToAvtiveGoalAndStrategy: No active goal exists.\n";
658 fout.close();
659 r5pars_.sim_err = true;
660 g_sim.Branch_center.setTempESMessage("InfoChunk::pointToAvtiveGoalAndStrategy err.");
662 }
663 }
664 if (this->getCurrentStrategy() == sim::None) {
665 bool found = false;
666 for (auto ritr = _perceived_info.strategy.rbegin(); ritr != _perceived_info.strategy.rend(); ritr++) {
667 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
668 this->strategy.push_back(*ritr);
669 found = true;
670 break;
671 }
672 }
673 if (!found) {
674 ofstream fout("err messages.txt", ios::app);
675 cout << "InfoChunk::pointToAvtiveGoalAndStrategy: No active strategy exists." << endl;
676 fout << r5pars_.timesno << " InfoChunk::pointToAvtiveGoalAndStrategy: No active strategy exists.\n";
677 fout.close();
678 r5pars_.sim_err = true;
679 g_sim.Branch_center.setTempESMessage("InfoChunk::pointToAvtiveGoalAndStrategy err.");
681 }
682 }
683}
684
686 bool found = false;
688 auto ritr = goal.rbegin();
689 while (ritr != goal.rend() && !found) {
690 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
691 found = true;
692 (*ritr)->setStateOfActivation(sim::State::Pause);
693 }
694 ritr++;
695 }
696 }
697 this->goal.push_back(shared_ptr<DecisionGoal>(_pt, [](DecisionGoal*){}));
698}
700 bool found = false;
702 auto ritr = strategy.rbegin();
703 while (ritr != strategy.rend() && !found) {
704 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
705 found = true;
706 (*ritr)->setStateOfActivation(sim::State::Pause);
707 }
708 ritr++;
709 }
710 }
711 this->strategy.push_back(shared_ptr<DecisionStrategy>(_pt, [](DecisionStrategy*){}));
712}
714 bool found = false;
716 auto ritr = subgoal.rbegin();
717 while (ritr != subgoal.rend() && !found) {
718 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
719 found = true;
720 (*ritr)->setStateOfActivation(sim::State::Pause);
721 }
722 ritr++;
723 }
724 }
725 this->subgoal.push_back(shared_ptr<DecisionSubGoal>(_pt, [](DecisionSubGoal*){}));
726}
728 bool found = false;
730 auto ritr = diagnosis.rbegin();
731 while (ritr != diagnosis.rend() && !found) {
732 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
733 found = true;
734 (*ritr)->setStateOfActivation(sim::State::Pause);
735 }
736 ritr++;
737 }
738 }
739 this->diagnosis.push_back(shared_ptr<DecisionDiagnosis>(_pt, [](DecisionDiagnosis*){}));
740}
742 bool found = false;
744 auto ritr = action_objective.rbegin();
745 while (ritr != action_objective.rend() && !found) {
746 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
747 found = true;
748 (*ritr)->setStateOfActivation(sim::State::Pause);
749 }
750 ritr++;
751 }
752 }
753 this->action_objective.push_back(shared_ptr<DecisionActionObjective>(_pt, [](DecisionActionObjective*){}));
754}
756 bool found = false;
758 auto ritr = action_pack.rbegin();
759 while (ritr != action_pack.rend() && !found) {
760 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
761 found = true;
762 (*ritr)->setStateOfActivation(sim::State::Pause);
763 }
764 ritr++;
765 }
766 }
767 this->action_pack.push_back(shared_ptr<DecisionActionPack>(_pt, [](DecisionActionPack*){}));
768}
770 bool found = false;
772 auto ritr = action.rbegin();
773 while (ritr != action.rend() && !found) {
774 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
775 found = true;
776 (*ritr)->setStateOfActivation(sim::State::Pause);
777 }
778 ritr++;
779 }
780 }
781 this->action.push_back(shared_ptr<DecisionAction>(_pt, [](DecisionAction*){}));
782}
784 bool found = false;
785 string _pt_procedure_name, ritr_procedure_name;
786 _pt_procedure_name = _pt->getProcedureName();
787 _pt_procedure_name += _pt->getStepName();
789 auto ritr = procedure_step.rbegin();
790 while (ritr != procedure_step.rend() && !found) {
791 ritr_procedure_name = (*ritr)->getProcedureName();
792 ritr_procedure_name += (*ritr)->getStepName();
793 if (_pt_procedure_name == ritr_procedure_name) {
794 // don't reset status if reactivating previous procedure
795 found = true;
796 } else if ((*ritr)->getStateOfActivation() == sim::State::Active) {
797 found = true;
798 (*ritr)->setStateOfActivation(sim::State::Pause);
799 }
800 ritr++;
801 }
802 }
803 if (!found) {
804 // add new procedure pointer to working memory stack
805 this->procedure_step.push_back(shared_ptr<DecisionProcedureStep>(_pt, [](DecisionProcedureStep*){}));
806 }
807}
809 bool found = false;
811 auto ritr = instinctive_response_procedure.rbegin();
812 while (ritr != instinctive_response_procedure.rend() && !found) {
813 if ((*ritr)->getStateOfActivation() == sim::State::Active) {
814 found = true;
815 (*ritr)->setStateOfActivation(sim::State::Pause);
816 }
817 ritr++;
818 }
819 }
820 this->instinctive_response_procedure.push_back(shared_ptr<DecisionProcedureStep>(_pt, [](DecisionProcedureStep*){}));
821}
822void InfoChunk::updateActionState(string _action_name, int _new_state) {
823 bool found = false;
824 auto ritr = action.rbegin();
825 while (ritr != action.rend() && !found) {
826 if (_action_name == (*ritr)->getActionName()) {
827 found = true;
828 (*ritr)->setStateOfActivation(_new_state);
829 }
830 ritr++;
831 }
832}
833
835 bool found = false;
836 DecisionAction *da_pt = nullptr;
837 auto ritr = action.rbegin();
838 while (ritr != action.rend() && !found) {
839 if ((*ritr)->getActionName() == str) {
840 found = true;
841 da_pt = ritr->get();
842 }
843 ritr++;
844 }
845 return da_pt;
846}
848 bool found = false;
849 MentalAlarm *da_pt = nullptr;
850 auto ritr = perceived_alarms.rbegin();
851 while (ritr != perceived_alarms.rend() && !found) {
852 if ((*ritr)->getAlarmName() == str) {
853 found = true;
854 da_pt = ritr->get();
855 }
856 ritr++;
857 }
858 return da_pt;
859}
861 string _step_name) {
862 DecisionProcedureStep *pds_pt = nullptr;
863 bool found = false;
864 auto ritr = this->instinctive_response_procedure.rbegin();
865 while (ritr != this->instinctive_response_procedure.rend() && !found) {
866 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name &&
867 (*ritr)->getStateOfActivation() != sim::State::Done && (*ritr)->getStateOfActivation() != sim::State::Interrupted
868 && (*ritr)->getStateOfActivation() != sim::State::Succeed) {
869 found = true;
870 pds_pt = ritr->get();
871 } else {
872 ritr++;
873 }
874 }
875 return pds_pt;
876}
877
878DecisionProcedureStep *InfoChunk::checkExistanceOfAProcedure(string _procedure_name, string _step_name) {
879 DecisionProcedureStep *pds_pt = nullptr;
880 bool found = false;
881 auto ritr = this->procedure_step.rbegin();
882 while (ritr != this->procedure_step.rend() && !found) {
883 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name &&
884 (*ritr)->getStateOfActivation() != sim::State::Done && (*ritr)->getStateOfActivation() != sim::State::Interrupted
885 && (*ritr)->getStateOfActivation() != sim::State::Succeed) {
886 found = true;
887 pds_pt = ritr->get();
888 } else {
889 ritr++;
890 }
891 }
892 return pds_pt;
893}
894
896 bool found = false;
897 MentalComponentState *da_pt = nullptr;
898 auto ritr = perceived_component_state.rbegin();
899 while (ritr != perceived_component_state.rend() && !found) {
900 if ((*ritr)->getDisplayName() == str) {
901 found = true;
902 da_pt = ritr->get();
903 }
904 ritr++;
905 }
906 return da_pt;
907}
909 bool found = false;
910 MentalSupportSystemState *da_pt = nullptr;
911 auto ritr = perceived_support_system_state.rbegin();
912 while (ritr != perceived_support_system_state.rend() && !found) {
913 if ((*ritr)->getDisplayName() == str) {
914 found = true;
915 da_pt = ritr->get();
916 }
917 ritr++;
918 }
919 return da_pt;
920}
922 bool found = false;
923 MentalParameterValue *da_pt = nullptr;
924 auto ritr = perceived_parameter_value.rbegin();
925 while (ritr != perceived_parameter_value.rend() && !found) {
926 if ((*ritr)->getDisplayName() == str) {
927 found = true;
928 da_pt = ritr->get();
929 }
930 ritr++;
931 }
932 return da_pt;
933}
935 bool found = false;
936 ExpectedMentalBelief *mp_pt = nullptr;
937 auto mental_belief_ritr = mental_belief.rbegin();
938 while (mental_belief_ritr != mental_belief.rend() && !found) {
939 if ((*mental_belief_ritr)->getInfoName() == str) {
940 found = true;
941 mp_pt = mental_belief_ritr->get();
942 }
943 mental_belief_ritr++;
944 }
945 return mp_pt;
946}
948 bool found = false;
949 MentalParameterTrend *da_pt = nullptr;
950 auto ritr = perceived_parameter_trend.rbegin();
951 while (ritr != perceived_parameter_trend.rend() && !found) {
952 if ((*ritr)->getDisplayName() == str) {
953 found = true;
954 da_pt = ritr->get();
955 }
956 ritr++;
957 }
958 return da_pt;
959}
961 bool found = false;
962 auto r_itr = goal.rbegin();
963 while (r_itr != goal.rend() && !found) {
964 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
965 found = true;
966 (*r_itr)->setStateOfActivation(sim::State::Pause);
967 }
968 r_itr++;
969 }
970}
972 bool found = false;
973 auto r_itr = strategy.rbegin();
974 while (r_itr != strategy.rend() && !found) {
975 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
976 found = true;
977 (*r_itr)->setStateOfActivation(sim::State::Pause);
978 }
979 r_itr++;
980 }
981}
983 bool found = false;
984 auto r_itr = subgoal.rbegin();
985 while (r_itr != subgoal.rend() && !found) {
986 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
987 found = true;
988 (*r_itr)->setStateOfActivation(sim::State::Pause);
989 }
990 r_itr++;
991 }
992}
994 bool found = false;
995 auto r_itr = diagnosis.rbegin();
996 while (r_itr != diagnosis.rend() && !found) {
997 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
998 found = true;
999 (*r_itr)->setStateOfActivation(sim::State::Pause);
1000 }
1001 r_itr++;
1002 }
1003}
1005 bool found = false;
1006 auto r_itr = action_objective.rbegin();
1007 while (r_itr != action_objective.rend() && !found) {
1008 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
1009 found = true;
1010 (*r_itr)->setStateOfActivation(sim::State::Pause);
1011 }
1012 r_itr++;
1013 }
1014}
1016 bool found = false;
1017 auto r_itr = action_pack.rbegin();
1018 while (r_itr != action_pack.rend() && !found) {
1019 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
1020 found = true;
1021 (*r_itr)->setStateOfActivation(sim::State::Pause);
1022 }
1023 r_itr++;
1024 }
1025}
1027 bool found = false;
1028 auto r_itr = action.rbegin();
1029 while (r_itr != action.rend() && !found) {
1030 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
1031 found = true;
1032 (*r_itr)->setStateOfActivation(sim::State::Pause);
1033 }
1034 r_itr++;
1035 }
1036}
1038 bool found = false;
1039 auto r_itr = procedure_step.rbegin();
1040 while (r_itr != procedure_step.rend() && !found) {
1041 if ((*r_itr)->getStateOfActivation() == sim::State::Active) {
1042 found = true;
1043 (*r_itr)->setStateOfActivation(sim::State::Pause);
1044 (*r_itr)->setLastProcedureName("NONE");
1045 (*r_itr)->setLastStepName("NONE");
1046 }
1047 r_itr++;
1048 }
1049}
1050
1052 bool found = false;
1053 int r_return = sim::None;
1054 decltype(perceived_alarms)::reverse_iterator ritr;
1055 ritr = perceived_alarms.rbegin();
1056 while (ritr != perceived_alarms.rend() && !found) {
1057 if ((*ritr)->getAlarmName() == _exp->getInfoName()) {
1058 found = true;
1059 if ((*ritr)->getObservedAlarmState() == _exp->getExpectedState()) {
1060 r_return = sim::State::Succeed;
1061 } else {
1062 r_return = sim::State::Failed;
1063 }
1064 }
1065 ritr++;
1066 }
1067 return r_return;
1068}
1070 bool found = false;
1071 int r_return = sim::None;
1072 decltype(perceived_component_state)::reverse_iterator ritr;
1073 ritr = perceived_component_state.rbegin();
1074 while (ritr != perceived_component_state.rend() && !found) {
1075 if ((*ritr)->getDisplayName() == _exp->getInfoName()) {
1076 found = true;
1077 if ((*ritr)->getObservedComponentState() == _exp->getExpectedState()) {
1078 r_return = sim::State::Succeed;
1079 } else {
1080 r_return = sim::State::Failed;
1081 }
1082 }
1083 ritr++;
1084 }
1085 return r_return;
1086};
1088 bool found = false;
1089 int r_return = sim::None;
1090 decltype(perceived_support_system_state)::reverse_iterator ritr;
1091 ritr = perceived_support_system_state.rbegin();
1092 while (ritr != perceived_support_system_state.rend() && !found) {
1093 if ((*ritr)->getDisplayName() == _exp->getInfoName()) {
1094 found = true;
1095 if ((*ritr)->getObservedSupportSystemState() == _exp->getExpectedState()) {
1096 r_return = sim::State::Succeed;
1097 } else {
1098 r_return = sim::State::Failed;
1099 }
1100 }
1101 ritr++;
1102 }
1103 return r_return;
1104};
1106 bool found = false;
1107 int r_return = sim::None;
1108 double observed_value, par1, par2;
1109 decltype(perceived_parameter_value)::reverse_iterator ritr;
1110 ritr = perceived_parameter_value.rbegin();
1111 while (ritr != perceived_parameter_value.rend() && !found) {
1112 if ((*ritr)->getDisplayName() == _exp->getInfoName()) {
1113 found = true;
1114 r_return = sim::State::Failed;
1115 observed_value = (*ritr)->getObservedParameterValue();
1116 par1 = _exp->getExpectedValue1();
1117 par2 = _exp->getExpectedValue2();
1118 switch (_exp->getLogicalRelation()) {
1119 case sim::Compare::GT: if (observed_value > par1) r_return = sim::State::Succeed;
1120 break;
1121 case sim::Compare::GE: if (observed_value >= par1) r_return = sim::State::Succeed;
1122 break;
1123 case sim::Compare::EQ: if (observed_value == par1) r_return = sim::State::Succeed;
1124 break;
1125 case sim::Compare::LE: if (observed_value <= par1) r_return = sim::State::Succeed;
1126 break;
1127 case sim::Compare::LT: if (observed_value < par1) r_return = sim::State::Succeed;
1128 break;
1129 case sim::Compare::Between: if (observed_value > par1 && observed_value < par2) r_return = sim::State::Succeed;
1130 break;
1131 default: ofstream fout("err messages.txt", ios::app);
1132 cout << "InfoChunk::checkWhetherExpectedParameterValueMatchObservation: KBExpectation: "
1133 << (*ritr)->getDisplayName()
1134 << " whose logical relation: " << _exp->getLogicalRelation() << " could not be recognized" << endl;
1135 fout << r5pars_.timesno << " InfoChunk::checkWhetherExpectedParameterValueMatchObservation: KBExpectation: "
1136 << (*ritr)->getDisplayName()
1137 << " whose logical relation: " << _exp->getLogicalRelation() << " could not be recognized.\n";
1138 fout.close();
1139 r5pars_.sim_err = true;
1140 g_sim.Branch_center.setTempESMessage("InfoChunk::checkWhetherExpectedParameterValueMatchObservation err.");
1142 break;
1143 }
1144 }
1145 ritr++;
1146 }
1147 return r_return;
1148}
1149
1151 bool found1 = false;
1152 bool found2 = false;
1153 int r_return = sim::None;
1154 double observed_value1, observed_value2;
1155 decltype(perceived_parameter_value)::reverse_iterator ritr;
1156 ritr = perceived_parameter_value.rbegin();
1157 //find first difference parameter in perceived information
1158 while (ritr != perceived_parameter_value.rend() && !found1) {
1159 if ((*ritr)->getDisplayName() == _expd->first_indicator.getInfoName()) {
1160 found1 = true;
1161 observed_value1 = (*ritr)->getObservedParameterValue();
1162 }
1163 ritr++;
1164 }
1165 //find second difference parameter in perceived information
1166 ritr = perceived_parameter_value.rbegin();
1167 while (ritr != perceived_parameter_value.rend() && !found2) {
1168 if ((*ritr)->getDisplayName() == _expd->second_indicator.getInfoName()) {
1169 found2 = true;
1170 observed_value2 = (*ritr)->getObservedParameterValue();
1171 }
1172 ritr++;
1173 }
1174 if (found1 == true && found2 == true) {
1175 r_return = sim::State::Failed;
1176 if (observed_value1 - observed_value2 > _expd->getThresholdValueThatActivatesExpectation()) {
1177 r_return = sim::State::Succeed;
1178 }
1179 }
1180 return r_return;
1181}
1182
1184 int r_return = sim::None;
1186 return r_return;
1187}
1188
1190 for (auto goal_itr = _ic.goal.begin(); goal_itr != _ic.goal.end(); goal_itr++) {
1191 auto goal_sp = make_shared<DecisionGoal>();
1192 goal_sp->copyDecisionGoal(**goal_itr);
1193 this->goal.push_back(goal_sp);
1194 }
1195 for (auto strategy_itr = _ic.strategy.begin(); strategy_itr != _ic.strategy.end(); strategy_itr++) {
1196 auto strategy_sp = make_shared<DecisionStrategy>();
1197 strategy_sp->copyDecisionStrategy(**strategy_itr);
1198 this->strategy.push_back(strategy_sp);
1199 }
1200 for (auto subgoal_itr = _ic.subgoal.begin(); subgoal_itr != _ic.subgoal.end(); subgoal_itr++) {
1201 auto subgoal_sp = make_shared<DecisionSubGoal>();
1202 subgoal_sp->copyDecisionSubGoal(**subgoal_itr);
1203 this->subgoal.push_back(subgoal_sp);
1204 }
1205 for (auto diagnosis_itr = _ic.diagnosis.begin(); diagnosis_itr != _ic.diagnosis.end(); diagnosis_itr++) {
1206 auto diagnosis_sp = make_shared<DecisionDiagnosis>();
1207 diagnosis_sp->copyDecisionDiagnosis(**diagnosis_itr);
1208 this->diagnosis.push_back(diagnosis_sp);
1209 }
1210 for (auto action_objective_itr = _ic.action_objective.begin(); action_objective_itr != _ic.action_objective.end();
1211 action_objective_itr++) {
1212 auto action_objective_sp = make_shared<DecisionActionObjective>();
1213 action_objective_sp->copyDecisionActionObjective(**action_objective_itr);
1214 this->action_objective.push_back(action_objective_sp);
1215 }
1216 for (auto action_pack_itr = _ic.action_pack.begin(); action_pack_itr != _ic.action_pack.end(); action_pack_itr++) {
1217 auto action_pack_sp = make_shared<DecisionActionPack>();
1218 action_pack_sp->copyDecisionActionPack(**action_pack_itr);
1219 this->action_pack.push_back(action_pack_sp);
1220 }
1221 for (auto action_itr = _ic.action.begin(); action_itr != _ic.action.end(); action_itr++) {
1222 auto action_sp = make_shared<DecisionAction>();
1223 action_sp->copyDecisionAction(**action_itr);
1224 this->action.push_back(action_sp);
1225 }
1226 for (auto procedure_step_itr = _ic.procedure_step.begin(); procedure_step_itr != _ic.procedure_step.end();
1227 procedure_step_itr++) {
1228 auto procedure_step_sp = make_shared<DecisionProcedureStep>();
1229 procedure_step_sp->copyDecisionProcedureStep(**procedure_step_itr);
1230 this->procedure_step.push_back(procedure_step_sp);
1231 }
1232 for (auto procedure_step_itr = _ic.instinctive_response_procedure.begin();
1233 procedure_step_itr != _ic.instinctive_response_procedure.end(); procedure_step_itr++) {
1234 auto procedure_step_sp = make_shared<DecisionProcedureStep>();
1235 procedure_step_sp->copyDecisionProcedureStep(**procedure_step_itr);
1236 this->instinctive_response_procedure.push_back(procedure_step_sp);
1237 }
1238 for (auto perceived_alarms_itr = _ic.perceived_alarms.begin(); perceived_alarms_itr != _ic.perceived_alarms.end();
1239 perceived_alarms_itr++) {
1240 auto perceived_alarms_sp = make_shared<MentalAlarm>();
1241 perceived_alarms_sp->copyMentalAlarm(**perceived_alarms_itr);
1242 this->perceived_alarms.push_back(perceived_alarms_sp);
1243 }
1244 for (auto perceived_component_state_itr = _ic.perceived_component_state.begin();
1245 perceived_component_state_itr != _ic.perceived_component_state.end(); perceived_component_state_itr++) {
1246 auto perceived_component_state_sp = make_shared<MentalComponentState>();
1247 perceived_component_state_sp->copyMentalComponentState(**perceived_component_state_itr);
1248 this->perceived_component_state.push_back(perceived_component_state_sp);
1249 }
1250 for (auto perceived_support_system_state_itr = _ic.perceived_support_system_state.begin();
1251 perceived_support_system_state_itr != _ic.perceived_support_system_state.end(); perceived_support_system_state_itr++) {
1252 auto perceived_support_system_state_sp = make_shared<MentalSupportSystemState>();
1253 perceived_support_system_state_sp->copyMentalSupportSystemState(**perceived_support_system_state_itr);
1254 this->perceived_support_system_state.push_back(perceived_support_system_state_sp);
1255 }
1256 for (auto perceived_parameter_value_itr = _ic.perceived_parameter_value.begin();
1257 perceived_parameter_value_itr != _ic.perceived_parameter_value.end(); perceived_parameter_value_itr++) {
1258 auto perceived_parameter_value_sp = make_shared<MentalParameterValue>();
1259 perceived_parameter_value_sp->copyMentalParameterValue(**perceived_parameter_value_itr);
1260 this->perceived_parameter_value.push_back(perceived_parameter_value_sp);
1261 }
1262 for (auto perceived_parameter_trend_itr = _ic.perceived_parameter_trend.begin();
1263 perceived_parameter_trend_itr != _ic.perceived_parameter_trend.end(); perceived_parameter_trend_itr++) {
1264 auto perceived_parameter_trend_sp = make_shared<MentalParameterTrend>();
1265 perceived_parameter_trend_sp->copyMentalParameterTrend(**perceived_parameter_trend_itr);
1266 this->perceived_parameter_trend.push_back(perceived_parameter_trend_sp);
1267 }
1268 for (auto mental_belief_itr = _ic.mental_belief.begin(); mental_belief_itr != _ic.mental_belief.end();
1269 mental_belief_itr++) {
1270 auto mental_belief_sp = make_shared<ExpectedMentalBelief>();
1271 mental_belief_sp->copyExpectedMentalBelief(**mental_belief_itr);
1272 this->mental_belief.push_back(mental_belief_sp);
1273 }
1274}
1275bool InfoChunk::diagnosisIsIncluded(string _diagnosis) {
1276 bool is_included = false;
1277 auto diagnosis_itr = diagnosis.begin();
1278 while (diagnosis_itr != diagnosis.end() && !is_included) {
1279 if ((*diagnosis_itr)->getDiagnosis() == _diagnosis) {
1280 is_included = true;
1281 }
1282 diagnosis_itr++;
1283 }
1284 return is_included;
1285}
1286void InfoChunk::setStateOfAProcedureStep(string _procedure_name, string _step_name, int _state) {
1287 bool found = false;
1288 decltype(procedure_step)::reverse_iterator ritr;
1289 ritr = procedure_step.rbegin();
1290 // reverse iterator starts at end of queue (ie last procedure step added) and works backwards
1291 while (ritr != procedure_step.rend() && !found) {
1292 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name) {
1293 found = true;
1294 (*ritr)->setStateOfActivation(_state);
1295 }
1296 ritr++;
1297 }
1298 if (!found) {
1299 ritr = this->instinctive_response_procedure.rbegin();
1300 while (ritr != this->instinctive_response_procedure.rend() && !found) {
1301 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name) {
1302 found = true;
1303 (*ritr)->setStateOfActivation(_state);
1304 }
1305 ritr++;
1306 }
1307 }
1308}
1309int InfoChunk::getStateOfAProcedureStep(string _procedure_name, string _step_name) {
1310 bool found = false;
1311 int state = sim::None;
1312 decltype(procedure_step)::reverse_iterator ritr;
1313 ritr = procedure_step.rbegin();
1314 // reverse iterator starts at end of queue (ie last procedure step added) and works backwards
1315 while (ritr != procedure_step.rend() && !found) {
1316 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name) {
1317 found = true;
1318 state = (*ritr)->getStateOfActivation();
1319 }
1320 ritr++;
1321 }
1322 if (!found) {
1323 ritr = this->instinctive_response_procedure.rbegin();
1324 while (ritr != this->instinctive_response_procedure.rend() && !found) {
1325 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name) {
1326 found = true;
1327 state = (*ritr)->getStateOfActivation();
1328 }
1329 ritr++;
1330 }
1331 }
1332 return state;
1333}
1334
1335int InfoChunk::getMentalPriorityOfAProcedureStep(string _procedure_name, string _step_name) {
1336 bool found = false;
1337 int state = sim::None;
1338 decltype(procedure_step)::reverse_iterator ritr;
1339 ritr = procedure_step.rbegin();
1340 // reverse iterator starts at end of queue (ie last procedure step added) and works backwards
1341 while (ritr != procedure_step.rend() && !found) {
1342 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name) {
1343 found = true;
1344 state = (*ritr)->getPriority();
1345 }
1346 ritr++;
1347 }
1348 if (!found) {
1349 ritr = this->instinctive_response_procedure.rbegin();
1350 while (ritr != this->instinctive_response_procedure.rend() && !found) {
1351 if ((*ritr)->getProcedureName() == _procedure_name && (*ritr)->getStepName() == _step_name) {
1352 found = true;
1353 state = (*ritr)->getPriority();
1354 }
1355 ritr++;
1356 }
1357 }
1358 return state;
1359}
1360
1362 fout << "GOAL " << this->goal.size() << '\n';
1363 for (auto goal_itr = goal.begin(); goal_itr != goal.end(); goal_itr++) {
1364 (*goal_itr)->saveDecisionGoalToFile(fout);
1365 }
1366 fout << "STRATEGY " << this->strategy.size() << '\n';
1367 for (auto strategy_itr = strategy.begin(); strategy_itr != strategy.end(); strategy_itr++) {
1368 (*strategy_itr)->saveDecisionStrategyToFile(fout);
1369 }
1370 fout << "SUBGOAL " << this->subgoal.size() << '\n';
1371 for (auto subgoal_itr = subgoal.begin(); subgoal_itr != subgoal.end(); subgoal_itr++) {
1372 (*subgoal_itr)->saveDecisionSubGoalToFile(fout);
1373 }
1374 fout << "DIAGNOSIS " << this->diagnosis.size() << '\n';
1375 for (auto diagnosis_itr = diagnosis.begin(); diagnosis_itr != diagnosis.end(); diagnosis_itr++) {
1376 (*diagnosis_itr)->saveDecisionDiagnosisToFile(fout);
1377 }
1378 fout << "ACTION_OBJECTIVE " << this->action_objective.size() << '\n';
1379 for (auto action_objective_itr = action_objective.begin(); action_objective_itr != action_objective.end();
1380 action_objective_itr++) {
1381 (*action_objective_itr)->saveDecisionActionObjectiveToFile(fout);
1382 }
1383 fout << "ACTION_PACK " << this->action_pack.size() << '\n';
1384 for (auto action_pack_itr = action_pack.begin(); action_pack_itr != action_pack.end(); action_pack_itr++) {
1385 (*action_pack_itr)->saveDecisionActionPackToFile(fout);
1386 }
1387 fout << "ACTION " << this->action.size() << '\n';
1388 for (auto action_itr = action.begin(); action_itr != action.end(); action_itr++) {
1389 (*action_itr)->saveDecisionActionToFile(fout);
1390 }
1391 fout << "PROCEDURE_STEP " << this->procedure_step.size() << '\n';
1392 for (auto procedure_step_itr = procedure_step.begin(); procedure_step_itr != procedure_step.end(); procedure_step_itr++) {
1393 (*procedure_step_itr)->saveDecisionProcedureStepToFile(fout);
1394 }
1395 fout << "INSTINCTIVE_RESPONSE " << this->instinctive_response_procedure.size() << '\n';
1396 for (auto procedure_step_itr = instinctive_response_procedure.begin();
1397 procedure_step_itr != instinctive_response_procedure.end(); procedure_step_itr++) {
1398 (*procedure_step_itr)->saveDecisionProcedureStepToFile(fout);
1399 }
1400 fout << "PERCEIVED_ALARM " << this->perceived_alarms.size() << '\n';
1401 for (auto perceived_alarms_itr = perceived_alarms.begin(); perceived_alarms_itr != perceived_alarms.end();
1402 perceived_alarms_itr++) {
1403 (*perceived_alarms_itr)->saveMentalAlarmToFile(fout);
1404 }
1405 fout << "PERCEIVED_COMPONENT_STATE " << this->perceived_component_state.size() << '\n';
1406 for (auto perceived_component_state_itr = perceived_component_state.begin();
1407 perceived_component_state_itr != perceived_component_state.end(); perceived_component_state_itr++) {
1408 (*perceived_component_state_itr)->saveMentalComponentStateToFile(fout);
1409 }
1410 fout << "PERCEIVED_SUPPORT_SYSTEM_STATE " << this->perceived_support_system_state.size() << '\n';
1411 for (auto perceived_support_system_state_itr = perceived_support_system_state.begin();
1412 perceived_support_system_state_itr != perceived_support_system_state.end(); perceived_support_system_state_itr++) {
1413 (*perceived_support_system_state_itr)->saveMentalSupportSystemStateToFile(fout);
1414 }
1415 fout << "PERCEIVED_PARAMETER_VALUE " << this->perceived_parameter_value.size() << '\n';
1416 for (auto perceived_parameter_value_itr = perceived_parameter_value.begin();
1417 perceived_parameter_value_itr != perceived_parameter_value.end(); perceived_parameter_value_itr++) {
1418 (*perceived_parameter_value_itr)->saveMentalParameterValueToFile(fout);
1419 }
1420 fout << "PERCEIVER_PARAMETER_TREND " << this->perceived_parameter_trend.size() << '\n';
1421 for (auto perceived_parameter_trend_itr = perceived_parameter_trend.begin();
1422 perceived_parameter_trend_itr != perceived_parameter_trend.end(); perceived_parameter_trend_itr++) {
1423 (*perceived_parameter_trend_itr)->saveMentalParameterTrendToFile(fout);
1424 }
1425 fout << "MENTAL_BELIEF " << this->mental_belief.size() << '\n';
1426 for (auto mental_belief_itr = mental_belief.begin(); mental_belief_itr != mental_belief.end(); mental_belief_itr++) {
1427 (*mental_belief_itr)->saveExpectedMentalBeliefToFile(fout);
1428 }
1429}
1431 int i, num;
1432 string str;
1433 fin >> str >> num;
1434 if (str != "GOAL") {
1435 this->generateErrorMessage("GOAL");
1436 return;
1437 } else {
1438 for (i = 0; i < num; i++) {
1439 auto goal_sp = make_shared<DecisionGoal>();
1440 goal_sp->retrieveDecisionGoalFromFile(fin);
1441 this->goal.push_back(goal_sp);
1442 }
1443 }
1444//
1445 fin >> str >> num;
1446 if (str != "STRATEGY") {
1447 this->generateErrorMessage("SUBGOAL");
1448 return;
1449 } else {
1450 for (i = 0; i < num; i++) {
1451 auto strategy_sp = make_shared<DecisionStrategy>();
1452 strategy_sp->retrieveDecisionStrategyFromFile(fin);
1453 this->strategy.push_back(strategy_sp);
1454 }
1455 }
1456//
1457 fin >> str >> num;
1458 if (str != "SUBGOAL") {
1459 this->generateErrorMessage("SUBGOAL");
1460 return;
1461 } else {
1462 for (i = 0; i < num; i++) {
1463 auto subgoal_sp = make_shared<DecisionSubGoal>();
1464 subgoal_sp->retrieveDecisionSubGoalFromFile(fin);
1465 this->subgoal.push_back(subgoal_sp);
1466 }
1467 }
1468//
1469 fin >> str >> num;
1470 if (str != "DIAGNOSIS") {
1471 this->generateErrorMessage("DIAGNOSIS");
1472 return;
1473 } else {
1474 for (i = 0; i < num; i++) {
1475 auto diagnosis_sp = make_shared<DecisionDiagnosis>();
1476 diagnosis_sp->retrieveDecisionDiagnosisFromFile(fin);
1477 this->diagnosis.push_back(diagnosis_sp);
1478 }
1479 }
1480//
1481 fin >> str >> num;
1482 if (str != "ACTION_OBJECTIVE") {
1483 this->generateErrorMessage("ACTION_OBJECTIVE");
1484 return;
1485 } else {
1486 for (i = 0; i < num; i++) {
1487 auto action_objective_sp = make_shared<DecisionActionObjective>();
1488 action_objective_sp->retrieveDecisionActionObjectiveFromFile(fin);
1489 this->action_objective.push_back(action_objective_sp);
1490 }
1491 }
1492//
1493 fin >> str >> num;
1494 if (str != "ACTION_PACK") {
1495 this->generateErrorMessage("ACTION_PACK");
1496 return;
1497 } else {
1498 for (i = 0; i < num; i++) {
1499 auto action_pack_sp = make_shared<DecisionActionPack>();
1500 action_pack_sp->retrieveDecisionActionPackFromFile(fin);
1501 this->action_pack.push_back(action_pack_sp);
1502 }
1503 }
1504//
1505 fin >> str >> num;
1506 if (str != "ACTION") {
1507 this->generateErrorMessage("ACTION");
1508 return;
1509 } else {
1510 for (i = 0; i < num; i++) {
1511 auto action_sp = make_shared<DecisionAction>();
1512 action_sp->retrieveDecisionActionFromFile(fin);
1513 this->action.push_back(action_sp);
1514 }
1515 }
1516//
1517 fin >> str >> num;
1518 if (str != "PROCEDURE_STEP") {
1519 this->generateErrorMessage("PROCEDURE_STEP");
1520 return;
1521 } else {
1522 for (i = 0; i < num; i++) {
1523 auto procedure_step_sp = make_shared<DecisionProcedureStep>();
1524 procedure_step_sp->retrieveDecisionProcedureStepFromFile(fin);
1525 this->procedure_step.push_back(procedure_step_sp);
1526 }
1527 }
1528//
1529 fin >> str >> num;
1530 if (str != "INSTINCTIVE_RESPONSE") {
1531 this->generateErrorMessage("INSTINCTIVE_RESPONSE");
1532 return;
1533 } else {
1534 for (i = 0; i < num; i++) {
1535 auto procedure_step_sp = make_shared<DecisionProcedureStep>();
1536 procedure_step_sp->retrieveDecisionProcedureStepFromFile(fin);
1537 this->instinctive_response_procedure.push_back(procedure_step_sp);
1538 }
1539 }
1540//
1541 fin >> str >> num;
1542 if (str != "PERCEIVED_ALARM") {
1543 this->generateErrorMessage("PERCEIVED_ALARM");
1544 return;
1545 } else {
1546 for (i = 0; i < num; i++) {
1547 auto perceived_alarms_sp = make_shared<MentalAlarm>();
1548 perceived_alarms_sp->retrieveMentalAlarmFromFile(fin);
1549 this->perceived_alarms.push_back(perceived_alarms_sp);
1550 }
1551 }
1552//
1553 fin >> str >> num;
1554 if (str != "PERCEIVED_COMPONENT_STATE") {
1555 this->generateErrorMessage("PERCEIVED_COMPONENT_STATE");
1556 return;
1557 } else {
1558 for (i = 0; i < num; i++) {
1559 auto perceived_component_state_sp = make_shared<MentalComponentState>();
1560 perceived_component_state_sp->retrieveMentalComponentStateFromFile(fin);
1561 this->perceived_component_state.push_back(perceived_component_state_sp);
1562 }
1563 }
1564//
1565 fin >> str >> num;
1566 if (str != "PERCEIVED_SUPPORT_SYSTEM_STATE") {
1567 this->generateErrorMessage("PERCEIVED_SUPPORT_SYSTEM_STATE");
1568 return;
1569 } else {
1570 for (i = 0; i < num; i++) {
1571 auto perceived_support_system_state_sp = make_shared<MentalSupportSystemState>();
1572 perceived_support_system_state_sp->retrieveMentalSupportSystemStateFromFile(fin);
1573 this->perceived_support_system_state.push_back(perceived_support_system_state_sp);
1574 }
1575 }
1576//
1577 fin >> str >> num;
1578 if (str != "PERCEIVED_PARAMETER_VALUE") {
1579 this->generateErrorMessage("PERCEIVED_PARAMETER_VALUE");
1580 return;
1581 } else {
1582 for (i = 0; i < num; i++) {
1583 auto perceived_parameter_value_sp = make_shared<MentalParameterValue>();
1584 perceived_parameter_value_sp->retrieveMentalParameterValueFromFile(fin);
1585 this->perceived_parameter_value.push_back(perceived_parameter_value_sp);
1586 }
1587 }
1588//
1589 fin >> str >> num;
1590 if (str != "PERCEIVER_PARAMETER_TREND") {
1591 this->generateErrorMessage("PERCEIVER_PARAMETER_TREND");
1592 return;
1593 } else {
1594 for (i = 0; i < num; i++) {
1595 auto perceived_parameter_trend_sp = make_shared<MentalParameterTrend>();
1596 perceived_parameter_trend_sp->retrieveMentalParameterTrendFromFile(fin);
1597 this->perceived_parameter_trend.push_back(perceived_parameter_trend_sp);
1598 }
1599 }
1600//
1601 fin >> str >> num;
1602 if (str != "MENTAL_BELIEF") {
1603 this->generateErrorMessage("MENTAL_BELIEF");
1604 return;
1605 } else {
1606 for (i = 0; i < num; i++) {
1607 auto mental_belief_sp = make_shared<ExpectedMentalBelief>();
1608 mental_belief_sp->retrieveExpectedMentalBeliefFromFile(fin);
1609 this->mental_belief.push_back(mental_belief_sp);
1610 }
1611 }
1612}
1613
1630}
1632 bool found = false;
1633 if (goal.size() == 0) return;
1634 for (auto goal_itr = goal.begin(); goal_itr != goal.end();
1635 goal_itr++) {//find teh corresponding goal in the ShortTermMemory::perceived_info
1636 auto goal_itr1 = _ic.goal.begin();
1637 auto goal_end = _ic.goal.end();
1638 found = false;
1639 while (goal_itr1 != goal_end && !found) {
1640 found = (*goal_itr)->checkIfIsIdenticalDecisionGoal(**goal_itr1);
1641 if (found) {
1642 *goal_itr = *goal_itr1;
1643 } else {
1644 goal_itr1++;
1645 }
1646 }
1647 if (!found) {//could not find teh corresponding goal
1648 cout << "Goal in ShortTermMemory::grouped_info " << (*goal_itr)->getDecision() << " generated at "
1649 << (*goal_itr)->getTimeAtWhichThisInfoIsPerceived()
1650 << " cound not find corresponding goal in the ShortTermMemory::perceived_info" << endl;
1651 ofstream fout("err messages.txt", ios::app);
1652 fout << r5pars_.timesno << " Goal in ShortTermMemory::grouped_info " << (*goal_itr)->getDecision()
1653 << " generated at "
1654 << (*goal_itr)->getTimeAtWhichThisInfoIsPerceived()
1655 << " cound not find corresponding goal in the ShortTermMemory::perceived_info\n";
1656 fout.close();
1657 r5pars_.sim_err = true;
1658 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoGoal err.");
1660 goal_itr->reset();
1661 }
1662 }
1663}
1664
1666 bool found = false;
1667 if (strategy.size() == 0) return;
1668 for (auto strategy_itr = strategy.begin(); strategy_itr != strategy.end();
1669 strategy_itr++) {//find teh corresponding strategy in the ShortTermMemory::perceived_info
1670 auto strategy_itr1 = _ic.strategy.begin();
1671 auto strategy_end = _ic.strategy.end();
1672 found = false;
1673 while (strategy_itr1 != strategy_end && !found) {
1674 found = (*strategy_itr)->checkIfIsIdenticalDecisionStrategy(**strategy_itr1);
1675 if (found) {
1676 *strategy_itr = *strategy_itr1;
1677 } else {
1678 strategy_itr1++;
1679 }
1680 }
1681 if (!found) {//could not find teh corresponding strategy
1682 cout << "Strategy in ShortTermMemory::grouped_info " << (*strategy_itr)->getDecision() << " generated at "
1683 << (*strategy_itr)->getTimeAtWhichThisInfoIsPerceived()
1684 << " cound not find corresponding strategy in the ShortTermMemory::perceived_info" << endl;
1685 ofstream fout("err messages.txt", ios::app);
1686 fout << r5pars_.timesno << " Strategy in ShortTermMemory::grouped_info " << (*strategy_itr)->getDecision()
1687 << " generated at "
1688 << (*strategy_itr)->getTimeAtWhichThisInfoIsPerceived()
1689 << " cound not find corresponding strategy in the ShortTermMemory::perceived_info\n";
1690 fout.close();
1691 r5pars_.sim_err = true;
1692 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoStrategy err.");
1694 strategy_itr->reset();
1695 }
1696 }
1697}
1698
1700 bool found = false;
1701 if (subgoal.size() == 0) return;
1702 for (auto subgoal_itr = subgoal.begin(); subgoal_itr != subgoal.end();
1703 subgoal_itr++) {//find teh corresponding subgoal in the ShortTermMemory::perceived_info
1704 auto subgoal_itr1 = _ic.subgoal.begin();
1705 auto subgoal_end = _ic.subgoal.end();
1706 found = false;
1707 while (subgoal_itr1 != subgoal_end && !found) {
1708 found = (*subgoal_itr)->checkIfIsIdenticalDecisionSubGoal(**subgoal_itr1);
1709 if (found) {
1710 *subgoal_itr = *subgoal_itr1;
1711 } else {
1712 subgoal_itr1++;
1713 }
1714 }
1715 if (!found) {//could not find teh corresponding subgoal
1716 cout << "Subgoal in ShortTermMemory::grouped_info " << (*subgoal_itr)->getDecision() << " generated at "
1717 << (*subgoal_itr)->getTimeAtWhichThisInfoIsPerceived()
1718 << " cound not find corresponding subgoal in the ShortTermMemory::perceived_info" << endl;
1719 ofstream fout("err messages.txt", ios::app);
1720 fout << r5pars_.timesno << " Subgoal in ShortTermMemory::grouped_info " << (*subgoal_itr)->getDecision()
1721 << " generated at "
1722 << (*subgoal_itr)->getTimeAtWhichThisInfoIsPerceived()
1723 << " cound not find corresponding subgoal in the ShortTermMemory::perceived_info\n";
1724 fout.close();
1725 r5pars_.sim_err = true;
1726 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoSubGoal err.");
1728 subgoal_itr->reset();
1729 }
1730 }
1731}
1732
1734 bool found = false;
1735 if (diagnosis.size() == 0) return;
1736 for (auto diagnosis_itr = diagnosis.begin(); diagnosis_itr != diagnosis.end();
1737 diagnosis_itr++) {//find teh corresponding diagnosis in the ShortTermMemory::perceived_info
1738 auto diagnosis_itr1 = _ic.diagnosis.begin();
1739 auto diagnosis_end = _ic.diagnosis.end();
1740 found = false;
1741 while (diagnosis_itr1 != diagnosis_end && !found) {
1742 found = (*diagnosis_itr)->checkIfIsIdenticalDecisionDiagnosis(**diagnosis_itr1);
1743 if (found) {
1744 *diagnosis_itr = *diagnosis_itr1;
1745 } else {
1746 diagnosis_itr1++;
1747 }
1748 }
1749 if (!found) {//could not find teh corresponding diagnosis
1750 cout << "Diagnosis in ShortTermMemory::grouped_info " << (*diagnosis_itr)->getDecision() << " generated at "
1751 << (*diagnosis_itr)->getTimeAtWhichThisInfoIsPerceived()
1752 << " cound not find corresponding diagnosis in the ShortTermMemory::perceived_info" << endl;
1753 ofstream fout("err messages.txt", ios::app);
1754 fout << r5pars_.timesno << " Diagnosis in ShortTermMemory::grouped_info " << (*diagnosis_itr)->getDecision()
1755 << " generated at "
1756 << (*diagnosis_itr)->getTimeAtWhichThisInfoIsPerceived()
1757 << " cound not find corresponding diagnosis in the ShortTermMemory::perceived_info\n";
1758 fout.close();
1759 r5pars_.sim_err = true;
1760 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoDiagnosis err.");
1762 diagnosis_itr->reset();
1763 }
1764 }
1765}
1767 bool found = false;
1768 if (action_objective.size() == 0) return;
1769 for (auto action_objective_itr = action_objective.begin(); action_objective_itr != action_objective.end();
1770 action_objective_itr++) {//find teh corresponding action_objective in the ShortTermMemory::perceived_info
1771 auto action_objective_itr1 = _ic.action_objective.begin();
1772 auto action_objective_end = _ic.action_objective.end();
1773 found = false;
1774 while (action_objective_itr1 != action_objective_end && !found) {
1775 found = (*action_objective_itr)->checkIfIsIdenticalDecisionActionObjective(**action_objective_itr1);
1776 if (found) {
1777 *action_objective_itr = *action_objective_itr1;
1778 } else {
1779 action_objective_itr1++;
1780 }
1781 }
1782 if (!found) {//could not find teh corresponding action_objective
1783 cout << "ActionObjective in ShortTermMemory::grouped_info " << (*action_objective_itr)->getDecision()
1784 << " generated at "
1785 << (*action_objective_itr)->getTimeAtWhichThisInfoIsPerceived()
1786 << " cound not find corresponding action_objective in the ShortTermMemory::perceived_info" << endl;
1787 ofstream fout("err messages.txt", ios::app);
1788 fout << r5pars_.timesno << " ActionObjective in ShortTermMemory::grouped_info "
1789 << (*action_objective_itr)->getDecision() << " generated at "
1790 << (*action_objective_itr)->getTimeAtWhichThisInfoIsPerceived()
1791 << " cound not find corresponding action_objective in the ShortTermMemory::perceived_info\n";
1792 fout.close();
1793 r5pars_.sim_err = true;
1794 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoActionObjective err.");
1796 action_objective_itr->reset();
1797 }
1798 }
1799}
1800
1802 bool found = false;
1803 if (action_pack.size() == 0) return;
1804 for (auto action_pack_itr = action_pack.begin(); action_pack_itr != action_pack.end();
1805 action_pack_itr++) {//find teh corresponding action_pack in the ShortTermMemory::perceived_info
1806 auto action_pack_itr1 = _ic.action_pack.begin();
1807 auto action_pack_end = _ic.action_pack.end();
1808 found = false;
1809 while (action_pack_itr1 != action_pack_end && !found) {
1810 found = (*action_pack_itr)->checkIfIsIdenticalDecisionActionPack(**action_pack_itr1);
1811 if (found) {
1812 *action_pack_itr = *action_pack_itr1;
1813 } else {
1814 action_pack_itr1++;
1815 }
1816 }
1817 if (!found) {//could not find teh corresponding action_pack
1818 cout << "ActionPack in ShortTermMemory::grouped_info " << (*action_pack_itr)->getActionPackName()
1819 << " generated at "
1820 << (*action_pack_itr)->getTimeAtWhichThisInfoIsPerceived()
1821 << " cound not find corresponding action_pack in the ShortTermMemory::perceived_info" << endl;
1822 ofstream fout("err messages.txt", ios::app);
1823 fout << r5pars_.timesno << " ActionPack in ShortTermMemory::grouped_info "
1824 << (*action_pack_itr)->getActionPackName() << " generated at "
1825 << (*action_pack_itr)->getTimeAtWhichThisInfoIsPerceived()
1826 << " cound not find corresponding action_pack in the ShortTermMemory::perceived_info\n";
1827 fout.close();
1828 r5pars_.sim_err = true;
1829 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoActionPack err.");
1831 action_pack_itr->reset();
1832 }
1833 }
1834}
1836 bool found = false;
1837 if (action.size() == 0) return;
1838 for (auto action_itr = action.begin(); action_itr != action.end();
1839 action_itr++) {//find teh corresponding action in the ShortTermMemory::perceived_info
1840 auto action_itr1 = _ic.action.begin();
1841 auto action_end = _ic.action.end();
1842 found = false;
1843 while (action_itr1 != action_end && !found) {
1844 found = (*action_itr)->checkIfIsIdenticalDecisionAction(**action_itr1);
1845 if (found) {
1846 *action_itr = *action_itr1;
1847 } else {
1848 action_itr1++;
1849 }
1850 }
1851 if (!found) {//could not find teh corresponding action
1852 cout << "Action in ShortTermMemory::grouped_info " << (*action_itr)->getActionName() << " generated at "
1853 << (*action_itr)->getTimeAtWhichThisInfoIsPerceived()
1854 << " cound not find corresponding action in the ShortTermMemory::perceived_info" << endl;
1855 ofstream fout("err messages.txt", ios::app);
1856 fout << r5pars_.timesno << " Action in ShortTermMemory::grouped_info " << (*action_itr)->getActionName()
1857 << " generated at "
1858 << (*action_itr)->getTimeAtWhichThisInfoIsPerceived()
1859 << " cound not find corresponding action in the ShortTermMemory::perceived_info\n";
1860 fout.close();
1861 r5pars_.sim_err = true;
1862 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoAction err.");
1864 action_itr->reset();
1865 }
1866 }
1867}
1869 bool found = false;
1870 if (procedure_step.size() == 0) return;
1871 for (auto procedure_step_itr = procedure_step.begin(); procedure_step_itr != procedure_step.end();
1872 procedure_step_itr++) {//find teh corresponding procedure_step in the ShortTermMemory::perceived_info
1873 auto procedure_step_itr1 = _ic.procedure_step.begin();
1874 auto procedure_step_end = _ic.procedure_step.end();
1875 found = false;
1876 while (procedure_step_itr1 != procedure_step_end && !found) {
1877 found = (*procedure_step_itr)->checkIfIsIdenticalDecisionProcedureStep(**procedure_step_itr1);
1878 if (found) {
1879 *procedure_step_itr = *procedure_step_itr1;
1880 } else {
1881 procedure_step_itr1++;
1882 }
1883 }
1884 if (!found) {//could not find teh corresponding procedure_step
1885 cout << "ProcedureStep in ShortTermMemory::grouped_info " << (*procedure_step_itr)->getProcedureName() << ' '
1886 << (*procedure_step_itr)->getStepName()
1887 << " cound not find corresponding procedure_step in the ShortTermMemory::perceived_info" << endl;
1888 ofstream fout("err messages.txt", ios::app);
1889 fout << r5pars_.timesno << " ProcedureStep in ShortTermMemory::grouped_info "
1890 << (*procedure_step_itr)->getProcedureName() << ' '
1891 << (*procedure_step_itr)->getStepName()
1892 << " cound not find corresponding procedure_step in the ShortTermMemory::perceived_info\n";
1893 fout.close();
1894 r5pars_.sim_err = true;
1895 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoProcedureStep err.");
1897 procedure_step_itr->reset();
1898 }
1899 }
1900}
1902 bool found = false;
1903 if (instinctive_response_procedure.size() == 0) return;
1904 for (auto instinctive_response_procedure_itr = instinctive_response_procedure.begin();
1905 instinctive_response_procedure_itr != instinctive_response_procedure.end();
1906 instinctive_response_procedure_itr++) {//find teh corresponding instinctive_response_procedure in the ShortTermMemory::perceived_info
1907 auto instinctive_response_procedure_itr1 = _ic.instinctive_response_procedure.begin();
1908 auto instinctive_response_procedure_end = _ic.instinctive_response_procedure.end();
1909 found = false;
1910 while (instinctive_response_procedure_itr1 != instinctive_response_procedure_end && !found) {
1911 found =
1912 (*instinctive_response_procedure_itr)->checkIfIsIdenticalDecisionProcedureStep(**instinctive_response_procedure_itr1);
1913 if (found) {
1914 *instinctive_response_procedure_itr = *instinctive_response_procedure_itr1;
1915 } else {
1916 instinctive_response_procedure_itr1++;
1917 }
1918 }
1919 if (!found) {//could not find teh corresponding instinctive_response_procedure
1920 cout << "InstinctiveResponseProcedure in ShortTermMemory::grouped_info "
1921 << (*instinctive_response_procedure_itr)->getProcedureName() << ' '
1922 << (*instinctive_response_procedure_itr)->getStepName()
1923 << " cound not find corresponding instinctive_response_procedure in the ShortTermMemory::perceived_info"
1924 << endl;
1925 ofstream fout("err messages.txt", ios::app);
1926 fout << r5pars_.timesno << " InstinctiveResponseProcedure in ShortTermMemory::grouped_info "
1927 << (*instinctive_response_procedure_itr)->getProcedureName() << ' '
1928 << (*instinctive_response_procedure_itr)->getStepName()
1929 << " cound not find corresponding instinctive_response_procedure in the ShortTermMemory::perceived_info\n";
1930 fout.close();
1931 r5pars_.sim_err = true;
1932 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoInstinctiveResponseProcedure err.");
1934 instinctive_response_procedure_itr->reset();
1935 }
1936 }
1937}
1939 bool found = false;
1940 if (perceived_alarms.size() == 0) return;
1941 for (auto perceived_alarms_itr = perceived_alarms.begin(); perceived_alarms_itr != perceived_alarms.end();
1942 perceived_alarms_itr++) {//find teh corresponding perceived_alarms in the ShortTermMemory::perceived_info
1943 auto perceived_alarms_itr1 = _ic.perceived_alarms.begin();
1944 auto perceived_alarms_end = _ic.perceived_alarms.end();
1945 found = false;
1946 while (perceived_alarms_itr1 != perceived_alarms_end && !found) {
1947 found = (*perceived_alarms_itr)->checkIfIsIdenticalMentalAlarm(**perceived_alarms_itr1);
1948 if (found) {
1949 *perceived_alarms_itr = *perceived_alarms_itr1;
1950 } else {
1951 perceived_alarms_itr1++;
1952 }
1953 }
1954 if (!found) {//could not find teh corresponding perceived_alarms
1955 cout << "Alarm in ShortTermMemory::grouped_info " << (*perceived_alarms_itr)->getAlarmName()
1956 << " cound not find corresponding perceived_alarms in the ShortTermMemory::perceived_info" << endl;
1957 ofstream fout("err messages.txt", ios::app);
1958 fout << r5pars_.timesno << " Alarm in ShortTermMemory::grouped_info " << (*perceived_alarms_itr)->getAlarmName()
1959 << " cound not find corresponding perceived_alarms in the ShortTermMemory::perceived_info\n";
1960 fout.close();
1961 r5pars_.sim_err = true;
1962 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoAlarm err.");
1964 perceived_alarms_itr->reset();
1965 }
1966 }
1967}
1969 bool found = false;
1970 if (perceived_component_state.size() == 0) return;
1971 for (auto perceived_component_state_itr = perceived_component_state.begin();
1972 perceived_component_state_itr != perceived_component_state.end();
1973 perceived_component_state_itr++) {//find teh corresponding perceived_component_state in the ShortTermMemory::perceived_info
1974 auto perceived_component_state_itr1 = _ic.perceived_component_state.begin();
1975 auto perceived_component_state_end = _ic.perceived_component_state.end();
1976 found = false;
1977 while (perceived_component_state_itr1 != perceived_component_state_end && !found) {
1978 found =
1979 (*perceived_component_state_itr)->checkIfIsIdenticalMentalComponentState(**perceived_component_state_itr1);
1980 if (found) {
1981 *perceived_component_state_itr = *perceived_component_state_itr1;
1982 } else {
1983 perceived_component_state_itr1++;
1984 }
1985 }
1986 if (!found) {//could not find teh corresponding perceived_component_state
1987 cout << "ComponentState in ShortTermMemory::grouped_info " << (*perceived_component_state_itr)->getDisplayName()
1988 << " cound not find corresponding perceived_component_state in the ShortTermMemory::perceived_info" << endl;
1989 ofstream fout("err messages.txt", ios::app);
1990 fout << r5pars_.timesno << " ComponentState in ShortTermMemory::grouped_info "
1991 << (*perceived_component_state_itr)->getDisplayName()
1992 << " cound not find corresponding perceived_component_state in the ShortTermMemory::perceived_info\n";
1993 fout.close();
1994 r5pars_.sim_err = true;
1995 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoComponentState err.");
1997 perceived_component_state_itr->reset();
1998 }
1999 }
2000}
2002 bool found = false;
2003 if (perceived_support_system_state.size() == 0) return;
2004 for (auto perceived_support_system_state_itr = perceived_support_system_state.begin();
2005 perceived_support_system_state_itr != perceived_support_system_state.end();
2006 perceived_support_system_state_itr++) {//find teh corresponding perceived_component_state in the ShortTermMemory::perceived_info
2007 auto perceived_support_system_state_itr1 = _ic.perceived_support_system_state.begin();
2008 auto perceived_support_system_state_end = _ic.perceived_support_system_state.end();
2009 found = false;
2010 while (perceived_support_system_state_itr1 != perceived_support_system_state_end && !found) {
2011 found =
2012 (*perceived_support_system_state_itr)->checkIfIsIdenticalMentalSupportSystemState(**perceived_support_system_state_itr1);
2013 if (found) {
2014 *perceived_support_system_state_itr = *perceived_support_system_state_itr1;
2015 } else {
2016 perceived_support_system_state_itr1++;
2017 }
2018 }
2019 if (!found) {//could not find teh corresponding perceived_component_state
2020 cout << "SupportSystemState in ShortTermMemory::grouped_info " << (*perceived_support_system_state_itr)->getDisplayName()
2021 << " cound not find corresponding perceived_support_system_state in the ShortTermMemory::perceived_info" << endl;
2022 ofstream fout("err messages.txt", ios::app);
2023 fout << r5pars_.timesno << " SupportSystemState in ShortTermMemory::grouped_info "
2024 << (*perceived_support_system_state_itr)->getDisplayName()
2025 << " cound not find corresponding perceived_support_system_state in the ShortTermMemory::perceived_info\n";
2026 fout.close();
2027 r5pars_.sim_err = true;
2028 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoComponentState err.");
2030 perceived_support_system_state_itr->reset();
2031 }
2032 }
2033}
2035 bool found = false;
2036 if (perceived_parameter_value.size() == 0) return;
2037 for (auto perceived_parameter_value_itr = perceived_parameter_value.begin();
2038 perceived_parameter_value_itr != perceived_parameter_value.end();
2039 perceived_parameter_value_itr++) {//find teh corresponding perceived_parameter_value in the ShortTermMemory::perceived_info
2040 auto perceived_parameter_value_itr1 = _ic.perceived_parameter_value.begin();
2041 auto perceived_parameter_value_end = _ic.perceived_parameter_value.end();
2042 found = false;
2043 while (perceived_parameter_value_itr1 != perceived_parameter_value_end && !found) {
2044 found =
2045 (*perceived_parameter_value_itr)->checkIfIsIdenticalMentalParameterValue(**perceived_parameter_value_itr1);
2046 if (found) {
2047 *perceived_parameter_value_itr = *perceived_parameter_value_itr1;
2048 } else {
2049 perceived_parameter_value_itr1++;
2050 }
2051 }
2052 if (!found) {//could not find teh corresponding perceived_parameter_value
2053 cout << "ParameterValue in ShortTermMemory::grouped_info " << (*perceived_parameter_value_itr)->getDisplayName()
2054 << " cound not find corresponding perceived_parameter_value in the ShortTermMemory::perceived_info" << endl;
2055 ofstream fout("err messages.txt", ios::app);
2056 fout << r5pars_.timesno << " ParameterValue in ShortTermMemory::grouped_info "
2057 << (*perceived_parameter_value_itr)->getDisplayName()
2058 << " cound not find corresponding perceived_parameter_value in the ShortTermMemory::perceived_info\n";
2059 fout.close();
2060 r5pars_.sim_err = true;
2061 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoComponentState err.");
2063 perceived_parameter_value_itr->reset();
2064 }
2065 }
2066}
2068 bool found = false;
2069 if (perceived_parameter_trend.size() == 0) return;
2070 for (auto perceived_parameter_trend_itr = perceived_parameter_trend.begin();
2071 perceived_parameter_trend_itr != perceived_parameter_trend.end();
2072 perceived_parameter_trend_itr++) {//find teh corresponding perceived_parameter_trend in the ShortTermMemory::perceived_info
2073 auto perceived_parameter_trend_itr1 = _ic.perceived_parameter_trend.begin();
2074 auto perceived_parameter_trend_end = _ic.perceived_parameter_trend.end();
2075 found = false;
2076 while (perceived_parameter_trend_itr1 != perceived_parameter_trend_end && !found) {
2077 found =
2078 (*perceived_parameter_trend_itr)->checkIfIsIdenticalMentalParameterTrend(**perceived_parameter_trend_itr1);
2079 if (found) {
2080 *perceived_parameter_trend_itr = *perceived_parameter_trend_itr1;
2081 } else {
2082 perceived_parameter_trend_itr1++;
2083 }
2084 }
2085 if (!found) {//could not find teh corresponding perceived_parameter_trend
2086 cout << "ParameterTrend in ShortTermMemory::grouped_info " << (*perceived_parameter_trend_itr)->getDisplayName()
2087 << " cound not find corresponding perceived_parameter_trend in the ShortTermMemory::perceived_info" << endl;
2088 ofstream fout("err messages.txt", ios::app);
2089 fout << r5pars_.timesno << " ParameterTrend in ShortTermMemory::grouped_info "
2090 << (*perceived_parameter_trend_itr)->getDisplayName()
2091 << " cound not find corresponding perceived_parameter_trend in the ShortTermMemory::perceived_info\n";
2092 fout.close();
2093 r5pars_.sim_err = true;
2094 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoComponentState err.");
2096 perceived_parameter_trend_itr->reset();
2097 }
2098 }
2099}
2101 bool found = false;
2102 if (mental_belief.size() == 0) return;
2103 for (auto mental_belief_itr = mental_belief.begin(); mental_belief_itr != mental_belief.end();
2104 mental_belief_itr++) {//find teh corresponding mental_belief in the ShortTermMemory::perceived_info
2105 auto mental_belief_itr1 = _ic.mental_belief.begin();
2106 auto mental_belief_end = _ic.mental_belief.end();
2107 found = false;
2108 while (mental_belief_itr1 != mental_belief_end && !found) {
2109 found = (*mental_belief_itr)->checkIfIsIdenticalExpectedMentalBelief(**mental_belief_itr1);
2110 if (found) {
2111 *mental_belief_itr = *mental_belief_itr1;
2112 } else {
2113 mental_belief_itr1++;
2114 }
2115 }
2116 if (!found) {//could not find teh corresponding mental_belief
2117 cout << "MentalBelief in ShortTermMemory::grouped_info " << (*mental_belief_itr)->getInfoName()
2118 << " cound not find corresponding mental_belief in the ShortTermMemory::perceived_info" << endl;
2119 ofstream fout("err messages.txt", ios::app);
2120 fout << r5pars_.timesno << " MentalBelief in ShortTermMemory::grouped_info "
2121 << (*mental_belief_itr)->getInfoName()
2122 << " cound not find corresponding mental_belief in the ShortTermMemory::perceived_info\n";
2123 fout.close();
2124 r5pars_.sim_err = true;
2125 g_sim.Branch_center.setTempESMessage("InfoChunk::replaceObjecByPointerForGroupedInfoComponentState err.");
2127 mental_belief_itr->reset();
2128 }
2129 }
2130}
2131DecisionGoal *InfoChunk::getActiveGoalPt() {//for perceived_info uses
2132 DecisionGoal *goal_pt = nullptr;
2133 bool found_goal = false;
2134 auto goal_itr = this->goal.rbegin();
2135 auto goal_itr_end = this->goal.rend();
2136 while (goal_itr != goal_itr_end && !found_goal) {
2137 if ((*goal_itr)->getStateOfActivation() == sim::State::Active) {
2138 goal_pt = goal_itr->get();
2139 found_goal = true;
2140 } else {
2141 goal_itr++;
2142 }
2143 }
2144 return goal_pt;
2145}
2147 DecisionStrategy *strategy_pt = nullptr;
2148 bool found_strategy = false;
2149 auto strategy_itr = this->strategy.rbegin();
2150 auto strategy_itr_end = this->strategy.rend();
2151 while (strategy_itr != strategy_itr_end && !found_strategy) {
2152 if ((*strategy_itr)->getStateOfActivation() == sim::State::Active) {
2153 strategy_pt = strategy_itr->get();
2154 found_strategy = true;
2155 } else {
2156 strategy_itr++;
2157 }
2158 }
2159 return strategy_pt;
2160}
2162 DecisionSubGoal *subgoal_pt = nullptr;
2163 bool found_subgoal = false;
2164 auto subgoal_itr = this->subgoal.rbegin();
2165 auto subgoal_itr_end = this->subgoal.rend();
2166 while (subgoal_itr != subgoal_itr_end && !found_subgoal) {
2167 if ((*subgoal_itr)->getStateOfActivation() == sim::State::Active) {
2168 subgoal_pt = subgoal_itr->get();
2169 found_subgoal = true;
2170 } else {
2171 subgoal_itr++;
2172 }
2173 }
2174 return subgoal_pt;
2175}
2176void InfoChunk::generateErrorMessage(string _err_message) {
2177 string str;
2178 str = "InfoChunk::retrieveInfoChunkFromFile File retrieval error in a function prior to ";
2179 str += _err_message;
2180 ofstream fout("err messages.txt", ios::app);
2181 cout << " " << r5pars_.timesno << " " << str << endl;
2182 fout << str << '\n';
2183 fout.close();
2184 r5pars_.sim_err = true;
2187};
2188
2189int InfoChunk::ReturnPositionOfOneMentalComponentStateInTheVector(MentalComponentState *_mc_pt) {//index of the item in perceived_component_state, or -1 if absent
2190 int i;
2191 bool found = false;
2192 i = this->perceived_component_state.size() - 1;
2193 if (i < 0) { return i; }
2194
2195 for (auto mc_ritr = this->perceived_component_state.rbegin();
2196 mc_ritr != this->perceived_component_state.rend() && found == false; mc_ritr++) {
2197 if (mc_ritr->get() == _mc_pt) {
2198 found = true;
2199 break;
2200 }
2201 i--;
2202 }
2203 return i;
2204}
2205
2207 int i;
2208 bool found = false;
2209 i = this->perceived_support_system_state.size() - 1;
2210 if (i < 0) { return i; }
2211
2212 for (auto mss_ritr = this->perceived_support_system_state.rbegin();
2213 mss_ritr != this->perceived_support_system_state.rend() && found == false; mss_ritr++) {
2214 if (mss_ritr->get() == _mss_pt) {
2215 found = true;
2216 break;
2217 }
2218 i--;
2219 }
2220 return i;
2221}
2222
2223int InfoChunk::ReturnPositionOfOneMentalParameterValue(MentalParameterValue *_mp_pt) {//index of the item in perceived_parameter_value, or -1 if absent
2224 int i;
2225 bool found = false;
2226 i = this->perceived_parameter_value.size() - 1;
2227 if (i < 0) { return i; }
2228
2229 for (auto mp_ritr = this->perceived_parameter_value.rbegin(); mp_ritr != this->perceived_parameter_value.rend();
2230 mp_ritr++) {
2231 if (mp_ritr->get() == _mp_pt) {
2232 found = true;
2233 break;
2234 }
2235 i--;
2236 }
2237 return i;
2238}
2239
2240int InfoChunk::ReturnPositionOfOneMentalAlarmInTheVector(MentalAlarm *_ma_pt) {//index of the item in perceived_alarms, or -1 if absent
2241 int i;
2242 bool found = false;
2243 i = this->perceived_alarms.size() - 1;
2244 if (i < 0) { return i; }
2245
2246 for (auto ma_ritr = this->perceived_alarms.rbegin(); ma_ritr != this->perceived_alarms.rend(); ma_ritr++) {
2247 if (ma_ritr->get() == _ma_pt) {
2248 found = true;
2249 break;
2250 }
2251 i--;
2252 }
2253 return i;
2254
2255}
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
void replaceObjecByPointerForGroupedInfoActionPack(InfoChunk &)
Definition: InfoChunk.cpp:1801
bool diagnosisIsIncluded(std::string)
Definition: InfoChunk.cpp:1275
DecisionProcedureStep * identifyTheMentalProcedureToBePerformed(std::string, std::string)
Definition: InfoChunk.cpp:547
void pointToTheNewActionPack(DecisionActionPack *)
Definition: InfoChunk.cpp:755
std::vector< std::shared_ptr< MentalSupportSystemState > > perceived_support_system_state
Definition: InfoChunk.h:146
void interruptCurrentProcedureStep()
Definition: InfoChunk.cpp:1037
void replaceObjecByPointerForGroupedInfoProcedureStep(InfoChunk &)
Definition: InfoChunk.cpp:1868
void addANewSubGoal(int, int)
Definition: InfoChunk.cpp:259
DecisionAction * checkExistanceOfAction(std::string)
Definition: InfoChunk.cpp:834
int getCurrentGoal()
Definition: InfoChunk.cpp:82
DecisionSubGoal * getActiveSubGoalPt()
Definition: InfoChunk.cpp:2161
int getTotalNumberOfFailedDiagnosis()
Definition: InfoChunk.cpp:75
std::string getCurrentDiagnosis()
Definition: InfoChunk.cpp:125
void interruptCurrentSubGoal()
Definition: InfoChunk.cpp:982
void pauseCurrenDiagnosisAndAddANewOne(std::string)
Definition: InfoChunk.cpp:503
void interruptCurrentActionObjective()
Definition: InfoChunk.cpp:1004
std::vector< std::shared_ptr< MentalParameterValue > > perceived_parameter_value
Definition: InfoChunk.h:147
std::vector< std::shared_ptr< DecisionSubGoal > > subgoal
Definition: InfoChunk.h:137
void pointToTheNewGoal(DecisionGoal *)
Definition: InfoChunk.cpp:685
int ReturnPositionOfOneMentalParameterValue(MentalParameterValue *)
Definition: InfoChunk.cpp:2223
std::string getCurrentProceduralStepName()
Definition: InfoChunk.cpp:155
void interruptCurrentAction()
Definition: InfoChunk.cpp:1026
void clearInfoChunk()
Definition: InfoChunk.cpp:24
DecisionProcedureStep * getCurrentProcedureStepPtr(int)
Definition: InfoChunk.cpp:201
MentalParameterValue * checkExistanceOfPerceivedParameterValue(std::string)
Definition: InfoChunk.cpp:921
std::string getCurrentInstinctiveResponseProceduralStepName()
Definition: InfoChunk.cpp:185
void clearInfoChunkPointers()
Definition: InfoChunk.cpp:41
bool includeActiveDiagnosis()
Definition: InfoChunk.cpp:536
void replaceObjecByPointerForGroupedInfoSubGoal(InfoChunk &)
Definition: InfoChunk.cpp:1699
MentalAlarm * checkExistanceOfPerceivedAlarms(std::string)
Definition: InfoChunk.cpp:847
std::vector< std::shared_ptr< MentalParameterTrend > > perceived_parameter_trend
Definition: InfoChunk.h:148
DecisionStrategy * getActiveStrategyPt()
Definition: InfoChunk.cpp:2146
void replaceObjecByPointerForGroupedInfoStrategy(InfoChunk &)
Definition: InfoChunk.cpp:1665
void interruptCurrentDiagnosis()
Definition: InfoChunk.cpp:993
std::vector< std::shared_ptr< DecisionStrategy > > strategy
Definition: InfoChunk.h:136
int getCurrentSubGoal()
Definition: InfoChunk.cpp:111
std::string getCurrentProcedureName()
Definition: InfoChunk.cpp:140
int getTotalNumberOfAlarmPerceived()
Definition: InfoChunk.cpp:72
bool isThereMentalProcedureWaitingForExecution(std::string, std::string)
Definition: InfoChunk.cpp:608
void pauseCurrenSubGoalAndAddANewOne(int)
Definition: InfoChunk.cpp:491
int checkWhetherExpectedParameterValueMatchObservation(KBExpectedParameterValueUnit *)
Definition: InfoChunk.cpp:1105
void replaceObjecByPointerForGroupedInfoAlarm(InfoChunk &)
Definition: InfoChunk.cpp:1938
int ReturnPositionOfOneMentalAlarmInTheVector(MentalAlarm *)
Definition: InfoChunk.cpp:2240
void pauseCurrenGoalAndAddANewOne(int)
Definition: InfoChunk.cpp:467
DecisionProcedureStep * checkExistanceOfAProcedure(std::string, std::string)
Definition: InfoChunk.cpp:878
MentalComponentState * checkExistanceOfPerceivedComponentState(std::string)
Definition: InfoChunk.cpp:895
int checkWhetherExpectedAlarmMatchObservation(KBExpectedAlarmStateUnit *)
Definition: InfoChunk.cpp:1051
void interruptCurrentGoal()
Definition: InfoChunk.cpp:960
int checkWhetherExpectedComponentStateMatchObservation(KBExpectedComponentStateUnit *)
Definition: InfoChunk.cpp:1069
DecisionGoal * getActiveGoalPt()
Definition: InfoChunk.cpp:2131
std::vector< std::shared_ptr< DecisionAction > > action
Definition: InfoChunk.h:141
void addANewGoal(int, int)
Definition: InfoChunk.cpp:240
void interruptCurrentStrategy()
Definition: InfoChunk.cpp:971
void copyInfoChunk(InfoChunk &)
Definition: InfoChunk.cpp:1189
int checkWhetherExpectedSupportSystemStateMatchObservation(KBExpectedSupportSystemStateUnit *)
Definition: InfoChunk.cpp:1087
void pointToTheNewActionObjective(DecisionActionObjective *)
Definition: InfoChunk.cpp:741
void pointToTheNewProcedureStep(DecisionProcedureStep *)
Definition: InfoChunk.cpp:783
std::string doneWithCurrentDiagnosisAndGoForPreviouslyPausedOne()
Definition: InfoChunk.cpp:377
std::vector< std::shared_ptr< DecisionActionPack > > action_pack
Definition: InfoChunk.h:140
void pointToTheNewAction(DecisionAction *)
Definition: InfoChunk.cpp:769
DecisionProcedureStep * getCurrentInstinctiveResponseProcedurePtr()
Definition: InfoChunk.cpp:226
std::vector< std::shared_ptr< ExpectedMentalBelief > > mental_belief
Definition: InfoChunk.h:149
void pauseCurrenStrategyAndAddANewOne(int)
Definition: InfoChunk.cpp:479
void pointToTheNewSubGoal(DecisionSubGoal *)
Definition: InfoChunk.cpp:713
void replaceObjecByPointerForGroupedInfoGoal(InfoChunk &)
Definition: InfoChunk.cpp:1631
int doneWithCurrentSubGoalAndGoForPreviouslyPausedOne()
Definition: InfoChunk.cpp:422
void saveInfoChunkToFile(std::ofstream &)
Definition: InfoChunk.cpp:1361
void addANewStrategy(int, int)
Definition: InfoChunk.cpp:246
void replaceObjecByPointerForGroupedInfoDiagnosis(InfoChunk &)
Definition: InfoChunk.cpp:1733
MentalParameterTrend * checkExistanceOfPerceivedParameterTrend(std::string)
Definition: InfoChunk.cpp:947
int checkWhetherExpectedParameterTrendMatchObservation(KBExpectedParameterTrendUnit *)
Definition: InfoChunk.cpp:1183
int checkWhetherExpectedParameterDifferenceMatchObservation(KBExpectedParameterDifferenceUnit *)
Definition: InfoChunk.cpp:1150
MentalSupportSystemState * checkExistanceOfPerceivedSupportSystemState(std::string)
Definition: InfoChunk.cpp:908
void pointToAvtiveGoalAndStrategy(InfoChunk &)
Definition: InfoChunk.cpp:643
virtual ~InfoChunk()
Definition: InfoChunk.cpp:22
DecisionProcedureStep * checkExistanceOfAnInstinctiveResponseProcedure(std::string, std::string)
Definition: InfoChunk.cpp:860
void replaceObjecByPointerForGroupedInfoMentalBelief(InfoChunk &)
Definition: InfoChunk.cpp:2100
void addANewDiagnosis(std::string, int)
Definition: InfoChunk.cpp:253
void pointToTheNewStrategy(DecisionStrategy *)
Definition: InfoChunk.cpp:699
void pointToTheNewInstinctiveResponseProcedureStep(DecisionProcedureStep *)
Definition: InfoChunk.cpp:808
int getStateOfAProcedureStep(std::string, std::string)
Definition: InfoChunk.cpp:1309
void replaceObjecByPointerForGroupedInfoSupportSystemState(InfoChunk &)
Definition: InfoChunk.cpp:2001
std::vector< std::shared_ptr< DecisionGoal > > goal
Definition: InfoChunk.h:135
std::vector< std::shared_ptr< DecisionDiagnosis > > diagnosis
Definition: InfoChunk.h:138
int getCurrentStrategy()
Definition: InfoChunk.cpp:97
int doneWithCurrentStrategyAndGoForPreviouslyPausedOne()
Definition: InfoChunk.cpp:333
void pointToTheNewDiagnosis(DecisionDiagnosis *)
Definition: InfoChunk.cpp:727
std::vector< std::shared_ptr< DecisionProcedureStep > > instinctive_response_procedure
Definition: InfoChunk.h:143
std::vector< std::shared_ptr< MentalAlarm > > perceived_alarms
Definition: InfoChunk.h:144
int doneWithCurrentGoalAndGoForPreviouslyPausedOne()
Definition: InfoChunk.cpp:289
std::vector< std::shared_ptr< MentalComponentState > > perceived_component_state
Definition: InfoChunk.h:145
std::vector< std::shared_ptr< DecisionProcedureStep > > procedure_step
Definition: InfoChunk.h:142
int ReturnPositionOfOneMentalComponentStateInTheVector(MentalComponentState *)
Definition: InfoChunk.cpp:2189
void replaceObjecByPointerForGroupedInfoActionObjective(InfoChunk &)
Definition: InfoChunk.cpp:1766
double getTotalWeightOfAlarmPerceived()
Definition: InfoChunk.cpp:64
void addNewInstinctiveResponseProcedure(std::string, std::string, int, int, double)
Definition: InfoChunk.cpp:272
void replaceObjecByPointerForGroupedInfoParameterValue(InfoChunk &)
Definition: InfoChunk.cpp:2034
void setStateOfAProcedureStep(std::string, std::string, int)
Definition: InfoChunk.cpp:1286
void replaceObjecByPointerForGroupedInfoAll(InfoChunk &)
Definition: InfoChunk.cpp:1614
void replaceObjecByPointerForGroupedInfoInstinctiveResponseProcedure(InfoChunk &)
Definition: InfoChunk.cpp:1901
bool activateTheDiagnosis(std::string)
Definition: InfoChunk.cpp:515
ExpectedMentalBelief * checkExistanceOfMentalBelief(std::string)
Definition: InfoChunk.cpp:934
void addNewProcedureStep(std::string, std::string, int)
Definition: InfoChunk.cpp:265
void replaceObjecByPointerForGroupedInfoComponentState(InfoChunk &)
Definition: InfoChunk.cpp:1968
void generateErrorMessage(std::string)
Definition: InfoChunk.cpp:2176
int getMentalPriorityOfAProcedureStep(std::string, std::string)
Definition: InfoChunk.cpp:1335
int getTotalPieceOfInfoPerceived()
Definition: InfoChunk.cpp:58
void replaceObjecByPointerForGroupedInfoAction(InfoChunk &)
Definition: InfoChunk.cpp:1835
void interruptCurrentActionPack()
Definition: InfoChunk.cpp:1015
int ReturnPositionOfOneMentalSupportSystemStateInTheVector(MentalSupportSystemState *)
Definition: InfoChunk.cpp:2206
std::vector< std::shared_ptr< DecisionActionObjective > > action_objective
Definition: InfoChunk.h:139
std::string getCurrentInstinctiveResponseProcedureName()
Definition: InfoChunk.cpp:170
void replaceObjecByPointerForGroupedInfoParameterTrend(InfoChunk &)
Definition: InfoChunk.cpp:2067
void retrieveInfoChunkFromFile(std::ifstream &)
Definition: InfoChunk.cpp:1430
void updateActionState(std::string, int)
Definition: InfoChunk.cpp:822
std::string getInfoName()
Definition: KBElement.cpp:26
void setStateOfActivation(int)
struct @0 r5pars_
constexpr int GE
Definition: SimConstants.h:88
constexpr int GT
Definition: SimConstants.h:87
constexpr int LE
Definition: SimConstants.h:90
constexpr int LT
Definition: SimConstants.h:91
constexpr int Between
Definition: SimConstants.h:92
constexpr int EQ
Definition: SimConstants.h:89
constexpr int Failed
Definition: SimConstants.h:103
constexpr int Interrupted
Definition: SimConstants.h:124
constexpr int Succeed
Definition: SimConstants.h:104
constexpr int Done
Definition: SimConstants.h:123
constexpr int Active
Definition: SimConstants.h:118
constexpr int Waiting
Definition: SimConstants.h:125
constexpr int Unknown
Definition: SimConstants.h:120
constexpr int Pause
Definition: SimConstants.h:119
constexpr int None
Definition: SimConstants.h:75
BranchRecord Branch_center
Dynamic event tree state.