← Documentation
ADS-IDAC Engine 5.0.0
ReasonMachine.cpp
Go to the documentation of this file.
1// ReasonMachine.cpp: implementation of the ReasonMachine class.
2//
4
5#include "ReasonMachine.h"
6#include "RMTokens.h"
7#include "../Crew/OperatorDM.h"
8#include "../ControlPanel/ControlPanel.h"
9#include "../Global/SimulationContext.h"
10using namespace std;
11
13// Construction/Destruction
15
17
19 this->m_fatigue_level = 0;
20 this->m_diagnosis_complexity = 0;
21 this->m_expert_level = 0.5;
22 this->m_cognitive_load = 0;
23 this->m_overall_stress = 0;
24 this->m_cognitive_resource_use = 0.2;
25 this->m_system_dynamic_level = 0;
27 this->m_decay_time_base_value = 300;
28
30 this->m_decay_time = 300;
31 // Deterministic defaults: the HAMLET/Neutral profiles do not set the
32 // attention-span base, and these fields are copied + serialized at every
33 // branch point. The defaults match m_attention_span / the memory-span
34 // base value set below.
36 this->m_memory_span = 4;
37 this->m_time_constraint = nullptr;
38 //
39
40 // m_current_thought_line_info and m_current_investigation_info default to nullptr
43 this->m_interuptiveness = 1;
44 //
48 this->m_attention_span = 20;
50 this->m_goofy_start_time = 0;
52 //
53
55 this->m_leisure_time = 0;
56
57 this->m_investigator_number = 1;
58 this->m_statement_number = 1;
60 this->m_RM_Token = rm::RoutineMonitor; //the default set is to start with routine monitor
62 this->m_block_alarm_jam = false;
63 this->m_time_length = 0.5;
64 this->m_timer_RM = 0;
65 this->m_consumed_time = 0;
66 this->m_first_round_check_done = false;
68 this->m_decay_constant_lamda = 0.1;
69 this->m_decay_lamda = 0.1;
70
71 this->m_Concept_Base = make_unique<KBConcept>();
72 this->m_IB = make_unique<InstantiationBase>();
73 this->m_MR = make_unique<MentalRepresentation>();
74 this->m_event_schema_base = make_unique<EventSchemaBase>();
75 this->m_routine_monitor = make_unique<RoutineMonitor>();
76
77 this->m_working_on_invest_link_pt = NULL;
78 this->m_working_on_invest_pt = NULL;
79 this->m_reading_indication_ID_pt = NULL;
80 // m_proximity defaults to nullptr
81
82 this->m_ID_working_on_invest = "";
84 this->m_ID_reading_indication = "";
85 this->m_ID_buffer_invest_pt = "";
86 this->m_buffer_invest_pt = NULL;
87 this->m_buffer_used_bl = false;
88}
89
91 this->m_Semantic_list.clear();
92 this->m_KE_list.clear();
93 this->m_KN_list.clear();
94 this->m_Knowledge_list.clear();
95
96 this->m_Statement_list.clear();
97 this->m_investigator_pool.clear();
98 this->m_investigator_link_pool.clear();
99
100 this->m_RM_Token_history.clear();
101 this->m_RM_token_endtime_history.clear();
102 this->m_temporary_statement_list.clear();
103 this->m_new_Statement_list.clear();
104 this->m_ID_temporary_statement_list.clear();
105 this->m_ID_new_statement_list.clear();
106
107 this->m_unresolved_investigator_pool.clear();
108 this->m_resolved_investigator_pool.clear();
109 this->m_success_investigator_pool.clear(); //3098, 3030
110 this->m_failed_investigator_pool.clear(); //
111 this->m_undetermined_investigator_pool.clear(); //3031
112 this->m_discarded_investigator_pool.clear(); //3090
113 this->m_cause_undetermined_investigato_pool.clear(); //3097
114 this->m_feedback_stack.clear();
115 this->m_investigation_trace.clear();
116
117 this->m_ID_unresolved_invest_pool.clear();
118 this->m_ID_resolved_invest_pool.clear();
119 this->m_ID_succes_invest_pool.clear();
120 this->m_ID_failed_invest_pool.clear();
121 this->m_ID_undertermined_invest_pool.clear();
122 this->m_ID_discarded_invest_pool.clear();
124 this->m_ID_feedback_stack.clear();
125 this->m_ID_invest_trace.clear();
126
127 this->m_tbi_P_list.clear();
128 this->m_tbi_A_list.clear();
129 this->m_tbi_C_list.clear();
130 this->m_tbi_SS_list.clear();
131
132 this->m_position_tbi_P_list.clear();
133 this->m_position_tbi_A_list.clear();
134 this->m_position_tbi_C_list.clear();
135 this->m_position_tbi_SS_list.clear();
136}
137
139 SentenceUnit *sent_pt = NULL;
140 bool found = false;
141 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end() && found == false;
142 sent_itr++) {
143 if ((*sent_itr)->CheckMatchBySentence(_input_sent_pt) == true) {
144 found = true;
145 sent_pt = sent_itr->get();
146 }
147 }
148 return sent_pt;
149}
150
152 //bool found = false;
153 Statement *state_pt;
154 auto state_itr = this->m_Statement_list.rbegin();
155 while (state_itr != this->m_Statement_list.rend()) {
156 if ((*state_itr)->m_sent_pt->CheckMatchBySentence(_sent_pt)) {
157 if (state_pt != 0) {
158 //this is to find the newest statement
159 if ((*state_itr)->m_time_range.m_end_time != 0 &&
160 state_pt->m_time_range.m_end_time != 0 &&
161 (*state_itr)->m_time_range.m_end_time > state_pt->m_time_range.m_end_time) { state_pt = state_itr->get(); }
162 if ((*state_itr)->m_time_range.m_time_before != 0 &&
163 state_pt->m_time_range.m_time_before != 0 &&
164 (*state_itr)->m_time_range.m_time_before > state_pt->m_time_range.m_time_before) {
165 state_pt = state_itr->get();
166 }
167 } else { state_pt = state_itr->get(); }
168 }
169 }
170 return state_pt;
171}
172
174 stringstream conv;
175 string ID_name;
176 conv << this->m_investigator_number;
177 ID_name = "investigator_" + conv.str();
178 this->m_investigator_number += 1;
179 auto Invest_owned = make_unique<Investigator>();
180 Investigator *Invest_pt = Invest_owned.get();
181 Invest_pt->m_motivation = 1;
182 Invest_pt->m_Happen = 3;
183 Invest_pt->m_Statement_pt = _state_pt;
184 this->AddDeltaToCognitiveLoad(0.024); //type 4
185 Invest_pt->m_ID = ID_name;
186 this->m_unresolved_investigator_pool.push_back(Invest_pt);
187 this->m_investigator_pool.push_back(std::move(Invest_owned));
188}
189
191 //the output is stored in this->m_temporary_statement_list
192 //KBConcept::getAntonymList is not finished yet
193 //semantic search
194 //this function returns the latest statement that has the same sentence as the input or the antonymy sentence of the input sentence.
195
196// float end1, end2;
197 Statement *happen_statement_pt = NULL;
198 Statement *not_happen_statement_pt = NULL;
199 Statement *found_statement_pt = NULL;
200 Statement *found_antonymy_statement_pt = NULL;
201
202 vector<SentenceUnit *> antonymy_sent_list;
203 SentenceUnit *antonymy_sent_pt;
204 SentenceUnit *found_sent_pt;
205
206 vector<IDElement *> antonym_list;
207 vector<IDElement *>::iterator antonym_itr;
208 IDElement *ID_pt;
209 ConceptBasicUnit *Concept_B_pt;
210 bool within_range;
211 bool found = false;
212 bool found_antonymy = false;
213 float start_compare, end_compare;
214
215
216 //to be added, add the searching for the conflicting/negation statement
217 switch (_sent_pt->m_sentence_type) {
218 case 1: ID_pt = _sent_pt->m_process_pt;
219 break;
220 case 2: ID_pt = _sent_pt->m_state_pt;
221 break;
222 case 3: ID_pt = _sent_pt->m_comparison_pt;
223 break;
224 case 4: ID_pt = _sent_pt->m_comparison_pt;
225 break;
226 case 5: ID_pt = _sent_pt->m_attribute_pt;
227 break;
228 }
229 //get all the antonyms
230 Concept_B_pt = (ConceptBasicUnit *) ID_pt;
231 antonym_list = Concept_B_pt->m_antonym_list;
232 //create corresponding antonymy sentences
233 for (antonym_itr = antonym_list.begin(); antonym_itr != antonym_list.end(); antonym_itr++) {
234 SentenceUnit antonymy_sent;
235 antonymy_sent.CopyFromAnotherSentence(_sent_pt);
236 switch (_sent_pt->m_sentence_type) {
237 case 1: antonymy_sent.m_process_pt = *antonym_itr;
238 break;
239 case 2: antonymy_sent.m_state_pt = *antonym_itr;
240 case 3: antonymy_sent.m_comparison_pt = *antonym_itr;
241 case 4: antonymy_sent.m_comparison_pt = *antonym_itr;
242 case 5: antonymy_sent.m_attribute_pt = *antonym_itr;
243 }
244 found_sent_pt = this->CheckExistInSemanticPoolBySentence(&antonymy_sent);
245 if (found_sent_pt != NULL) { antonymy_sent_list.push_back(found_sent_pt); }
246 }
247
248 //
249 for (auto statement_ritr = this->m_Statement_list.rbegin(); statement_ritr != this->m_Statement_list.rend();
250 statement_ritr++) {
251 within_range = false;
252 //to be added, add a filter for activation threshold
253 //caution about the uninitiated variable
254 if ((*statement_ritr)->m_time_range.m_end_time != 0) {
255 end_compare = (*statement_ritr)->m_time_range.m_end_time;
256 } else if ((*statement_ritr)->m_time_range.m_time_before != 0) {
257 end_compare = (*statement_ritr)->m_time_range.m_time_before;
258 } else {}//warning message, this statement doesn't specify an end time range
259 if ((*statement_ritr)->m_time_range.m_start_time != 0) {
260 start_compare = (*statement_ritr)->m_time_range.m_start_time;
261 } else if ((*statement_ritr)->m_time_range.m_time_after != 0) {
262 start_compare = (*statement_ritr)->m_time_range.m_time_after;
263 } else {}//warning message, this statement doesn't specify a start time range
264
265 //compare whether there is overlap between the statement time range and the target range
266 if (end_compare >= _start && end_compare <= _end) {
267 within_range = true;
268 } else if (start_compare >= _start && start_compare <= _end) {
269 within_range = true;
270 } else if (start_compare <= _start && end_compare >= _end) {
271 within_range = true;
272 }
273 //compare the statement with the input sentence
274 //strict comparison
275 //to be added, make the comparison more flexible
276 if (within_range == true) {
277 auto cur_stmt = statement_ritr->get();
278 if (cur_stmt->m_sent_pt == _sent_pt) {
279 if (cur_stmt->m_state == true) {//happen
280 if (happen_statement_pt == NULL) {
281 happen_statement_pt = cur_stmt;
282 } else if (happen_statement_pt->m_time_range.GetTimeBoundLater()
283 < cur_stmt->m_time_range.GetTimeBoundLater()) {
284 happen_statement_pt = cur_stmt;
285 }
286 } else {//not happen
287 if (not_happen_statement_pt == NULL) {
288 not_happen_statement_pt = cur_stmt;
289 } else if (not_happen_statement_pt->m_time_range.GetTimeBoundLater()
290 < cur_stmt->m_time_range.GetTimeBoundLater()) {
291 not_happen_statement_pt = cur_stmt;
292 }
293 }
294 /*
295 if(found == false)
296 {
297 found_statement_pt = *statement_ritr;
298 found = true;
299 }
300 else
301 {
302 if(end_compare > found_statement_pt->m_time_range.m_end_time && end_compare > found_statement_pt->m_time_range.m_time_before)
303 {found_statement_pt = *statement_ritr;}
304 } */
305 } else if (cur_stmt->m_sent_pt->m_sentence_type == _sent_pt->m_sentence_type
306 && cur_stmt->m_sent_pt->m_subject_pt == _sent_pt->m_subject_pt) {
307 // start to compare the statement witht the antonymy sentences
308 for (auto antonymy_sent_itr = antonymy_sent_list.begin(); antonymy_sent_itr != antonymy_sent_list.end();
309 antonymy_sent_itr++) {
310 if (cur_stmt->m_sent_pt == (*antonymy_sent_itr)) {
311 if (cur_stmt->m_state == true) {//not happen
312 if (not_happen_statement_pt == NULL) {
313 not_happen_statement_pt = cur_stmt;
314 } else if (not_happen_statement_pt->m_time_range.GetTimeBoundLater()
315 < cur_stmt->m_time_range.GetTimeBoundLater()) {
316 not_happen_statement_pt = cur_stmt;
317 }
318 } else {
319 if (cur_stmt->m_sent_pt->WhetherItIsBiState() == true) {//happen
320 if (happen_statement_pt == NULL) {
321 happen_statement_pt = cur_stmt;
322 } else if (happen_statement_pt->m_time_range.GetTimeBoundLater()
323 < cur_stmt->m_time_range.GetTimeBoundLater()) {
324 happen_statement_pt = cur_stmt;
325 }
326 } else {}//unknown
327 }
328 /*
329 if(found_antonymy == false)
330 {
331 found_antonymy_statement_pt = *statement_ritr;
332 found_antonymy = true;
333 }
334 else
335 {
336 if(end_compare > found_antonymy_statement_pt->m_time_range.m_end_time && end_compare > found_antonymy_statement_pt->m_time_range.m_time_before)
337 {found_antonymy_statement_pt = *statement_ritr;}
338 }
339 */
340 }
341 }// end of iteration of antonymy_sent_itr
342 }//end of sentence type check
343 }//end of if(within_range == true)
344 }//end of iteration of statements
345 //clear the memory usage
346 antonymy_sent_list.clear();
347 antonym_list.clear();
348
349 this->m_temporary_statement_list.clear();
350 this->m_temporary_statement_list.push_back(happen_statement_pt);
351 this->m_temporary_statement_list.push_back(not_happen_statement_pt);
352 /*
353 end1 = 0;
354 end2 = 0;
355 if(found_statement_pt != NULL)
356 {
357 end1 = found_statement_pt->m_time_range.m_end_time;
358 if(found_statement_pt->m_time_range.m_time_before > found_statement_pt->m_time_range.m_end_time)
359 {end1 = found_statement_pt->m_time_range.m_time_before;}
360 }
361
362 if(found_antonymy_statement_pt != NULL)
363 {
364 end2 = found_antonymy_statement_pt->m_time_range.m_end_time;
365 if(found_antonymy_statement_pt->m_time_range.m_time_before > found_antonymy_statement_pt->m_time_range.m_end_time)
366 {end2 = found_antonymy_statement_pt->m_time_range.m_time_before;}
367 }
368
369 if(end1 > end2)
370 {return found_statement_pt;}
371 else
372 {return found_antonymy_statement_pt;}
373 */
374}
375
377
378 Statement *new_statement_pt;
379 IDElement *ID_pt;
380 MRParameterUnit *P_pt;
383 MRValueSchema *value_schema_pt;
384 float value1, value2;
385 bool exist_on_CP = false;
386 bool IsTrue = false;
387
388 //get the value of the subject
389 ID_pt = this->m_MR->CheckExistenceByConceptStrict(_sent_pt->m_subject_pt);
390 if (ID_pt == 0) {
391 return NULL;
392 }
393 if (ID_pt->m_ID_Type == 201) {//this is a MRParameterUnit, compare the reading with a value
394 P_pt = (MRParameterUnit *) ID_pt;
395 value_schema_pt = P_pt->FoundAValueReadingWithinTimeRange(_start, _end);
396 if (value_schema_pt == 0) { return NULL; }
397 } else if (ID_pt->m_ID_Type == 202) {//this is a MRComponentStateUnit, compare the current position with a value
398 C_pt = (MRComponentStateUnit *) ID_pt;
399 value_schema_pt = C_pt->FoundAPositionReadingWithinTimeRange(_start, _end);
400 if (value_schema_pt == 0) { return NULL; }
401 } else { return NULL; }
402 value1 = value_schema_pt->m_perceived_value;
403
404 //get the value of the object
405 if (_sent_pt->m_sentence_type == 4) {
406 ID_pt = this->m_MR->CheckExistenceByConceptStrict(_sent_pt->m_object_pt);
407 if (ID_pt == 0) {
408 return NULL;
409 }
410 if (ID_pt->m_ID_Type == 201) {//this is a MRParameterUnit, compare the reading with a value
411 P_pt = (MRParameterUnit *) ID_pt;
412 value_schema_pt = P_pt->FoundAValueReadingWithinTimeRange(_start, _end);
413 if (value_schema_pt == 0) { return NULL; }
414 } else if (ID_pt->m_ID_Type == 202) {//this is a MRComponentStateUnit, compare the current position with a value
415 C_pt = (MRComponentStateUnit *) ID_pt;
416 value_schema_pt = C_pt->FoundAPositionReadingWithinTimeRange(_start, _end);
417 if (value_schema_pt == 0) { return NULL; }
418 } else { return NULL; }
419 value2 = value_schema_pt->m_perceived_value;
420 } else if (_sent_pt->m_sentence_type == 3) {
421 value2 = _sent_pt->m_value;
422 } else { return NULL; }//error message, the sentence type is beyond the scope
423
424 //Compare
425 if (_sent_pt->m_comparison_pt == this->m_Concept_Base->getBiggerPt()) {
426 if (value1 > value2) { IsTrue = true; }//create a statement to say it is true;
427 } else if (value1 == value2) {
428 if (value1 < value2) { IsTrue = true; }
429 } else if (_sent_pt->m_comparison_pt == this->m_Concept_Base->getEqualPt()) {
430 if (value1 == value2) { IsTrue = true; }
431 } else {}//warning message
432 //caution here
433 auto new_statement_owned = make_unique<Statement>();
434 new_statement_pt = new_statement_owned.get();
435 new_statement_pt->m_sent_pt = _sent_pt;
436 new_statement_pt->m_confidence = 1;
437 new_statement_pt->m_factual_type = 1;
438 new_statement_pt->m_time_range.m_start_time = value_schema_pt->m_time_perceived;
439 new_statement_pt->m_time_range.m_end_time = value_schema_pt->m_perceived_value;
440 new_statement_pt->m_state = IsTrue;
441 this->AddANewStatement(new_statement_owned.release());
442 return new_statement_pt;
443}
444
446 KnowledgeElement *found_KE_pt;
447 bool found = false;
448 for (auto KE_itr = this->m_KE_list.begin(); KE_itr != this->m_KE_list.end() && found == false; KE_itr++) {
449 //firstly compare the sentence
450 if ((*KE_itr)->m_SentenceUnit_pt->CheckMatchBySentence(statement_pt->m_sent_pt) == true) {
451 //then compare the negation and statement state(true or false)
452 if ((*KE_itr)->m_negation == false && statement_pt->m_state == true) {
453 found = true;
454 found_KE_pt = KE_itr->get();
455 } else if ((*KE_itr)->m_negation == true && statement_pt->m_state == false) {
456 found = true;
457 found_KE_pt = KE_itr->get();
458 }
459 }
460 }
461 if (found == true) {
462 return found_KE_pt;
463 } else {
464 return NULL;
465 }
466}
467
469 Investigator *found_invest_pt = NULL;
470 KnowledgeElement *KE_pt;
471 bool found = false;
472 bool SameContent = false;
473 float IV_start, IV_end;
474 //think about using reverse iterator to increase the efficiency
475 for (auto invest_ritr = this->m_investigator_pool.rbegin();
476 invest_ritr != this->m_investigator_pool.rend() && found == false; invest_ritr++) {
477 if ((*invest_ritr)->m_Statement_pt != 0) {
478 if ((*invest_ritr)->m_Happen == 4) { continue; }
479 if ((*invest_ritr)->m_Statement_pt->m_sent_pt->CheckMatchBySentence(_KE_pt->m_SentenceUnit_pt)
480 == true) {//it's the same sentence
481 if ((*invest_ritr)->m_Statement_pt->m_state != _KE_pt->m_negation) {//verified the negation symbol
482 //compare the time range of the statement with the required time range of the KE
483 if ((*invest_ritr)->m_Statement_pt->m_time_range.m_end_time != 0) {
484 IV_end = (*invest_ritr)->m_Statement_pt->m_time_range.m_end_time;
485 } else if ((*invest_ritr)->m_Statement_pt->m_time_range.m_time_before != 0) {
486 IV_end = (*invest_ritr)->m_Statement_pt->m_time_range.m_end_time;
487 }
488
489 if ((*invest_ritr)->m_Statement_pt->m_time_range.m_start_time != 0) {
490 IV_start = (*invest_ritr)->m_Statement_pt->m_time_range.m_start_time;
491 } else if ((*invest_ritr)->m_Statement_pt->m_time_range.m_time_after != 0) {
492 IV_start = (*invest_ritr)->m_Statement_pt->m_time_range.m_time_after;
493 }
494
495 if (IV_end >= _start && IV_end <= _end) {
496 found = true;
497 found_invest_pt = invest_ritr->get();
498 } else if (IV_start >= _start && IV_start <= _end) {
499 found = true;
500 found_invest_pt = invest_ritr->get();
501 } else if (IV_start <= _start && IV_end >= _end) {
502 found = true;
503 found_invest_pt = invest_ritr->get();
504 }
505 }
506 }
507 } else if ((*invest_ritr)->m_KElement_ID_pt != 0) {
508 //caution, this directly compare the ID of the KnowledgeElements
509
510 if ((*invest_ritr)->m_Happen == 2 && (*invest_ritr)->m_upperstream_ID_list.size() == 0) { continue; }
511 if ((*invest_ritr)->m_Happen == 3 && (*invest_ritr)->m_Statement_pt == NULL) { continue; }
512
513 //if((*invest_ritr)->m_Happen != 3 && (*invest_ritr)->m_Happen != 1)
514 //{continue;}
515
516 if ((*invest_ritr)->m_KElement_ID_pt->m_ID == (_KE_pt->m_ID)) {//It's the same knowledge element
517 KE_pt = (KnowledgeElement *) invest_ritr->get();
518 if ((*invest_ritr)->m_effective_end >= _start && (*invest_ritr)->m_effective_start <= _end) {
519 found = true;
520 found_invest_pt = invest_ritr->get();
521 } else if ((*invest_ritr)->m_effective_start >= _start && (*invest_ritr)->m_effective_start <= _end) {
522 found = true;
523 found_invest_pt = invest_ritr->get();
524 } else if ((*invest_ritr)->m_effective_start <= _start && (*invest_ritr)->m_effective_end >= _end) {
525 found = true;
526 found_invest_pt = invest_ritr->get();
527 }
528 }
529 } else {} //warning message, this investigator doesn't have either a statement or a knowledgeElement
530 }//end of iteration
531 if (found == true) {
532 return found_invest_pt;
533 } else {
534 return NULL;
535 }
536}//end of function
537
538
540
541 bool stay_on_the_current_item = false;
542 float fl_value;
543 string str;
544
545 Investigator *invest_pt;
546
548 //Activation Decay
549
550 this->ActivationDecayofRM();
551
553 //This is first round check process
554// if (r5pars_.timesno <= 700) {
555 if (r5pars_.timesno <= 200) {
556 this->m_tbi_A_list.clear();
557 return;
558// } else if (r5pars_.timesno > 700 && r5pars_.timesno < 800) {
559 } else if (r5pars_.timesno > 200 && r5pars_.timesno < 250) {
561 return;
562 }
563
564 if (r5pars_.timesno >= 1809) { this->PrintMessage(""); }
565
567 //ReasonMachine starts from here
568
569 this->m_consumed_time = 0;
570 this->m_time_length = 0.5; //to be modified
571 this->m_leisure_time = false;
572
573 //update at the beginning of this step
574 this->m_system_dynamic_level *= exp(-0.013 * this->m_time_length);
575 this->m_cognitive_load *= exp(-0.013 * this->m_time_length);
576
578 this->m_event_schema_base->CrossCheckProcedureUse();
580
581 //Performance Shaping Factor Update
582 //passive alarm load
583 this->m_passive_alarm_load->AddNewDataPoint(this->m_tbi_A_list.size());
584
585 if (r5pars_.timesno < 850 && r5pars_.timesno > 848) {
586 /*while(this->m_investigator_pool.size() > 0)
587 {
588 invest_itr = this->m_investigator_pool.begin();
589 invest_pt = *invest_itr;
590 this->m_investigator_pool.erase(invest_itr);
591 //delete (invest_pt);there is a memory leakage here
592 }*/
593 this->m_investigator_pool.clear();
594 this->m_unresolved_investigator_pool.clear();
595 /*this->m_resolved_investigator_pool.clear();
596 this->m_success_investigator_pool.clear();
597 this->m_failed_investigator_pool.clear();
598 this->m_undetermined_investigator_pool.clear();
599 this->m_discarded_investigator_pool.clear();
600 this->m_cause_undetermined_investigato_pool.clear();
601 this->m_feedback_stack.clear();
602 this->m_investigation_trace.clear();
603 this->m_investigator_link_pool.clear(); */
604 this->m_working_on_invest_pt = NULL;
605 this->m_working_on_invest_link_pt = NULL;
606
607 for (auto &stmt : this->m_Statement_list) {
608 stmt->m_ID_investigator = "";
609 stmt->m_investigator_ID_pt = NULL;
610 }
611 }
612
613 while (this->m_consumed_time < this->m_time_length && this->m_leisure_time == false) {
614 if (this->m_tbi_A_list.size() > 0 || this->m_tbi_C_list.size() > 0 || this->m_tbi_P_list.size() > 0 || this->m_tbi_SS_list.size() > 0) {
616 if (this->m_unresolved_investigator_pool.size() > 0) {
617 if (this->m_working_on_invest_pt != NULL) {//don't interrupt the must-continuous process
618 if (this->m_working_on_invest_pt->m_investigator_token == inv::RequestInfoRead) { stay_on_the_current_item = true; }
619 }
621 if (this->m_RM_Token == rm::WorkOnInvestigator || this->m_RM_Token == rm::WorkOnInvestigatorLink) { stay_on_the_current_item = true; }
622 }
623 if (this->m_working_on_invest_link_pt != NULL && this->m_working_on_invest_pt != NULL) {
624 stay_on_the_current_item = true;
627 == this->m_current_investigation_info->m_name) { this->ChangeRMTokenValue(rm::WorkOnInvestigatorLink); }
628 else if (this->m_working_on_invest_pt->m_ID
629 == this->m_current_investigation_info->m_name) { this->ChangeRMTokenValue(rm::WorkOnInvestigator); }
630 else { this->ChangeRMTokenValue(rm::Prioritize); }
631 }
632 }
633 //need to add the InvestigatorLink expection here
634 if (stay_on_the_current_item == false) { this->ChangeRMTokenValue(rm::Prioritize); }
635 }
636 } else {
637 switch (this->m_RM_Token) {
639 break;
641 break;
643 break;
645 break;
646 default:
647 //error message, unexpected situation, check the m_RM_Token;
648 break;
649 }
650 }
651 }
652 this->m_Concept_Base->AddDataSetOfTheConceptBase();
653
657}
658
660 //Token 0010: Routine Monitoring
661 vector<float>::reverse_iterator fl_ritr;
662 float fl;
663 switch (this->m_routine_monitor->m_routine_monitor_Token) {
664 case 11:
665 if (this->m_RM_token_endtime_history.size() != 0) {
666 fl_ritr = this->m_RM_token_endtime_history.rbegin();
667 fl = *fl_ritr;
668 if (r5pars_.timesno - fl > 30) {
669 if (this->m_event_schema_base->GenerateANewInvestigatorOrNot() == true) {
671 break;
672 }
673 if (this->m_decayed_item_pt_list.size() > 0) {
675 exp(-0.04 * (r5pars_.timesno
676 - this->m_goofy_start_time))));
677 }
678 }
679 }
680 if (this->m_routine_monitor->GetaMonitorUnit11() < 1.0
681 && this->m_routine_monitor->m_routine_monitor_Token == 11) { this->NotDoingAnything(); }
682 break;
683 case 12: this->m_routine_monitor->WorkOnASelectedUnit12();
684 break;
685 default: break;
686 }
687}
688
690 //Token 0020: Interpretation, preprocessing of the newly perceived information
691 vector<MentalParameterValue *>::iterator M_P_itr;
692 vector<MentalAlarm *>::iterator M_A_itr;
693 vector<MentalComponentState *>::iterator M_C_itr;
694 vector<MentalSupportSystemState *>::iterator M_SS_itr;
695 MentalParameterValue *M_P_pt;
696 MentalAlarm *M_A_pt;
697 MentalComponentState *M_C_pt;
699 IDElement *ID_pt;
700 MRParameterUnit *MR_P_pt, *MR_P_pt2;
701 MRComponentStateUnit *MR_C_pt, *MR_C_pt2;
702 MRSupportSystemStateUnit *MR_SS_pt, *MR_SS_pt2;
703 MRAlarmUnit *MR_A_pt, *MR_A_pt2;
704 bool expecting_indication_bl = false;
705 ProximityGroupUnit *pu_pt = NULL;
706 string MR_name, CP_name;
707 string indicator_name;
708 vector<string>::iterator str_itr;
709 float perceived_value;
710 int perceived_state;
711
712 //firstly check the newly coming alarms. To be added based on the passive information load, if there
713 //are too many alarms sounding/flashing and cause a jam, the operator might choose to block and ignore
714 //the new coming alarms.
715
716 //then process the new parameter and component state information.
717 //"MentalParameter" could be associated with either a power plant parameter, or a valve position indication
718 //"MentalComponentState" is only associated with component State.
719
720 //*
721 //Processing Alarms
722 //*
723 //PSF slot: passive information load
724 MR_P_pt = NULL;
725 MR_P_pt2 = NULL;
726 MR_C_pt = NULL;
727 MR_C_pt2 = NULL;
728 MR_A_pt = NULL;
729 MR_A_pt2 = NULL;
730 if (r5pars_.timesno > 1347) { MR_P_pt = NULL; }
731
732 if (this->m_tbi_A_list.size() > 1) { this->PrintMessage(""); }
733 if ((this->m_tbi_A_list.size() > 0) && this->m_block_alarm_jam == false) {
734 if (this->m_block_alarm_jam == false) {
735 M_A_itr = this->m_tbi_A_list.begin();
736 M_A_pt = *M_A_itr;
737 //get alarm name
738 indicator_name = M_A_pt->getAlarmName();
739 if (indicator_name.empty() == true) {}//error message
740
741 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
742 if (ID_pt != NULL) {//If there is a mapping on the Mental Representation, then interpret the alarm information
743 if (ID_pt->m_ID_Type != 203) {//error message
744 return;
745 }
746
747 //check whether it is expected indication
748 if (ID_pt == this->m_reading_indication_ID_pt) {
749 expecting_indication_bl = true;
750 }
751
752 MR_A_pt = (MRAlarmUnit *) ID_pt;
753 MR_A_pt->AddNewAlarmState(M_A_pt->getObservedAlarmState(), this->m_operator, expecting_indication_bl);
754 //add the proximity feature here
755 pu_pt = NULL;
756 pu_pt = this->m_proximity->FindAProximityGroupUnitByOneMemberName(MR_A_pt->m_Concept_pt->m_ID);
757 this->AddConsumptedDeltaT(1);
758 }
759 //Clean this from the m_tbi_A_list
760 this->m_tbi_A_list.erase(M_A_itr);
761 //add time consumption here
763
764 } else {
765 //add time consumption here
766 //need a place to record intended alarm/parameter/componentstate
767 //to be added, pick out the intended alarms
769 this->m_tbi_A_list.clear();
770 }
771 }
772
773 //*
774 //Processing Parameters
775 //*
776
777 else if (this->m_tbi_P_list.size() > 0) {
778 M_P_itr = this->m_tbi_P_list.begin();
779 M_P_pt = *M_P_itr;
780 //get parameter name
781 { indicator_name = M_P_pt->getDisplayName(); }
782 if (indicator_name == "SG_A_NR_Level") { this->PrintMessage(""); }
783 if (indicator_name.empty() == true) {}//error message
784
785 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
786 if (ID_pt != NULL) {//interpret
787 if (ID_pt == this->m_reading_indication_ID_pt) {//it is an expecting indication from the onging investigator
788 expecting_indication_bl = true;
789 }
790
791 switch (ID_pt->m_ID_Type) {
792 case 201: // it is a MRParameterUnit
793 MR_P_pt = (MRParameterUnit *) ID_pt;
794 if (MR_P_pt->m_parameter_indicator_ID == indicator_name) {
795 MR_P_pt->AddNewValue(M_P_pt->getObservedParameterValue(), this->m_operator, expecting_indication_bl);
796 } else if (MR_P_pt->m_parameter_rate_indicator_ID == indicator_name) {
797 MR_P_pt->AddNewRate(M_P_pt->getObservedParameterValue(), this->m_operator, expecting_indication_bl);
798 } else {}//error message
799
800 //add the proximity feature here
801 pu_pt = NULL;
802 pu_pt = this->m_proximity->FindAProximityGroupUnitByOneMemberName(MR_P_pt->m_Concept_ID_pt->m_ID);
803 break;
804 case 202: // it is a MRComponentStateUnit
805 MR_C_pt = (MRComponentStateUnit *) ID_pt;
806 MR_C_pt->AddNewPositionValue(M_P_pt->getObservedParameterValue(), this->m_operator, expecting_indication_bl);
807 //add the proximity feature here
808 pu_pt = NULL;
809 pu_pt = this->m_proximity->FindAProximityGroupUnitByOneMemberName(MR_C_pt->m_Concept_ID_pt->m_ID);
810 //note to cancel the same request in the list
811 //add the time cost
812 break;
813
814 default:
815 //error message
816 break;
817 }
818 //add time consumption
820 }
821 //Clean this from the m_tbi_P_list
822 this->m_tbi_P_list.erase(M_P_itr);
823 }
824
825 //*
826 //Processing Component States
827 //*
828 else if (this->m_tbi_C_list.size() > 0) {
829 M_C_itr = this->m_tbi_C_list.begin();
830 M_C_pt = *M_C_itr;
831
832 //get componentstate name
833 { indicator_name = M_C_pt->getDisplayName(); }
834 if (indicator_name.empty() == true) {}//error message
835
836 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
837 if (ID_pt != NULL) {//interpret
838 if (ID_pt->m_ID_Type != 202) {//error message
839 return;
840 }
841
842 if (ID_pt == this->m_reading_indication_ID_pt) {//it is an expecting indication from the onging investigator
843 expecting_indication_bl = true;
844 }
845
846 MR_C_pt = (MRComponentStateUnit *) ID_pt;
847 MR_C_pt->AddNewState(M_C_pt->getObservedComponentState(), this->m_operator, expecting_indication_bl);
848
849 pu_pt = NULL;
850 pu_pt = this->m_proximity->FindAProximityGroupUnitByOneMemberName(MR_C_pt->m_Concept_ID_pt->m_ID);
851 }
852 //Clean this from the m_tbi_C_list
853 this->m_tbi_C_list.erase(M_C_itr);
854 //add time consumption
856 }
857 //*
858 //Processing Support System States
859 //*
860 else if (this->m_tbi_SS_list.size() > 0) {
861 M_SS_itr = this->m_tbi_SS_list.begin();
862 M_SS_pt = *M_SS_itr;
863
864 //get support system state name
865 { indicator_name = M_SS_pt->getDisplayName(); }
866 if (indicator_name.empty() == true) {}//error message
867
868 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
869 if (ID_pt != NULL) {//interpret
870 if (ID_pt->m_ID_Type != 204) {//error message
871 return;
872 }
873
874 if (ID_pt == this->m_reading_indication_ID_pt) {//it is an expecting indication from the onging investigator
875 expecting_indication_bl = true;
876 }
877
878 MR_SS_pt = (MRSupportSystemStateUnit *) ID_pt;
879 MR_SS_pt->AddNewState(M_SS_pt->getObservedSupportSystemState(), this->m_operator, expecting_indication_bl);
880
881 pu_pt = NULL;
882 pu_pt = this->m_proximity->FindAProximityGroupUnitByOneMemberName(MR_SS_pt->m_Concept_ID_pt->m_ID);
883 }
884 //Clean this from the m_tbi_SS_list
885 this->m_tbi_SS_list.erase(M_SS_itr);
886 //add time consumption
888 } else {
889 //PSF slot: idle time
890 if (this->m_unresolved_investigator_pool.size() > 0) { this->m_RM_Token = rm::Prioritize; }
891 else { this->m_RM_Token = rm::RoutineMonitor; }
892 }
893 //finish the current reading
894 if (expecting_indication_bl == true) { this->m_reading_indication_ID_pt = NULL; }
895
896 //Read the proximate indications
897
898 if (pu_pt == NULL) { return; }
899
900 for (str_itr = pu_pt->indication_concept_ID_list.begin(); str_itr != pu_pt->indication_concept_ID_list.end();
901 str_itr++) {
902 MR_name = *str_itr;
903 if (MR_A_pt != NULL) {
904 if (MR_A_pt->m_Concept_pt->m_ID.compare(MR_name) == 0) { continue; }
905 }
906 if (MR_P_pt != NULL) {
907 if (MR_P_pt->m_Concept_ID_pt->m_ID.compare(MR_name) == 0) { continue; }
908 }
909 if (MR_C_pt != NULL) {
910 if (MR_C_pt->m_Concept_ID_pt->m_ID.compare(MR_name) == 0) { continue; }
911 }
912 ID_pt = this->m_MR->CheckExistenceByConceptName(MR_name);
913 if (ID_pt == NULL) { this->ErrorMessage("Error: could not find a MR unit for a proximity item: " + MR_name); }
914
915 if (ID_pt->m_ID_Type == 201) {
916 MR_P_pt2 = (MRParameterUnit *) ID_pt;
917 if (MR_P_pt != NULL) {
918 if (MR_P_pt->m_parameter_indicator_ID == indicator_name) {
919 if (MR_P_pt2->m_parameter_indicator_ID.compare("NONE") != 0) {
920 perceived_value = this->GetAParameterValueImediately(MR_P_pt2->m_parameter_indicator_ID);
921 MR_P_pt2->AddNewValue(perceived_value, this->m_operator, false);
922 }
923 } else if (MR_P_pt->m_parameter_rate_indicator_ID == indicator_name) {
924 if (MR_P_pt2->m_parameter_rate_indicator_ID.compare("NONE") != 0) {
925 perceived_value = this->GetAParameterValueImediately(MR_P_pt2->m_parameter_rate_indicator_ID);
926 MR_P_pt2->AddNewRate(perceived_value, this->m_operator, false);
927 }
928 }
929 } else {
930 perceived_value = this->GetAParameterValueImediately(MR_P_pt2->m_parameter_indicator_ID);
931 MR_P_pt2->AddNewValue(perceived_value, this->m_operator, false);
932 }
933
934 } else if (ID_pt->m_ID_Type == 202) {
935 MR_C_pt2 = (MRComponentStateUnit *) ID_pt;
936 if (MR_C_pt2->m_CS_type == 0) {//state indication
937 if (MR_C_pt2->Component_State_Indicator_ID.compare("NONE") != 0) {
938 perceived_state = this->GetAComponentStateImediately(MR_C_pt2->Component_State_Indicator_ID);
939 MR_C_pt2->AddNewState(perceived_state, this->m_operator, false);
940 }
941 } else if (MR_C_pt2->m_CS_type == 1) {//position indication
942 if (MR_C_pt2->Control_Value_Indicator_ID.compare("NONE") != 0) {
943 perceived_value = this->GetAParameterValueImediately(MR_C_pt2->Control_Value_Indicator_ID);
944 MR_C_pt2->AddNewPositionValue(perceived_value, this->m_operator, false);
945 }
946 }
947 } else if (ID_pt->m_ID_Type == 204) {
948 MR_SS_pt2 = (MRSupportSystemStateUnit *) ID_pt;
949 if (MR_SS_pt2->Support_System_State_Indicator_ID.compare("NONE") != 0) {
951 MR_SS_pt2->AddNewState(perceived_state, this->m_operator, false);
952 }
953 } else if (ID_pt->m_ID_Type == 203) {
954 MR_A_pt2 = (MRAlarmUnit *) ID_pt;
955 perceived_state = this->GetAlarmStateImediately(MR_A_pt2->m_alarm_indicator_name);
956 MR_A_pt2->AddNewAlarmState(perceived_state, this->m_operator, false);
957 }//to be added for the proximity of alarm position
958
959 this->AddConsumptedDeltaT(1);
960 }
961}
962
964 //Token 0030: Prioritize the unfinished Investigators and InvestigatorLinks and chose one
965 //To be added
966 IDElement *ID_pt;
967 vector<IDElement *>::reverse_iterator ID_ritr;
968 vector<string>::iterator str_itr;
969
970 vector<StringTimeIntervalUnit *> recent_lines; //
971
972 Investigator *newest_invest_pt = NULL;
973 Investigator *current_invest_pt = NULL;
974 Investigator *invest_in_early_line = NULL;
975
976 Investigator *newest_invest_in_current_line = NULL;
977 InvestigatorLink *newest_link_in_current_line = NULL;
978
979 InvestigatorLink *current_link_pt = NULL;
980 InvestigatorLink *link_in_early_line = NULL;
981
982 int position_in_lines;
983 int largest_position_in_lines = 0;
984
985 Investigator *next_invest_pt = NULL;
986 InvestigatorLink *next_invest_link_pt = NULL;
987
988 Investigator *invest_pt = NULL;
989 InvestigatorLink *link_pt = NULL;
990
991 float invest_score, highest_invest_score = 0;
992 float invest_link_score, highest_invest_link_score = 0;
993
994 float newest_time = 0;
995 float newest_link_time = 0;
996
997 float link_time = 0;
998 float invest_time = 0;
999
1000 bool use_neutral_style = false;
1001 bool added_bl = false;
1002 bool use_these_codes = true;
1003
1004 int thought_line_distance;
1005 int investigation_distance;
1006
1007 int smallest_line_distance = 0;
1008 int smallest_invest_distance = 0;
1009
1010 int smallest_link_line_distance = 0;
1011 int smallest_link_invest_distance = 0;
1012
1013 int n_Count;
1014 int i;
1015
1016 bool compare_invest_distance;
1017 bool open_to_routine_monitor = false;
1018
1019 stringstream conv;
1020
1021 if (r5pars_.timesno > 948) { this->PrintMessage(""); }
1022
1023 if (this->m_feedback_stack.size() > 0) {
1024 //depth first
1025 ID_ritr = this->m_feedback_stack.rbegin();
1026 ID_pt = *ID_ritr;
1027 if (ID_pt->m_ID == "Investigator_228") { this->PrintMessage(""); }
1028 switch (ID_pt->m_ID_Type) {
1029 case 301: this->m_working_on_invest_pt = (Investigator *) ID_pt;
1031 break;
1032 case 302: this->m_working_on_invest_link_pt = (InvestigatorLink *) ID_pt;
1034 break;
1035 default:
1036 //error message
1037 break;
1038 }
1039 return;
1040 }
1041
1044 this->m_event_schema_base->UpdateTheInterestForInvestigatorOrInvestigatorLink();
1045 this->m_event_schema_base->GenerateANewInvestigatorOrNot();
1046
1048 open_to_routine_monitor = false;
1049/* open_to_routine_monitor = true;
1050 for(invest_itr = this->m_unresolved_investigator_pool.begin(); invest_itr != this->m_unresolved_investigator_pool.end() && open_to_routine_monitor == true; invest_itr++)
1051 {
1052 if((*invest_itr)->m_invest_dormant == true || (*invest_itr)->m_invest_pause == true)
1053 {continue;}
1054 if(this->WetherAnInvestigationItemBelongsToTheCurrentThoughtLine(*invest_itr) == true)
1055 {open_to_routine_monitor = false;}
1056 }
1057 for(invest_link_itr = this->m_investigator_link_pool.begin(); invest_link_itr != this->m_investigator_link_pool.end() && open_to_routine_monitor == true; invest_link_itr++)
1058 {
1059 if((*invest_link_itr)->m_invest_link_dormant == true || (*invest_link_itr)->m_invest_link_pause == true)
1060 {continue;}
1061 if(this->WetherAnInvestigationItemBelongsToTheCurrentThoughtLine(*invest_link_itr) == true)
1062 {open_to_routine_monitor = false;}
1063 }
1064*/ }
1065
1067 //fill the recent thought line list for Vagabond style
1068 if (this->m_current_thought_line_info != nullptr) { recent_lines.push_back(this->m_current_thought_line_info.get()); }
1069 auto line_ritr1 = this->m_thought_line_history.rbegin();
1070 i = 0;
1071 while (i <= this->m_memory_span
1072 && line_ritr1 != this->m_thought_line_history.rend()) {//these codes are for Vagabond style
1073 //push this back to the recent line list if new to the list
1074 added_bl = false;
1075 auto line_itr2 = recent_lines.begin();
1076 while (line_itr2 != recent_lines.end() && added_bl == false) {
1077 if ((*line_ritr1)->CompareThisUnitWithAnotherStringTimeIntervalUnitOnThoughtLineList(*line_itr2) == true) {
1078 added_bl = true;
1079 }
1080 line_itr2++;
1081 }
1082 if (added_bl == false) {
1083 recent_lines.push_back(line_ritr1->get());// ealier position means more recent line
1084 if ((*line_ritr1)->m_interrupted_bl == true) {
1085 i++;
1086 } else {
1087 if ((*line_ritr1)->m_interval_end - (*line_ritr1)->m_interval_start > 0) { i++; }
1088 }
1089 }
1090 line_ritr1++;
1091 }
1092 }
1093
1094 //These codes are for HamletB style
1096 for (str_itr = this->m_ongoing_item_stack.begin();
1097 str_itr != this->m_ongoing_item_stack.end() && next_invest_pt == NULL && next_invest_link_pt == NULL;
1098 str_itr++) {
1099 invest_pt = this->FindInvestigatorByID(*str_itr);
1100 if (invest_pt != NULL) {
1101 invest_score = invest_pt->CalculateFilteredPrioritizingScoreOfInvestigator();
1102 if (invest_score != 0 && invest_pt->m_investigator_token == inv::RetrieveNextLink) {
1103 next_invest_pt = invest_pt;
1104 }
1105 continue;
1106 }
1107
1108 }
1109
1110 /* for test, restore this will get back to the old stable codes
1111 for(str_itr = this->m_ongoing_item_stack.begin(); str_itr != this->m_ongoing_item_stack.end() && next_invest_pt == NULL && next_invest_link_pt == NULL; str_itr++)
1112 {
1113 invest_pt = this->FindInvestigatorByID(*str_itr);
1114 if(invest_pt != NULL)
1115 {
1116 invest_score = invest_pt->CalculateFilteredPrioritizingScoreOfInvestigator();
1117 if(invest_score != 0)
1118 {next_invest_pt = invest_pt;}
1119 continue;
1120 }
1121
1122 link_pt = this->FindInvestigatorLinkByID(*str_itr);
1123 if(link_pt != NULL)
1124 {
1125 if(link_pt->m_forgotten_bl == true)
1126 {continue;}
1127 invest_link_score = link_pt->CalculateFilteredPrioritizingScoreOfInvestigatorLink();
1128 if(invest_link_score != 0)
1129 {next_invest_link_pt = link_pt;}
1130 continue;
1131 }
1132 else
1133 {this->ErrorMessage("unable to identify this item " + *str_itr);}
1134 }
1135 */
1136
1137 if (next_invest_pt != NULL || next_invest_link_pt != NULL) { use_these_codes = false; }
1138 else {
1139 use_these_codes = true;
1140 use_neutral_style = true;
1141 if (this->m_unresolved_investigator_pool.size() == 0
1142 || this->m_routine_monitor->GetTheLongestIntervalRatio() > 3) {
1143 open_to_routine_monitor = true;
1144 }//normally conduct routine monitor when the operator finishes his investigation. But do the routine monitor if it has been a long while not checking an indication
1145 }
1146 }
1147
1148 if (this->m_unresolved_investigator_pool.size() == 0) {
1149 if (this->m_routine_monitor->GetTheLongestIntervalRatio() < 1) { this->NotDoingAnything(); }
1150 else { this->ChangeRMTokenValue(rm::RoutineMonitor); }
1151 return;
1152 }
1153
1154 if (open_to_routine_monitor == true && this->m_routine_monitor->GetTheLongestIntervalRatio() >= 1) {
1156 return;
1157 }
1158
1159 //
1160 /*
1161 Prioritization Factors:
1162 1, activation level
1163 2, interest from the event schema
1164 3, whether it is following the same thought line
1165 4, whether it is a thougth line newly generated
1166 5, depth first or width first
1167 6,
1168 */
1169 //if(this->m_problem_solving_style == HAMLET || this->m_problem_solving_style == NEUTRAL)
1171 use_neutral_style = true;
1173 if (this->m_current_thought_line_info == nullptr) { use_neutral_style = true; }
1174 else if (this->m_current_investigation_info == nullptr) {
1175 use_neutral_style = true;
1176 }
1177 } else if (this->m_problem_solving_style == ProblemSolvingStyle::Hamlet) { use_neutral_style = false; }
1178
1179 if (this->m_working_on_invest_pt != NULL) {
1180 if (this->m_working_on_invest_pt->m_ID == "Investigator_224" && r5pars_.timesno > 1191) { this->PrintMessage(""); }
1181 }
1182
1183 n_Count = 0;
1184
1185 for (auto invest_itr = this->m_unresolved_investigator_pool.begin();
1186 invest_itr != this->m_unresolved_investigator_pool.end() && use_these_codes == true; invest_itr++) {
1187 if ((*invest_itr)->m_ID == "Investigator_3") { this->PrintMessage(""); }
1188
1189 invest_score = (*invest_itr)->CalculateFilteredPrioritizingScoreOfInvestigator();
1190 if (invest_score == 0) { continue; }
1191 //modify this score
1192 /*if(this->m_problem_solving_style == HAMLET)
1193 {
1194 if((*invest_itr) == this->m_working_on_invest_pt)
1195 {invest_score *= 1.2;}
1196 else if(this->FindThePositionInTheThoughtLineHistory((IDElement*)(*invest_itr)) == 1)
1197 {invest_score *= 1.5;}
1198 }
1199 else if(this->m_problem_solving_style == VAGABOND)
1200 {
1201 if((*invest_itr) == this->m_working_on_invest_pt)
1202 {invest_score *= 0.8;}
1203 }*/
1204
1205 n_Count++;
1206 if ((*invest_itr)->m_ID == "Investigator_221") { this->PrintMessage(""); }
1207
1208 switch (this->m_problem_solving_style) {
1210 //the priority order of Vagabond style
1211 //1--new coming phenomenal, active time > the current investigation line start time
1212 //2--current investigation within attention span
1213 //3--if the current investigation is out of attention span. Shifts to the newest uninvestigated item
1214 //4--the item has the largest position in the recent lines. newest of the euqal lines
1215 //5--the current item that is out of attention span
1216 if ((((*invest_itr)->m_downstream_ID_list.size() == 0 || (*invest_itr)->m_motivation == 1) &&
1217 ((*invest_itr)->m_investigator_token == inv::GetCorrespondingKE || (*invest_itr)->m_investigator_token == inv::FindMatchingStatement))
1218 || ((*invest_itr)->m_investigator_token == 3012
1219 && (*invest_itr)->m_investigator_token_history.size() == 0)) {// find the newest original invest
1220 invest_time = (*invest_itr)->GetInitiationTimeOrStatementTimeOrLastActiveTime();
1221 if (invest_time > newest_time) {
1222 newest_time = invest_time;
1223 newest_invest_pt = (*invest_itr);
1224 }
1225 } else {
1226 //for other investigators which have been started already, find the position in the recent thougth lines
1227 //the decay of the investigators is seperate from the inclusion in the recent thougth lines
1228 //find the position in the recent thought line
1229 if ((*invest_itr) == this->m_working_on_invest_pt) {
1230 current_invest_pt = (*invest_itr);
1231 newest_invest_in_current_line = current_invest_pt;
1232 break;
1233 }
1234
1235 auto line_itr2 = recent_lines.begin();
1236 position_in_lines = 0;
1237 i = 1;
1238 while (line_itr2 != recent_lines.end() && position_in_lines == 0) {
1239 if ((*line_itr2)->CheckWhetherContainsAnItemInTheThoughtLine((IDElement *) (*invest_itr)) == true) {
1240 position_in_lines = i;
1241 }
1242 i++;
1243 line_itr2++;
1244 }
1245
1246 if (position_in_lines == 1 && current_invest_pt == NULL) {
1247 if (newest_invest_in_current_line == NULL) { newest_invest_in_current_line = *invest_itr; }
1248 else if ((*invest_itr)->GetInitiationTimeOrStatementTimeOrLastActiveTime()
1249 > newest_invest_in_current_line->GetInitiationTimeOrStatementTimeOrLastActiveTime()) {
1250 newest_invest_in_current_line = *invest_itr;
1251 }
1252 }
1253
1254 if (position_in_lines > largest_position_in_lines) {
1255 largest_position_in_lines = position_in_lines;
1256 invest_in_early_line = *invest_itr;
1257 } else if (position_in_lines != 0 && position_in_lines == largest_position_in_lines) {
1258 if ((*invest_itr)->GetInitiationTimeOrStatementTimeOrLastActiveTime()
1259 > invest_in_early_line->GetInitiationTimeOrStatementTimeOrLastActiveTime()) {
1260 largest_position_in_lines = position_in_lines;
1261 invest_in_early_line = *invest_itr;
1262 }
1263 }
1264 }
1265 break;
1266
1269 if (use_neutral_style == false) {
1270 compare_invest_distance = false;
1271 thought_line_distance = this->FindThePositionInTheThoughtLineHistory((IDElement *) (*invest_itr));
1272 investigation_distance = this->FindThePositionInTheInvestigationHistory((*invest_itr)->m_ID);
1273 if (smallest_line_distance == 0) {
1274 if (thought_line_distance > 0 || next_invest_pt == NULL) {//switch
1275 smallest_line_distance = thought_line_distance;
1276 smallest_invest_distance = investigation_distance;
1277 next_invest_pt = (*invest_itr);
1278 highest_invest_score = invest_score;
1279 } else { compare_invest_distance = true; }
1280 } else {
1281 if (thought_line_distance > 0) {
1282 if (thought_line_distance < smallest_line_distance) {//switch
1283 smallest_link_line_distance = thought_line_distance;
1284 smallest_invest_distance = investigation_distance;
1285 next_invest_pt = (*invest_itr);
1286 highest_invest_score = invest_score;
1287 } else if (thought_line_distance == smallest_line_distance) { compare_invest_distance = true; }
1288 }
1289 }
1290
1291 if (compare_invest_distance == true) {
1292 if (investigation_distance == smallest_invest_distance || next_invest_pt == NULL) {
1293 if (invest_score > highest_invest_score) {
1294 smallest_line_distance = thought_line_distance;
1295 smallest_invest_distance = investigation_distance;
1296 next_invest_pt = (*invest_itr);
1297 highest_invest_score = invest_score;
1298 }
1299 } else if (smallest_invest_distance == 0 || investigation_distance < smallest_invest_distance) {
1300 smallest_line_distance = thought_line_distance;
1301 smallest_invest_distance = investigation_distance;
1302 next_invest_pt = (*invest_itr);
1303 highest_invest_score = invest_score;
1304 }
1305 }
1306 }
1307 break;
1308 case ProblemSolvingStyle::HamletB: thought_line_distance = this->FindThePositionInTheThoughtLineHistory((IDElement *) (*invest_itr));
1309 if (thought_line_distance == 1) {
1310 invest_score *= 1 + exp(-0.128 * (18 / this->m_attention_span) * (r5pars_.timesno
1311 - this->m_current_thought_line_info->m_interval_start));
1312 }
1313 break;
1314 case ProblemSolvingStyle::Neutral: break;
1315 }
1316
1317 if (use_neutral_style == true) {
1318 if (invest_score > highest_invest_score) {
1319 next_invest_pt = (*invest_itr);
1320 highest_invest_score = invest_score;
1321 }
1322 }
1323 }
1324
1325 newest_link_time = 0;
1326 for (auto invest_link_itr = this->m_investigator_link_pool.begin();
1327 invest_link_itr != this->m_investigator_link_pool.end() && use_these_codes == true; invest_link_itr++) {
1328 if ((*invest_link_itr)->m_ID == "InvestigatorLink_64") { this->PrintMessage("check"); }
1329 if ((*invest_link_itr)->m_forgotten_bl == true) { continue; }
1330 invest_link_score = (*invest_link_itr)->CalculateFilteredPrioritizingScoreOfInvestigatorLink();
1331 if (invest_link_score == 0) { continue; }
1332 n_Count++;
1333
1334 switch (this->m_problem_solving_style) {
1336
1337 if (invest_link_itr->get() == this->m_working_on_invest_link_pt) {
1338 current_link_pt = invest_link_itr->get();
1339 newest_link_in_current_line = current_link_pt;
1340 break;
1341 }
1342
1343 auto line_itr2 = recent_lines.begin();
1344 position_in_lines = 0;
1345 i = 1;
1346 while (line_itr2 != recent_lines.end() && position_in_lines == 0) {
1347 if ((*line_itr2)->CheckWhetherContainsAnItemInTheThoughtLine((IDElement *) invest_link_itr->get()) == true) {
1348 position_in_lines = i;
1349 }
1350 i++;
1351 line_itr2++;
1352 }
1353 if (position_in_lines == 1 && current_invest_pt == NULL && current_link_pt == NULL) {
1354 if (newest_link_in_current_line != NULL) {
1355 if ((*invest_link_itr)->GetDownstreamInitiationTimeOrStatementTime()
1356 > newest_link_in_current_line->GetDownstreamInitiationTimeOrStatementTime()) {
1357 newest_link_in_current_line = invest_link_itr->get();
1358 }
1359 } else if (newest_invest_in_current_line != NULL) {
1360 if ((*invest_link_itr)->GetDownstreamInitiationTimeOrStatementTime()
1361 > newest_invest_in_current_line->GetInitiationTimeOrStatementTimeOrLastActiveTime()) {
1362 newest_link_in_current_line = invest_link_itr->get();
1363 }
1364 } else { newest_link_in_current_line = invest_link_itr->get(); }
1365 }
1366 if (position_in_lines > largest_position_in_lines) {
1367 largest_position_in_lines = position_in_lines;
1368 link_in_early_line = invest_link_itr->get();
1369 } else if (position_in_lines != 0 && position_in_lines == largest_position_in_lines) {
1370 if (link_in_early_line != NULL) {
1371 if ((*invest_link_itr)->GetDownstreamInitiationTimeOrStatementTime()
1372 > link_in_early_line->GetDownstreamInitiationTimeOrStatementTime()) {
1373 largest_position_in_lines = position_in_lines;
1374 link_in_early_line = invest_link_itr->get();
1375 }
1376 } else if (invest_in_early_line != NULL) {
1377 if ((*invest_link_itr)->GetDownstreamInitiationTimeOrStatementTime()
1378 > invest_in_early_line->GetInitiationTimeOrStatementTimeOrLastActiveTime()) {
1379 largest_position_in_lines = position_in_lines;
1380 link_in_early_line = invest_link_itr->get();
1381 }
1382 }
1383 }
1384
1385 /*link_time = (*invest_link_itr)->GetDownstreamInitiationTimeOrStatementTime();
1386 if(link_time > newest_link_time)
1387 {
1388 next_invest_link_pt = (*invest_link_itr);
1389 newest_link_time = link_time;
1390 }*/
1391 break;
1392 }
1395 if (use_neutral_style == false) {
1396 compare_invest_distance = false;
1397 thought_line_distance = this->FindThePositionInTheThoughtLineHistory((IDElement *) invest_link_itr->get());
1398 investigation_distance = this->FindThePositionInTheInvestigationHistory((*invest_link_itr)->m_ID);
1399 if (smallest_link_line_distance == 0) {
1400 if (thought_line_distance > 0 || next_invest_link_pt == NULL) {//switch
1401 smallest_link_line_distance = thought_line_distance;
1402 smallest_link_invest_distance = investigation_distance;
1403 next_invest_link_pt = invest_link_itr->get();
1404 highest_invest_link_score = invest_link_score;
1405 } else { compare_invest_distance = true; }
1406 } else {
1407 if (thought_line_distance > 0) {
1408 if (thought_line_distance < smallest_link_line_distance) {//switch
1409 smallest_link_line_distance = thought_line_distance;
1410 smallest_link_invest_distance = investigation_distance;
1411 next_invest_link_pt = invest_link_itr->get();
1412 highest_invest_link_score = invest_link_score;
1413 } else if (thought_line_distance == smallest_link_line_distance) { compare_invest_distance = true; }
1414 }
1415 }
1416
1417 if (compare_invest_distance == true) {
1418 if (smallest_link_invest_distance)
1419 investigation_distance = this->FindThePositionInTheInvestigationHistory((*invest_link_itr)->m_ID);
1420 if (investigation_distance == smallest_link_invest_distance || next_invest_link_pt == NULL) {
1421 if (invest_link_score > highest_invest_link_score) {
1422 smallest_link_line_distance = thought_line_distance;
1423 smallest_link_invest_distance = investigation_distance;
1424 next_invest_link_pt = invest_link_itr->get();
1425 highest_invest_link_score = invest_link_score;
1426 }
1427 } else if (smallest_link_invest_distance == 0 || investigation_distance < smallest_link_invest_distance) {
1428 smallest_link_line_distance = thought_line_distance;
1429 smallest_link_invest_distance = investigation_distance;
1430 next_invest_link_pt = invest_link_itr->get();
1431 highest_invest_link_score = invest_link_score;
1432 }
1433 }
1434 }
1435 break;
1436 case ProblemSolvingStyle::Neutral: break;
1437 }
1438 //
1439 if (use_neutral_style == true) {
1440 if (invest_link_score > highest_invest_link_score) {
1441 next_invest_link_pt = invest_link_itr->get();
1442 highest_invest_link_score = invest_link_score;
1443 }
1444 }
1445
1446 }
1447
1448 int selection = 0;
1449
1450
1451
1452/* if(this->m_problem_solving_style == HAMLET)
1453 {
1454 if(max(highest_invest_score, highest_invest_link_score) < this->m_routine_monitor->GetTheLongestIntervalRatio()/this->m_routine_monitor_threshold)
1455 {
1456 this->m_working_on_invest_link_pt = NULL;
1457 this->m_working_on_invest_pt = NULL;
1458 this->ChangeRMTokenValue(rm::RoutineMonitor);
1459 return;
1460 }
1461 }*/
1462 bool move_to_next = true;
1464 open_to_routine_monitor = false;
1465 if (newest_invest_pt == NULL && this->m_current_thought_line_info == nullptr) {
1466 next_invest_pt = NULL;
1467 next_invest_link_pt = NULL;
1468 move_to_next = false;
1469 }
1470
1471 if (move_to_next == true && newest_invest_pt != NULL) {//priority 1
1472 if (this->m_current_thought_line_info == nullptr) {
1473 next_invest_pt = newest_invest_pt;
1474 next_invest_link_pt = NULL;
1475 move_to_next = false;
1476 } else if (newest_invest_pt->GetInitiationTimeOrStatementTimeOrLastActiveTime()
1477 > this->m_current_thought_line_info->m_interval_start) {
1478 next_invest_pt = newest_invest_pt;
1479 next_invest_link_pt = NULL;
1480 move_to_next = false;
1481 }
1482 }
1483
1484 if (move_to_next == true && (r5pars_.timesno - this->m_current_thought_line_info->m_interval_start
1485 < this->m_attention_span)) {//priority 2, the current investigation line is still within bound
1486 //if(current_invest_pt != NULL)
1487
1488 if (newest_link_in_current_line != NULL) {
1489 next_invest_pt = NULL;
1490 next_invest_link_pt = newest_link_in_current_line;
1491 move_to_next = false;
1492 } else if (newest_invest_in_current_line != NULL) {
1493 next_invest_pt = newest_invest_in_current_line;
1494 next_invest_link_pt = NULL;
1495 move_to_next = false;
1496 }
1497 }
1498
1499 if (move_to_next == true) { open_to_routine_monitor = true; }
1500 if (move_to_next == true && newest_invest_pt != NULL) {//priority 3, investigate a new item
1501 next_invest_pt = newest_invest_pt;
1502 next_invest_link_pt = NULL;
1503 move_to_next = false;
1504 }
1505
1506 if (move_to_next == true && largest_position_in_lines != 0) {//priority 4, investigate an early thought line
1507 if (link_in_early_line != NULL) {
1508 next_invest_pt = NULL;
1509 next_invest_link_pt = link_in_early_line;
1510 move_to_next = false;
1511
1512 } else if (invest_in_early_line != NULL) {
1513 next_invest_pt = invest_in_early_line;
1514 next_invest_link_pt = NULL;
1515 move_to_next = false;
1516 }
1517 }
1518
1519 if (move_to_next == true) {//priority 5, continue to work on the current line
1520 if (newest_link_in_current_line != NULL) {
1521 next_invest_pt = NULL;
1522 next_invest_link_pt = newest_link_in_current_line;
1523 move_to_next = false;
1524 } else if (newest_invest_in_current_line != NULL) {
1525 next_invest_pt = newest_invest_in_current_line;
1526 next_invest_link_pt = NULL;
1527 move_to_next = false;
1528 }
1529 }
1530 }
1531
1532 if (next_invest_link_pt == NULL && next_invest_pt == NULL) {
1533 //HAMELET_B only conduct routine monitor when he finish his current task
1534
1535 this->m_working_on_invest_link_pt = NULL;
1536 this->m_working_on_invest_pt = NULL;
1537 if (this->m_routine_monitor->GetTheLongestIntervalRatio() < 1) { this->NotDoingAnything(); }
1538 else { this->ChangeRMTokenValue(rm::RoutineMonitor); }
1539 return;
1540 }
1541
1542 if (next_invest_link_pt == NULL) { selection = 1; }
1543 else if (next_invest_pt == NULL) { selection = 2; }
1544 else {
1545 if (use_neutral_style == true) {
1546 if (highest_invest_score > highest_invest_link_score) { selection = 1; }
1547 else { selection = 2; }
1549 if (newest_time > newest_link_time) { selection = 1; }
1550 else { selection = 2; }
1552 compare_invest_distance = false;
1553 if (smallest_line_distance == smallest_link_line_distance) { compare_invest_distance = true; }
1554 else if (smallest_link_line_distance == 0) { selection = 1; }
1555 else if (smallest_line_distance == 0) { selection = 2; }
1556 else if (smallest_line_distance < smallest_link_invest_distance) { selection = 1; }
1557 else if (smallest_line_distance > smallest_link_invest_distance) { selection = 2; }
1558
1559 if (compare_invest_distance == true) {
1560 if (smallest_invest_distance == smallest_link_invest_distance) {
1561 if (highest_invest_score > highest_invest_link_score) { selection = 1; }
1562 else { selection = 2; }
1563 } else if (smallest_invest_distance == 0) { selection = 2; }
1564 else if (smallest_link_invest_distance == 0) { selection = 1; }
1565 else if (smallest_invest_distance < smallest_link_invest_distance) { selection = 1; }
1566 else { selection = 2; }
1567 }
1568 } else { this->ErrorMessage("Unrecongnized problem solving style"); }
1569 }
1570
1571 if (selection == 1) {
1572 conv.str("");
1573 conv << highest_invest_score;
1574 this->WriteAuxInfo("Prioritization Score: " + conv.str());
1575 this->m_working_on_invest_pt = next_invest_pt;
1576 this->m_working_on_invest_link_pt = NULL;
1578 } else if (selection == 2) {
1579 conv.str("");
1580 conv << highest_invest_link_score;
1581 this->WriteAuxInfo("Prioritization Score: " + conv.str());
1582 this->m_working_on_invest_link_pt = next_invest_link_pt;
1583 this->m_working_on_invest_pt = NULL;
1585 }
1586}
1587
1589 //Token 3000: work on a specified Investigator
1590 //To be added
1591 vector<string>::iterator str_itr;
1592 string line_ID;
1593 SentenceUnit *sent_pt;
1594 vector<IDElement *>::iterator ID_itr;
1596 bool exist_bl = false;
1597
1598 this->m_goofy_start_time = 0;
1599
1600 if (sent_pt->m_activation < 1) {
1602 }
1603 if (this->m_working_on_invest_pt != NULL) {
1604 //check point
1605 if (this->m_working_on_invest_pt->m_ID == "Investigator_22") { this->PrintMessage("check"); }
1606
1607 //update thought line info
1608 if (this->m_current_thought_line_info == nullptr) {
1609 this->m_current_thought_line_info = make_unique<StringTimeIntervalUnit>();
1610 this->m_current_thought_line_info->m_interval_start = r5pars_.timesno;
1612 this->m_current_thought_line_info->m_thought_line_list.push_back(this->m_working_on_invest_pt->m_ID);
1613 }
1614 for (str_itr = this->m_working_on_invest_pt->m_thoughtline_roots_list.begin();
1615 str_itr != this->m_working_on_invest_pt->m_thoughtline_roots_list.end(); str_itr++) {
1616 line_ID = *str_itr;
1617 this->m_current_thought_line_info->m_thought_line_list.push_back(line_ID);
1618 }
1619 } else {
1620 this->CheckWhetherTheThoughtLineHasChanged(); //line update has to be earlier than the investigation info updates
1621 }
1622
1623 //update investigation info
1624 if (this->m_current_investigation_info == nullptr) {
1625 this->m_current_investigation_info = make_unique<StringTimeIntervalUnit>();
1626 this->m_current_investigation_info->m_interval_start = r5pars_.timesno;
1628 } else {
1630 if (this->m_working_on_invest_pt->m_ID.compare(this->m_current_investigation_info->m_name) != 0) {
1631 this->m_current_investigation_info->m_interval_end = r5pars_.timesno;
1632 this->m_investigation_history.push_back(std::move(this->m_current_investigation_info));
1633
1634 this->m_current_investigation_info = make_unique<StringTimeIntervalUnit>();
1635 this->m_current_investigation_info->m_interval_start = r5pars_.timesno;
1637 }
1638 }
1639 }
1640
1643 }
1644 //
1646 } else {}//error message
1647}
1648
1650 //Token 3100: work on a specified InvestigatorLink
1651 //To be added
1652 vector<string>::iterator str_itr;
1653 string line_ID;
1654
1655 if (this->m_working_on_invest_link_pt != NULL) {
1656 this->m_goofy_start_time = 0;
1657
1658 //update thought line info
1659 if (this->m_current_thought_line_info == nullptr) {
1660 this->m_current_thought_line_info = make_unique<StringTimeIntervalUnit>();
1661 this->m_current_thought_line_info->m_interval_start = r5pars_.timesno;
1662 for (str_itr = this->m_working_on_invest_link_pt->m_thoughtline_roots_list.begin();
1663 str_itr != this->m_working_on_invest_link_pt->m_thoughtline_roots_list.end(); str_itr++) {
1664 line_ID = *str_itr;
1665 this->m_current_thought_line_info->m_thought_line_list.push_back(line_ID);
1666 }
1667 } else {
1669 }
1670 //update investigation info
1671 if (this->m_current_investigation_info == nullptr) {
1672 this->m_current_investigation_info = make_unique<StringTimeIntervalUnit>();
1673 this->m_current_investigation_info->m_interval_start = r5pars_.timesno;
1675 } else {
1677 if (this->m_working_on_invest_link_pt->m_ID.compare(this->m_current_investigation_info->m_name) != 0) {
1678 this->m_current_investigation_info->m_interval_end = r5pars_.timesno;
1679 this->m_investigation_history.push_back(std::move(this->m_current_investigation_info));
1680
1681 this->m_current_investigation_info = make_unique<StringTimeIntervalUnit>();
1682 this->m_current_investigation_info->m_interval_start = r5pars_.timesno;
1684 }
1685 }
1686 }
1688 //
1690 } else {}//error message
1691}
1692
1694 bool finished = false;
1695 vector<IDElement *>::iterator ID_itr;
1696 for (ID_itr = this->m_feedback_stack.begin(); ID_itr != this->m_feedback_stack.end(); ID_itr++) {
1697 if ((*ID_itr) == _ID_pt) {
1698 this->m_feedback_stack.erase(ID_itr);
1699 break;
1700 }
1701 }
1702}
1703
1705
1706 if (this->m_operator == 0) {}//error message: the m_operator has not been initiated
1707
1708 this->m_passive_alarm_load = make_unique<PassiveAlarmLoadUnit>();
1709
1710 //
1712
1713 //initiate the concept base
1714 this->m_Concept_Base->m_operator = this->m_operator;
1715 this->m_Concept_Base->ReadKBConceptInfoFromInputFile();
1716 this->m_Concept_Base->ReadAntonymBaseFromInputFile();
1717
1718 //initiate the Instantiation Base
1719 this->m_IB->m_operator = this->m_operator;
1720 this->m_IB->ReadInstantiationBaseFromInputFile();
1721
1722 //initiate the mental representation m_MR
1723 this->m_MR->m_operator = this->m_operator;
1724 this->m_MR->ReadMentalRepresentationtInfoFromInputFile();
1725
1726 //initiate the m_Semantic_list
1728 this->PrintSemanticBase();
1729
1730 //initiate the KnowledgeUnitBase
1732
1733 //initiate the EventSchemaBase
1734 this->m_event_schema_base->m_operator = this->m_operator;
1735 this->m_event_schema_base->ReadEventSchemaBaseFromInputFile();
1736
1737 //initiate the Routine Monitor
1738 this->m_routine_monitor->m_operator = this->m_operator;
1739 this->m_routine_monitor->ReadRoutineMonitorInforFromInputFile();
1740
1741 //initiate the Proximity Models
1742 this->m_proximity = make_unique<ProximityModel>();
1743 this->m_proximity->m_operator = this->m_operator;
1744 this->m_proximity->ReadProximityModelFromInputFile();
1745
1746 //
1747 if (this->m_operator == sim::Operator::ODM) {
1749 } else {
1751 }
1752 //
1755
1756 this->PrintKnowledgeWeb();
1757}
1758
1760 string directory, str, str1, str2, str_ID, file_name;
1761 ifstream fin;
1762 int n_Unit, i;
1763 unique_ptr<SentenceUnit> sent_pt;
1764 unique_ptr<SentenceUnit> sent2_pt;
1765 IDElement *ID_pt;
1766 string err_mes;
1767 stringstream conv;
1768
1769 //Automatically create some sentences based on the Mental Representation
1770 string ID_name;
1771 IDElement *ID_X_pt;
1772 vector<IDElement *> processed_X_list;
1773 vector<IDElement *>::iterator ID_X_itr;
1774 bool for_X_bl;
1775 Label label_pt;
1776 Label label_obj_pt;
1777 Instantiation *Inst_pt;
1778 Instantiation *Inst_obj_pt;
1779 ConceptComposedUnit *CC_pt;
1780 ConceptComposedUnit *CC_obj_pt;
1781
1782 for (size_t MR_P_idx = 1; MR_P_idx < this->m_MR->m_MRParameter_list.size(); MR_P_idx++) {
1783 auto &MR_P_pt = this->m_MR->m_MRParameter_list[MR_P_idx];
1784 for_X_bl = false;
1785 ID_X_pt = NULL;
1786
1787 if (MR_P_pt->m_Concept_ID_pt->m_ID_Type == 002) {
1788 CC_pt = (ConceptComposedUnit *) (MR_P_pt->m_Concept_ID_pt);
1789 ID_X_pt = CC_pt->m_Indefinite_Concept_ID_pt;
1790 }
1791 if (ID_X_pt != NULL) {
1792 for_X_bl = true;
1793 for (ID_X_itr = processed_X_list.begin(); ID_X_itr != processed_X_list.end() && for_X_bl == true; ID_X_itr++) {
1794 if ((*ID_X_itr) == ID_X_pt) {
1795 for_X_bl = false;
1796 }
1797 }
1798 if (for_X_bl == true) {
1799 processed_X_list.push_back(ID_X_pt);
1800 }
1801 }
1802
1803 sent_pt = make_unique<SentenceUnit>();
1804 sent_pt->m_ID = MR_P_pt->m_Concept_ID_pt->m_ID + "_increase";
1805 sent_pt->m_sentence_type = 1;
1806 sent_pt->m_subject_pt = MR_P_pt->m_Concept_ID_pt;
1807 sent_pt->m_process_pt = this->m_Concept_Base->getIncreasePt();
1808 this->m_Semantic_list.push_back(std::move(sent_pt));
1809
1810 sent_pt = make_unique<SentenceUnit>();
1811 sent_pt->m_ID = MR_P_pt->m_Concept_ID_pt->m_ID + "_decrease";
1812 sent_pt->m_sentence_type = 1;
1813 sent_pt->m_subject_pt = MR_P_pt->m_Concept_ID_pt;
1814 sent_pt->m_process_pt = this->m_Concept_Base->getDecreasePt();
1815 this->m_Semantic_list.push_back(std::move(sent_pt));
1816
1817 sent_pt = make_unique<SentenceUnit>();
1818 sent_pt->m_ID = MR_P_pt->m_Concept_ID_pt->m_ID + "_stable";
1819 sent_pt->m_sentence_type = 1;
1820 sent_pt->m_subject_pt = MR_P_pt->m_Concept_ID_pt;
1821 sent_pt->m_process_pt = this->m_Concept_Base->getStablePt();
1822 this->m_Semantic_list.push_back(std::move(sent_pt));
1823
1824 if (for_X_bl == true) {
1825 sent_pt = make_unique<SentenceUnit>();
1826 sent_pt->m_ID = ID_X_pt->m_ID + "_increase";
1827 sent_pt->m_sentence_type = 1;
1828 sent_pt->m_subject_pt = ID_X_pt;
1829 sent_pt->m_process_pt = this->m_Concept_Base->getIncreasePt();
1830 this->m_Semantic_list.push_back(std::move(sent_pt));
1831
1832 sent_pt = make_unique<SentenceUnit>();
1833 sent_pt->m_ID = ID_X_pt->m_ID + "_decrease";
1834 sent_pt->m_sentence_type = 1;
1835 sent_pt->m_subject_pt = ID_X_pt;
1836 sent_pt->m_process_pt = this->m_Concept_Base->getDecreasePt();
1837 this->m_Semantic_list.push_back(std::move(sent_pt));
1838
1839 sent_pt = make_unique<SentenceUnit>();
1840 sent_pt->m_ID = ID_X_pt->m_ID + "_stable";
1841 sent_pt->m_sentence_type = 1;
1842 sent_pt->m_subject_pt = ID_X_pt;
1843 sent_pt->m_process_pt = this->m_Concept_Base->getStablePt();
1844 this->m_Semantic_list.push_back(std::move(sent_pt));
1845 }
1846 }
1847
1848 for (auto &MR_C_pt : this->m_MR->m_MRComponent_list) {
1849 for_X_bl = false;
1850 ID_X_pt = NULL;
1851 if (MR_C_pt->m_Concept_ID_pt->m_ID_Type == 002) {
1852 CC_pt = (ConceptComposedUnit *) (MR_C_pt->m_Concept_ID_pt);
1853 ID_X_pt = CC_pt->m_Indefinite_Concept_ID_pt;
1854 }
1855 if (ID_X_pt != NULL) {
1856 for_X_bl = true;
1857 for (ID_X_itr = processed_X_list.begin(); ID_X_itr != processed_X_list.end() && for_X_bl == true; ID_X_itr++) {
1858 if ((*ID_X_itr) == ID_X_pt) {
1859 for_X_bl = false;
1860 }
1861 }
1862 if (for_X_bl == true) {
1863 processed_X_list.push_back(ID_X_pt);
1864 }
1865 }
1866
1867 if (MR_C_pt->m_CS_type == 0) {
1868 sent_pt = make_unique<SentenceUnit>();
1869 sent_pt->m_ID = MR_C_pt->m_Concept_ID_pt->m_ID + "_ON";
1870 sent_pt->m_sentence_type = 2;
1871 sent_pt->m_subject_pt = MR_C_pt->m_Concept_ID_pt;
1872 sent_pt->m_state_pt = this->m_Concept_Base->getONpt();
1873 this->m_Semantic_list.push_back(std::move(sent_pt));
1874
1875 sent_pt = make_unique<SentenceUnit>();
1876 sent_pt->m_ID = MR_C_pt->m_Concept_ID_pt->m_ID + "_OFF";
1877 sent_pt->m_sentence_type = 2;
1878 sent_pt->m_subject_pt = MR_C_pt->m_Concept_ID_pt;
1879 sent_pt->m_state_pt = this->m_Concept_Base->getOFFpt();
1880 this->m_Semantic_list.push_back(std::move(sent_pt));
1881
1882 sent_pt = make_unique<SentenceUnit>();
1883 sent_pt->m_ID = MR_C_pt->m_Concept_ID_pt->m_ID + "_turn_on";
1884 sent_pt->m_sentence_type = 1;
1885 sent_pt->m_subject_pt = MR_C_pt->m_Concept_ID_pt;
1886 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOnPt();
1887 this->m_Semantic_list.push_back(std::move(sent_pt));
1888
1889 sent_pt = make_unique<SentenceUnit>();
1890 sent_pt->m_ID = MR_C_pt->m_Concept_ID_pt->m_ID + "_turn_off";
1891 sent_pt->m_sentence_type = 1;
1892 sent_pt->m_subject_pt = MR_C_pt->m_Concept_ID_pt;
1893 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOffPt();
1894 this->m_Semantic_list.push_back(std::move(sent_pt));
1895
1896 if (for_X_bl == true) {
1897 sent_pt = make_unique<SentenceUnit>();
1898 sent_pt->m_ID = ID_X_pt->m_ID + "_ON";
1899 sent_pt->m_sentence_type = 2;
1900 sent_pt->m_subject_pt = ID_X_pt;
1901 sent_pt->m_state_pt = this->m_Concept_Base->getONpt();
1902 this->m_Semantic_list.push_back(std::move(sent_pt));
1903
1904 sent_pt = make_unique<SentenceUnit>();
1905 sent_pt->m_ID = ID_X_pt->m_ID + "_OFF";
1906 sent_pt->m_sentence_type = 2;
1907 sent_pt->m_subject_pt = ID_X_pt;
1908 sent_pt->m_state_pt = this->m_Concept_Base->getOFFpt();
1909 this->m_Semantic_list.push_back(std::move(sent_pt));
1910
1911 sent_pt = make_unique<SentenceUnit>();
1912 sent_pt->m_ID = ID_X_pt->m_ID + "_turn_on";
1913 sent_pt->m_sentence_type = 1;
1914 sent_pt->m_subject_pt = ID_X_pt;
1915 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOnPt();
1916 this->m_Semantic_list.push_back(std::move(sent_pt));
1917
1918 sent_pt = make_unique<SentenceUnit>();
1919 sent_pt->m_ID = ID_X_pt->m_ID + "_turn_off";
1920 sent_pt->m_sentence_type = 1;
1921 sent_pt->m_subject_pt = ID_X_pt;
1922 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOffPt();
1923 this->m_Semantic_list.push_back(std::move(sent_pt));
1924 }
1925 } else if (MR_C_pt->m_CS_type == 1) {
1926 sent_pt = make_unique<SentenceUnit>();
1927 sent_pt->m_ID = MR_C_pt->m_Concept_ID_pt->m_ID + "_open_bigger";
1928 sent_pt->m_sentence_type = 1;
1929 sent_pt->m_subject_pt = MR_C_pt->m_Concept_ID_pt;
1930 sent_pt->m_process_pt = this->m_Concept_Base->getOpenBiggerPt();
1931 this->m_Semantic_list.push_back(std::move(sent_pt));
1932
1933 sent_pt = make_unique<SentenceUnit>();
1934 sent_pt->m_ID = MR_C_pt->m_Concept_ID_pt->m_ID + "_close_smaller";
1935 sent_pt->m_sentence_type = 1;
1936 sent_pt->m_subject_pt = MR_C_pt->m_Concept_ID_pt;
1937 sent_pt->m_process_pt = this->m_Concept_Base->getCloseSmallerPt();
1938 this->m_Semantic_list.push_back(std::move(sent_pt));
1939
1940 if (for_X_bl == true) {
1941 sent_pt = make_unique<SentenceUnit>();
1942 sent_pt->m_ID = ID_X_pt->m_ID + "_open_bigger";
1943 sent_pt->m_sentence_type = 1;
1944 sent_pt->m_subject_pt = ID_X_pt;
1945 sent_pt->m_process_pt = this->m_Concept_Base->getOpenBiggerPt();
1946 this->m_Semantic_list.push_back(std::move(sent_pt));
1947
1948 sent_pt = make_unique<SentenceUnit>();
1949 sent_pt->m_ID = ID_X_pt->m_ID + "_close_smaller";
1950 sent_pt->m_sentence_type = 1;
1951 sent_pt->m_subject_pt = ID_X_pt;
1952 sent_pt->m_process_pt = this->m_Concept_Base->getCloseSmallerPt();
1953 this->m_Semantic_list.push_back(std::move(sent_pt));
1954 }
1955 } else {}//error message
1956 }
1957
1958 for (auto &MR_SS_pt : this->m_MR->m_MRSupportSystem_list) {
1959 for_X_bl = false;
1960 ID_X_pt = NULL;
1961 if (MR_SS_pt->m_Concept_ID_pt->m_ID_Type == 002) {
1962 CC_pt = (ConceptComposedUnit *) (MR_SS_pt->m_Concept_ID_pt);
1963 ID_X_pt = CC_pt->m_Indefinite_Concept_ID_pt;
1964 }
1965 if (ID_X_pt != NULL) {
1966 for_X_bl = true;
1967 for (ID_X_itr = processed_X_list.begin(); ID_X_itr != processed_X_list.end() && for_X_bl == true; ID_X_itr++) {
1968 if ((*ID_X_itr) == ID_X_pt) {
1969 for_X_bl = false;
1970 }
1971 }
1972 if (for_X_bl == true) {
1973 processed_X_list.push_back(ID_X_pt);
1974 }
1975 }
1976
1977 sent_pt = make_unique<SentenceUnit>();
1978 sent_pt->m_ID = MR_SS_pt->m_Concept_ID_pt->m_ID + "_ON";
1979 sent_pt->m_sentence_type = 2;
1980 sent_pt->m_subject_pt = MR_SS_pt->m_Concept_ID_pt;
1981 sent_pt->m_state_pt = this->m_Concept_Base->getONpt();
1982 this->m_Semantic_list.push_back(std::move(sent_pt));
1983
1984 sent_pt = make_unique<SentenceUnit>();
1985 sent_pt->m_ID = MR_SS_pt->m_Concept_ID_pt->m_ID + "_OFF";
1986 sent_pt->m_sentence_type = 2;
1987 sent_pt->m_subject_pt = MR_SS_pt->m_Concept_ID_pt;
1988 sent_pt->m_state_pt = this->m_Concept_Base->getOFFpt();
1989 this->m_Semantic_list.push_back(std::move(sent_pt));
1990
1991 sent_pt = make_unique<SentenceUnit>();
1992 sent_pt->m_ID = MR_SS_pt->m_Concept_ID_pt->m_ID + "_turn_on";
1993 sent_pt->m_sentence_type = 1;
1994 sent_pt->m_subject_pt = MR_SS_pt->m_Concept_ID_pt;
1995 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOnPt();
1996 this->m_Semantic_list.push_back(std::move(sent_pt));
1997
1998 sent_pt = make_unique<SentenceUnit>();
1999 sent_pt->m_ID = MR_SS_pt->m_Concept_ID_pt->m_ID + "_turn_off";
2000 sent_pt->m_sentence_type = 1;
2001 sent_pt->m_subject_pt = MR_SS_pt->m_Concept_ID_pt;
2002 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOffPt();
2003 this->m_Semantic_list.push_back(std::move(sent_pt));
2004
2005 if (for_X_bl == true) {
2006 sent_pt = make_unique<SentenceUnit>();
2007 sent_pt->m_ID = ID_X_pt->m_ID + "_ON";
2008 sent_pt->m_sentence_type = 2;
2009 sent_pt->m_subject_pt = ID_X_pt;
2010 sent_pt->m_state_pt = this->m_Concept_Base->getONpt();
2011 this->m_Semantic_list.push_back(std::move(sent_pt));
2012
2013 sent_pt = make_unique<SentenceUnit>();
2014 sent_pt->m_ID = ID_X_pt->m_ID + "_OFF";
2015 sent_pt->m_sentence_type = 2;
2016 sent_pt->m_subject_pt = ID_X_pt;
2017 sent_pt->m_state_pt = this->m_Concept_Base->getOFFpt();
2018 this->m_Semantic_list.push_back(std::move(sent_pt));
2019
2020 sent_pt = make_unique<SentenceUnit>();
2021 sent_pt->m_ID = ID_X_pt->m_ID + "_turn_on";
2022 sent_pt->m_sentence_type = 1;
2023 sent_pt->m_subject_pt = ID_X_pt;
2024 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOnPt();
2025 this->m_Semantic_list.push_back(std::move(sent_pt));
2026
2027 sent_pt = make_unique<SentenceUnit>();
2028 sent_pt->m_ID = ID_X_pt->m_ID + "_turn_off";
2029 sent_pt->m_sentence_type = 1;
2030 sent_pt->m_subject_pt = ID_X_pt;
2031 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOffPt();
2032 this->m_Semantic_list.push_back(std::move(sent_pt));
2033 }
2034 }
2035
2036 for (auto &MR_A_pt : this->m_MR->m_MRAlarm_list) {
2037 for_X_bl = false;
2038 ID_X_pt = NULL;
2039 if (MR_A_pt->m_Concept_pt->m_ID_Type == 002) {
2040 CC_pt = (ConceptComposedUnit *) (MR_A_pt->m_Concept_pt);
2041 ID_X_pt = CC_pt->m_Indefinite_Concept_ID_pt;
2042 }
2043 if (ID_X_pt != NULL) {
2044 for_X_bl = true;
2045 for (ID_X_itr = processed_X_list.begin(); ID_X_itr != processed_X_list.end() && for_X_bl == true; ID_X_itr++) {
2046 if ((*ID_X_itr) == ID_X_pt) {
2047 for_X_bl = false;
2048 }
2049 }
2050 if (for_X_bl == true) {
2051 processed_X_list.push_back(ID_X_pt);
2052 }
2053 }
2054
2055 sent_pt = make_unique<SentenceUnit>();
2056 sent_pt->m_ID = MR_A_pt->m_Concept_pt->m_ID + "_turn_on";
2057 sent_pt->m_sentence_type = 1;
2058 sent_pt->m_subject_pt = MR_A_pt->m_Concept_pt;
2059 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOnPt();
2060 this->m_Semantic_list.push_back(std::move(sent_pt));
2061
2062 sent_pt = make_unique<SentenceUnit>();
2063 sent_pt->m_ID = MR_A_pt->m_Concept_pt->m_ID + "_turn_off";
2064 sent_pt->m_sentence_type = 1;
2065 sent_pt->m_subject_pt = MR_A_pt->m_Concept_pt;
2066 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOffPt();
2067 this->m_Semantic_list.push_back(std::move(sent_pt));
2068
2069 sent_pt = make_unique<SentenceUnit>();
2070 sent_pt->m_ID = MR_A_pt->m_Concept_pt->m_ID + "_ON";
2071 sent_pt->m_sentence_type = 2;
2072 sent_pt->m_subject_pt = MR_A_pt->m_Concept_pt;
2073 sent_pt->m_state_pt = this->m_Concept_Base->getONpt();
2074 this->m_Semantic_list.push_back(std::move(sent_pt));
2075
2076 sent_pt = make_unique<SentenceUnit>();
2077 sent_pt->m_ID = MR_A_pt->m_Concept_pt->m_ID + "_OFF";
2078 sent_pt->m_sentence_type = 2;
2079 sent_pt->m_subject_pt = MR_A_pt->m_Concept_pt;
2080 sent_pt->m_state_pt = this->m_Concept_Base->getOFFpt();
2081 this->m_Semantic_list.push_back(std::move(sent_pt));
2082
2083 if (for_X_bl == true) {
2084 sent_pt = make_unique<SentenceUnit>();
2085 sent_pt->m_ID = ID_X_pt->m_ID + "_turn_on";
2086 sent_pt->m_sentence_type = 1;
2087 sent_pt->m_subject_pt = ID_X_pt;
2088 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOnPt();
2089 this->m_Semantic_list.push_back(std::move(sent_pt));
2090
2091 sent_pt = make_unique<SentenceUnit>();
2092 sent_pt->m_ID = ID_X_pt->m_ID + "_turn_off";
2093 sent_pt->m_sentence_type = 1;
2094 sent_pt->m_subject_pt = ID_X_pt;
2095 sent_pt->m_process_pt = this->m_Concept_Base->getTurnOffPt();
2096 this->m_Semantic_list.push_back(std::move(sent_pt));
2097
2098 sent_pt = make_unique<SentenceUnit>();
2099 sent_pt->m_ID = ID_X_pt->m_ID + "_ON";
2100 sent_pt->m_sentence_type = 2;
2101 sent_pt->m_subject_pt = ID_X_pt;
2102 sent_pt->m_state_pt = this->m_Concept_Base->getONpt();
2103 this->m_Semantic_list.push_back(std::move(sent_pt));
2104
2105 sent_pt = make_unique<SentenceUnit>();
2106 sent_pt->m_ID = ID_X_pt->m_ID + "_OFF";
2107 sent_pt->m_sentence_type = 2;
2108 sent_pt->m_subject_pt = ID_X_pt;
2109 sent_pt->m_state_pt = this->m_Concept_Base->getOFFpt();
2110 this->m_Semantic_list.push_back(std::move(sent_pt));
2111 }
2112 }
2113
2114 //get the directory "Input\Crew\DecisionMaker\RM\KB_ODM_Semantic_Base.txt"
2115 if (this->m_operator == sim::Operator::ODM) {
2116 file_name = g_sim.SScheduler.getODMDirectory();
2117 file_name += "RM/";
2118 file_name += "KB_ODM_Semantic_Base.txt";
2119 } else if (this->m_operator == sim::Operator::OAT) {
2120 file_name = g_sim.SScheduler.getOATDirectory();
2121 file_name += "RM/";
2122 file_name += "KB_OAT_Semantic_Base.txt";
2123 } else {
2124 err_mes = "unable to identify operator type in ReasonMachine::ReadSemanticSentencesFromInputFile()";
2125 this->ErrorMessage(err_mes);
2126 return;
2127 }
2128
2129 //
2130 fin.open(file_name.c_str(), ios::in);
2131 if (!fin.is_open()) {
2132 err_mes = "could not open the file: " + file_name;
2133 this->ErrorMessage(err_mes);
2134 return;
2135 } else {
2136 //start to read this input file
2137
2138 //read type 1 semantic sentence. E.g. "PRZ_pres decrease"
2139 fin >> str >> n_Unit;
2140 if (str.compare("No_of_Type_1_Semantic_Sentences") != 0) {
2141 err_mes = "format error in " + file_name + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2142 err_mes += '\n';
2143 err_mes += "No_of_Type_1_Semantic_Sentences is not aligned";
2144 this->ErrorMessage(err_mes);
2145 return;
2146 }
2147 for (i = 0; i < n_Unit; i++) {
2148 sent_pt = make_unique<SentenceUnit>();
2149 fin >> str >> str_ID;
2150 if (this->SearchSentenceByID(str_ID) != NULL) {
2151 err_mes = "Sentence: " + str_ID + " already exists! use a different ID name!";
2152 this->ErrorMessage(err_mes);
2153 return;
2154 }
2155 sent_pt->m_ID = str_ID;
2156 sent_pt->m_sentence_type = 1;
2157
2158 //subject ID
2159 fin >> str;
2160 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2161 if (ID_pt == NULL) {
2162 err_mes = "can not find " + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2163 this->ErrorMessage(err_mes);
2164 return;
2165 } else { sent_pt->m_subject_pt = ID_pt; }
2166
2167 //process ID
2168 fin >> str;
2169 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2170 if (ID_pt == NULL) {
2171 err_mes = "can not find " + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2172 this->ErrorMessage(err_mes);
2173 return;
2174 } else {
2175 sent_pt->m_process_pt = ID_pt;
2176 }
2177 SentenceUnit *sent_raw = sent_pt.get();
2178 this->m_Semantic_list.push_back(std::move(sent_pt));
2179
2180 Inst_pt = this->m_IB->CheckExistanceOfInstantiationGroupByIndefiniteConceptName(sent_raw->m_subject_pt->m_ID);
2181 if (Inst_pt != NULL) {
2182 for (auto CC_itr = Inst_pt->m_instance_list.begin(); CC_itr != Inst_pt->m_instance_list.end(); CC_itr++) {
2183 sent2_pt = make_unique<SentenceUnit>();
2184 sent2_pt->CopyFromAnotherSentence(sent_raw);
2185 sent2_pt->m_subject_pt = (IDElement *) (*CC_itr);
2186 SentenceUnit *sent2_raw = sent2_pt.get();
2187 this->m_Semantic_list.push_back(std::move(sent2_pt));
2188 sent2_raw->m_ID = sent2_raw->m_subject_pt->m_ID + "_" + sent2_raw->m_process_pt->m_ID;
2189 }
2190 }
2191 }
2192
2193 //read type 2 semantic sentence, e.g. "AFWP ON"
2194 fin >> str >> n_Unit;
2195 if (str.compare("No_of_Type_2_Semantic_Sentences") != 0) {
2196 err_mes = "format error in " + file_name + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2197 err_mes += '\n';
2198 err_mes += "No_of_Type_2_Semantic_Sentences is not aligned";
2199 this->ErrorMessage(err_mes);
2200 return;
2201 }
2202 for (i = 0; i < n_Unit; i++) {
2203 sent_pt = make_unique<SentenceUnit>();
2204 fin >> str >> str_ID;
2205 if (this->SearchSentenceByID(str_ID) != NULL) {
2206 err_mes = "Sentence: " + str_ID + " already exists! use a different ID name!";
2207 this->ErrorMessage(err_mes);
2208 return;
2209 }
2210 sent_pt->m_ID = str_ID;
2211 sent_pt->m_sentence_type = 2;
2212
2213 //subject ID
2214 fin >> str;
2215 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2216 if (ID_pt == NULL) {
2217 err_mes = "can not find " + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2218 this->ErrorMessage(err_mes);
2219 return;
2220 } else { sent_pt->m_subject_pt = ID_pt; }
2221
2222 //state ID
2223 fin >> str;
2224 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2225 if (ID_pt == NULL) {
2226 err_mes = "can not find " + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2227 this->ErrorMessage(err_mes);
2228 return;
2229 } else { sent_pt->m_state_pt = ID_pt; }
2230 SentenceUnit *sent_raw = sent_pt.get();
2231 this->m_Semantic_list.push_back(std::move(sent_pt));
2232 Inst_pt = this->m_IB->CheckExistanceOfInstantiationGroupByIndefiniteConceptName(sent_raw->m_subject_pt->m_ID);
2233 if (Inst_pt != NULL) {
2234 for (auto CC_itr = Inst_pt->m_instance_list.begin(); CC_itr != Inst_pt->m_instance_list.end(); CC_itr++) {
2235 sent2_pt = make_unique<SentenceUnit>();
2236 sent2_pt->CopyFromAnotherSentence(sent_raw);
2237 sent2_pt->m_subject_pt = (IDElement *) (*CC_itr);
2238 sent2_pt->m_ID = sent2_pt->m_subject_pt->m_ID + "_" + sent2_pt->m_state_pt->m_ID;
2239 this->m_Semantic_list.push_back(std::move(sent2_pt));
2240 }
2241 }
2242 }
2243 //read type 3 semantic sentence, e.g. "PRZ_pres < 1800"
2244 fin >> str >> n_Unit;
2245 if (str.compare("No_of_Type_3_Semantic_Sentences") != 0) {
2246 err_mes = "format error in " + file_name + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2247 err_mes += '\n';
2248 err_mes += "No_of_Type_3_Semantic_Sentences is not aligned";
2249 this->ErrorMessage(err_mes);
2250 return;
2251 }
2252 for (i = 0; i < n_Unit; i++) {
2253 sent_pt = make_unique<SentenceUnit>();
2254 fin >> str >> str_ID;
2255 if (this->SearchSentenceByID(str_ID) != NULL) {
2256 err_mes = "Sentence: " + str_ID + " already exists! use a different ID name!";
2257 this->ErrorMessage(err_mes);
2258 return;
2259 }
2260 sent_pt->m_ID = str_ID;
2261 sent_pt->m_sentence_type = 3;
2262
2263 //subject ID
2264 fin >> str;
2265 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2266 if (ID_pt == NULL) {
2267 err_mes = "can not find " + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2268 this->ErrorMessage(err_mes);
2269 return;
2270 } else { sent_pt->m_subject_pt = ID_pt; }
2271
2272 //comparison ID
2273 fin >> str;
2274 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2275 if (ID_pt == NULL) {
2276 err_mes = "can not find " + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2277 this->ErrorMessage(err_mes);
2278 return;
2279 } else { sent_pt->m_comparison_pt = ID_pt; }
2280
2281 //value
2282 fin >> sent_pt->m_value;
2283 SentenceUnit *sent_raw = sent_pt.get();
2284 this->m_Semantic_list.push_back(std::move(sent_pt));
2285 Inst_pt = this->m_IB->CheckExistanceOfInstantiationGroupByIndefiniteConceptName(sent_raw->m_subject_pt->m_ID);
2286 if (Inst_pt != NULL) {
2287 for (auto CC_itr = Inst_pt->m_instance_list.begin(); CC_itr != Inst_pt->m_instance_list.end(); CC_itr++) {
2288 sent2_pt = make_unique<SentenceUnit>();
2289 sent2_pt->CopyFromAnotherSentence(sent_raw);
2290 sent2_pt->m_subject_pt = (IDElement *) (*CC_itr);
2291 conv.str("");
2292 conv << sent2_pt->m_value;
2293 sent2_pt->m_ID = sent2_pt->m_subject_pt->m_ID + "_" + sent2_pt->m_comparison_pt->m_ID + "_" + conv.str();
2294 this->m_Semantic_list.push_back(std::move(sent2_pt));
2295 }
2296 }
2297 }
2298
2299 //read type 4 semantic sentence, e.g. "SG_A_temp < PRZ_temp"
2300 fin >> str >> n_Unit;
2301 if (str.compare("No_of_Type_4_Semantic_Sentences") != 0) {
2302 err_mes = "format error in " + file_name + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2303 err_mes += '\n';
2304 err_mes += "No_of_Type_4_Semantic_Sentences is not aligned";
2305 this->ErrorMessage(err_mes);
2306 return;
2307 }
2308 for (i = 0; i < n_Unit; i++) {
2309 sent_pt = make_unique<SentenceUnit>();
2310 fin >> str >> str_ID;
2311 if (this->SearchSentenceByID(str_ID) != NULL) {
2312 err_mes = "Sentence: " + str_ID + " already existed!";
2313 this->ErrorMessage(err_mes);
2314 return;
2315 }
2316 sent_pt->m_ID = str_ID;
2317 sent_pt->m_sentence_type = 4;
2318
2319 //subject ID
2320 fin >> str;
2321 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2322 if (ID_pt == NULL) {
2323 err_mes = "can not find" + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2324 this->ErrorMessage(err_mes);
2325 return;
2326 } else { sent_pt->m_subject_pt = ID_pt; }
2327
2328 //comparison ID
2329 fin >> str;
2330 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2331 if (ID_pt == NULL) {
2332 err_mes = "can not find" + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2333 this->ErrorMessage(err_mes);
2334 return;
2335 } else { sent_pt->m_comparison_pt = ID_pt; }
2336
2337 //object ID
2338 fin >> str;
2339 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2340 if (ID_pt == NULL) {
2341 err_mes = "can not find " + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2342 this->ErrorMessage(err_mes);
2343 return;
2344 } else { sent_pt->m_object_pt = ID_pt; }
2345
2346 fin >> sent_pt->m_delta_value;
2347 SentenceUnit *sent_raw = sent_pt.get();
2348 this->m_Semantic_list.push_back(std::move(sent_pt));
2349
2350 Inst_pt = this->m_IB->CheckExistanceOfInstantiationGroupByIndefiniteConceptName(sent_raw->m_subject_pt->m_ID);
2351 Inst_obj_pt = this->m_IB->CheckExistanceOfInstantiationGroupByIndefiniteConceptName(sent_raw->m_object_pt->m_ID);
2352 if (Inst_pt != NULL && Inst_obj_pt == NULL) {
2353 for (auto CC_itr = Inst_pt->m_instance_list.begin(); CC_itr != Inst_pt->m_instance_list.end(); CC_itr++) {
2354 sent2_pt = make_unique<SentenceUnit>();
2355 sent2_pt->CopyFromAnotherSentence(sent_raw);
2356 sent2_pt->m_subject_pt = (IDElement *) (*CC_itr);
2357 sent2_pt->m_ID =
2358 sent2_pt->m_subject_pt->m_ID + "_" + sent2_pt->m_comparison_pt->m_ID + "_" + sent2_pt->m_object_pt->m_ID;
2359 this->m_Semantic_list.push_back(std::move(sent2_pt));
2360 }
2361 } else if (Inst_pt == NULL && Inst_obj_pt != NULL) {
2362 for (auto CC_obj_itr = Inst_obj_pt->m_instance_list.begin(); CC_obj_itr != Inst_obj_pt->m_instance_list.end();
2363 CC_obj_itr++) {
2364 sent2_pt = make_unique<SentenceUnit>();
2365 sent2_pt->CopyFromAnotherSentence(sent_raw);
2366 sent2_pt->m_object_pt = (IDElement *) (*CC_obj_itr);
2367 sent2_pt->m_ID =
2368 sent2_pt->m_subject_pt->m_ID + "_" + sent2_pt->m_comparison_pt->m_ID + "_" + sent2_pt->m_object_pt->m_ID;
2369 this->m_Semantic_list.push_back(std::move(sent2_pt));
2370 }
2371 } else if (Inst_pt != NULL && Inst_obj_pt != NULL) {
2372 if (Inst_pt->m_label_pt == Inst_obj_pt->m_label_pt) {
2373 for (auto CC_itr = Inst_pt->m_instance_list.begin(); CC_itr != Inst_pt->m_instance_list.end(); CC_itr++) {
2374 CC_pt = (ConceptComposedUnit *) (*CC_itr);
2375 sent2_pt = make_unique<SentenceUnit>();
2376 SentenceUnit *sent2_raw = sent2_pt.get();
2377 for (auto CC_obj_itr = Inst_obj_pt->m_instance_list.begin();
2378 CC_obj_itr != Inst_obj_pt->m_instance_list.end() && sent2_raw->m_object_pt == NULL; CC_obj_itr++) {
2379 CC_obj_pt = (ConceptComposedUnit *) (*CC_obj_itr);
2380 if (CC_pt->m_label_ID_pt == CC_obj_pt->m_label_ID_pt) {
2381 sent2_pt->CopyFromAnotherSentence(sent_raw);
2382 sent2_pt->m_subject_pt = (IDElement *) (*CC_itr);
2383 sent2_pt->m_object_pt = (IDElement *) (*CC_obj_itr);
2384 sent2_pt->m_ID = sent2_pt->m_subject_pt->m_ID + "_" + sent2_pt->m_comparison_pt->m_ID + "_"
2385 + sent2_pt->m_object_pt->m_ID;
2386 this->m_Semantic_list.push_back(std::move(sent2_pt));
2387 }
2388 }
2389 if (sent2_raw->m_object_pt == NULL) {
2390 err_mes = (*CC_itr)->m_ID + " could not find a matching objective in " + sent_raw->m_ID;
2391 }
2392 }
2393
2394 } else {
2395 for (auto CC_itr = Inst_pt->m_instance_list.begin(); CC_itr != Inst_pt->m_instance_list.end(); CC_itr++) {
2396 CC_pt = (ConceptComposedUnit *) (*CC_itr);
2397 for (auto CC_obj_itr = Inst_obj_pt->m_instance_list.begin(); CC_obj_itr != Inst_obj_pt->m_instance_list.end();
2398 CC_obj_itr++) {
2399 CC_obj_pt = (ConceptComposedUnit *) (*CC_obj_itr);
2400 sent2_pt = make_unique<SentenceUnit>();
2401 sent2_pt->CopyFromAnotherSentence(sent_raw);
2402 sent2_pt->m_subject_pt = (IDElement *) (*CC_itr);
2403 sent2_pt->m_object_pt = (IDElement *) (*CC_obj_itr);
2404 sent2_pt->m_ID = sent2_pt->m_subject_pt->m_ID + "_" + sent2_pt->m_comparison_pt->m_ID + "_"
2405 + sent2_pt->m_object_pt->m_ID;
2406 this->m_Semantic_list.push_back(std::move(sent2_pt));
2407 }
2408
2409 }
2410 }
2411 }
2412 }
2413
2414 //read type 5 semantic sentence, e.g. "SG_A ruptured"
2415 fin >> str >> n_Unit;
2416 if (str.compare("No_of_Type_5_Semantic_Sentences") != 0) {
2417 err_mes = "format error in " + file_name + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2418 err_mes += '\n';
2419 err_mes += "No_of_Type_5_Semantic_Sentences is not aligned";
2420 this->ErrorMessage(err_mes);
2421 return;
2422
2423 }
2424 for (i = 0; i < n_Unit; i++) {
2425 fin >> str >> str_ID;
2426 if (this->SearchSentenceByID(str_ID) != NULL) {
2427 err_mes = "Sentence: " + str_ID + " already exists! use a different ID name!";
2428 this->ErrorMessage(err_mes);
2429 return;
2430 }
2431 sent_pt = make_unique<SentenceUnit>();
2432 sent_pt->m_ID = str_ID;
2433 sent_pt->m_sentence_type = 5;
2434
2435 //subject ID
2436 fin >> str;
2437 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2438 if (ID_pt == NULL) {
2439 err_mes = "can not find" + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2440 this->ErrorMessage(err_mes);
2441 return;
2442 } else { sent_pt->m_subject_pt = ID_pt; }
2443
2444 //attributive ID
2445 fin >> str;
2446 ID_pt = this->m_Concept_Base->FindConceptByID(str);
2447 if (ID_pt == NULL) {
2448 err_mes = "can not find" + str + "Location: ReasonMachine::ReadSemanticSentencesFromInputFile()";
2449 this->ErrorMessage(err_mes);
2450 return;
2451 } else { sent_pt->m_attribute_pt = ID_pt; }
2452
2453 SentenceUnit *sent_raw = sent_pt.get();
2454 this->m_Semantic_list.push_back(std::move(sent_pt));
2455 Inst_pt = this->m_IB->CheckExistanceOfInstantiationGroupByIndefiniteConceptName(sent_raw->m_subject_pt->m_ID);
2456 if (Inst_pt != NULL) {
2457 for (auto CC_itr = Inst_pt->m_instance_list.begin(); CC_itr != Inst_pt->m_instance_list.end(); CC_itr++) {
2458 sent2_pt = make_unique<SentenceUnit>();
2459 sent2_pt->CopyFromAnotherSentence(sent_raw);
2460 sent2_pt->m_subject_pt = (IDElement *) (*CC_itr);
2461 sent2_pt->m_ID = sent2_pt->m_subject_pt->m_ID + "_" + sent2_pt->m_attribute_pt->m_ID;
2462 this->m_Semantic_list.push_back(std::move(sent2_pt));
2463 }
2464 }
2465 }
2466 }
2467 fin.close();
2468}
2469
2471 string directory, str, str1, file_name;
2472 string err_mes;
2473 ifstream fin;
2474 int n_Unit, i;
2475 KnowledgeUnit *KU_pt;
2476
2478
2479 //get the directory "Input\Crew\DecisionMaker\RM\KB_ODM_Knowledge_Unit_Base.txt"
2480 if (this->m_operator == sim::Operator::ODM) {
2481 file_name = g_sim.SScheduler.getODMDirectory();
2482 file_name += "RM/";
2483 file_name += "KB_ODM_Knowledge_Unit_Base.txt";
2484 } else if (this->m_operator == sim::Operator::OAT) {
2485 file_name = g_sim.SScheduler.getOATDirectory();
2486 file_name += "RM/";
2487 file_name += "KB_ODM_Knowledge_Unit_Base.txt";
2488 } else {} //error message, unable to identify the operator type in ReasonMachine::ReadSemanticSentencesFromInputFile()
2489
2490 //
2491 fin.open(file_name.c_str(), ios::in);
2492 if (!fin.is_open()) {
2493 err_mes = "could not open file: " + file_name;
2494 this->ErrorMessage(err_mes);
2495 return;
2496 } else {
2497 fin >> str >> n_Unit;
2498 if (str.compare("Number_of_Knowledge_Unit") != 0) {
2499 err_mes = "Missing line: Number_of_Knowledge_Unit";
2500 this->ErrorMessage(err_mes);
2501 return;
2502 }
2503 for (i = 0; i < n_Unit; i++) {
2504 auto KU_owned = make_unique<KnowledgeUnit>();
2505 KU_pt = KU_owned.get();
2506 KU_pt->m_operator = this->m_operator;
2508 if (this->FindKnowledgeUnitByID(KU_pt->m_ID) != NULL) {
2509 this->ErrorMessage(KU_pt->m_ID + " already exist!");
2510 return;
2511 }
2512 this->AddANewKnowledgeUnit(KU_owned.release());
2513 }
2514 }
2515 fin.close();
2516}
2517
2519 SentenceUnit *sent_pt;
2520 SentenceUnit *found_sent_pt = NULL;
2521
2522 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end() && found_sent_pt == NULL;
2523 sent_itr++) {
2524 sent_pt = sent_itr->get();
2525 if (sent_pt->m_ID == _ID) {
2526 found_sent_pt = sent_pt;
2527 }
2528 }
2529 return found_sent_pt;
2530}
2531
2532//DEL void ReasonMachine::PropagateActivationFromSemanticSentenceToConceptBase(SentenceUnit *)
2533//DEL {
2534//DEL
2535//DEL }
2536
2538 //decay of concept
2539 this->m_Concept_Base->ActivationDecayOfConcept(this->m_decay_lamda);
2540 //decay of semantic sentence
2541 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
2542 (*sent_itr)->ActivationDecay(this->m_decay_lamda);
2543 }
2544 //decay of statement
2545 for (auto statement_itr = this->m_Statement_list.begin(); statement_itr != this->m_Statement_list.end(); statement_itr++) {
2546 (*statement_itr)->ActivationDecay(this->m_decay_lamda);
2547 }
2548}
2549
2551 SentenceUnit *sent_pt;
2552 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
2553 sent_pt = sent_itr->get();
2555 }
2556
2557}
2558
2559//DEL void ReasonMachine::PropagateActivationFromSemanticSentenceToConceptUnit(SentenceUnit *)
2560//DEL {
2561//DEL
2562//DEL }
2563
2565
2566 if (_sent_pt->m_change_ratio == 1) { return; }
2567
2568 this->m_Concept_Base->SaveActivationToOldActivationVariable();
2569 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
2570 (*sent_itr)->m_old_activation = (*sent_itr)->m_activation;
2571 }
2572
2573 //top down activation propagation
2575 this->m_Concept_Base->PropagateActivationAmongConceptsTopDown();
2576
2577 //refill the ConceptComposedUnitUpdateList
2578 this->m_Concept_Base->FillTheConceptCompsedUnitUpdateList();
2579
2580 //bottom up activation propagation
2581 this->m_Concept_Base->PropagateActivationFromBasicConceptToComposedConcept();
2582 this->m_Concept_Base->PropagateActivationAmongComposedConceptBottomUp();
2583 this->m_Concept_Base->FillTheConceptCompsedUnitUpdateList();
2585
2586 //clean activation_change_ratio
2587 this->m_Concept_Base->SetAllConceptActivationChangeBackToOneAndCleanTheUpdateList();
2589}
2590
2592 double sum;
2593 sum = this->m_consumed_time
2595 if (sum > this->m_time_length) {
2596 this->m_consumed_time = this->m_time_length;
2597 this->m_timer_RM = sum - this->m_time_length;
2598 } else {
2599 this->m_consumed_time = sum;
2600 }
2601}
2602
2604 if (this->m_timer_RM == 0) { return; }
2605 if (this->m_timer_RM > (this->m_time_length - this->m_consumed_time)) {
2606 this->m_timer_RM -= (this->m_time_length - this->m_consumed_time);
2607 this->m_consumed_time = this->m_time_length;
2608 } else {
2609 this->m_consumed_time += this->m_timer_RM;
2610 this->m_timer_RM = 0;
2611 }
2612}
2613
2615 vector<MentalAlarm *>::iterator m_A_itr;
2616 IDElement *ID_pt;
2617 string indicator_name;
2618 string alarm_size;
2619 MentalAlarm *M_A_pt;
2620 bool found_expected_one = false;
2621 int keep_i = 0;
2622 int i = 0;
2623 string rm_aux_info;
2624 stringstream conv;
2625
2626 conv.str("");
2627 conv << this->m_tbi_A_list.size();
2628 alarm_size = conv.str();
2629
2630 m_A_itr = this->m_tbi_A_list.begin();
2631 //to be removed
2632 //if(this->m_problem_solving_style == HAMLET_B)
2633 //{return;}
2634 while (this->m_tbi_A_list.size() > this->m_max_length_of_alarms_stack) {
2635 //get alarm name
2636 //keep_i = 0;
2637 M_A_pt = *m_A_itr;
2638 indicator_name = M_A_pt->getAlarmName();
2639 if (indicator_name.empty() == true) {}//error message
2640 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
2641 if (ID_pt != NULL && ID_pt == this->m_reading_indication_ID_pt) {
2642 found_expected_one = true;
2643 keep_i++;
2644 } else {
2645 //write aux information
2646 rm_aux_info = "slipped information: ";
2647 rm_aux_info += (*m_A_itr)->getAlarmName();
2648 rm_aux_info += ": ";
2649 if ((*m_A_itr)->getObservedAlarmState() == sim::State::On) { rm_aux_info += "ON "; }
2650 else { rm_aux_info += "OFF "; }
2651 rm_aux_info += alarm_size;
2652 rm_aux_info += "/";
2653 conv.str("");
2654 conv << this->m_max_length_of_alarms_stack;
2655 rm_aux_info += conv.str();
2656
2657 this->WriteAuxInfo(rm_aux_info);
2658
2659 //erase this alarm information
2660 this->m_tbi_A_list.erase(m_A_itr);
2661 }
2662 m_A_itr = this->m_tbi_A_list.begin();
2663 if (found_expected_one == true) {
2664 if (this->m_tbi_A_list.size() == 1) { break; }
2665 for (i = 0; i < keep_i; i++) { m_A_itr++; }
2666 if (keep_i >= this->m_tbi_A_list.size()) { break; }
2667 }
2668 }
2669}
2670
2672 //activation propagation
2673 _statement_pt->m_activation = 1;
2674 _statement_pt->m_last_activated_time = r5pars_.timesno;
2675 this->CrankASentenceUnitActivationToAGivenValue(_statement_pt->m_sent_pt, 1.0);
2676}
2677
2679 string ID_name;
2680 stringstream conv;
2681 string prompt;
2682
2683 this->m_Statement_list.push_back(unique_ptr<Statement>(_statement_pt));
2684 this->AddDeltaToCognitiveLoad(0.04);
2685 //check point
2686 //if(_statement_pt->m_sent_pt->m_ID == "SG_C_level_>_SG_B_level" || _statement_pt->m_sent_pt->m_ID == "SG_C_level_>_SG_A_level" || _statement_pt->m_sent_pt->m_ID == "SG_A_NR_level_>_SG_B_NR_level" || _statement_pt->m_sent_pt->m_ID == "SG_A_WR_level_>_SG_B_WR_level")
2687 if (_statement_pt->m_sent_pt->m_ID == "SG_C_level_>_SG_B_level"
2688 || _statement_pt->m_sent_pt->m_ID == "SG_C_level_>_SG_A_level") {
2689 this->PrintMessage("Check point");
2690 }
2691 //
2692
2693 conv.str(""); // clean the conv
2694 conv << this->m_Statement_list.size();
2695 ID_name = "statement_" + conv.str();
2696 _statement_pt->m_ID = ID_name;
2697 _statement_pt->m_time_generated = r5pars_.timesno;
2698 _statement_pt->m_last_activated_time = r5pars_.timesno;
2699 _statement_pt->m_operator = this->m_operator;
2700
2701 //
2702 if (ID_name == "statement_2472") { this->PrintMessage("Check"); }
2703
2704
2705 //activation propagation
2706 _statement_pt->m_activation = 1;
2707 this->CrankASentenceUnitActivationToAGivenValue(_statement_pt->m_sent_pt, 1.0);
2708
2709 //print prompt
2710 prompt = "A new Statement is generated: ";
2711
2712 if (_statement_pt->m_sent_pt == NULL) {
2713 prompt = "A new state is NULL!";
2714 this->ErrorMessage(prompt);
2715 } else {
2716 prompt += _statement_pt->GetThisStatementWords();
2717 }
2718 this->PrintMessage(prompt);
2719
2720 this->MakeOneStepInferenceFromAStatement(_statement_pt);
2721}
2722
2724 string ID_name;
2725 stringstream conv;
2726 string prompt;
2727 string rm_aux_info;
2728
2729 this->m_investigator_pool.push_back(unique_ptr<Investigator>(_invest_pt));
2730 this->m_unresolved_investigator_pool.push_back(_invest_pt);
2731
2732 conv.str(""); // clean the conv
2733 conv << this->m_investigator_pool.size();
2734 ID_name = "Investigator_" + conv.str();
2735
2736 if (ID_name == "Investigator_159") { this->PrintMessage(""); }
2737 //check point
2738 /*if(_invest_pt->m_KElement_ID_pt != NULL)
2739 {
2740 if(_invest_pt->m_KElement_ID_pt->m_ID == "KE_MSI_OFF")
2741 {
2742 this->PrintMessage("check point");
2743 }
2744 }
2745 */
2746 _invest_pt->m_ID = ID_name;
2747 if (_invest_pt->m_Statement_pt != NULL) {
2749 }
2750 _invest_pt->m_investigation_initiate_time = r5pars_.timesno;
2751 _invest_pt->m_operator = this->m_operator;
2752
2753 prompt = "A new investigator is generated";
2754 cout << "Time: " << r5pars_.timesno << ": " << prompt << " ";
2755
2756 //test
2757 ofstream fout("RMI.txt", ios::app);
2758 fout << "Time: " << r5pars_.timesno << ": " << prompt << " ";
2759 fout.close();
2760
2761 if (_invest_pt->m_Statement_pt != NULL) {
2762 prompt = "To investigate this statement: ";
2763 cout << prompt << " ";
2764 ofstream fout("RMI.txt", ios::app);
2765 fout << prompt;
2766 fout.close();
2767
2768 _invest_pt->m_Statement_pt->PrintThisStatement();
2769 //check point
2770 if (_invest_pt->m_Statement_pt->m_sent_pt->m_ID == "power_increase") {
2771 this->PrintMessage("Check point");
2772 }
2773 } else {
2774 prompt = "To investigate this Knowledge Element: ";
2775 cout << prompt << _invest_pt->m_KElement_ID_pt->m_ID;
2776 ofstream fout("RMI.txt", ios::app);
2777 fout << prompt << _invest_pt->m_KElement_ID_pt->m_ID;
2778 fout.close();
2779 }
2780 //
2781 this->m_event_schema_base->AddNewSymptomCaseWithNewInvestigatorIfNecessary(_invest_pt);
2782
2783 if ((this->FindASimilarInvestigatorRecentlyResolved(_invest_pt) != NULL
2784 || this->FindASimilarOngoingInvestigator(_invest_pt) != NULL) && _invest_pt->m_active_investigation == false) {
2785 rm_aux_info = "Item forgotten: ";
2786 rm_aux_info += _invest_pt->m_ID;
2787 this->WriteAuxInfo(rm_aux_info);
2788 _invest_pt->m_investigation_closed = true;
2789 this->RemoveInvestigatorFromUnresolvedPool(_invest_pt);
2790 }
2791}
2792
2794 string prompt;
2795 int old_token = this->m_RM_Token;
2796 this->m_RM_Token_history.push_back(this->m_RM_Token);
2797 this->m_RM_token_endtime_history.push_back(r5pars_.timesno);
2798 this->m_RM_Token = _token;
2799
2800 //output text
2801 prompt = "The Token of Reasoning Module changed from ";
2802 prompt += this->TranslateRMTokenToWords(old_token);
2803 prompt += " to ";
2804 prompt += this->TranslateRMTokenToWords(_token);
2805 if (_token == rm::WorkOnInvestigator) {
2806 prompt += "\n";
2807 prompt += "now work on this investigator:\n";
2809 } else if (_token == rm::WorkOnInvestigatorLink) {
2810 prompt += "\n";
2811 prompt += "now work on this InvestigatorLink: \n";
2813 }
2814 this->PrintMessage(prompt);
2815}
2816
2818 vector<Investigator *>::iterator invest_itr;
2819 string prompt;
2820 bool found = false;
2821
2822 for (auto invest_itr = this->m_unresolved_investigator_pool.begin();
2823 invest_itr != this->m_unresolved_investigator_pool.end() && found == false; invest_itr++) {
2824 if ((*invest_itr) == _invest_pt) {
2825 found = true;
2826 this->m_unresolved_investigator_pool.erase(invest_itr);
2827 }
2828 }
2829}
2830
2832 string ID_name;
2833 stringstream conv;
2834
2835 this->m_investigator_link_pool.push_back(unique_ptr<InvestigatorLink>(_link_pt));
2836 conv.str(""); // clean the conv
2837 conv << this->m_investigator_link_pool.size();
2838 ID_name = "InvestigatorLink_" + conv.str();
2839 _link_pt->m_ID = ID_name;
2840 _link_pt->m_operator = this->m_operator;
2842 // check point
2843 if (_link_pt->m_K_unit_pt->m_ID == "KE_MFWP_X_trip_turn_on->KE_MFW_X_flow_decrease") {
2844 this->PrintMessage("Check point");
2845 }
2846}
2847
2849 ifstream fin;
2850 KnowledgeElement *KE_pt;
2851 KnowledgeNode *KN_pt;
2852 int i, n_unit;
2853 string str, ID_name;
2854 string file_name;
2855 string err_mes;
2856
2857 SentenceUnit *sent_pt;
2858
2859 //Create a true KE and a false KE for each sentence in the semantic pool
2860 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
2861 sent_pt = sent_itr->get();
2862 ID_name = "KE_" + sent_pt->m_ID;
2863 auto KE_owned = make_unique<KnowledgeElement>();
2864 KE_pt = KE_owned.get();
2865 KE_pt->m_operator = this->m_operator;
2866 KE_pt->m_ID = ID_name;
2867 KE_pt->m_negation = false;
2868 KE_pt->m_SentenceUnit_pt = sent_pt;
2869 this->m_KE_list.push_back(std::move(KE_owned));
2870 }
2871 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
2872 sent_pt = sent_itr->get();
2873 ID_name = "KE_FALSE_" + sent_pt->m_ID;
2874 auto KE_owned = make_unique<KnowledgeElement>();
2875 KE_pt = KE_owned.get();
2876 KE_pt->m_operator = this->m_operator;
2877 KE_pt->m_ID = ID_name;
2878 KE_pt->m_negation = true;
2879 KE_pt->m_SentenceUnit_pt = sent_pt;
2880 this->m_KE_list.push_back(std::move(KE_owned));
2881 }
2882
2883 //get the directory "Input\Crew\DecisionMaker\RM\KB_ODM_Knowledge_Unit_Base.txt"
2884 if (this->m_operator == sim::Operator::ODM) {
2885 file_name = g_sim.SScheduler.getODMDirectory();
2886 file_name += "RM/";
2887 file_name += "KB_ODM_Knowledge_Node_Base.txt";
2888 } else if (this->m_operator == sim::Operator::OAT) {
2889 file_name = g_sim.SScheduler.getOATDirectory();
2890 file_name += "RM/";
2891 file_name += "KB_ODM_Knowledge_Node_Base.txt";
2892 } else {} //error message, unable to identify the operator type in ReasonMachine::ReadSemanticSentencesFromInputFile()
2893
2894 fin.open(file_name.c_str(), ios::in);
2895 if (!fin.is_open()) {
2896 err_mes = "could not open file: " + file_name;
2897 this->ErrorMessage(err_mes);
2898 return;
2899 } else {
2900/*
2901 fin >> str >> n_unit;
2902 if(str.compare("Number_of_Knowledge_Element") != 0)
2903 {
2904 err_mes = "missing line: Number_of_Knowledge_Element";
2905 this->ErrorMessage(err_mes);
2906 return;
2907 }
2908
2909 for(i = 0; i < n_unit; i++)
2910 {
2911 KE_pt = new KnowledgeElement();
2912 KE_pt->m_operator = this->m_operator;
2913 KE_pt->ReadThisKEFromFile(fin);
2914 this->m_KE_list.push_back(unique_ptr<KnowledgeElement>(KE_pt));
2915 }
2916*/
2917 fin >> str >> n_unit;
2918 if (str.compare("Number_of_Knowledge_Node") != 0) {}//error message
2919
2920 for (i = 0; i < n_unit; i++) {
2921 auto KN_owned = make_unique<KnowledgeNode>();
2922 KN_pt = KN_owned.get();
2923 KN_pt->m_operator = this->m_operator;
2924 KN_pt->ReadThisKNinfoFromFile(fin);
2925 this->m_KN_list.push_back(std::move(KN_owned));
2926 }
2927 }
2928 fin.close();
2929}
2930
2932
2933 KnowledgeElement *found_KE_pt = NULL;
2934 for (auto KE_itr = this->m_KE_list.begin(); KE_itr != this->m_KE_list.end() && found_KE_pt == NULL; KE_itr++) {
2935 if ((*KE_itr)->m_ID == _ID_name) {
2936 found_KE_pt = KE_itr->get();
2937 }
2938 }
2939 return found_KE_pt;
2940}
2941
2943 KnowledgeNode *found_KN_pt = NULL;
2944
2945 for (auto KN_itr = this->m_KN_list.begin(); KN_itr != this->m_KN_list.end() && found_KN_pt == NULL; KN_itr++) {
2946 if ((*KN_itr)->m_ID == _ID_name) {
2947 found_KN_pt = KN_itr->get();
2948 }
2949 }
2950 return found_KN_pt;
2951}
2952
2954 this->m_MR->FirstRoundCheckOftheMR();
2955}
2956
2958 //Token 0020: Interpretation, preprocessing of the newly perceived information
2959 vector<MentalParameterValue *>::iterator M_P_itr;
2960 vector<MentalAlarm *>::iterator M_A_itr;
2961 vector<MentalComponentState *>::iterator M_C_itr;
2962 vector<MentalSupportSystemState *>::iterator M_SS_itr;
2963 MentalParameterValue *M_P_pt;
2964 MentalAlarm *M_A_pt;
2965 MentalComponentState *M_C_pt;
2966 MentalSupportSystemState *M_SS_pt;
2967 IDElement *ID_pt;
2968 MRParameterUnit *MR_P_pt;
2969 MRComponentStateUnit *MR_C_pt;
2970 MRSupportSystemStateUnit *MR_SS_pt;
2971 MRAlarmUnit *MR_A_pt;
2972 bool expecting_indication_bl = false;
2973
2974 string indicator_name;
2975
2976 for (M_A_itr = this->m_tbi_A_list.begin(); M_A_itr != this->m_tbi_A_list.end(); M_A_itr++) {
2977 M_A_pt = *M_A_itr;
2978 //get alarm name
2979 indicator_name = M_A_pt->getAlarmName();
2980 if (indicator_name.empty() == true) {
2981 cout << "Indicator name does not exist: " << indicator_name << endl;
2982 }//error message
2983
2984 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
2985 if (ID_pt != NULL) {//If there is a mapping on the Mental Representation, then interpret the alarm information
2986 if (ID_pt->m_ID_Type != 203) {//error message
2987 return;
2988 }
2989 MR_A_pt = (MRAlarmUnit *) ID_pt;
2991 }
2992 }
2993 this->m_tbi_A_list.clear();
2994
2995
2996 //*
2997 //Processing Parameters
2998 //*
2999
3000 for (M_P_itr = this->m_tbi_P_list.begin(); M_P_itr != this->m_tbi_P_list.end(); M_P_itr++) {
3001 M_P_pt = *M_P_itr;
3002 //get parameter name
3003 { indicator_name = M_P_pt->getDisplayName(); }
3004 if (indicator_name.empty() == true) {
3005 cout << "Indicator name does not exist: " << indicator_name << endl;
3006 }//error message
3007
3008 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
3009 if (ID_pt != NULL) {//interpret
3010 switch (ID_pt->m_ID_Type) {
3011 case 201: // it is a MRParameterUnit
3012 MR_P_pt = (MRParameterUnit *) ID_pt;
3013 if (MR_P_pt->m_parameter_indicator_ID == indicator_name) {
3015 } else if (MR_P_pt->m_parameter_rate_indicator_ID == indicator_name) {
3017 } else {}//error message
3019 break;
3020 case 202: // it is a MRComponentStateUnit
3021 // MR_C_pt = (MRComponentStateUnit *)ID_pt;
3022 // MR_C_pt->AddNewPositionValueForFirstRoundCheck(M_P_pt->getObservedParameterValue(), this->m_operator);
3023 break;
3024 default:
3025 //error message
3026 break;
3027 }
3028 }
3029 }
3030 this->m_tbi_P_list.clear();
3031
3032 //*
3033 //Processing Component States
3034 //*
3035 for (M_C_itr = this->m_tbi_C_list.begin(); M_C_itr != this->m_tbi_C_list.end(); M_C_itr++) {
3036 M_C_pt = *M_C_itr;
3037
3038 //get componentstate name
3039 { indicator_name = M_C_pt->getDisplayName(); }
3040 if (indicator_name.empty() == true) {}//error message
3041
3042 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
3043 if (ID_pt != NULL) {//interpret
3044 if (ID_pt->m_ID_Type != 202) {//error message
3045 return;
3046 }
3047 MR_C_pt = (MRComponentStateUnit *) ID_pt;
3049 }
3050 }
3051 this->m_tbi_C_list.clear();
3052
3053 //*
3054 //Processing Support System States
3055 //*
3056 for (M_SS_itr = this->m_tbi_SS_list.begin(); M_SS_itr != this->m_tbi_SS_list.end(); M_SS_itr++) {
3057 M_SS_pt = *M_SS_itr;
3058
3059 //get support system state name
3060 { indicator_name = M_SS_pt->getDisplayName(); }
3061 if (indicator_name.empty() == true) {}//error message
3062
3063 ID_pt = this->m_MR->CheckExistenceByIndicationName(indicator_name);
3064 if (ID_pt != NULL) {//interpret
3065 if (ID_pt->m_ID_Type != 202) {//error message
3066 return;
3067 }
3068 MR_SS_pt = (MRSupportSystemStateUnit *) ID_pt;
3070 }
3071 }
3072 this->m_tbi_SS_list.clear();
3073}
3074
3076 cout << r5pars_.timesno << " " << str << " in ReasonMachine.cpp" << '\n';
3077 ofstream fout("err messages.txt", ios::app);
3078 fout << r5pars_.timesno << " " << str << '\n';
3079 fout.close();
3080 //r5pars_.terminateall = true;
3081}
3082
3084 string ID_name;
3085 stringstream conv;
3086 this->m_Knowledge_list.push_back(unique_ptr<KnowledgeUnit>(_KU_pt));
3087
3088 conv.str(""); // clean the conv
3089 conv << this->m_Statement_list.size();
3090 ID_name = "KnowledgeUnit_" + conv.str();
3091 //_KU_pt->m_ID = ID_name;
3092}
3093
3095 cout << "Time: " << r5pars_.timesno << ": " << str << '\n';
3096
3097 //test
3098 ofstream fout("RMI.txt", ios::app);
3099 fout << "Time: " << r5pars_.timesno << ": " << str << '\n';
3100 fout.close();
3101
3102}
3104 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
3105 (*sent_itr)->m_change_ratio = 1;
3106 }
3107}
3108
3110 string str;
3111 switch (_token) {
3112 case rm::RoutineMonitor: str = "OneStepRoutineMonitor10";
3113 break;
3114 case rm::Prioritize: str = "OneStepPrioritizeInvestigation30";
3115 break;
3116 case rm::WorkOnInvestigator: str = "OneStepWorkOnSelectedInvestigator3000";
3117 break;
3118 case rm::WorkOnInvestigatorLink: str = "OneStepWorkOnSelectedInvestigatorLink3100";
3119 break;
3120 default:
3121 //error message, unexpected situation, check the m_RM_Token;
3122 str = "Unrecognized RM token!";
3123 break;
3124 }
3125 return str;
3126}
3127
3129 /*
3130 fout <<"\n" << "Time: " << r5pars_.timesno << ":\n" << str << '\n';
3131 fout.close();
3132 */
3133 string file_name;
3134 file_name = g_sim.SScheduler.getOutputDirectory();
3135 file_name += "RMOutPut/";
3136 file_name += "ODM_Semantic_Base.txt";
3137 ofstream fout(file_name.c_str(), ios::out);
3138 vector<SentenceUnit *>::iterator sent_itr;
3139 fout << "There are " << this->m_Semantic_list.size() << " sentences in total" << '\n';
3140 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
3141 fout << (*sent_itr)->m_ID << '\n';
3142 }
3143 fout.close();
3144
3145}
3146
3148 unique_ptr<SentenceUnit> sent_X_owned;
3149 SentenceUnit *sent_return_pt = NULL;
3150 ConceptComposedUnit *CC_pt;
3151 IDElement *sub_X_pt = NULL;
3152 IDElement *obj_X_pt = NULL;
3153 IDElement *sub_label_pt = NULL;
3154 IDElement *obj_label_pt = NULL;
3155 string err_mes;
3156
3157 if (_sent_pt->m_subject_pt->m_ID_Type == 002) {
3158 CC_pt = (ConceptComposedUnit *) (_sent_pt->m_subject_pt);
3159 sub_X_pt = CC_pt->m_Indefinite_Concept_ID_pt;
3160 sub_label_pt = CC_pt->m_label_ID_pt;
3161 }
3162 if (_sent_pt->m_object_pt != NULL) {
3163 if (_sent_pt->m_object_pt->m_ID_Type == 002) {
3164 CC_pt = (ConceptComposedUnit *) (_sent_pt->m_object_pt);
3165 obj_X_pt = CC_pt->m_Indefinite_Concept_ID_pt;
3166 obj_label_pt = CC_pt->m_label_ID_pt;
3167 }
3168 }
3169 if (sub_X_pt == NULL && obj_X_pt == NULL) {
3170 return NULL;
3171 }
3172 if (sub_label_pt != NULL && obj_label_pt != NULL && sub_label_pt != obj_label_pt) {
3173 err_mes = _sent_pt->m_ID + " belongs to two lable groups which is beyond the current source codes";
3174 this->ErrorMessage(err_mes);
3175 return NULL;
3176 }
3177 sent_X_owned = make_unique<SentenceUnit>();
3178 sent_X_owned->CopyFromAnotherSentence(_sent_pt);
3179 if (sub_X_pt != NULL) {
3180 sent_X_owned->m_subject_pt = (IDElement *) sub_X_pt;
3181 }
3182 if (obj_X_pt != NULL) {
3183 sent_X_owned->m_object_pt = (IDElement *) obj_X_pt;
3184 }
3185 sent_return_pt = this->CheckExistInSemanticPoolBySentence(sent_X_owned.get());
3186 if (sent_return_pt == NULL) {
3187 err_mes = "could not find a indefinite sentence for " + _sent_pt->m_ID;
3188 this->ErrorMessage(err_mes);
3189 return NULL;
3190 }
3191 return sent_return_pt;
3192
3193}
3194
3196 vector<KnowledgeElement *>::iterator KE_itr;
3197 KnowledgeElement *KE_found_pt = NULL;
3198 for (auto KE_itr = this->m_KE_list.begin(); KE_itr != this->m_KE_list.end() && KE_found_pt == NULL; KE_itr++) {
3199 if ((*KE_itr)->m_SentenceUnit_pt == _sent_pt && (*KE_itr)->m_negation == _Neg_bl) {
3200 KE_found_pt = KE_itr->get();
3201 }
3202 }
3203 return KE_found_pt;
3204}
3205
3207 SentenceUnit *sent_found_pt = NULL;
3208 SentenceUnit *instance_sent_pt;
3209 vector<Instantiation *>::iterator inst_itr;
3210 vector<ConceptComposedUnit *>::iterator CC_itr;
3211 bool change_bl = false;
3212 ConceptComposedUnit *CC_pt1 = NULL;
3213 ConceptComposedUnit *CC_pt2 = NULL;
3214
3215 if (sent_X_pt->m_subject_pt->m_ID_Type == 002) {
3216 CC_pt1 = (ConceptComposedUnit *) (sent_X_pt->m_subject_pt);
3217 }
3218 if (sent_X_pt->m_object_pt != 0) {
3219 if (sent_X_pt->m_object_pt->m_ID_Type == 002) {
3220 CC_pt2 = (ConceptComposedUnit *) (sent_X_pt->m_object_pt);
3221 }
3222 }
3223
3224 if (CC_pt1 == NULL && CC_pt2 == NULL) {
3225 return NULL;
3226 }
3227 SentenceUnit instance_sent;
3228 instance_sent.CopyFromAnotherSentence(sent_X_pt);
3229 for (auto inst_itr = this->m_IB->m_instantiation_list.begin(); inst_itr != this->m_IB->m_instantiation_list.end();
3230 inst_itr++) {
3231 if ((*inst_itr)->m_indefinite_instance_pt == CC_pt1) {
3232 change_bl = true;
3233 for (auto CC_itr = (*inst_itr)->m_instance_list.begin(); CC_itr != (*inst_itr)->m_instance_list.end(); CC_itr++) {
3234 if ((*CC_itr)->m_label_ID_pt == label_ID_pt)
3235 instance_sent.m_subject_pt = (IDElement *) (*CC_itr);
3236 }
3237 }
3238 if ((*inst_itr)->m_indefinite_instance_pt == CC_pt2) {
3239 change_bl = true;
3240 for (auto CC_itr = (*inst_itr)->m_instance_list.begin(); CC_itr != (*inst_itr)->m_instance_list.end(); CC_itr++) {
3241 if ((*CC_itr)->m_label_ID_pt == label_ID_pt)
3242 instance_sent.m_object_pt = (IDElement *) (*CC_itr);
3243 }
3244 }
3245 }
3246 if (change_bl == false) {
3247 return NULL;
3248 }
3249 sent_found_pt = this->CheckExistInSemanticPoolBySentence(&instance_sent);
3250 if (sent_found_pt == NULL) {
3251 this->ErrorMessage("could not find the instance sentence");
3252 return NULL;
3253 } else {
3254 return sent_found_pt;
3255 }
3256}
3257
3259 KnowledgeElement *KE_starting_pt;
3260 KnowledgeElement *KE_starting_X_pt = NULL;
3261 KnowledgeElement *KE_down_X_pt = NULL;
3262 KnowledgeElement *KE_pt;
3263 KnowledgeElement *KE_buffer_pt;
3264 KnowledgeNode *KN_pt;
3265 vector<KnowledgeElement *>::iterator KE_itr;
3266 Statement *new_statement_pt;
3267 SentenceUnit *sent_pt;
3268 IDElement *label_ID_pt;
3269 Label *label_group_pt;
3270 vector<IDElement *>::iterator ID_itr;
3271 Investigator *invest_pt;
3272 int match = 0;
3273
3274 KE_starting_pt = this->FindAKEbySentenceAndNegationSign(_statement_pt->m_sent_pt, !_statement_pt->m_state);
3275 if (KE_starting_pt == NULL) {
3276 return;
3277 }
3278
3280 if (sent_pt != NULL) {
3281 KE_starting_X_pt = this->FindAKEbySentenceAndNegationSign(sent_pt, KE_starting_pt->m_negation);
3282 label_ID_pt = _statement_pt->m_sent_pt->GetLabelOfThisSentence();
3283 }
3284 for (auto KU_itr = this->m_Knowledge_list.begin(); KU_itr != this->m_Knowledge_list.end(); KU_itr++) {
3285 if ((*KU_itr)->m_accessable_bl == false) { continue; }
3286
3287 //First check the upperstream of this KnowledgeUnit
3288
3289 if ((*KU_itr)->m_inference_type == 1 || (*KU_itr)->m_inference_type == 3) {
3290 match = 0;
3291 //0--not match
3292 //1--match witht the KE_starting_pt
3293 //2--match witht the KE_starting_X_pt
3294 if ((*KU_itr)->m_Ancestor_pt->m_ID_Type == 401) {
3295 KE_pt = (KnowledgeElement *) (*KU_itr)->m_Ancestor_pt;
3296 if (KE_pt == KE_starting_pt) {
3297 match = 1;
3298 } else if (KE_pt == KE_starting_X_pt) {
3299 match = 2;
3300 }
3301 } else if ((*KU_itr)->m_Ancestor_pt->m_ID_Type == 402) {
3302 KN_pt = (KnowledgeNode *) (*KU_itr)->m_Ancestor_pt;
3303 if (KN_pt->m_Node_Type == 3) {
3304 for (auto KE_itr = KN_pt->M_KElement_list.begin(); KE_itr != KN_pt->M_KElement_list.end(); KE_itr++) {
3305 if ((*KE_itr) == KE_starting_pt) {
3306 match = 1;
3307 }
3308 }
3309 }
3310 }
3311
3312 if (match == 1) {
3313 KE_buffer_pt = (KnowledgeElement *) ((*KU_itr)->m_Descendant_pt);
3314 label_group_pt = this->m_IB->CheckWhetherASentenceContainIndefiniteItem(KE_buffer_pt->m_SentenceUnit_pt);
3315 if (label_group_pt != NULL) {
3316 for (ID_itr = label_group_pt->m_label_option_list.begin();
3317 ID_itr != label_group_pt->m_label_option_list.end(); ID_itr++) {
3318 sent_pt = this->InstantiateAnIndefiniteSentenceWithLabel(KE_buffer_pt->m_SentenceUnit_pt, (*ID_itr));
3319 if (sent_pt == NULL) {
3320 this->ErrorMessage("Error!");
3321 return;
3322 }
3323 { auto stmt_owned = make_unique<Statement>();
3324 new_statement_pt = stmt_owned.get();
3325 if (_statement_pt->m_factual_type == 1 || _statement_pt->m_factual_type == 2) {
3326 new_statement_pt->m_factual_type = 2;
3327 } else { new_statement_pt->m_factual_type = 3; }
3328 new_statement_pt->m_sent_pt = sent_pt;
3329 new_statement_pt->m_state = !KE_buffer_pt->m_negation;
3330 new_statement_pt->m_time_generated = r5pars_.timesno;
3331 new_statement_pt->m_time_range.CopyTimeRangeFromAnother(_statement_pt->m_time_range);
3332 new_statement_pt->CopyAuxInfoFromUpperstreamStatement(_statement_pt);
3333 new_statement_pt->m_upperstream_statement_list.push_back(_statement_pt);
3334 this->AddANewStatement(stmt_owned.release()); }
3335 this->m_MR->UpdateMRwithNewInference(new_statement_pt);
3336 _statement_pt->m_downstream_statement_list.push_back(new_statement_pt);
3337
3338 if (this->FoundASimilarStatementInLast10Seconds(new_statement_pt) == NULL
3339 && this->FindAMatchingInvestigatorForAStatement(new_statement_pt) == false) {
3340 //add investigator for this new statement
3341 { auto invest_owned = make_unique<Investigator>();
3342 invest_pt = invest_owned.get();
3343 invest_pt->m_note = "by a statement";
3344 invest_pt->m_motivation = 1;
3345 invest_pt->m_Statement_pt = new_statement_pt;
3346 this->AddDeltaToCognitiveLoad(0.024); //type 4
3347 invest_pt->m_Happen = 3;
3348 invest_pt->m_operator = this->m_operator;
3349 invest_pt->m_root_of_a_thought_line = true;
3350 this->AddNewInvestigator(invest_owned.release());
3351 //link the statement to the statement pointer
3352 new_statement_pt->m_investigator_ID_pt = (IDElement *) invest_pt; }
3353 }
3354 }
3355 } else {
3356 { auto stmt_owned = make_unique<Statement>();
3357 new_statement_pt = stmt_owned.get();
3358 if (_statement_pt->m_factual_type == 1 || _statement_pt->m_factual_type == 2) {
3359 new_statement_pt->m_factual_type = 2;
3360 } else { new_statement_pt->m_factual_type = 3; }
3361 new_statement_pt->m_sent_pt = KE_buffer_pt->m_SentenceUnit_pt;
3362 new_statement_pt->m_state = !KE_buffer_pt->m_negation;
3363 new_statement_pt->m_time_generated = r5pars_.timesno;
3364 new_statement_pt->CopyAuxInfoFromUpperstreamStatement(_statement_pt);
3365 new_statement_pt->m_time_range.CopyTimeRangeFromAnother(_statement_pt->m_time_range);
3366 new_statement_pt->m_upperstream_statement_list.push_back(_statement_pt);
3367 _statement_pt->m_downstream_statement_list.push_back(new_statement_pt);
3368 this->AddANewStatement(stmt_owned.release()); }
3369 this->m_MR->UpdateMRwithNewInference(new_statement_pt);
3370
3371 if (this->FoundASimilarStatementInLast10Seconds(new_statement_pt) == NULL
3372 && this->FindAMatchingInvestigatorForAStatement(new_statement_pt) == false) {
3373 //add investigator for this new statement
3374 { auto invest_owned = make_unique<Investigator>();
3375 invest_pt = invest_owned.get();
3376 invest_pt->m_note = "by a statement";
3377 invest_pt->m_motivation = 1;
3378 invest_pt->m_Statement_pt = new_statement_pt;
3379 this->AddDeltaToCognitiveLoad(0.024); //type 4
3380 invest_pt->m_Happen = 3;
3381 invest_pt->m_operator = this->m_operator;
3382 invest_pt->m_root_of_a_thought_line = true;
3383 this->AddNewInvestigator(invest_owned.release());
3384 //link the statement to the statement pointer
3385 new_statement_pt->m_investigator_ID_pt = (IDElement *) invest_pt; }
3386 }
3387 }
3388 } else if (match == 2) {
3389 KE_buffer_pt = (KnowledgeElement *) (*KU_itr)->m_Descendant_pt;
3390 sent_pt = this->InstantiateAnIndefiniteSentenceWithLabel(KE_buffer_pt->m_SentenceUnit_pt, label_ID_pt);
3391 if (sent_pt == NULL) {
3392 sent_pt = KE_buffer_pt->m_SentenceUnit_pt;
3393 }
3394 { auto stmt_owned = make_unique<Statement>();
3395 new_statement_pt = stmt_owned.get();
3396 if (_statement_pt->m_factual_type == 1 || _statement_pt->m_factual_type == 2) {
3397 new_statement_pt->m_factual_type = 2;
3398 } else { new_statement_pt->m_factual_type = 3; }
3399 new_statement_pt->m_sent_pt = sent_pt;
3400 new_statement_pt->m_state = !KE_buffer_pt->m_negation;
3401 new_statement_pt->m_time_generated = r5pars_.timesno;
3402 new_statement_pt->CopyAuxInfoFromUpperstreamStatement(_statement_pt);
3403 new_statement_pt->m_time_range.CopyTimeRangeFromAnother(_statement_pt->m_time_range);
3404 new_statement_pt->m_upperstream_statement_list.push_back(_statement_pt);
3405 _statement_pt->m_downstream_statement_list.push_back(new_statement_pt);
3406 this->AddANewStatement(stmt_owned.release()); }
3407 this->m_MR->UpdateMRwithNewInference(new_statement_pt);
3408 //add investigator for this new statement
3409 if (this->FoundASimilarStatementInLast10Seconds(new_statement_pt) == NULL
3410 && this->FindAMatchingInvestigatorForAStatement(new_statement_pt) == false) {
3411 { auto invest_owned = make_unique<Investigator>();
3412 invest_pt = invest_owned.get();
3413 invest_pt->m_note = "by a statement";
3414 invest_pt->m_motivation = 1;
3415 invest_pt->m_Statement_pt = new_statement_pt;
3416 this->AddDeltaToCognitiveLoad(0.024); //type 4
3417 invest_pt->m_Happen = 3;
3418 invest_pt->m_operator = this->m_operator;
3419 invest_pt->m_root_of_a_thought_line = true;
3420 this->AddNewInvestigator(invest_owned.release());
3421 //link the statement to the statement pointer
3422 new_statement_pt->m_investigator_ID_pt = (IDElement *) invest_pt; }
3423 }
3424 }
3425 }
3426
3427 if ((*KU_itr)->m_inference_type == 2 || (*KU_itr)->m_inference_type == 3) {
3428 KE_pt = (KnowledgeElement *) (*KU_itr)->m_Descendant_pt;
3429
3430 //caution: the inference only applies to one to one, KnowledgeNode is not included in the reference mechanism.
3431 if ((*KU_itr)->m_Ancestor_pt->m_ID_Type == 401) {//upperstream is a knowledge element
3432 if (KE_pt == KE_starting_pt) {
3433 KE_buffer_pt = (KnowledgeElement *) (*KU_itr)->m_Ancestor_pt;
3434 label_group_pt = this->m_IB->CheckWhetherASentenceContainIndefiniteItem(KE_buffer_pt->m_SentenceUnit_pt);
3435 if (label_group_pt != NULL) {
3436 for (ID_itr = label_group_pt->m_label_option_list.begin();
3437 ID_itr != label_group_pt->m_label_option_list.end(); ID_itr++) {
3438 sent_pt = this->InstantiateAnIndefiniteSentenceWithLabel(KE_buffer_pt->m_SentenceUnit_pt, (*ID_itr));
3439 if (sent_pt == NULL) {
3440 this->ErrorMessage("Error!");
3441 return;
3442 }
3443 { auto stmt_owned = make_unique<Statement>();
3444 new_statement_pt = stmt_owned.get();
3445 if (_statement_pt->m_factual_type == 1 || _statement_pt->m_factual_type == 2) {
3446 new_statement_pt->m_factual_type = 2;
3447 } else { new_statement_pt->m_factual_type = 3; }
3448 new_statement_pt->m_sent_pt = sent_pt;
3449 new_statement_pt->m_state = !KE_buffer_pt->m_negation;
3450 new_statement_pt->m_time_generated = r5pars_.timesno;
3451 new_statement_pt->CopyAuxInfoFromUpperstreamStatement(_statement_pt);
3452 new_statement_pt->m_time_range.CopyTimeRangeFromAnother(_statement_pt->m_time_range);
3453 new_statement_pt->m_upperstream_statement_list.push_back(_statement_pt);
3454 _statement_pt->m_downstream_statement_list.push_back(new_statement_pt);
3455 this->AddANewStatement(stmt_owned.release()); }
3456 this->m_MR->UpdateMRwithNewInference(new_statement_pt);
3457 //add investigator for this new statement
3458 if (this->FoundASimilarStatementInLast10Seconds(new_statement_pt) == NULL
3459 && this->FindAMatchingInvestigatorForAStatement(new_statement_pt) == false) {
3460 { auto invest_owned = make_unique<Investigator>();
3461 invest_pt = invest_owned.get();
3462 invest_pt->m_note = "by a statement";
3463 invest_pt->m_motivation = 1;
3464 invest_pt->m_Statement_pt = new_statement_pt;
3465 this->AddDeltaToCognitiveLoad(0.024); //type 4
3466 invest_pt->m_Happen = 3;
3467 invest_pt->m_operator = this->m_operator;
3468 invest_pt->m_root_of_a_thought_line = true;
3469 this->AddNewInvestigator(invest_owned.release());
3470 //link the statement to the statement pointer
3471 new_statement_pt->m_investigator_ID_pt = (IDElement *) invest_pt; }
3472 }
3473 }
3474 } else {
3475 { auto stmt_owned = make_unique<Statement>();
3476 new_statement_pt = stmt_owned.get();
3477 if (_statement_pt->m_factual_type == 1 || _statement_pt->m_factual_type == 2) {
3478 new_statement_pt->m_factual_type = 2;
3479 } else { new_statement_pt->m_factual_type = 3; }
3480 new_statement_pt->m_sent_pt = KE_buffer_pt->m_SentenceUnit_pt;
3481 new_statement_pt->m_state = !KE_buffer_pt->m_negation;
3482 new_statement_pt->m_time_generated = r5pars_.timesno;
3483 new_statement_pt->CopyAuxInfoFromUpperstreamStatement(_statement_pt);
3484 new_statement_pt->m_time_range.CopyTimeRangeFromAnother(_statement_pt->m_time_range);
3485 new_statement_pt->m_upperstream_statement_list.push_back(_statement_pt);
3486 _statement_pt->m_downstream_statement_list.push_back(new_statement_pt);
3487 this->AddANewStatement(stmt_owned.release()); }
3488 this->m_MR->UpdateMRwithNewInference(new_statement_pt);
3489 //add investigator for this new statement
3490 if (this->FoundASimilarStatementInLast10Seconds(new_statement_pt) == NULL
3491 && this->FindAMatchingInvestigatorForAStatement(new_statement_pt) == false) {
3492 { auto invest_owned = make_unique<Investigator>();
3493 invest_pt = invest_owned.get();
3494 invest_pt->m_note = "by a statement";
3495 invest_pt->m_motivation = 1;
3496 invest_pt->m_Statement_pt = new_statement_pt;
3497 this->AddDeltaToCognitiveLoad(0.024); //type 4
3498 invest_pt->m_Happen = 3;
3499 invest_pt->m_operator = this->m_operator;
3500 invest_pt->m_root_of_a_thought_line = true;
3501 this->AddNewInvestigator(invest_owned.release());
3502 //link the statement to the statement pointer
3503 new_statement_pt->m_investigator_ID_pt = (IDElement *) invest_pt; }
3504 }
3505 }
3506 } else if (KE_pt == KE_starting_X_pt) {
3507 KE_buffer_pt = (KnowledgeElement *) (*KU_itr)->m_Ancestor_pt;
3508 sent_pt = this->InstantiateAnIndefiniteSentenceWithLabel(KE_buffer_pt->m_SentenceUnit_pt, label_ID_pt);
3509 if (sent_pt == NULL) {
3510 sent_pt = KE_buffer_pt->m_SentenceUnit_pt;
3511 }
3512 { auto stmt_owned = make_unique<Statement>();
3513 new_statement_pt = stmt_owned.get();
3514 if (_statement_pt->m_factual_type == 1 || _statement_pt->m_factual_type == 2) {
3515 new_statement_pt->m_factual_type = 2;
3516 } else { new_statement_pt->m_factual_type = 3; }
3517 new_statement_pt->m_sent_pt = sent_pt;
3518 new_statement_pt->m_state = !KE_buffer_pt->m_negation;
3519 new_statement_pt->m_time_generated = r5pars_.timesno;
3520 new_statement_pt->CopyAuxInfoFromUpperstreamStatement(_statement_pt);
3521 new_statement_pt->m_time_range.CopyTimeRangeFromAnother(_statement_pt->m_time_range);
3522 new_statement_pt->m_upperstream_statement_list.push_back(_statement_pt);
3523 _statement_pt->m_downstream_statement_list.push_back(new_statement_pt);
3524 this->AddANewStatement(stmt_owned.release()); }
3525 this->m_MR->UpdateMRwithNewInference(new_statement_pt);
3526 //add investigator for this new statement
3527 {
3528 auto invest_owned = make_unique<Investigator>();
3529 invest_pt = invest_owned.get();
3530 invest_pt->m_note = "by a statement";
3531 invest_pt->m_motivation = 1;
3532 invest_pt->m_Statement_pt = new_statement_pt;
3533 this->AddDeltaToCognitiveLoad(0.024); //type 4
3534 invest_pt->m_Happen = 3;
3535 invest_pt->m_operator = this->m_operator;
3536 invest_pt->m_root_of_a_thought_line = true;
3537 this->AddNewInvestigator(invest_owned.release());
3538 //link the statement to the statement pointer
3539 new_statement_pt->m_investigator_ID_pt = (IDElement *) invest_pt;
3540 }
3541 }
3542 } else if ((*KU_itr)->m_Ancestor_pt->m_ID_Type == 402) {// upperstream is a knowledge node
3543 }
3544 }
3545 }
3546
3547}
3548
3550 string dir_path, statement_path, invest_path, MR_path, esb_path, link_path, history_path, dynamic_path,
3551 thought_line_path, activation_path;
3552 stringstream conv;
3553
3554 //get the output file directory
3556 conv.str("");
3557 conv << es_id;
3558
3559 dir_path = g_sim.SScheduler.getOutputDirectory();
3560 dir_path += "RMOutPut/";
3561 statement_path = dir_path + "ODM_statements_" + conv.str() + ".txt";
3562 invest_path = dir_path + "ODM_investigations_" + conv.str() + ".txt";
3563 MR_path = dir_path + "ODM_MentalRepresentation_" + conv.str() + ".txt";
3564 esb_path = dir_path + "ODM_DiagnoseInvestigation_" + conv.str() + ".txt";
3565 link_path = dir_path + "ODM_InvestigationLink_" + conv.str() + ".txt";
3566 history_path = dir_path + "ODM_History_" + conv.str() + ".txt";
3567 dynamic_path = dir_path + "ODM_PSF_Dynamic_Parameter_History_" + conv.str() + ".txt";
3568 thought_line_path = dir_path + "ODM_thougt_line_history_" + conv.str() + ".txt";
3569 //activation_path = "C://ADS//examples//Beaver_Valley_benchmark//Output//KPS//KPSFolder_0//";
3570 //activation_path += "ZKPS_" + conv.str() + ".txt";
3571 activation_path = dir_path + "ODM_Activation_" + conv.str() + ".txt";
3572
3573 this->SaveStatementsToFile(statement_path);
3574 this->SaveInvestigationsToFile(invest_path);
3575 this->SaveInvestigationLinkInfo(link_path);
3576 this->SaveRMHisoty(history_path);
3577 this->SaveThoughtLineHistory(thought_line_path);
3578 this->m_MR->SaveMentalRepresentationInforToFile(MR_path);
3579 this->m_event_schema_base->SaveAllDiagnoseInvestigatorInforToFile(esb_path);
3580 this->SavePSFandDynamicParametersToFile(dynamic_path);
3581 this->m_Concept_Base->SaveConceptActivationIntoOutputFile(activation_path);
3582}
3583
3585 vector<Statement *>::iterator statement_itr;
3586 Statement *statement_pt;
3587
3588 ofstream fout(_path.c_str(), ios::out);
3589 for (auto statement_itr = this->m_Statement_list.begin(); statement_itr != this->m_Statement_list.end(); statement_itr++) {
3590 statement_pt = statement_itr->get();
3591 fout
3592 << statement_pt->m_ID << '\t'
3593 << statement_pt->m_time_generated << '\t'
3594 << statement_pt->m_sent_pt->m_ID << '\t';
3595 if (statement_pt->m_state == true) {
3596 fout << "true" << '\t';
3597 } else {
3598 fout << "false" << '\t';
3599 }
3600
3601 fout << "confidence: " << statement_pt->m_confidence << '\t';
3602
3603 if (statement_pt->m_time_range.m_start_time != 0) {
3604 fout << "<" << statement_pt->m_time_range.m_start_time << " , ";
3605 } else {
3606 fout << "(" << statement_pt->m_time_range.m_time_after << " , ";
3607 }
3608 if (statement_pt->m_time_range.m_end_time != 0) {
3609 fout << statement_pt->m_time_range.m_end_time << ">";
3610 } else {
3611 fout << statement_pt->m_time_range.m_time_before << ")";
3612 }
3613 fout << '\n';
3614 }
3615 fout.close();
3616}
3617
3619 vector<Investigator *>::iterator invest_itr;
3620 Investigator *invest_pt;
3621 Investigator *invest_buffer_pt;
3622 InvestigatorLink *invest_link_pt;
3623 KnowledgeElement *KE_pt;
3624 vector<int>::iterator token_itr;
3625 vector<IDElement *>::iterator link_ID_itr;
3626 vector<IDElement *>::iterator invest_ID_itr;
3627 vector<float>::iterator fl_itr;
3628
3629 ofstream fout(_path.c_str(), ios::out);
3630
3631
3632 //Add the header line
3633 fout
3634 << "Investigator ID" << '\t'
3635 << "Is a Root" << '\t'
3636 << "Statement Info" << '\t'
3637 << "KnowledgeElement Info" << '\t'
3638 << "Happen or Not" << '\t'
3639 << "Explained or Not" << '\t'
3640 << "Investigator Token history" << '\t'
3641 << "Upperstream Investigators" << '\t'
3642 << "Derived by" << '\t'
3643 << "investigation initiate time" << '\t'
3644 << "investigation cease time" << '\t'
3645 << "Dormant or Not" << '\t'
3646 << "Link to SymptomInvestigator" << '\t'
3647 << "Open status" << '\n';
3648
3649 for (auto invest_itr = this->m_investigator_pool.begin(); invest_itr != this->m_investigator_pool.end(); invest_itr++) {
3650 invest_pt = invest_itr->get();
3651 //if(invest_pt->m_invest_dormant == true)
3652 //{continue;}
3653 //ID
3654 fout << invest_pt->m_ID << '\t';
3655 //Is it the first one in the thread
3656 if (invest_pt->m_downstream_ID_list.size() == 0 || invest_pt->m_motivation == 1) {
3657 fout << "Origin" << '\t';
3658 } else {
3659 fout << "Derived" << '\t';
3660 }
3661 //statement info
3662 if (invest_pt->m_Statement_pt != NULL) {
3663 fout << invest_pt->m_Statement_pt->m_ID << ": ";
3664 fout << invest_pt->m_Statement_pt->m_sent_pt->m_ID << " ";
3665 if (invest_pt->m_Statement_pt->m_state == true) {
3666 //fout << "true ";
3667 } else {
3668 fout << "false ";
3669 }
3670 } else if (invest_pt->m_possible_statement_pt != NULL) {
3671 fout << invest_pt->m_possible_statement_pt->m_ID << ": ";
3672 fout << invest_pt->m_possible_statement_pt->m_sent_pt->m_ID << " ";
3673 if (invest_pt->m_possible_statement_pt->m_state == true) {
3674 //fout << "true ";
3675 } else {
3676 fout << "false ";
3677 }
3678 } else if (invest_pt->m_inconsistant_statement != NULL) {
3679 fout << invest_pt->m_inconsistant_statement->m_ID << ": ";
3680 fout << invest_pt->m_inconsistant_statement->m_sent_pt->m_ID << " ";
3681 if (invest_pt->m_inconsistant_statement->m_state == true) {
3682 //fout << "true ";
3683 } else {
3684 fout << "false ";
3685 }
3686 }
3687 fout << '\t';
3688
3689 //KnoweldgeElement Info
3690 if (invest_pt->m_KElement_ID_pt != NULL) {
3691 KE_pt = (KnowledgeElement *) invest_pt->m_KElement_ID_pt;
3692 fout << KE_pt->m_SentenceUnit_pt->m_ID << " ";
3693 if (KE_pt->m_negation == false) {
3694 //fout << " true ";
3695 } else {
3696 fout << " false ";
3697 }
3698 fout << "(" << invest_pt->m_effective_start;
3699 fout << " , ";
3700 fout << invest_pt->m_effective_end << ")";
3701 }
3702 fout << '\t';
3703
3704 //Happen of Not?
3705 switch (invest_pt->m_Happen) {
3706 case 1: fout << "?";
3707 break;
3708 case 2: fout << "U";
3709 break;
3710 case 3: fout << "Yes";
3711 break;
3712 case 4: fout << "No";
3713 break;
3714 }
3715 fout << '\t';
3716
3717 //Explained or Not?
3718 switch (invest_pt->m_explained) {
3719 case 1: fout << "?";
3720 break;
3721 case 2: fout << "U";
3722 break;
3723 case 3: fout << "Succeeded";
3724 break;
3725 case 4: fout << "Failed";
3726 break;
3727 default: break;
3728 }
3729 fout << '\t';
3730 // to be added, the explanation information
3731 /*if(invest_pt->m_explanation_link_list.size() > 0)
3732 {
3733 invest_link_pt = (InvestigatorLink *)(*invest_pt->m_explanation_link_list.begin());
3734 fout << (*invest_link_pt->m_upperstream_ID_list.begin())->m_ID ;
3735 }
3736 fout << '\t';*/
3737 fl_itr = invest_pt->m_invest_token_endtime_history.begin();
3738 for (token_itr = invest_pt->m_investigator_token_history.begin();
3739 token_itr != invest_pt->m_investigator_token_history.end(); token_itr++) {
3740 fout << "(" << (*token_itr) << "-" << (*fl_itr) << ") ";
3741 fl_itr++;
3742 }
3743
3744 fout << invest_pt->m_investigator_token;
3745 fout << '\t';
3746
3747 for (link_ID_itr = invest_pt->m_upperstream_ID_list.begin(); link_ID_itr != invest_pt->m_upperstream_ID_list.end();
3748 link_ID_itr++) {
3749 invest_link_pt = (InvestigatorLink *) (*link_ID_itr);
3750 for (invest_ID_itr = invest_link_pt->m_upperstream_ID_list.begin();
3751 invest_ID_itr != invest_link_pt->m_upperstream_ID_list.end(); invest_ID_itr++) {
3752 invest_buffer_pt = (Investigator *) (*invest_ID_itr);
3753 fout << (*invest_ID_itr)->m_ID << ": " << invest_buffer_pt->m_Happen;
3754 }
3755 }
3756 fout << '\t';
3757 fout << invest_pt->m_note;
3758 fout << '\t';
3759 fout << invest_pt->m_investigation_initiate_time << '\t';
3760 fout << invest_pt->m_investigation_cease_time << '\t';
3761 fout << invest_pt->m_invest_dormant << '\t';
3762 if (invest_pt->m_SI_ID_pt != NULL) { fout << invest_pt->m_SI_ID_pt->m_ID; }
3763 else { fout << "NONE"; }
3764 if (invest_pt->m_investigation_closed == true) { fout << "closed"; }
3765 else { fout << "open"; }
3766 fout << '\n';
3767 }
3768 fout.close();
3769}
3770
3772 KnowledgeUnit *KU_found_pt = NULL;
3773 for (auto KU_itr = this->m_Knowledge_list.begin(); KU_itr != this->m_Knowledge_list.end() && KU_found_pt == NULL;
3774 KU_itr++) {
3775 if ((*KU_itr)->m_ID == str_ID) {
3776 KU_found_pt = KU_itr->get();
3777 }
3778 }
3779 return KU_found_pt;
3780}
3781
3783
3784}
3785
3787 vector<Investigator *>::iterator invest_itr;
3788 vector<InvestigatorLink *>::iterator invest_link_itr;
3789
3790 for (auto invest_itr = this->m_unresolved_investigator_pool.begin();
3791 invest_itr != this->m_unresolved_investigator_pool.end(); invest_itr++) {
3792 (*invest_itr)->m_interest_from_SymptomInvestigator = 0;
3793 }
3794 for (auto invest_link_itr = this->m_investigator_link_pool.begin();
3795 invest_link_itr != this->m_investigator_link_pool.end(); invest_link_itr++) {
3796 (*invest_link_itr)->m_interest_from_SymptomInvestigator = 0;
3797 }
3798}
3799
3802 if (this->m_consumed_time < this->m_time_length) {
3803 this->m_consumed_time = this->m_time_length;
3804 }
3805 return;
3806}
3807
3809
3810 /*
3811 StringTimeIntervalUnit * m_current_thought_line_info;
3812 vector<StringTimeIntervalUnit *> m_thought_line_history;
3813
3814 StringTimeIntervalUnit * m_current_investigation_info;
3815 vector<StringTimeIntervalUnit *> m_investigation_history;
3816
3817 //float m_ability_of_integrating_evidence;
3818 */
3819 StringTimeIntervalUnit *info_pt;
3820
3821 if (_RM_pt->m_current_thought_line_info != nullptr) {
3822 this->m_current_thought_line_info = make_unique<StringTimeIntervalUnit>();
3823 this->m_current_thought_line_info->CopyFromAnotherStringTimeIntervalUnit(_RM_pt->m_current_thought_line_info.get());
3824 }
3825 if (_RM_pt->m_current_investigation_info != nullptr) {
3826 this->m_current_investigation_info = make_unique<StringTimeIntervalUnit>();
3827 this->m_current_investigation_info->CopyFromAnotherStringTimeIntervalUnit(_RM_pt->m_current_investigation_info.get());
3828 }
3829
3830 if (this->m_investigation_history.size() != 0) {
3831 this->ErrorMessage("this->m_investigation_history.size() != 0");
3832 return;
3833 }
3834 if (this->m_thought_line_history.size() != 0) {
3835 this->ErrorMessage("this->m_thought_line_history.size() != 0");
3836 return;
3837 }
3838
3839 for (auto info_itr = _RM_pt->m_investigation_history.begin(); info_itr != _RM_pt->m_investigation_history.end();
3840 info_itr++) {
3841 auto info_owned = make_unique<StringTimeIntervalUnit>();
3842 info_owned->CopyFromAnotherStringTimeIntervalUnit(info_itr->get());
3843 this->m_investigation_history.push_back(std::move(info_owned));
3844 }
3845
3846 for (auto info_itr = _RM_pt->m_thought_line_history.begin(); info_itr != _RM_pt->m_thought_line_history.end();
3847 info_itr++) {
3848 auto info_owned = make_unique<StringTimeIntervalUnit>();
3849 info_owned->CopyFromAnotherStringTimeIntervalUnit(info_itr->get());
3850 this->m_thought_line_history.push_back(std::move(info_owned));
3851 }
3852
3853
3854 //firstly, copy the short variables
3856 this->m_block_alarm_jam = _RM_pt->m_block_alarm_jam;
3857 this->m_consumed_time = _RM_pt->m_consumed_time;
3859 this->m_decay_lamda = _RM_pt->m_decay_lamda;
3862 this->m_leisure_time = _RM_pt->m_leisure_time;
3864 this->m_operator = _RM_pt->m_operator;
3865 this->m_RM_Token = _RM_pt->m_RM_Token;
3866 this->m_time_length = _RM_pt->m_time_length;
3867 this->m_timer_RM = _RM_pt->m_timer_RM;
3869 this->m_proximity = make_unique<ProximityModel>();
3870 this->m_proximity->CopyProximityModelFromAnother(_RM_pt->m_proximity.get());
3872 this->m_attention_span = _RM_pt->m_attention_span;
3873 this->m_memory_span = _RM_pt->m_memory_span;
3874 this->m_interuptiveness = _RM_pt->m_interuptiveness;
3875 this->m_goofy_start_time = _RM_pt->m_goofy_start_time;
3876
3878 this->m_fatigue_level = _RM_pt->m_fatigue_level;
3880 this->m_expert_level = _RM_pt->m_expert_level;
3881 this->m_cognitive_load = _RM_pt->m_cognitive_load;
3882 this->m_overall_stress = _RM_pt->m_overall_stress;
3884
3892 this->m_decay_time = _RM_pt->m_decay_time;
3893
3894
3895 // moderate complex variables
3896 //this->m_RM_Token_history
3897 vector<int>::iterator i_itr;
3898 vector<float>::iterator fl_itr;
3899 for (i_itr = _RM_pt->m_RM_Token_history.begin(); i_itr != _RM_pt->m_RM_Token_history.end(); i_itr++) {
3900 this->m_RM_Token_history.push_back(*i_itr);
3901 }
3902 for (fl_itr = _RM_pt->m_RM_token_endtime_history.begin(); fl_itr != _RM_pt->m_RM_token_endtime_history.end();
3903 fl_itr++) {
3904 this->m_RM_token_endtime_history.push_back(*fl_itr);
3905 }
3906/*
3907 vector<ValueTimeLineUnit *> m_max_alarm_length_timeline;
3908 vector<ValueTimeLineUnit *> m_cognitive_time_cost_multiplier_timeline;*/
3909 vector<ValueTimeLineUnit *>::iterator v_itr;
3910 ValueTimeLineUnit *v_pt;
3911
3912 if (this->m_max_alarm_length_timeline.size()
3913 > 0) { this->ErrorMessage("this->m_max_alarm_length_timeline.size() > 0"); }
3914 if (this->m_cognitive_time_cost_multiplier_timeline.size() > 0) {
3915 this->ErrorMessage("this->m_max_alarm_length_timeline.size() > 0");
3916 }
3917
3918 //PSF history
3919
3920 for (auto v_itr = _RM_pt->m_time_load_history.begin(); v_itr != _RM_pt->m_time_load_history.end(); v_itr++) {
3921 auto v_owned = make_unique<ValueTimeLineUnit>();
3922 v_owned->CopyFromAnotherVTLU(v_itr->get());
3923 this->m_time_load_history.push_back(std::move(v_owned));
3924 }
3925 for (auto v_itr = _RM_pt->m_fatigue_history.begin(); v_itr != _RM_pt->m_fatigue_history.end(); v_itr++) {
3926 auto v_owned = make_unique<ValueTimeLineUnit>();
3927 v_owned->CopyFromAnotherVTLU(v_itr->get());
3928 this->m_fatigue_history.push_back(std::move(v_owned));
3929 }
3930 for (auto v_itr = _RM_pt->m_diagnosis_complexity_history.begin(); v_itr != _RM_pt->m_diagnosis_complexity_history.end();
3931 v_itr++) {
3932 auto v_owned = make_unique<ValueTimeLineUnit>();
3933 v_owned->CopyFromAnotherVTLU(v_itr->get());
3934 this->m_diagnosis_complexity_history.push_back(std::move(v_owned));
3935 }
3936 for (auto v_itr = _RM_pt->m_cognitive_load_history.begin(); v_itr != _RM_pt->m_cognitive_load_history.end(); v_itr++) {
3937 auto v_owned = make_unique<ValueTimeLineUnit>();
3938 v_owned->CopyFromAnotherVTLU(v_itr->get());
3939 this->m_cognitive_load_history.push_back(std::move(v_owned));
3940 }
3941 for (auto v_itr = _RM_pt->m_stress_history.begin(); v_itr != _RM_pt->m_stress_history.end(); v_itr++) {
3942 auto v_owned = make_unique<ValueTimeLineUnit>();
3943 v_owned->CopyFromAnotherVTLU(v_itr->get());
3944 this->m_stress_history.push_back(std::move(v_owned));
3945 }
3946//manifestation parameters
3947 for (auto v_itr = _RM_pt->m_cognitive_resouse_use_history.begin(); v_itr != _RM_pt->m_cognitive_resouse_use_history.end();
3948 v_itr++) {
3949 auto v_owned = make_unique<ValueTimeLineUnit>();
3950 v_owned->CopyFromAnotherVTLU(v_itr->get());
3951 this->m_cognitive_resouse_use_history.push_back(std::move(v_owned));
3952 }
3953
3954 for (auto v_itr = _RM_pt->m_routine_monitor_interval_multiplier_history.begin();
3955 v_itr != _RM_pt->m_routine_monitor_interval_multiplier_history.end(); v_itr++) {
3956 auto v_owned = make_unique<ValueTimeLineUnit>();
3957 v_owned->CopyFromAnotherVTLU(v_itr->get());
3958 this->m_routine_monitor_interval_multiplier_history.push_back(std::move(v_owned));
3959 }
3960 for (auto v_itr = _RM_pt->m_attention_span_history.begin(); v_itr != _RM_pt->m_attention_span_history.end(); v_itr++) {
3961 auto v_owned = make_unique<ValueTimeLineUnit>();
3962 v_owned->CopyFromAnotherVTLU(v_itr->get());
3963 this->m_attention_span_history.push_back(std::move(v_owned));
3964 }
3965 for (auto v_itr = _RM_pt->m_memory_span_history.begin(); v_itr != _RM_pt->m_memory_span_history.end(); v_itr++) {
3966 auto v_owned = make_unique<ValueTimeLineUnit>();
3967 v_owned->CopyFromAnotherVTLU(v_itr->get());
3968 this->m_memory_span_history.push_back(std::move(v_owned));
3969 }
3970 for (auto v_itr = _RM_pt->m_decay_time_history.begin(); v_itr != _RM_pt->m_decay_time_history.end(); v_itr++) {
3971 auto v_owned = make_unique<ValueTimeLineUnit>();
3972 v_owned->CopyFromAnotherVTLU(v_itr->get());
3973 this->m_decay_time_history.push_back(std::move(v_owned));
3974 }
3975 for (auto v_itr = _RM_pt->m_cognitive_time_cost_multiplier_history.begin();
3976 v_itr != _RM_pt->m_cognitive_time_cost_multiplier_history.end(); v_itr++) {
3977 auto v_owned = make_unique<ValueTimeLineUnit>();
3978 v_owned->CopyFromAnotherVTLU(v_itr->get());
3979 this->m_cognitive_time_cost_multiplier_history.push_back(std::move(v_owned));
3980 }
3981
3982 for (auto v_itr = _RM_pt->m_max_alarm_length_timeline.begin(); v_itr != _RM_pt->m_max_alarm_length_timeline.end();
3983 v_itr++) {
3984 auto v_owned = make_unique<ValueTimeLineUnit>();
3985 v_owned->CopyFromAnotherVTLU(v_itr->get());
3986 this->m_max_alarm_length_timeline.push_back(std::move(v_owned));
3987 }
3988
3989 for (auto v_itr = _RM_pt->m_cognitive_time_cost_multiplier_timeline.begin();
3990 v_itr != _RM_pt->m_cognitive_time_cost_multiplier_timeline.end(); v_itr++) {
3991 auto v_owned = make_unique<ValueTimeLineUnit>();
3992 v_owned->CopyFromAnotherVTLU(v_itr->get());
3993 this->m_cognitive_time_cost_multiplier_timeline.push_back(std::move(v_owned));
3994 }
3995 //complex structured variables
3996 //this->m_Concept_Base
3997 this->m_Concept_Base->CopyStaticKBConceptFromAnother(_RM_pt->m_Concept_Base.get());
3998
3999 //this->m_IB
4000 this->m_IB->CopyInstantiationBaseFromAnotherIB(_RM_pt->m_IB.get());
4001
4002 //this->m_Semantic_list
4004
4005 //this->m_KE_list
4006 this->CopyStaticKEfromAnotherRM(_RM_pt);
4007
4008 //this->m_KN_list
4009 this->CopyStaticKNfromAnotherRM(_RM_pt);
4010
4011 //this->m_Knowledge_list
4012 KnowledgeUnit *KU_pt;
4013 if (this->m_Knowledge_list.size() != 0) {
4014 this->ErrorMessage("this->m_Knowledge_list.size() != 0");
4015 }
4016 for (auto KU_itr = _RM_pt->m_Knowledge_list.begin(); KU_itr != _RM_pt->m_Knowledge_list.end(); KU_itr++) {
4017 auto KU_owned = make_unique<KnowledgeUnit>();
4018 KU_owned->CopyStaticKnowledgeUnitInfoFromAnother(KU_itr->get());
4019 this->m_Knowledge_list.push_back(std::move(KU_owned));
4020 }
4021
4022 //this->m_routine_monitor
4023 this->m_routine_monitor->CopyRoutineMonitorInfoFromAnother(_RM_pt->m_routine_monitor.get());
4024
4025
4026 //this->m_event_schema_base
4027 this->m_event_schema_base->CopyESBinfoFromAnother(_RM_pt->m_event_schema_base.get());
4028 //need to copy the dynamic information
4029
4030 //this->m_MR
4031 this->m_MR->CopyMentalRepresentationFromAnother(_RM_pt->m_MR.get());
4032
4033 vector<Investigator *>::iterator invest_itr;
4034 Investigator *invest_pt;
4035 //this->m_investigator_pool
4036 if (this->m_investigator_pool.size() != 0) {
4037 this->ErrorMessage("if(this->m_investigator_pool.size() != 0");
4038 return;
4039 }
4040 for (auto invest_itr = _RM_pt->m_investigator_pool.begin(); invest_itr != _RM_pt->m_investigator_pool.end();
4041 invest_itr++) {
4042 auto invest_owned = make_unique<Investigator>();
4043 invest_owned->CopyInvestigatorInfoFromAnother(invest_itr->get());
4044 this->m_investigator_pool.push_back(std::move(invest_owned));
4045 }
4046
4047 //this->m_Statement_list
4048 vector<Statement *>::iterator state_itr;
4049 Statement *state_pt;
4050 if (this->m_Statement_list.size() != 0) {
4051 this->ErrorMessage("this->m_Statement_list.size() != 0");
4052 return;
4053 }
4054 for (auto state_itr = _RM_pt->m_Statement_list.begin(); state_itr != _RM_pt->m_Statement_list.end(); state_itr++) {
4055 auto state_owned = make_unique<Statement>();
4056 state_owned->CopyStatementInfoFromAnother(state_itr->get());
4057 this->m_Statement_list.push_back(std::move(state_owned));
4058 }
4059
4060 //this->m_investigator_link_pool
4061 vector<InvestigatorLink *>::iterator link_itr;
4062 InvestigatorLink *link_pt;
4063 if (this->m_investigator_link_pool.size() != 0) {
4064 this->ErrorMessage("this->m_investigator_link_pool.size() != 0");
4065 return;
4066 }
4067 for (auto link_itr = _RM_pt->m_investigator_link_pool.begin(); link_itr != _RM_pt->m_investigator_link_pool.end();
4068 link_itr++) {
4069 auto link_owned = make_unique<InvestigatorLink>();
4070 link_owned->CopyInvestigatorLinkInfoFromAnother(link_itr->get());
4071 this->m_investigator_link_pool.push_back(std::move(link_owned));
4072 }
4073
4074 //this->m_working_on_invest_link_pt
4075 //this->m_working_on_invest_pt
4076 //this->m_reading_indication_ID_pt
4077/*
4078 string m_ID_working_on_invest;
4079 string m_ID_working_on_invest_link;
4080 string m_ID_reading_indication;
4081*/
4082 if (_RM_pt->m_working_on_invest_link_pt != NULL) {
4085
4086 if (_RM_pt->m_working_on_invest_pt != NULL) { this->m_ID_working_on_invest = _RM_pt->m_working_on_invest_pt->m_ID; }
4087 else { this->m_ID_working_on_invest = _RM_pt->m_ID_working_on_invest; }
4088
4089 if (_RM_pt->m_reading_indication_ID_pt != NULL) {
4091 } else { this->m_ID_reading_indication = _RM_pt->m_ID_reading_indication; }
4092
4093 if (this->m_ID_unresolved_invest_pool.size() != 0) {
4094 this->ErrorMessage("this->m_ID_unresolved_invest_pool.size() != 0");
4095 return;
4096 }
4097 if (this->m_ID_resolved_invest_pool.size() != 0) {
4098 this->ErrorMessage("this->m_ID_resolved_invest_pool.size() != 0");
4099 return;
4100 }
4101 if (this->m_ID_succes_invest_pool.size() != 0) {
4102 this->ErrorMessage("this->m_ID_succes_invest_pool.size() != 0");
4103 return;
4104 }
4105 if (this->m_ID_failed_invest_pool.size() != 0) {
4106 this->ErrorMessage("this->m_ID_failed_invest_pool.size() != 0");
4107 return;
4108 }
4109 if (this->m_ID_undertermined_invest_pool.size() != 0) {
4110 this->ErrorMessage("this->m_ID_undertermined_invest_pool.size() != 0");
4111 return;
4112 }
4113 if (this->m_ID_discarded_invest_pool.size() != 0) {
4114 this->ErrorMessage("this->m_ID_discarded_invest_pool.size() != 0");
4115 return;
4116 }
4117 if (this->m_ID_cause_undertermined_invest_pool.size() != 0) {
4118 this->ErrorMessage("this->m_ID_cause_undertermined_invest_pool.size() != 0");
4119 return;
4120 }
4121 if (this->m_ID_feedback_stack.size() != 0) {
4122 this->ErrorMessage("this->m_ID_feedback_stack.size() != 0");
4123 return;
4124 }
4125 if (this->m_ID_invest_trace.size() != 0) {
4126 this->ErrorMessage("this->m_ID_invest_trace.size() != 0");
4127 return;
4128 }
4129 //this->m_cause_undetermined_investigato_pool
4130 //this->m_discarded_investigator_pool
4131 //this->m_failed_investigator_pool
4132 //this->m_resolved_investigator_pool
4133 //this->m_success_investigator_pool
4134 //this->m_undetermined_investigator_pool
4135 //this->m_unresolved_investigator_pool
4136 //this->m_feedback_stack
4137 //this->m_investigation_trace
4138/*
4139 vector<Investigator *> m_unresolved_investigator_pool;
4140 vector<Investigator *> m_resolved_investigator_pool;
4141 vector<Investigator *> m_success_investigator_pool; //3098, 3030
4142 vector<Investigator *> m_failed_investigator_pool; //
4143 vector<Investigator *> m_undetermined_investigator_pool; //3031
4144 vector<Investigator *> m_discarded_investigator_pool; //3090
4145 vector<Investigator *> m_cause_undetermined_investigato_poolm_cause_undetermined_investigato_pool; //3097
4146 vector<IDElement*> m_feedback_stack;
4147 vector<IDElement *> m_investigation_trace;
4148
4149 vector<string> m_ID_unresolved_invest_pool;
4150 vector<string> m_ID_resolved_invest_pool;
4151 vector<string> m_ID_succes_invest_pool;
4152 vector<string> m_ID_failed_invest_pool;
4153 vector<string> m_ID_undertermined_invest_pool;
4154 vector<string> m_ID_discarded_invest_pool;
4155 vector<string> m_ID_cause_undertermined_invest_pool;
4156 vector<string> m_ID_feedback_stack;
4157 vector<string> m_ID_invest_trace;
4158*/
4159 vector<string>::iterator str_itr;
4160 string ID;
4161
4162 if (this->m_ongoing_item_stack.size() != 0) { this->ErrorMessage("this->m_ongoing_item_stack.size() != 0"); }
4163
4164 for (str_itr = _RM_pt->m_ongoing_item_stack.begin(); str_itr != _RM_pt->m_ongoing_item_stack.end(); str_itr++) {
4165 ID = *str_itr;
4166 this->m_ongoing_item_stack.push_back(ID);
4167 }
4168
4169 if (_RM_pt->m_unresolved_investigator_pool.size() != 0) {
4170 for (auto invest_itr = _RM_pt->m_unresolved_investigator_pool.begin();
4171 invest_itr != _RM_pt->m_unresolved_investigator_pool.end(); invest_itr++) {
4172 ID = (*invest_itr)->m_ID;
4173 this->m_ID_unresolved_invest_pool.push_back(ID);
4174 }
4175 } else {
4176 for (str_itr = _RM_pt->m_ID_unresolved_invest_pool.begin(); str_itr != _RM_pt->m_ID_unresolved_invest_pool.end();
4177 str_itr++) {
4178 ID = *str_itr;
4179 this->m_ID_unresolved_invest_pool.push_back(ID);
4180 }
4181 }
4182
4183 if (_RM_pt->m_resolved_investigator_pool.size() != 0) {
4184 for (auto invest_itr = _RM_pt->m_resolved_investigator_pool.begin();
4185 invest_itr != _RM_pt->m_resolved_investigator_pool.end(); invest_itr++) {
4186 ID = (*invest_itr)->m_ID;
4187 this->m_ID_resolved_invest_pool.push_back(ID);
4188 }
4189 } else {
4190 for (str_itr = _RM_pt->m_ID_resolved_invest_pool.begin(); str_itr != _RM_pt->m_ID_resolved_invest_pool.end();
4191 str_itr++) {
4192 ID = *str_itr;
4193 this->m_ID_resolved_invest_pool.push_back(ID);
4194 }
4195 }
4196
4197 if (_RM_pt->m_success_investigator_pool.size() != 0) {
4198 for (auto invest_itr = _RM_pt->m_success_investigator_pool.begin();
4199 invest_itr != _RM_pt->m_success_investigator_pool.end(); invest_itr++) {
4200 ID = (*invest_itr)->m_ID;
4201 this->m_ID_succes_invest_pool.push_back(ID);
4202 }
4203 } else {
4204 for (str_itr = _RM_pt->m_ID_succes_invest_pool.begin(); str_itr != _RM_pt->m_ID_succes_invest_pool.end();
4205 str_itr++) {
4206 ID = *str_itr;
4207 this->m_ID_succes_invest_pool.push_back(ID);
4208 }
4209 }
4210 if (_RM_pt->m_failed_investigator_pool.size() != 0) {
4211 for (auto invest_itr = _RM_pt->m_failed_investigator_pool.begin();
4212 invest_itr != _RM_pt->m_failed_investigator_pool.end(); invest_itr++) {
4213 ID = (*invest_itr)->m_ID;
4214 this->m_ID_failed_invest_pool.push_back(ID);
4215 }
4216 } else {
4217 for (str_itr = _RM_pt->m_ID_failed_invest_pool.begin(); str_itr != _RM_pt->m_ID_failed_invest_pool.end();
4218 str_itr++) {
4219 ID = *str_itr;
4220 this->m_ID_failed_invest_pool.push_back(ID);
4221 }
4222 }
4223
4224 if (_RM_pt->m_undetermined_investigator_pool.size() != 0) {
4225 for (auto invest_itr = _RM_pt->m_undetermined_investigator_pool.begin();
4226 invest_itr != _RM_pt->m_undetermined_investigator_pool.end(); invest_itr++) {
4227 ID = (*invest_itr)->m_ID;
4228 this->m_ID_undertermined_invest_pool.push_back(ID);
4229 }
4230 } else {
4231 for (str_itr = _RM_pt->m_ID_undertermined_invest_pool.begin();
4232 str_itr != _RM_pt->m_ID_undertermined_invest_pool.end(); str_itr++) {
4233 ID = *str_itr;
4234 this->m_ID_undertermined_invest_pool.push_back(ID);
4235 }
4236 }
4237 if (_RM_pt->m_discarded_investigator_pool.size() != 0) {
4238 for (auto invest_itr = _RM_pt->m_discarded_investigator_pool.begin();
4239 invest_itr != _RM_pt->m_discarded_investigator_pool.end(); invest_itr++) {
4240 ID = (*invest_itr)->m_ID;
4241 this->m_ID_discarded_invest_pool.push_back(ID);
4242 }
4243 } else {
4244 for (str_itr = _RM_pt->m_ID_discarded_invest_pool.begin(); str_itr != _RM_pt->m_ID_discarded_invest_pool.end();
4245 str_itr++) {
4246 ID = *str_itr;
4247 this->m_ID_discarded_invest_pool.push_back(ID);
4248 }
4249 }
4250
4251 if (_RM_pt->m_cause_undetermined_investigato_pool.size() != 0) {
4252 for (auto invest_itr = _RM_pt->m_cause_undetermined_investigato_pool.begin();
4253 invest_itr != _RM_pt->m_cause_undetermined_investigato_pool.end(); invest_itr++) {
4254 ID = (*invest_itr)->m_ID;
4255 this->m_ID_cause_undertermined_invest_pool.push_back(ID);
4256 }
4257 } else {
4258 for (str_itr = _RM_pt->m_ID_cause_undertermined_invest_pool.begin();
4259 str_itr != _RM_pt->m_ID_cause_undertermined_invest_pool.end(); str_itr++) {
4260 ID = *str_itr;
4261 this->m_ID_cause_undertermined_invest_pool.push_back(ID);
4262 }
4263 }
4264
4265 vector<IDElement *>::iterator ID_itr;
4266
4267 if (_RM_pt->m_decayed_item_pt_list.size() != 0) {
4268 for (ID_itr = _RM_pt->m_decayed_item_pt_list.begin(); ID_itr != _RM_pt->m_decayed_item_pt_list.end(); ID_itr++) {
4269 ID = (*ID_itr)->m_ID;
4270 this->m_decayed_item_ID_list.push_back(ID);
4271 }
4272 } else {
4273 for (str_itr = _RM_pt->m_decayed_item_ID_list.begin(); str_itr != _RM_pt->m_decayed_item_ID_list.end(); str_itr++) {
4274 ID = *str_itr;
4275 this->m_decayed_item_ID_list.push_back(ID);
4276 }
4277 }
4278
4279 if (_RM_pt->m_feedback_stack.size() != 0) {
4280 for (ID_itr = _RM_pt->m_feedback_stack.begin(); ID_itr != _RM_pt->m_feedback_stack.end(); ID_itr++) {
4281 ID = (*ID_itr)->m_ID;
4282 this->m_ID_feedback_stack.push_back(ID);
4283 }
4284 } else {
4285 for (str_itr = _RM_pt->m_ID_feedback_stack.begin(); str_itr != _RM_pt->m_ID_feedback_stack.end(); str_itr++) {
4286 ID = *str_itr;
4287 this->m_ID_feedback_stack.push_back(ID);
4288 }
4289 }
4290
4291 if (_RM_pt->m_investigation_trace.size() != 0) {
4292 for (ID_itr = _RM_pt->m_investigation_trace.begin(); ID_itr != _RM_pt->m_investigation_trace.end(); ID_itr++) {
4293 ID = (*ID_itr)->m_ID;
4294 this->m_ID_invest_trace.push_back(ID);
4295 }
4296 } else {
4297 for (str_itr = _RM_pt->m_ID_invest_trace.begin(); str_itr != _RM_pt->m_ID_invest_trace.end(); str_itr++) {
4298 ID = *str_itr;
4299 this->m_ID_invest_trace.push_back(ID);
4300 }
4301 }
4302
4303 if (this->m_position_tbi_A_list.size() != 0) {
4304 this->ErrorMessage("this->m_position_tbi_A_list.size() != 0");
4305 return;
4306 }
4307 if (this->m_position_tbi_C_list.size() != 0) {
4308 this->ErrorMessage("this->m_position_tbi_C_list.size() != 0");
4309 return;
4310 }
4311 if (this->m_position_tbi_SS_list.size() != 0) {
4312 this->ErrorMessage("this->m_position_tbi_SS_list.size() != 0");
4313 return;
4314 }
4315 if (this->m_position_tbi_P_list.size() != 0) {
4316 this->ErrorMessage("this->m_position_tbi_P_list.size() != 0");
4317 return;
4318 }
4319 //this->m_tbi_A_list
4320 //this->m_tbi_C_list
4321 //this->m_tbi_P_list
4322/*
4323 vector<MentalParameterValue *> m_tbi_P_list;
4324 vector<MentalAlarm *> m_tbi_A_list;
4325 vector<MentalComponentState *> m_tbi_C_list;
4326
4327 vector<int> m_position_tbi_p_list;
4328 vector<int> m_position_tbi_A_list;
4329 vector<int> m_position_tbi_C_list;
4330
4331*/
4332
4333 vector<int>::iterator int_itr;
4334 int i;
4335 InfoChunk *perceived_pt;
4336 vector<MentalComponentState *>::iterator mc_itr;
4337 vector<MentalSupportSystemState *>::iterator mss_itr;
4338 vector<MentalAlarm *>::iterator ma_itr;
4339 vector<MentalParameterValue *>::iterator mp_itr;
4340
4341 if (_RM_pt->m_operator == sim::Operator::ODM) { perceived_pt = &(g_sim.Decision_Maker.memory.perceived_info); }
4342 else if (_RM_pt->m_operator == sim::Operator::OAT) { perceived_pt = &(g_sim.Action_Taker.memory.perceived_info); }
4343
4344 if (_RM_pt->m_tbi_P_list.size() != 0) {
4345 for (mp_itr = _RM_pt->m_tbi_P_list.begin(); mp_itr != _RM_pt->m_tbi_P_list.end(); mp_itr++) {
4346 i = perceived_pt->ReturnPositionOfOneMentalParameterValue(*mp_itr);
4347 this->m_position_tbi_P_list.push_back(i);
4348 }
4349 } else {
4350 for (int_itr = _RM_pt->m_position_tbi_P_list.begin(); int_itr != _RM_pt->m_position_tbi_P_list.end(); int_itr++) {
4351 i = *int_itr;
4352 this->m_position_tbi_P_list.push_back(i);
4353 }
4354 }
4355
4356 //
4357 if (r5pars_.timesno > 1050 && r5pars_.timesno < 1054) { this->PrintMessage(""); }
4358 //
4359 if (_RM_pt->m_tbi_A_list.size() != 0) {
4360 for (ma_itr = _RM_pt->m_tbi_A_list.begin(); ma_itr != _RM_pt->m_tbi_A_list.end(); ma_itr++) {
4361 i = perceived_pt->ReturnPositionOfOneMentalAlarmInTheVector(*ma_itr);
4362 this->m_position_tbi_A_list.push_back(i);
4363 }
4364 } else {
4365 for (int_itr = _RM_pt->m_position_tbi_A_list.begin(); int_itr != _RM_pt->m_position_tbi_A_list.end(); int_itr++) {
4366 i = *int_itr;
4367 this->m_position_tbi_A_list.push_back(i);
4368 }
4369 }
4370
4371 if (_RM_pt->m_tbi_C_list.size() != 0) {
4372 for (mc_itr = _RM_pt->m_tbi_C_list.begin(); mc_itr != _RM_pt->m_tbi_C_list.end(); mc_itr++) {
4373 i = perceived_pt->ReturnPositionOfOneMentalComponentStateInTheVector(*mc_itr);
4374 this->m_position_tbi_C_list.push_back(i);
4375 }
4376 } else {
4377 for (int_itr = _RM_pt->m_position_tbi_C_list.begin(); int_itr != _RM_pt->m_position_tbi_C_list.end(); int_itr++) {
4378 i = *int_itr;
4379 this->m_position_tbi_C_list.push_back(i);
4380 }
4381 }
4382
4383 if (_RM_pt->m_tbi_SS_list.size() != 0) {
4384 for (mss_itr = _RM_pt->m_tbi_SS_list.begin(); mss_itr != _RM_pt->m_tbi_SS_list.end(); mss_itr++) {
4386 this->m_position_tbi_SS_list.push_back(i);
4387 }
4388 } else {
4389 for (int_itr = _RM_pt->m_position_tbi_SS_list.begin(); int_itr != _RM_pt->m_position_tbi_SS_list.end(); int_itr++) {
4390 i = *int_itr;
4391 this->m_position_tbi_SS_list.push_back(i);
4392 }
4393 }
4394
4395 //useful but won't be needed for restart
4396 //this->m_temporary_statement_list
4397 //this->m_new_Statement_list
4398 //this->m_recent_finished_invest_pt
4399
4400 //unused variable
4401 //this->m_investigator_number
4402 //this->m_investigator_link_number
4403
4404/*
4405 PassiveAlarmLoadUnit * m_passive_alarm_load;
4406 TimeConstrainedModule * m_time_constraint;
4407 float m_cognitive_time_cost_base_multiplier;
4408 bool m_buffer_used_bl;
4409 Investigator * m_buffer_invest_pt;
4410*/
4411 this->m_buffer_used_bl = _RM_pt->m_buffer_used_bl;
4414
4415 this->m_passive_alarm_load = make_unique<PassiveAlarmLoadUnit>();
4416 this->m_passive_alarm_load->CopyFromAnotherPassiveAlarmLoadUnit(_RM_pt->m_passive_alarm_load.get());
4417
4418 if (_RM_pt->m_buffer_invest_pt != NULL) { this->m_ID_buffer_invest_pt = _RM_pt->m_buffer_invest_pt->m_ID; }
4419
4420}
4421
4423 //concept base
4424 this->m_Concept_Base->ConvertConnectionToStringForm();
4425 this->m_IB->ConvertIBInfoToStringForm();
4426
4427 //semantic base
4428 vector<SentenceUnit *>::iterator sent_itr;
4429 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++) {
4430 (*sent_itr)->ConvertSentenceInfoToStringForm();
4431 }
4432
4433 //KnowledgeElement
4434 vector<KnowledgeElement *>::iterator KE_itr;
4435 for (auto KE_itr = this->m_KE_list.begin(); KE_itr != this->m_KE_list.end(); KE_itr++) {
4436 (*KE_itr)->ConvertKEinfoToStringForm();
4437 }
4438
4439 //KnowledgeNode
4440 vector<KnowledgeNode *>::iterator KN_itr;
4441 for (auto KN_itr = this->m_KN_list.begin(); KN_itr != this->m_KN_list.end(); KN_itr++) {
4442 (*KN_itr)->ConvertKNinfoToStringForm();
4443 }
4444
4445 //KnowledgeUnit
4446 for (auto KU_itr = this->m_Knowledge_list.begin(); KU_itr != this->m_Knowledge_list.end(); KU_itr++) {
4447 (*KU_itr)->ConvertKnowledgeLinkInfoToString();
4448 }
4449
4450 //EventSchemaBase
4451 this->m_event_schema_base->ConvertStaticESBinfoToString();
4452
4453}
4454
4456 if (this->m_Semantic_list.size() == 0) {
4457 for (auto sent_itr = _RM_pt->m_Semantic_list.begin(); sent_itr != _RM_pt->m_Semantic_list.end(); sent_itr++) {
4458 auto sent_pt = make_unique<SentenceUnit>();
4459 sent_pt->CopyStaticInfoFromAnotherSentence(sent_itr->get());
4460 this->m_Semantic_list.push_back(std::move(sent_pt));
4461 }
4462 }
4463}
4464
4466 vector<KnowledgeElement *>::iterator KE_itr;
4467 KnowledgeElement *KE_pt;
4468 if (this->m_KE_list.size() != 0) {
4469 this->ErrorMessage("this->m_KE_list.size() != 0");
4470 }
4471 for (auto KE_itr = _RM_pt->m_KE_list.begin(); KE_itr != _RM_pt->m_KE_list.end(); KE_itr++) {
4472 auto KE_owned = make_unique<KnowledgeElement>();
4473 KE_owned->CopyStaticKEinfoFromAnother(KE_itr->get());
4474 this->m_KE_list.push_back(std::move(KE_owned));
4475 }
4476}
4477
4479 vector<KnowledgeNode *>::iterator KN_itr;
4480 KnowledgeNode *KN_pt;
4481 if (this->m_KN_list.size() != 0) {
4482 this->ErrorMessage("this->m_KN_list.size() != 0");
4483 }
4484
4485 for (auto KN_itr = _RM_pt->m_KN_list.begin(); KN_itr != _RM_pt->m_KN_list.end(); KN_itr++) {
4486 auto KN_owned = make_unique<KnowledgeNode>();
4487 KN_owned->CopyStaticKNinfoFromAnother(KN_itr->get());
4488 this->m_KN_list.push_back(std::move(KN_owned));
4489 }
4490}
4491
4493 //
4494 if (this->m_operator == sim::Operator::ODM) {
4496 } else {
4498 }
4499 //
4500
4501 //KBConcept * m_Concept_Base;
4502 this->m_Concept_Base->BuidConnectionsWithinKBConcept();
4503
4504 //vector<SentenceUnit *> m_Semantic_list; //Yuandan LI
4505 vector<SentenceUnit *>::iterator sent_itr;
4506 for (auto sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end();
4507 sent_itr++) { (*sent_itr)->BuildTheConnectionsToThisSentence((void *) this); }
4508
4509 //vector<KnowledgeElement *> m_KE_list;
4510 vector<KnowledgeElement *>::iterator KE_itr;
4511 for (auto KE_itr = this->m_KE_list.begin(); KE_itr != this->m_KE_list.end();
4512 KE_itr++) { (*KE_itr)->BuildTheConnectionsToThisKE((void *) this); }
4513
4514 //vector<KnowledgeNode *> m_KN_list;
4515 vector<KnowledgeNode *>::iterator KN_itr;
4516 for (auto KN_itr = this->m_KN_list.begin(); KN_itr != this->m_KN_list.end();
4517 KN_itr++) { (*KN_itr)->BuildConnectionsToThisKN((void *) this); }
4518
4519 //vector<KnowledgeUnit *> m_Knowledge_list;
4520 for (auto KU_itr = this->m_Knowledge_list.begin(); KU_itr != this->m_Knowledge_list.end();
4521 KU_itr++) { (*KU_itr)->BuildConnectionsToThisKU((void *) this); }
4522
4523 //InstantiationBase * m_IB;
4524 this->m_IB->BuildConnectionsForTheInstantiationBase((void *) this);
4525
4526
4528 //vector<Statement *> m_Statement_list; //Yuandan LI
4529 vector<Statement *>::iterator state_itr;
4530 for (auto state_itr = this->m_Statement_list.begin(); state_itr != this->m_Statement_list.end();
4531 state_itr++) { (*state_itr)->BuildConnectionsToThisStatement((void *) this); }
4532
4533 //vector<Statement *> m_temporary_statement_list;
4534 for (auto state_itr = this->m_temporary_statement_list.begin(); state_itr != this->m_temporary_statement_list.end();
4535 state_itr++) { (*state_itr)->BuildConnectionsToThisStatement((void *) this); }
4536
4537 //vector<Statement *> m_new_Statement_list;
4538 for (auto state_itr = this->m_new_Statement_list.begin(); state_itr != this->m_new_Statement_list.end();
4539 state_itr++) { (*state_itr)->BuildConnectionsToThisStatement((void *) this); }
4540
4541 //vector<Investigator *> m_investigator_pool;
4542 vector<Investigator *>::iterator invest_itr;
4543 for (auto invest_itr = this->m_investigator_pool.begin(); invest_itr != this->m_investigator_pool.end();
4544 invest_itr++) { (*invest_itr)->BuildTheConnectionsToThisInvestigator((void *) this); }
4545
4546 //vector<InvestigatorLink *> m_investigator_link_pool;
4547 vector<InvestigatorLink *>::iterator link_itr;
4548 for (auto link_itr = this->m_investigator_link_pool.begin(); link_itr != this->m_investigator_link_pool.end();
4549 link_itr++) { (*link_itr)->BuildConnectionsToThisInvestigatorLink((void *) this); }
4550
4551 vector<string>::iterator str_itr;
4552 Investigator *invest_pt;
4553
4554 //vector<Investigator *> m_unresolved_investigator_pool;
4555 for (str_itr = this->m_ID_unresolved_invest_pool.begin(); str_itr != this->m_ID_unresolved_invest_pool.end();
4556 str_itr++) {
4557 invest_pt = this->FindInvestigatorByID(*str_itr);
4558 if (invest_pt == NULL) {
4559 this->ErrorMessage("could not find this investigator " + *str_itr);
4560 return;
4561 }
4562 this->m_unresolved_investigator_pool.push_back(invest_pt);
4563 }
4564 this->m_ID_unresolved_invest_pool.clear();
4565
4566 //vector<Investigator *> m_resolved_investigator_pool;
4567 for (str_itr = this->m_ID_resolved_invest_pool.begin(); str_itr != this->m_ID_resolved_invest_pool.end(); str_itr++) {
4568 invest_pt = this->FindInvestigatorByID(*str_itr);
4569 if (invest_pt == NULL) {
4570 this->ErrorMessage("could not find this investigator " + *str_itr);
4571 return;
4572 }
4573 this->m_resolved_investigator_pool.push_back(invest_pt);
4574 }
4575 this->m_ID_resolved_invest_pool.clear();
4576
4577 //vector<Investigator *> m_success_investigator_pool; //3098, 3030
4578 for (str_itr = this->m_ID_succes_invest_pool.begin(); str_itr != this->m_ID_succes_invest_pool.end(); str_itr++) {
4579 invest_pt = this->FindInvestigatorByID(*str_itr);
4580 if (invest_pt == NULL) {
4581 this->ErrorMessage("could not find this investigator " + *str_itr);
4582 return;
4583 }
4584 this->m_success_investigator_pool.push_back(invest_pt);
4585 }
4586 this->m_ID_succes_invest_pool.clear();
4587
4588 //vector<Investigator *> m_failed_investigator_pool;
4589 for (str_itr = this->m_ID_failed_invest_pool.begin(); str_itr != this->m_ID_failed_invest_pool.end(); str_itr++) {
4590 invest_pt = this->FindInvestigatorByID(*str_itr);
4591 if (invest_pt == NULL) {
4592 this->ErrorMessage("could not find this investigator " + *str_itr);
4593 return;
4594 }
4595 this->m_failed_investigator_pool.push_back(invest_pt);
4596 }
4597 this->m_ID_failed_invest_pool.clear();
4598
4599 //vector<Investigator *> m_undetermined_investigator_pool; //3031
4600 for (str_itr = this->m_ID_undertermined_invest_pool.begin(); str_itr != this->m_ID_undertermined_invest_pool.end();
4601 str_itr++) {
4602 invest_pt = this->FindInvestigatorByID(*str_itr);
4603 if (invest_pt == NULL) {
4604 this->ErrorMessage("could not find this investigator " + *str_itr);
4605 return;
4606 }
4607 this->m_undetermined_investigator_pool.push_back(invest_pt);
4608 }
4609 this->m_ID_undertermined_invest_pool.clear();
4610
4611 //vector<Investigator *> m_discarded_investigator_pool; //3090
4612 for (str_itr = this->m_ID_discarded_invest_pool.begin(); str_itr != this->m_ID_discarded_invest_pool.end();
4613 str_itr++) {
4614 invest_pt = this->FindInvestigatorByID(*str_itr);
4615 if (invest_pt == NULL) {
4616 this->ErrorMessage("could not find this investigator " + *str_itr);
4617 return;
4618 }
4619 this->m_discarded_investigator_pool.push_back(invest_pt);
4620 }
4621 this->m_ID_discarded_invest_pool.clear();
4622
4623 //vector<Investigator *> m_cause_undetermined_investigato_pool; //3097
4624 for (str_itr = this->m_ID_cause_undertermined_invest_pool.begin();
4625 str_itr != this->m_ID_cause_undertermined_invest_pool.end(); str_itr++) {
4626 invest_pt = this->FindInvestigatorByID(*str_itr);
4627 if (invest_pt == NULL) {
4628 this->ErrorMessage("could not find this investigator " + *str_itr);
4629 return;
4630 }
4631 this->m_cause_undetermined_investigato_pool.push_back(invest_pt);
4632 }
4634
4635 //Investigator * m_working_on_invest_pt;
4636 if (this->m_ID_working_on_invest.compare("") != 0) {
4638 if (this->m_working_on_invest_pt == NULL) {
4639 this->ErrorMessage("could not find this investigator " + this->m_ID_working_on_invest);
4640 return;
4641 }
4642 }
4643 this->m_ID_working_on_invest = "";
4644
4645 //InvestigatorLink * m_working_on_invest_link_pt;
4646 if (this->m_ID_working_on_invest_link.compare("") != 0) {
4648 if (this->m_working_on_invest_link_pt == NULL) {
4649 this->ErrorMessage("could not find this investigatorlink " + this->m_ID_working_on_invest_link);
4650 return;
4651 }
4652 }
4653 this->m_ID_working_on_invest_link = "";
4654
4655 //IDElement * m_reading_indication_ID_pt;
4656 if (this->m_ID_reading_indication.compare("") != 0) {
4657 this->m_reading_indication_ID_pt = this->m_MR->FindMRUnitByID(this->m_ID_reading_indication);
4658 if (this->m_reading_indication_ID_pt == NULL) {
4659 this->ErrorMessage("could not find the reading indication unit " + this->m_ID_reading_indication);
4660 return;
4661 }
4662 }
4663 this->m_ID_reading_indication = "";
4664
4665 //MentalRepresentation * m_MR;
4666 this->m_MR->BuildConnectionsForMentalRepresentation((void *) this);
4667
4668 //vector<string> m_ID_temporary_statement_list;
4669 Statement *state_pt = NULL;
4670 for (str_itr = this->m_ID_temporary_statement_list.begin(); str_itr != this->m_ID_temporary_statement_list.end();
4671 str_itr++) {
4672 state_pt = this->FindStatementByID(*str_itr);
4673 if (state_pt == NULL) {
4674 this->ErrorMessage("could not find this statement " + *str_itr);
4675 return;
4676 }
4677 this->m_temporary_statement_list.push_back(state_pt);
4678 }
4679 this->m_ID_temporary_statement_list.clear();
4680
4681 //vector<string> m_ID_new_statement_list;
4682 for (str_itr = this->m_ID_new_statement_list.begin(); str_itr != this->m_ID_new_statement_list.end(); str_itr++) {
4683 state_pt = this->FindStatementByID(*str_itr);
4684 if (state_pt == NULL) {
4685 this->ErrorMessage("could not find this statement " + *str_itr);
4686 return;
4687 }
4688 this->m_new_Statement_list.push_back(state_pt);
4689 }
4690 this->m_ID_new_statement_list.clear();
4691
4692 //vector<string> m_ID_feedback_stack;
4693 IDElement *ID_pt;
4694 for (str_itr = this->m_ID_feedback_stack.begin(); str_itr != this->m_ID_feedback_stack.end(); str_itr++) {
4695 ID_pt = this->FindInvestigatorOrLinkByID(*str_itr);
4696 if (ID_pt == NULL) {
4697 this->ErrorMessage("could not find this " + *str_itr);
4698 return;
4699 }
4700 this->AddToRMFeedbackStack(ID_pt);
4701 }
4702 this->m_ID_feedback_stack.clear();
4703
4704 for (str_itr = this->m_decayed_item_ID_list.begin(); str_itr != this->m_decayed_item_ID_list.end(); str_itr++) {
4705 ID_pt = this->FindInvestigatorOrLinkByID(*str_itr);
4706 if (ID_pt == NULL) {
4707 this->ErrorMessage("could not find this " + *str_itr);
4708 return;
4709 }
4710 this->m_decayed_item_pt_list.push_back(ID_pt);
4711 }
4712 this->m_decayed_item_ID_list.clear();
4713
4714 //vector<IDElement *> m_investigation_trace;
4715 for (str_itr = this->m_ID_invest_trace.begin(); str_itr != this->m_ID_invest_trace.end(); str_itr++) {
4716 ID_pt = this->FindInvestigatorOrLinkByID(*str_itr);
4717 if (ID_pt == NULL) {
4718 this->ErrorMessage("could not find this " + *str_itr);
4719 return;
4720 }
4721 this->m_investigation_trace.push_back(ID_pt);
4722 }
4723 this->m_ID_invest_trace.clear();
4724
4725 //RoutineMonitor * m_routine_monitor;
4726 this->m_routine_monitor->BuildConnectionsForRoutineMonitor((void *) this);
4727
4728 //
4729 this->m_event_schema_base->BuildTheConnectionsForThisEventSchemaBase((void *) this);
4730
4731/*
4732 vector<MentalParameterValue *> m_tbi_P_list;
4733 vector<MentalAlarm *> m_tbi_A_list;
4734 vector<MentalComponentState *> m_tbi_C_list;
4735*/
4736 ShortTermMemory *stm_pt;
4737 if (this->m_operator == sim::Operator::ODM) { stm_pt = &(g_sim.Decision_Maker.memory); }
4738 else if (this->m_operator == sim::Operator::OAT) { stm_pt = &(g_sim.Action_Taker.memory); }
4739
4740 vector<int>::iterator int_itr;
4741 MentalAlarm *a_pt;
4745
4746 for (int_itr = this->m_position_tbi_A_list.begin(); int_itr != this->m_position_tbi_A_list.end(); int_itr++) {
4747 a_pt = stm_pt->perceived_info.perceived_alarms[*int_itr].get();
4748 this->m_tbi_A_list.push_back(a_pt);
4749 }
4750 this->m_position_tbi_A_list.clear();
4751
4752 for (int_itr = this->m_position_tbi_C_list.begin(); int_itr != this->m_position_tbi_C_list.end(); int_itr++) {
4753 c_pt = stm_pt->perceived_info.perceived_component_state[*int_itr].get();
4754 this->m_tbi_C_list.push_back(c_pt);
4755 }
4756 this->m_position_tbi_C_list.clear();
4757
4758 for (int_itr = this->m_position_tbi_SS_list.begin(); int_itr != this->m_position_tbi_SS_list.end(); int_itr++) {
4759 ss_pt = stm_pt->perceived_info.perceived_support_system_state[*int_itr].get();
4760 this->m_tbi_SS_list.push_back(ss_pt);
4761 }
4762 this->m_position_tbi_SS_list.clear();
4763
4764 for (int_itr = this->m_position_tbi_P_list.begin(); int_itr != this->m_position_tbi_P_list.end(); int_itr++) {
4765 p_pt = stm_pt->perceived_info.perceived_parameter_value[*int_itr].get();
4766 this->m_tbi_P_list.push_back(p_pt);
4767 }
4768 this->m_position_tbi_P_list.clear();
4769
4770 /*
4771 PassiveAlarmLoadUnit * m_passive_alarm_load;
4772 TimeConstrainedModule * m_time_constraint;
4773 Investigator * m_buffer_invest_pt;
4774*/
4775 if (this->m_ID_buffer_invest_pt.compare("") != 0) {
4777 if (this->m_buffer_invest_pt == NULL) {
4778 this->ErrorMessage("could not find this investigator " + this->m_ID_buffer_invest_pt);
4779 }
4780 }
4781 //
4782 if (this->m_operator == sim::Operator::ODM) {
4784 } else {
4786 }
4787 //
4788}
4789
4791 vector<Investigator *>::iterator invest_itr;
4792 Investigator *found_invest = NULL;
4793
4794 for (auto invest_itr = this->m_investigator_pool.begin();
4795 invest_itr != this->m_investigator_pool.end() && found_invest == NULL; invest_itr++) {
4796 if ((*invest_itr)->m_ID == _ID) {
4797 found_invest = invest_itr->get();
4798 }
4799 }
4800 return found_invest;
4801}
4802
4804 vector<Statement *>::iterator state_itr;
4805 Statement *found_state = NULL;
4806 for (auto state_itr = this->m_Statement_list.begin(); state_itr != this->m_Statement_list.end() && found_state == NULL;
4807 state_itr++) {
4808 if ((*state_itr)->m_ID == _ID) { found_state = state_itr->get(); }
4809 }
4810 return found_state;
4811}
4812
4814 InvestigatorLink *found_link = NULL;
4815 vector<InvestigatorLink *>::iterator link_itr;
4816
4817 for (auto link_itr = this->m_investigator_link_pool.begin();
4818 link_itr != this->m_investigator_link_pool.end() && found_link == NULL; link_itr++) {
4819 if ((*link_itr)->m_ID == _ID) { found_link = link_itr->get(); }
4820 }
4821 return found_link;
4822}
4823
4825 IDElement *found_pt = NULL;
4826 found_pt = this->FindInvestigatorByID(_ID);
4827 if (found_pt == NULL) { found_pt = this->FindInvestigatorLinkByID(_ID); }
4828 return found_pt;
4829}
4830
4832}
4833
4834// RM gate: with the cycle disabled the live RM persists across sequence
4835// restores instead of being cloned from the snapshot. Clearing the to-be-
4836// investigated queues makes its state match what a fresh clone would carry
4837// (see docs/developer/internals/reason-machine-status.md).
4839 this->m_tbi_P_list.clear();
4840 this->m_tbi_A_list.clear();
4841 this->m_tbi_C_list.clear();
4842 this->m_tbi_SS_list.clear();
4843 this->m_position_tbi_P_list.clear();
4844 this->m_position_tbi_A_list.clear();
4845 this->m_position_tbi_C_list.clear();
4846 this->m_position_tbi_SS_list.clear();
4847}
4848
4850 vector<IDElement *>::iterator ID_itr;
4851 Investigator *invest_pt;
4852 InvestigatorLink *link_pt;
4853
4854 ofstream fout(_path.c_str(), ios::out);
4855 fout << "ID" << '\t' << "starting time" << '\t' << "ending time" << '\n';
4856 for (auto info_itr = this->m_investigation_history.begin(); info_itr != this->m_investigation_history.end(); info_itr++) {
4857 fout << (*info_itr)->m_name << '\t';
4858 fout << (*info_itr)->m_interval_start << '\t';
4859 fout << (*info_itr)->m_interval_end << '\t';
4860 if ((*info_itr)->m_name.compare(0, 13, "Investigator_") == 0) {
4861 invest_pt = this->FindInvestigatorByID((*info_itr)->m_name);
4862 if (invest_pt == NULL) { fout << "error" << '\t'; }
4863 else {
4864 if (invest_pt->m_KElement_ID_pt != NULL) { fout << invest_pt->m_KElement_ID_pt->m_ID << "||"; }
4865 if (invest_pt->m_Statement_pt != NULL) { fout << invest_pt->m_Statement_pt->m_sent_pt->m_ID << "||"; }
4866 fout << invest_pt->m_Happen << " " << invest_pt->m_explained;
4867 }
4868 } else if ((*info_itr)->m_name.compare(0, 17, "InvestigatorLink_") == 0) {
4869 link_pt = this->FindInvestigatorLinkByID((*info_itr)->m_name);
4870 if (link_pt == NULL) { fout << "error" << '\t'; }
4871 else {
4872 fout << link_pt->m_ID << " links " << link_pt->m_downstream_ID_pt->m_ID << " and ";
4873 for (ID_itr = link_pt->m_upperstream_ID_list.begin(); ID_itr != link_pt->m_upperstream_ID_list.end();
4874 ID_itr++) {
4875 fout << (*ID_itr)->m_ID << " , ";
4876 }
4877 }
4878 } else {}
4879 fout << '\n';
4880 }
4881 fout.close();
4882}
4883
4885 vector<InvestigatorLink *>::iterator link_itr;
4886 InvestigatorLink *link_pt;
4887 Investigator *invest_pt;
4888 vector<int>::iterator int_itr;
4889 vector<IDElement *>::iterator ID_itr;
4890 string str;
4891
4892 ofstream fout(_path.c_str(), ios::out);
4893 fout
4894 << "Link ID" << '\t'
4895 << "Path status" << '\t'
4896 << "Upperstream ID" << '\t'
4897 << "Downstream ID" << '\t'
4898 << "Condition ID" << '\t'
4899 << "Token History" << '\t'
4900 << "Dormant" << '\n';
4901 for (auto link_itr = this->m_investigator_link_pool.begin(); link_itr != this->m_investigator_link_pool.end();
4902 link_itr++) {
4903 link_pt = link_itr->get();
4904 fout << link_pt->m_ID << '\t';
4905 fout << link_pt->m_path_status << '\t';
4906 for (ID_itr = link_pt->m_upperstream_ID_list.begin(); ID_itr != link_pt->m_upperstream_ID_list.end(); ID_itr++) {
4907 invest_pt = (Investigator *) (*ID_itr);
4908 fout << invest_pt->m_ID;
4909 fout << ": ";
4910 fout << invest_pt->m_Happen << "; ";
4911 }
4912 fout << '\t';
4913
4914 invest_pt = (Investigator *) (link_pt->m_downstream_ID_pt);
4915 if (invest_pt != NULL) {
4916 fout << invest_pt->m_ID;
4917 fout << ": " << invest_pt->m_Happen;
4918 }
4919 fout << '\t';
4920
4921 invest_pt = (Investigator *) (link_pt->m_condition_ID_pt);
4922 if (invest_pt != NULL) {
4923 fout << invest_pt->m_ID;
4924 fout << ": " << invest_pt->m_Happen;
4925 }
4926 fout << '\t';
4927
4928 for (int_itr = link_pt->m_invest_link_Token_history.begin(); int_itr != link_pt->m_invest_link_Token_history.end();
4929 int_itr++) {
4930 fout << *int_itr;
4931 fout << '-';
4932 }
4933 fout << '\t';
4934
4935 fout << link_pt->m_invest_link_dormant;
4936 fout << '\n';
4937 }
4938 fout.close();
4939}
4940
4942 bool existing = false;
4943 vector<IDElement *>::iterator ID_itr;
4944 if (_ID_pt->m_ID == "Investigator_228" && r5pars_.timesno > 600) { this->PrintMessage(""); }
4945
4946 for (ID_itr = this->m_feedback_stack.begin(); ID_itr != this->m_feedback_stack.end(); ID_itr++) {
4947 if (*ID_itr == _ID_pt) { existing = true; }
4948 }
4949 if (existing == true) { return; }
4950 else { this->m_feedback_stack.push_back(_ID_pt); }
4951}
4952
4954 string directory, str, str1, file_name;
4955 string err_mes;
4956 ifstream fin;
4957
4958 //get the directory "Input\Crew\DecisionMaker\RM\KB_ODM_Knowledge_Unit_Base.txt"
4959 if (this->m_operator == sim::Operator::ODM) {
4960 file_name = g_sim.SScheduler.getODMDirectory();
4961 file_name += "RM/";
4962 file_name += "KB_ODM_RM_Profile.txt";
4963 } else if (this->m_operator == sim::Operator::OAT) {
4964 file_name = g_sim.SScheduler.getOATDirectory();
4965 file_name += "RM/";
4966 file_name += "KB_OAT_RM_Profile.txt";
4967 } else {} //error message, unable to identify the operator type in ReasonMachine::ReadSemanticSentencesFromInputFile()
4968
4969 //
4970 fin.open(file_name.c_str(), ios::in);
4971 if (!fin.is_open()) {
4972 err_mes = "could not open file: " + file_name;
4973 this->ErrorMessage(err_mes);
4974 return;
4975 } else {
4976 fin >> str;
4977 fin >> str;
4978 fin >> str;
4979 fin >> str;
4980 fin >> str;
4981 fin >> str;
4982
4983 fin >> str;
4984 if (str.compare("Problem_solving_style:") != 0) {
4985 err_mes = "Missing line: Problem_solving_style:" + file_name + " " + str;
4986 this->ErrorMessage(err_mes);
4987 return;
4988 }
4989 fin >> str;
4990 if (str.compare("NEUTRAL") == 0) {
4992 } else if (str.compare("VAGABOND") == 0) {
4995 this->m_routine_monitor_threshold = 1.5;
4996 this->m_interuptiveness = 2;
4997 this->m_attention_span_base_value = 10;
4998 } else if (str.compare("HAMLET_B") == 0) {
5000 this->m_routine_monitor_threshold = 0.5;
5001 this->m_interuptiveness = 1;
5002 this->m_attention_span_base_value = 20;
5003 } else if (str.compare("HAMLET") == 0) {
5006 this->m_interuptiveness = 1;
5007 } else if (str.compare("GARDEN_PATH") == 0) {
5010 this->m_interuptiveness = 0.5;
5011 this->m_attention_span_base_value = 30;
5012 } else { this->ErrorMessage("Unrecognized problem solving style!"); }
5013
5014 fin >> str;
5015 if (str.compare("Initial_fatigue_level:") != 0) {
5016 err_mes = "Missing line: Initial_fatigue_level:";
5017 this->ErrorMessage(err_mes);
5018 return;
5019 }
5020 fin >> this->m_initial_fatigue_level;
5021
5022 fin >> str;
5023 if (str.compare("Expert_Level:") != 0) {
5024 err_mes = "Missing line: Expert_Level:";
5025 this->ErrorMessage(err_mes);
5026 return;
5027 }
5028 fin >> this->m_expert_level;
5029 }
5030 fin.close();
5031}
5032
5034
5035}
5036
5037//DEL void ReasonMachine::UpdateTimeLineOfDynamicParameters()
5038//DEL {
5039//DEL
5040//DEL
5041//DEL }
5042
5044 ValueTimeLineUnit *v_pt;
5045 int n_row = 0;
5046 int i;
5047
5048//6 PSFs
5049 n_row = max<int>(n_row, this->m_time_load_history.size());
5050 n_row = max<int>(n_row, this->m_passive_alarm_load->m_passive_alarm_load_timeline.size());
5051 n_row = max<int>(n_row, this->m_cognitive_load_history.size());
5052 n_row = max<int>(n_row, this->m_diagnosis_complexity_history.size());
5053 n_row = max<int>(n_row, this->m_stress_history.size());
5054 n_row = max<int>(n_row, this->m_fatigue_history.size());
5055
5056//7 manifestation parameters
5057 n_row = max<int>(n_row, this->m_max_alarm_length_timeline.size());
5058 n_row = max<int>(n_row, this->m_cognitive_resouse_use_history.size());
5059 n_row = max<int>(n_row, this->m_cognitive_time_cost_multiplier_timeline.size());
5060 n_row = max<int>(n_row, this->m_routine_monitor_interval_multiplier_history.size());
5061 n_row = max<int>(n_row, this->m_attention_span_history.size());
5062 n_row = max<int>(n_row, this->m_memory_span_history.size());
5063 n_row = max<int>(n_row, this->m_decay_time_history.size());
5064
5065 ofstream fout(_path.c_str(), ios::out);
5066 fout << 14 << n_row + 1 << '\n';
5067 fout << "Time" << '\t'
5068 << "PSF_Time_Constraint_Load" << '\t'
5069 << "PSF_Passive_Alarm_Load" << '\t'
5070 << "PSF_Cognitive_Load" << '\t'
5071 << "PSF_Diagnosis_Complexity" << '\t'
5072 << "PSF_Stress" << '\t'
5073 << "PSF_Fatigue" << '\t'
5074
5075 << "Model_Parameter_Max_Alarm_Stack_Length" << '\t'
5076 << "Model_Parameter_Cognitive_Resouse_Use" << '\t'
5077 << "Model_Parameter_Cognitive_Time_Cost_Multiplier" << '\t'
5078 << "Model_Parameter_Routin_Monitor_Interval_Multiplier" << '\t'
5079 << "Model_Parameter_Attention_Span" << '\t'
5080 << "Model_Parameter_Memory_Span" << '\t'
5081 << "Model_Parameter_Investigation_Item_Decay_Time" << '\t'
5082 << '\n';
5083
5084 i = 0;
5085 while (i < n_row) {
5086//time and psfs
5087 if (i < this->m_time_load_history.size()) {
5088 v_pt = this->m_time_load_history[i].get();
5089 fout << v_pt->m_time << '\t';
5090 fout << v_pt->m_fl << '\t';
5091 }
5092
5093 if (i < this->m_passive_alarm_load->m_passive_alarm_load_timeline.size()) {
5094 v_pt = this->m_passive_alarm_load->m_passive_alarm_load_timeline[i].get();
5095 fout << v_pt->m_fl << '\t';
5096 }
5097
5098 if (i < this->m_cognitive_load_history.size()) {
5099 v_pt = this->m_cognitive_load_history[i].get();
5100 fout << v_pt->m_fl << '\t';
5101 }
5102
5103 if (i < this->m_diagnosis_complexity_history.size()) {
5104 v_pt = this->m_diagnosis_complexity_history[i].get();
5105 fout << v_pt->m_fl << '\t';
5106 }
5107
5108 if (i < this->m_stress_history.size()) {
5109 v_pt = this->m_stress_history[i].get();
5110 fout << v_pt->m_fl << '\t';
5111 }
5112
5113 if (i < this->m_fatigue_history.size()) {
5114 v_pt = this->m_fatigue_history[i].get();
5115 fout << v_pt->m_fl << '\t';
5116 }
5117//manifestation
5118 if (i < this->m_max_alarm_length_timeline.size()) {
5119 v_pt = this->m_max_alarm_length_timeline[i].get();
5120 fout << v_pt->m_int << '\t';
5121 }
5122
5123 if (i < this->m_cognitive_resouse_use_history.size()) {
5124 v_pt = this->m_cognitive_resouse_use_history[i].get();
5125 fout << v_pt->m_fl << '\t';
5126 }
5127
5128 if (i < this->m_cognitive_time_cost_multiplier_history.size()) {
5129 v_pt = this->m_cognitive_time_cost_multiplier_history[i].get();
5130 fout << v_pt->m_fl << '\t';
5131 }
5132
5133 if (i < this->m_routine_monitor_interval_multiplier_history.size()) {
5135 fout << v_pt->m_fl << '\t';
5136 }
5137
5138 if (i < this->m_attention_span_history.size()) {
5139 v_pt = this->m_attention_span_history[i].get();
5140 fout << v_pt->m_fl << '\t';
5141 }
5142
5143 if (i < this->m_memory_span_history.size()) {
5144 v_pt = this->m_memory_span_history[i].get();
5145 fout << v_pt->m_fl << '\t';
5146 }
5147
5148 if (i < this->m_decay_time_history.size()) {
5149 v_pt = this->m_decay_time_history[i].get();
5150 fout << v_pt->m_fl << '\t';
5151 }
5152
5153 fout << '\n';
5154 i++;
5155 }
5156
5157 fout.close();
5158}
5159
5161 SystemDisplay *_system_display;
5162 DisplayParameterValue *_parameter_value;
5163 DisplayParameterValueRate *_parameter_trend;
5164 DisplayHeatStructure *_heat_structure;
5165 DisplayType display_type;
5166
5167 /*MRParameterUnit * M_P_pt;
5168 M_P_pt = (MRParameterUnit *)(this->m_MR->FindMRUnitByID(MR_name));
5169 if(M_P_pt == NULL || M_P_pt->m_ID_Type != 201)
5170 {this->ErrorMessage("could not find a MRParameterUnit of " + MR_name); return 0;}
5171 CP_name = M_P_pt->m_parameter_indicator_ID;
5172 */
5173 float perceived_value = 0;
5174 _system_display = g_sim.Indicator.indicators.getDisplayFromMap(CP_name);
5175 if (_system_display != 0) {
5176 display_type = _system_display->getTypeOfDisplay();
5177 if (display_type == DisplayType::ParameterValue) {
5178 _parameter_value = (DisplayParameterValue *) _system_display;
5179 perceived_value = _parameter_value->getDisplayedParameterValue();
5180 } else if (display_type == DisplayType::HeatStructure) {
5181 _heat_structure = (DisplayHeatStructure *) _system_display;
5182 perceived_value = _heat_structure->getDisplayedParameterValue();
5183 } else if (display_type == DisplayType::ParameterTrend) {
5184 _parameter_trend = (DisplayParameterValueRate *) _system_display;
5185 perceived_value = _parameter_trend->getRateOfChange();
5186 } else { this->ErrorMessage("Unrecognized parameter type of " + CP_name); }
5187 } else { this->ErrorMessage("Could not find such a parameter " + CP_name); }
5188 return perceived_value;
5189}
5190
5192 /*M_C_pt = (MRComponentStateUnit *)(this->m_MR->FindMRUnitByID(MR_name));
5193 if(M_C_pt == NULL || M_C_pt->m_ID_Type != 202)
5194 {this->ErrorMessage("could not find a MRComponentStateUnit of " + MR_name); return 0;}
5195
5196 if(M_C_pt->m_CS_type == 0)
5197 {CP_name = M_C_pt->Component_State_Indicator_ID;}
5198 else
5199 {
5200 CP_name = M_C_pt->Control_Value_Indicator_ID;
5201 }*/
5202
5203 SystemDisplay *_system_display;
5204 DisplayType display_type;
5205 DisplayComponentState *_component_state;
5206 DisplaySupportSystemState *_support_system_state;
5207
5208 int perceived_state = 0;
5209 _system_display = g_sim.Indicator.indicators.getDisplayFromMap(CP_name);
5210 if (_system_display != 0) {
5211 if (display_type == DisplayType::ComponentState) {
5212 _component_state = (DisplayComponentState *) _system_display;
5213 perceived_state = _component_state->getDisplayedComponentOperationalState();
5214 } else {
5215 this->ErrorMessage(
5216 "Unreconginzed type othat than DisplayType::ComponentState or DisplayType::SupportSystemState for " + CP_name);
5217 }
5218 } else { this->ErrorMessage("Could not find a system display for " + CP_name); }
5219 return perceived_state;
5220}
5221
5223
5224 SystemDisplay *_system_display;
5225 DisplayType display_type;
5226 DisplaySupportSystemState *_support_system_state;
5227
5228 int perceived_state = 0;
5229 _system_display = g_sim.Indicator.indicators.getDisplayFromMap(CP_name);
5230 if (_system_display != 0) {
5231 if (display_type == DisplayType::SupportSystemState) {
5232 _support_system_state = (DisplaySupportSystemState *) _system_display;
5233 perceived_state = _support_system_state->getDisplayedSupportSystemOperationalState();
5234 } else {
5235 this->ErrorMessage(
5236 "Unreconginzed type other than DisplayType::SupportSystemState for " + CP_name);
5237 }
5238 } else { this->ErrorMessage("Could not find a system display for " + CP_name); }
5239 return perceived_state;
5240}
5241
5243 SystemAlarm *_system_alarm;
5244 int perceived_state = 0;
5245
5246 _system_alarm = g_sim.Indicator.alarms.getAlarmFromMap(CP_name);
5247 if (_system_alarm != NULL) { perceived_state = _system_alarm->getDisplayedAlarmState(); }
5248 else { this->ErrorMessage("Could not find a system alarm of " + CP_name); }
5249
5250 return perceived_state;
5251}
5252
5254 string line_ID;
5255 vector<string>::iterator str_itr;
5256 bool has_changed = false;
5257 Investigator *invest_pt = NULL;
5258 InvestigatorLink *link_pt = NULL;
5259 if (this->m_RM_Token == rm::WorkOnInvestigator) {
5260 for (str_itr = this->m_current_thought_line_info->m_thought_line_list.begin();
5261 str_itr != this->m_current_thought_line_info->m_thought_line_list.end(); str_itr++) {
5262 if (this->m_working_on_invest_pt->CheckWhetherInAThoughtLine(*str_itr) == false) { has_changed = true; }
5263 }
5264 } else if (this->m_RM_Token == rm::WorkOnInvestigatorLink) {
5265 for (str_itr = this->m_current_thought_line_info->m_thought_line_list.begin();
5266 str_itr != this->m_current_thought_line_info->m_thought_line_list.end(); str_itr++) {
5267 if (this->m_working_on_invest_link_pt->CheckWhetherInAThoughtLine(*str_itr) == false) { has_changed = true; }
5268 }
5269 }
5270
5271 if (has_changed == true) {
5272 this->m_current_thought_line_info->m_interval_end = r5pars_.timesno;
5273 if (this->m_current_investigation_info != nullptr) {
5274 invest_pt = this->FindInvestigatorByID(this->m_current_investigation_info->m_name);
5275 if (invest_pt == NULL) {
5276 link_pt = this->FindInvestigatorLinkByID(this->m_current_investigation_info->m_name);
5277 }
5278 if (invest_pt != NULL) {
5279 if (invest_pt->m_investigation_closed == false) {
5280 this->m_current_investigation_info->m_interrupted_bl = true;
5281 }
5282 }
5283 if (link_pt != NULL) {
5285 this->m_current_investigation_info->m_interrupted_bl = true;
5286 }
5287 }
5288 }
5289
5290 this->m_thought_line_history.push_back(std::move(this->m_current_thought_line_info));
5291
5292 this->m_current_thought_line_info = make_unique<StringTimeIntervalUnit>();
5293 this->m_current_thought_line_info->m_interval_start = r5pars_.timesno;
5294 if (this->m_RM_Token == rm::WorkOnInvestigator) {
5296 this->m_current_thought_line_info->m_thought_line_list.push_back(this->m_working_on_invest_pt->m_ID);
5297 }
5298 for (str_itr = this->m_working_on_invest_pt->m_thoughtline_roots_list.begin();
5299 str_itr != this->m_working_on_invest_pt->m_thoughtline_roots_list.end(); str_itr++) {
5300 line_ID = *str_itr;
5301 this->m_current_thought_line_info->m_thought_line_list.push_back(line_ID);
5302 }
5303 } else {
5304 for (str_itr = this->m_working_on_invest_link_pt->m_thoughtline_roots_list.begin();
5305 str_itr != this->m_working_on_invest_link_pt->m_thoughtline_roots_list.end(); str_itr++) {
5306 line_ID = *str_itr;
5307 this->m_current_thought_line_info->m_thought_line_list.push_back(line_ID);
5308 }
5309 }
5310 }
5311 return;
5312}
5313
5315 bool remove_it;
5316 vector<Investigator *>::iterator invest_itr;
5317 vector<InvestigatorLink *>::iterator link_itr;
5318 vector<Statement *>::iterator state_itr;
5319 Investigator *oldest_invest_pt = NULL;
5320 InvestigatorLink *oldest_link_pt = NULL;
5321 int i = 0;
5322 int n_Count = 0;
5323 int n_max_item;
5324 string rm_aux_info;
5325
5326 vector<IDElement *> subject_list;
5327 vector<IDElement *>::iterator subject_itr;
5328 IDElement *subject_pt;
5329
5330 if (r5pars_.timesno < 852) {
5331 //here need to clear the statement member link of investigators
5332 for (auto invest_itr = this->m_investigator_pool.begin(); invest_itr != this->m_investigator_pool.end(); invest_itr++) {
5333 if ((*invest_itr)->m_Statement_pt != NULL) {
5334 (*invest_itr)->m_Statement_pt->m_investigator_ID_pt = NULL;
5335 (*invest_itr)->m_Statement_pt->m_ID_investigator = "";
5336 }
5337 }
5338 this->m_investigator_pool.clear();
5339 this->m_unresolved_investigator_pool.clear();
5340 }
5341
5342 for (auto link_itr = this->m_investigator_link_pool.begin(); link_itr != this->m_investigator_link_pool.end();
5343 link_itr++) {
5344 if ((*link_itr)->m_invest_link_dormant == true || (*link_itr)->m_invest_link_pause == true
5345 || (*link_itr)->m_invest_link_Token == inv_link::TransferOut || (*link_itr)->m_forgotten_bl == true) { continue; }
5346
5347 remove_it = false;
5348 if (r5pars_.timesno - (*link_itr)->m_link_last_activated_time > this->m_decay_time) { remove_it = true; }
5349
5350 if ((*link_itr)->m_SI_ID_pt != NULL) { remove_it = false; }
5351
5352 if (remove_it == true) {
5353 (*link_itr)->m_forgotten_bl = true;
5354 //rite aux information
5355 rm_aux_info = "Item forgotten: ";
5356 rm_aux_info += (*link_itr)->m_ID;
5357 this->WriteAuxInfo(rm_aux_info);
5358 } else {
5359 n_Count++;
5360 if (oldest_link_pt == NULL) { oldest_link_pt = link_itr->get(); }
5361 else if ((*link_itr)->m_link_last_activated_time < oldest_link_pt->m_link_last_activated_time) {
5362 oldest_link_pt = link_itr->get();
5363 }
5364 }
5365 }
5366
5367 while (i < this->m_unresolved_investigator_pool.size()) {
5368 invest_itr = this->m_unresolved_investigator_pool.begin();
5369 invest_itr += i;
5370
5371 remove_it = false;
5372 //criteria:
5373 //activation
5374 //inactive time since the initiation
5375 if ((*invest_itr)->m_invest_dormant == true
5376 && (r5pars_.timesno - (*invest_itr)->m_investigation_initiate_time > this->m_decay_time / 2)) {
5377 remove_it = true;
5378 }
5379
5380 if ((*invest_itr)->m_invest_dormant == false) {
5381 if ((*invest_itr)->m_investigator_token == inv::GetCorrespondingKE
5382 && (r5pars_.timesno - (*invest_itr)->m_last_active_time > this->m_decay_time)) { remove_it = true; }
5383 else if ((*invest_itr)->m_investigator_token == inv::FindMatchingStatement
5384 && (r5pars_.timesno - (*invest_itr)->m_last_active_time > this->m_decay_time)) { remove_it = true; }
5385 }
5386
5387 //is it initiated by a SymptomInvestigator?
5388 if ((*invest_itr)->m_note.compare("by event schema") == 0) { remove_it = false; }
5389
5390 if ((*invest_itr)->m_invest_pause == true) { remove_it = false; }
5391
5392 if (remove_it == true) {
5393 if ((*invest_itr)->m_ID == "Investigator_378") { this->PrintMessage(""); }
5394 //rite aux information
5395 rm_aux_info = "Item forgotten: ";
5396 rm_aux_info += (*invest_itr)->m_ID;
5397 this->WriteAuxInfo(rm_aux_info);
5398
5399 (*invest_itr)->m_investigation_closed = true;
5400 this->AddItemToDecayedItemList((IDElement *) (*invest_itr));
5401 this->RemoveInvestigatorFromUnresolvedPool(*invest_itr);
5402 } else {
5403 i++;
5404 if ((*invest_itr)->m_invest_dormant == false && (*invest_itr)->m_invest_pause == false) {
5405 //n_Count++;
5406 if ((*invest_itr)->m_Statement_pt != NULL) {
5407 subject_pt = (*invest_itr)->m_Statement_pt->m_sent_pt->m_subject_pt;
5408 } else {
5409 subject_pt = ((KnowledgeElement *) ((*invest_itr)->m_KElement_ID_pt))->m_SentenceUnit_pt->m_subject_pt;
5410 }
5411 for (subject_itr = subject_list.begin(); subject_itr != subject_list.end() && subject_pt != NULL;
5412 subject_itr++) {
5413 if (subject_pt == *subject_itr) { subject_pt = NULL; }
5414 }
5415 if (subject_pt != NULL) {
5416 subject_list.push_back(subject_pt);
5417 n_Count++;
5418 }
5419 if (oldest_invest_pt == NULL) {
5420 oldest_invest_pt = *invest_itr;
5421 } else if ((*invest_itr)->m_last_active_time < oldest_invest_pt->m_last_active_time) {
5422 oldest_invest_pt = *invest_itr;
5423 }
5424 }
5425 }
5426 }
5427
5428 if (this->m_problem_solving_style == ProblemSolvingStyle::Vagabond) { n_max_item = 1.8 * this->m_memory_span; }
5429 else if (this->m_problem_solving_style == ProblemSolvingStyle::HamletB) { n_max_item = 7; }
5430 else { n_max_item = 7; }
5431
5432 while (n_Count > n_max_item && (oldest_invest_pt != NULL || oldest_link_pt != NULL)) {
5433 //decay one item
5434 if (oldest_invest_pt != NULL && oldest_link_pt != NULL) {
5435 if (oldest_invest_pt->m_last_active_time < oldest_link_pt->m_link_last_activated_time) {
5436 oldest_invest_pt->m_investigation_closed = true;
5437 this->AddItemToDecayedItemList((IDElement *) oldest_invest_pt);
5438 this->RemoveInvestigatorFromUnresolvedPool(oldest_invest_pt);
5439 //rite aux information
5440 rm_aux_info = "Item forgotten: ";
5441 rm_aux_info += oldest_invest_pt->m_ID;
5442 this->WriteAuxInfo(rm_aux_info);
5443 } else {
5444 oldest_link_pt->m_forgotten_bl = true;
5445 this->AddItemToDecayedItemList((IDElement *) oldest_link_pt);
5446 //rite aux information
5447 rm_aux_info = "Item forgotten: ";
5448 rm_aux_info += oldest_link_pt->m_ID;
5449 this->WriteAuxInfo(rm_aux_info);
5450 }
5451 } else if (oldest_invest_pt != NULL) {
5452 oldest_invest_pt->m_investigation_closed = true;
5453 this->AddItemToDecayedItemList((IDElement *) oldest_invest_pt);
5454 this->RemoveInvestigatorFromUnresolvedPool(oldest_invest_pt);
5455 //rite aux information
5456 rm_aux_info = "Item forgotten: ";
5457 rm_aux_info += oldest_invest_pt->m_ID;
5458 this->WriteAuxInfo(rm_aux_info);
5459 } else {
5460 oldest_link_pt->m_forgotten_bl = true;
5461 this->AddItemToDecayedItemList((IDElement *) oldest_link_pt);
5462 //rite aux information
5463 rm_aux_info = "Item forgotten: ";
5464 rm_aux_info += oldest_link_pt->m_ID;
5465 this->WriteAuxInfo(rm_aux_info);
5466 }
5467
5468 //recalculate
5469 n_Count = 0;
5470 subject_list.clear();
5471 if (oldest_link_pt != NULL) {
5472 if (oldest_link_pt->m_forgotten_bl == true) {
5473 oldest_link_pt = NULL;
5474 for (auto link_itr = this->m_investigator_link_pool.begin(); link_itr != this->m_investigator_link_pool.end();
5475 link_itr++) {
5476 if ((*link_itr)->m_invest_link_pause == false && (*link_itr)->m_invest_link_dormant == false
5477 && (*link_itr)->m_forgotten_bl == false && (*link_itr)->m_invest_link_Token != inv_link::TransferOut) {
5478 n_Count++;
5479 if (oldest_link_pt == NULL) { oldest_link_pt = link_itr->get(); }
5480 else if ((*link_itr)->m_link_last_activated_time < oldest_link_pt->m_link_last_activated_time) {
5481 oldest_link_pt = link_itr->get();
5482 }
5483 }
5484 }
5485 }
5486 }
5487 if (oldest_invest_pt != NULL) {
5488 if (oldest_invest_pt->m_investigation_closed == true) {
5489 oldest_invest_pt = NULL;
5490 for (auto invest_itr = this->m_unresolved_investigator_pool.begin();
5491 invest_itr != this->m_unresolved_investigator_pool.end(); invest_itr++) {
5492 if ((*invest_itr)->m_invest_dormant == false && (*invest_itr)->m_invest_pause == false
5493 && (*invest_itr)->m_investigation_closed == false) {
5494 if ((*invest_itr)->m_Statement_pt != NULL) {
5495 subject_pt = (*invest_itr)->m_Statement_pt->m_sent_pt->m_subject_pt;
5496 } else {
5497 subject_pt = ((KnowledgeElement *) ((*invest_itr)->m_KElement_ID_pt))->m_SentenceUnit_pt->m_subject_pt;
5498 }
5499 for (subject_itr = subject_list.begin(); subject_itr != subject_list.end() && subject_pt != NULL;
5500 subject_itr++) {
5501 if (subject_pt == *subject_itr) { subject_pt = NULL; }
5502 }
5503 if (subject_pt != NULL) {
5504 subject_list.push_back(subject_pt);
5505 n_Count++;
5506 }
5507 if (oldest_invest_pt == NULL) { oldest_invest_pt = *invest_itr; }
5508 else if ((*invest_itr)->m_last_active_time < oldest_invest_pt->m_last_active_time) {
5509 oldest_invest_pt = *invest_itr;
5510 }
5511 }
5512 }
5513 }
5514 }
5515
5516 }
5517}
5518
5520 /*return the reverse position in the investigation history,
5521 0--no search result
5522 1--the current investigation item
5523 n--the last nth investigation item
5524 */
5525
5526 int count;
5527 bool found;
5528 int position = 0;
5529
5530 if (this->m_current_investigation_info != nullptr) {
5531 if (_ID.compare(this->m_current_investigation_info->m_name) == 0) {
5532 position = 1;
5533 return position;
5534 }
5535 }
5536 count = 2;
5537 found = false;
5538 for (auto info_ritr = this->m_investigation_history.rbegin();
5539 info_ritr != this->m_investigation_history.rend() && count < 50 && found == false; info_ritr++) {
5540 if (_ID.compare((*info_ritr)->m_name) == 0) {
5541 found = true;
5542 position = count;
5543 }
5544 count++;
5545 }
5546 return position;
5547}
5548
5550 /*return the reverse position in the thoughtline history,
5551 0--no search result
5552 1--the current thought line
5553 n--the last nth thought line
5554 */
5555
5556 int count;
5557 bool found;
5558 int position = 0;
5559 vector<string>::iterator str_itr;
5560 Investigator *invest_pt = NULL;
5561 InvestigatorLink *link_pt = NULL;
5562 if (_ID_pt->m_ID_Type == 301) {
5563 invest_pt = (Investigator *) _ID_pt;
5564 } else if (_ID_pt->m_ID_Type == 302) {
5565 link_pt = (InvestigatorLink *) _ID_pt;
5566 } else {
5567 this->ErrorMessage("Unrecognized Investigation Item Input");
5568 return 0;
5569 }
5570
5571 if (this->m_current_thought_line_info != nullptr) {
5572 for (str_itr = this->m_current_thought_line_info->m_thought_line_list.begin();
5573 str_itr != this->m_current_thought_line_info->m_thought_line_list.end(); str_itr++) {
5574 switch (_ID_pt->m_ID_Type) {
5575 case 301:
5576 if (invest_pt->CheckWhetherInAThoughtLine(*str_itr) == true) {
5577 position = 1;
5578 return position;
5579 }
5580 break;
5581 case 302:
5582 if (link_pt->CheckWhetherInAThoughtLine(*str_itr) == true) {
5583 position = 1;
5584 return position;
5585 }
5586 break;
5587 }
5588 }
5589 }
5590
5591 found = false;
5592 count = 2;
5593 for (auto info_ritr = this->m_thought_line_history.rbegin();
5594 info_ritr != this->m_thought_line_history.rend() && found == false && count <= 20; info_ritr++) {
5595 for (str_itr = (*info_ritr)->m_thought_line_list.begin(); str_itr != (*info_ritr)->m_thought_line_list.end();
5596 str_itr++) {
5597 switch (_ID_pt->m_ID_Type) {
5598 case 301:
5599 if (invest_pt->CheckWhetherInAThoughtLine(*str_itr) == true) {
5600 position = count;
5601 return position;
5602 }
5603 break;
5604 case 302:
5605 if (link_pt->CheckWhetherInAThoughtLine(*str_itr) == true) {
5606 position = count;
5607 return position;
5608 }
5609 break;
5610 }
5611 }
5612 count++;
5613 }
5614 return position;
5615}
5616
5618 this->m_unresolved_investigator_pool.push_back(_invest_pt);
5619 return;
5620}
5621
5623 vector<string>::iterator str_itr;
5624 vector<IDElement *>::iterator link_ID_itr;
5625 vector<IDElement *>::iterator invest_ID_itr;
5626 InvestigatorLink *link_pt;
5627 Investigator *invest_pt;
5628 Investigator *invest_pt2;
5629
5630 ofstream fout(_path.c_str(), ios::out);
5631 fout << "starting time" << '\t' << "ending time" << '\t' << "ID List" << '\n';
5632 for (auto info_itr = this->m_thought_line_history.begin(); info_itr != this->m_thought_line_history.end(); info_itr++) {
5633 fout << (*info_itr)->m_interval_start << '\t';
5634 fout << (*info_itr)->m_interval_end << '\t';
5635 for (str_itr = (*info_itr)->m_thought_line_list.begin(); str_itr != (*info_itr)->m_thought_line_list.end();
5636 str_itr++) {
5637 fout << (*str_itr) << " || ";
5638 }
5639
5640 fout << '\t';
5641 str_itr = (*info_itr)->m_thought_line_list.begin();
5642 invest_pt = this->FindInvestigatorByID(*str_itr);
5643 if (invest_pt != NULL) {
5644 if (invest_pt->m_KElement_ID_pt != NULL) {
5645 fout << invest_pt->m_KElement_ID_pt->m_ID << '\t';
5646 fout << "(" << invest_pt->m_effective_start;
5647 fout << " , ";
5648 fout << invest_pt->m_effective_end << ")";
5649 }
5650 fout << '\t';
5651 if (invest_pt->m_explained == 3) { fout << "success"; }
5652 else if (invest_pt->m_explained == 4) { fout << "fail"; }
5653 else if (invest_pt->m_explained == 2) { fout << "uncertain"; }
5654 else if (invest_pt->m_explained == 1) { fout << "unfinish"; }
5655 fout << '\t';
5656
5657 for (link_ID_itr = invest_pt->m_explanation_link_list.begin();
5658 link_ID_itr != invest_pt->m_explanation_link_list.end(); link_ID_itr++) {
5659 link_pt = (InvestigatorLink *) (*link_ID_itr);
5660 for (invest_ID_itr = link_pt->m_upperstream_ID_list.begin();
5661 invest_ID_itr != link_pt->m_upperstream_ID_list.end(); invest_ID_itr++) {
5662 invest_pt2 = (Investigator *) (*invest_ID_itr);
5663 if (invest_pt2->m_KElement_ID_pt != NULL) { fout << invest_pt2->m_KElement_ID_pt->m_ID; }
5664 fout << "; ";
5665 }
5666 }
5667 }
5668 fout << '\t';
5669 if ((*info_itr)->m_interrupted_bl == true) {
5670 fout << "Interrupted";
5671 } else { fout << "Normal transit"; }
5672 fout << '\n';
5673 }
5674 fout.close();
5675}
5676
5678 ofstream fout("AuxInfo.txt", ios::app);
5679 fout << "Time: " << r5pars_.timesno << "\t" << str << '\n';
5680 fout.close();
5681}
5682
5684 Investigator *invest_pt;
5685 InvestigatorLink *link_pt;
5686 bool within_line = false;
5687 vector<string>::iterator str_itr;
5688
5689 if (this->m_current_thought_line_info == nullptr) { return false; }
5690//301--Investigator
5691 //302--InvestigatorLink
5692 for (str_itr = this->m_current_thought_line_info->m_thought_line_list.begin();
5693 str_itr != this->m_current_thought_line_info->m_thought_line_list.end() && within_line == false; str_itr++) {
5694 switch (_ID_pt->m_ID_Type) {
5695 case 301: invest_pt = (Investigator *) _ID_pt;
5696 if (invest_pt->CheckWhetherInAThoughtLine(*str_itr) == true) { within_line = true; }
5697 break;
5698 case 302: link_pt = (InvestigatorLink *) _ID_pt;
5699 if (link_pt->CheckWhetherInAThoughtLine(*str_itr) == true) { within_line = true; }
5700 break;
5701 }
5702 }
5703
5704 return within_line;
5705}
5706
5708 float activation;
5709 activation = min<float>(_a, 1);
5710 if (activation < _sent_pt->m_activation) { return; }
5711 _sent_pt->m_old_activation = _sent_pt->m_activation;
5712 _sent_pt->m_change_ratio = activation / (_sent_pt->m_activation);
5713 _sent_pt->m_activation = activation;
5716}
5717
5719 Statement *found_pt = NULL;
5720 Statement *state_pt;
5721
5722 bool stop_bl = false;
5723 for (auto state_ritr = this->m_Statement_list.rbegin();
5724 state_ritr != this->m_Statement_list.rend() && found_pt == NULL && stop_bl == false; state_ritr++) {
5725 state_pt = state_ritr->get();
5726 if (state_pt == _statement_pt) { continue; }
5727 if (state_pt->m_time_generated < _statement_pt->m_time_range.GetTimeBoundLater() - 10) { stop_bl = true; }
5728 if (state_pt->m_sent_pt == _statement_pt->m_sent_pt && state_pt->m_state == _statement_pt->m_state) {
5729 if (state_pt->m_time_range.GetTimeBoundLater() - _statement_pt->m_time_range.GetTimeBoundLater() < 10 &&
5730 _statement_pt->m_time_range.GetTimeBoundLater() - state_pt->m_time_range.GetTimeBoundLater() < 10) {
5731 found_pt = state_pt;
5732 }
5733 }
5734 }
5735 return found_pt;
5736}
5737
5739 bool found = false;
5740 bool consist_bl;
5741 Investigator *invest_pt;
5742 KnowledgeElement *KE_pt;
5743 float t1 = _state_pt->m_time_range.GetTimeBoundEarlier();
5744 float t2 = _state_pt->m_time_range.GetTimeBoundLater();
5745
5746 for (auto invest_ritr = this->m_investigator_pool.rbegin();
5747 invest_ritr != this->m_investigator_pool.rend() && found == false; invest_ritr++) {
5748 invest_pt = invest_ritr->get();
5749 if (invest_pt->m_KElement_ID_pt == NULL) { continue; }
5750 KE_pt = (KnowledgeElement *) invest_pt->m_KElement_ID_pt;
5751 if (_state_pt->m_sent_pt != KE_pt->m_SentenceUnit_pt) { continue; }
5752 if (_state_pt->m_state == KE_pt->m_negation) { continue; }
5753 if ((t1 >= invest_pt->m_effective_start && t1 <= invest_pt->m_effective_end)
5754 ||
5755 (t2 >= invest_pt->m_effective_start && t2 <= invest_pt->m_effective_end)) {
5756 found = true;
5757 if (invest_pt->m_Statement_pt == NULL) {
5758 invest_pt->m_Statement_pt = _state_pt;
5759 this->AddDeltaToCognitiveLoad(0.024); //type 4
5760 _state_pt->m_investigator_ID_pt = (IDElement *) invest_pt;
5761 if (invest_pt->m_Happen == 2) {
5762 invest_pt->m_Happen = 3;
5763 }
5764 }
5765 }
5766 }
5767 return found;
5768}
5769
5771 //50 second
5772 Investigator *invest_pt;
5773 Investigator *found_invest_pt = NULL;
5774 SentenceUnit *sent_pt1;
5775 SentenceUnit *sent_pt2;
5776 float time_center;
5777 if (_invest_pt->m_Statement_pt != NULL) {
5778 time_center = _invest_pt->m_Statement_pt->m_time_range.GetTimeBoundLater();
5779 if (time_center == 0) { this->PrintMessage(""); }
5780 sent_pt1 = _invest_pt->m_Statement_pt->m_sent_pt;
5781 } else {
5782 time_center = min(_invest_pt->m_effective_end, _invest_pt->m_investigation_initiate_time);
5783 sent_pt1 = ((KnowledgeElement *) _invest_pt)->m_SentenceUnit_pt;
5784 }
5785
5786 for (auto invest_ritr = this->m_resolved_investigator_pool.rbegin();
5787 invest_ritr != this->m_resolved_investigator_pool.rend() && found_invest_pt == NULL; invest_ritr++) {
5788 invest_pt = *invest_ritr;
5789 if (invest_pt->m_KElement_ID_pt == NULL) { continue; }
5790 sent_pt2 = ((KnowledgeElement *) invest_pt->m_KElement_ID_pt)->m_SentenceUnit_pt;
5791 if (sent_pt1 != sent_pt2) { continue; }
5792
5793 if (invest_pt->m_Happen_incomplete == true || invest_pt->m_Explain_incomplete == true) { continue; }
5794
5795 if (time_center > invest_pt->m_effective_start - 300 && time_center < invest_pt->m_effective_end + 300) {
5796 found_invest_pt = invest_pt;
5797 }
5798 }
5799 return found_invest_pt;
5800}
5801
5803 //50 second
5804 Investigator *invest_pt;
5805 Investigator *found_invest_pt = NULL;
5806 SentenceUnit *sent_pt1;
5807 SentenceUnit *sent_pt2;
5808 float time_center;
5809 if (_invest_pt->m_Statement_pt != NULL) {
5810 time_center = _invest_pt->m_Statement_pt->m_time_range.GetTimeBoundLater();
5811 if (time_center == 0) { this->PrintMessage(""); }
5812 sent_pt1 = _invest_pt->m_Statement_pt->m_sent_pt;
5813 } else {
5814 time_center = min(_invest_pt->m_effective_end, _invest_pt->m_investigation_initiate_time);
5815 sent_pt1 = ((KnowledgeElement *) _invest_pt)->m_SentenceUnit_pt;
5816 }
5817
5818 for (auto invest_ritr = this->m_unresolved_investigator_pool.rbegin();
5819 invest_ritr != this->m_unresolved_investigator_pool.rend() && found_invest_pt == NULL; invest_ritr++) {
5820 invest_pt = *invest_ritr;
5821
5822 if (invest_pt->m_Statement_pt != NULL) {
5823 sent_pt2 = invest_pt->m_Statement_pt->m_sent_pt;
5824 if (_invest_pt->m_Statement_pt != NULL) {
5825 if (_invest_pt->m_Statement_pt->m_state != invest_pt->m_Statement_pt->m_state) { continue; }
5826 }
5827 } else {
5828 sent_pt2 = ((KnowledgeElement *) invest_pt->m_KElement_ID_pt)->m_SentenceUnit_pt;
5829 }
5830 if (sent_pt1 != sent_pt2) { continue; }
5831
5832 if (invest_pt->m_KElement_ID_pt == NULL) {
5833 if (time_center > invest_pt->m_Statement_pt->m_time_range.GetTimeBoundEarlier() - 150
5834 && time_center < invest_pt->m_Statement_pt->m_time_range.GetTimeBoundLater()) { found_invest_pt = invest_pt; }
5835 } else if (time_center > invest_pt->m_effective_start - 150 && time_center < invest_pt->m_effective_end + 150) {
5836 found_invest_pt = invest_pt;
5837 }
5838 }
5839 return found_invest_pt;
5840}
5841
5843 vector<string>::iterator str_itr;
5844
5845 int i;
5846 str_itr = this->m_ongoing_item_stack.begin();
5847 i = 0;
5848
5849 while (i < this->m_ongoing_item_stack.size()) {
5850 str_itr = this->m_ongoing_item_stack.begin();
5851 str_itr += i;
5852 if (_ID.compare(*str_itr) == 0) {
5853 this->m_ongoing_item_stack.erase(str_itr);
5854 } else { i++; }
5855 }
5856}
5857
5859 bool added = false;
5860 vector<string>::iterator str_itr;
5861
5862 str_itr = this->m_ongoing_item_stack.begin();
5863 while (str_itr != this->m_ongoing_item_stack.end() && added == false) {
5864 if (_ID.compare(*str_itr) == 0) { added = true; }
5865 str_itr++;
5866 }
5867
5868 if (added == false) { this->m_ongoing_item_stack.push_back(_ID); }
5869}
5870
5872 string str;
5873 str = "Goofy";
5874 this->WriteAuxInfo(str);
5875 this->m_consumed_time = this->m_time_length;
5876 if (this->m_goofy_start_time < 0.0001) { this->m_goofy_start_time = r5pars_.timesno; }
5877
5879 exp(-0.04 * (r5pars_.timesno - this->m_goofy_start_time))));
5880}
5881
5883 float deltaT;
5884 deltaT = this->m_time_length - this->m_consumed_time;
5886 deltaT += 0.001;
5887 return deltaT;
5888}
5889
5891 Statement *state_pt;
5892 vector<Statement *> state_list;
5893 vector<Statement *>::iterator state_itr;
5894 vector<Statement *>::iterator state_itr2;
5895 vector<Statement *>::iterator state_itr3;
5896 bool exist_bl;
5897 Investigator *invest_pt;
5898 SentenceUnit *sent_pt;
5899
5900 state_list.push_back(_state_pt);
5901 int i = 0;
5902
5903 while (i < state_list.size()) {
5904 state_itr = state_list.begin();
5905 state_itr += i;
5906 state_pt = *state_itr;
5907 sent_pt = state_pt->m_sent_pt;
5908 if (sent_pt->m_activation < 1) {
5910 }
5911 //first check the investigator associated with this statement
5912 if (state_pt->m_investigator_ID_pt != 0) {
5913 invest_pt = (Investigator *) (state_pt->m_investigator_ID_pt);
5914 if (invest_pt != NULL) {
5915 if (invest_pt->m_investigation_closed == true
5916 && invest_pt->m_investigator_token < inv::ActiveThreshold) {// check whether to resume this item
5917 if ((this->FindASimilarInvestigatorRecentlyResolved(invest_pt) != NULL
5918 || this->FindASimilarOngoingInvestigator(invest_pt) != NULL)
5919 && invest_pt->m_active_investigation == false) {//not to resume this item
5920 } else {
5921 invest_pt->ReopenThisInvestigator();
5922 }
5923 }
5924 }
5925 }
5926 //propagate to the uppstream of this item
5927 for (state_itr2 = state_pt->m_upperstream_statement_list.begin();
5928 state_itr2 != state_pt->m_upperstream_statement_list.end(); state_itr2++) {
5929 exist_bl = false;
5930 for (state_itr3 = state_list.begin(); exist_bl == false && state_itr3 != state_list.end(); state_itr3++) {
5931 if ((*state_itr3) == (*state_itr2)) { exist_bl = true; }
5932 }
5933 if (exist_bl == false) { state_list.push_back(*state_itr2); }
5934 }
5935 //propagate to the downstream of this item
5936 for (state_itr2 = state_pt->m_downstream_statement_list.begin();
5937 state_itr2 != state_pt->m_downstream_statement_list.end(); state_itr2++) {
5938 exist_bl = false;
5939 for (state_itr3 = state_list.begin(); exist_bl == false && state_itr3 != state_list.end(); state_itr3++) {
5940 if ((*state_itr3) == (*state_itr2)) { exist_bl = true; }
5941 }
5942 if (exist_bl == false) { state_list.push_back(*state_itr2); }
5943 }
5944
5945 i++;
5946 }
5947 state_list.clear();
5948}
5949
5951 vector<IDElement *>::iterator ID_itr;
5952 int i;
5953
5954 i = 0;
5955 while (i < this->m_decayed_item_pt_list.size()) {
5956 ID_itr = this->m_decayed_item_pt_list.begin();
5957 ID_itr += i;
5958 if ((*ID_itr) == _ID_pt) { this->m_decayed_item_pt_list.erase(ID_itr); }
5959 else { i++; }
5960 }
5961
5962}
5963
5965 vector<IDElement *>::iterator ID_itr;
5966 bool exist_bl = false;
5967
5968 for (ID_itr = this->m_decayed_item_pt_list.begin(); ID_itr != this->m_decayed_item_pt_list.end() && exist_bl == false;
5969 ID_itr++) {
5970 if ((*ID_itr) == _ID_pt) {
5971 exist_bl = true;
5972 break;
5973 }
5974 }
5975
5976 if (exist_bl == false) {
5977 this->m_decayed_item_pt_list.push_back(_ID_pt);
5978 }
5979}
5980
5982 vector<IDElement *>::iterator ID_itr;
5983 float score;
5984 Investigator *invest_pt;
5985 InvestigatorLink *link_pt;
5986 SentenceUnit *sent_pt;
5987
5988 int i = 0;
5989 if (r5pars_.timesno > 1740) { i = 0; }
5990
5991 while (i < this->m_decayed_item_pt_list.size()) {
5992 //three barries:
5993 //1--activation level
5994 //2--last active time has to be within 300 second
5995 //3--not paused, not dormant
5996 ID_itr = this->m_decayed_item_pt_list.begin();
5997 ID_itr += i;
5998 if (i == 23) { i = i; }
5999
6000 if ((*ID_itr)->m_ID_Type == 301) {
6001 invest_pt = (Investigator *) (*ID_itr);
6002 if (invest_pt->m_invest_dormant == true || invest_pt->m_invest_pause == true
6003 || (r5pars_.timesno - invest_pt->m_last_active_time > 300)) {
6004 i++;
6005 continue;
6006 }
6007
6008 sent_pt = invest_pt->GetSemanticSentenceOfThisInvestigator();
6009 if (sent_pt->m_activation > _value) {
6010 if (this->FindASimilarInvestigatorRecentlyResolved(invest_pt) == NULL
6011 && this->FindASimilarOngoingInvestigator(invest_pt) == NULL) {
6012 invest_pt->ReopenThisInvestigator();
6013 //this->m_decayed_item_pt_list.erase(ID_itr);
6014 if (i == this->m_decayed_item_pt_list.size()) { break; }
6015 continue;
6016 }
6017 }
6018 } else if ((*ID_itr)->m_ID_Type == 302) {
6019 link_pt = (InvestigatorLink *) (*ID_itr);
6020 if (link_pt->m_invest_link_dormant == true || link_pt->m_invest_link_pause == true
6021 || (r5pars_.timesno - link_pt->m_link_last_activated_time > 300)) {
6022 i++;
6023 continue;
6024 }
6025
6026 if (link_pt->GetActivationOfthisLink() > _value) {
6027 link_pt->m_forgotten_bl = false;
6028 this->m_decayed_item_pt_list.erase(ID_itr);
6029 continue;
6030 }
6031 }
6032
6033 i++;
6034 }
6035
6036}
6037
6039 _delta *= 0.108;
6040 this->m_cognitive_load += _delta;
6041 this->m_cognitive_load = min<float>(this->m_cognitive_load, 1);
6042}
6043
6045 _delta *= 0.108;
6046 this->m_system_dynamic_level += _delta;
6047}
6048
6050 float value;
6051 bool confuse_bl;
6052 float max_confusion = 0;
6053 int num;
6054
6055 //cogntive load is already updated
6056
6057 //complexity
6058 if (r5pars_.timesno > 1860) { this->PrintMessage(""); }
6059 for (auto di_itr = this->m_event_schema_base->m_diagnose_invest_list.begin();
6060 di_itr != this->m_event_schema_base->m_diagnose_invest_list.end(); di_itr++) {
6061 if ((*di_itr)->m_terminate_investigation == true) { continue; }
6062 confuse_bl = false;
6063 if ((*di_itr)->m_N_setback_list.size() > 0) {
6064 num = *((*di_itr)->m_N_setback_list.rbegin());
6065 if (num > 0) {
6066 { max_confusion = max((*di_itr)->m_confidence, max_confusion); }
6067 }
6068 }
6069 }
6070
6071 this->m_diagnosis_complexity = 0.8 * this->m_system_dynamic_level + 0.2 * max_confusion;
6072
6073 //stress
6074 this->m_overall_stress = 0.25
6075 * (this->m_passive_alarm_load->GetAlarmLoadValue() + this->m_time_constraint->getTimeConstrainedPIFValue() / 10
6077
6078 //fatigue
6079 this->m_load_stress_integration_of_time += this->m_cognitive_load * pow(1 + this->m_overall_stress, 2);
6080 this->m_fatigue_level = this->m_initial_fatigue_level + 0.20 * (1 - exp(-0.00008 * r5pars_.timesno))
6081 + 0.8 * (1 - exp(-0.000054 * this->m_load_stress_integration_of_time));
6082}
6083
6085 //alarm stack length
6086 this->m_max_length_of_alarms_stack = (4 + 3 * this->m_interuptiveness)
6087 * (1 - 0.5 * this->m_passive_alarm_load->GetAlarmLoadValue() / this->m_interuptiveness)
6088 * (1 - 0.5 * this->m_time_constraint->getTimeConstrainedPIFValue() / 10) * (1 - 0.5 * this->m_fatigue_level);
6089
6090 //Cognitive Resource Use
6093 + 0.3 * this->m_passive_alarm_load->GetAlarmLoadValue()
6094 + 0.2 * this->m_cognitive_load
6095 + 0.1 * this->m_diagnosis_complexity;
6096
6097 //time cost multiplier
6099 1 / ((1 + this->m_cognitive_resource_use) * (1 - 0.8 * this->m_fatigue_level));
6100
6101 //routine monitor interval multiplier
6103
6104 //attention span
6106 / ((1 + this->m_time_constraint->getTimeConstrainedPIFValue() / 10) * (1 + this->m_fatigue_level));
6107
6108 //memory span
6109 this->m_memory_span = this->m_memory_span_base_value * (1 + this->m_expert_level)
6110 / ((1 + 0.2 * this->m_time_constraint->getTimeConstrainedPIFValue() / 10) * (1 + this->m_fatigue_level));
6111
6112 //decay time
6114 / ((1 + this->m_fatigue_level) * (1 + this->m_passive_alarm_load->GetAlarmLoadValue()));
6115
6116}
6117
6119 unique_ptr<ValueTimeLineUnit> vtu_pt;
6120
6121//PSF
6122 //time constraint load
6123 vtu_pt = make_unique<ValueTimeLineUnit>();
6124 vtu_pt->m_time = r5pars_.timesno;
6125 vtu_pt->m_fl = this->m_time_constraint->getTimeConstrainedPIFValue() / 10;
6126 this->m_time_load_history.push_back(std::move(vtu_pt));
6127
6128 //passive load
6129 vtu_pt = make_unique<ValueTimeLineUnit>();
6130 vtu_pt->m_time = r5pars_.timesno;
6131 vtu_pt->m_fl = this->m_passive_alarm_load->m_alarm_load_value;
6132 this->m_passive_alarm_load->m_passive_alarm_load_timeline.push_back(std::move(vtu_pt));
6133
6134 //fatigue
6135 vtu_pt = make_unique<ValueTimeLineUnit>();
6136 vtu_pt->m_time = r5pars_.timesno;
6137 vtu_pt->m_fl = this->m_fatigue_level;
6138 this->m_fatigue_history.push_back(std::move(vtu_pt));
6139
6140 //complexity
6141 vtu_pt = make_unique<ValueTimeLineUnit>();
6142 vtu_pt->m_time = r5pars_.timesno;
6143 vtu_pt->m_fl = this->m_diagnosis_complexity;
6144 this->m_diagnosis_complexity_history.push_back(std::move(vtu_pt));
6145
6146 //cognitive load
6147 vtu_pt = make_unique<ValueTimeLineUnit>();
6148 vtu_pt->m_time = r5pars_.timesno;
6149 vtu_pt->m_fl = this->m_cognitive_load;
6150 this->m_cognitive_load_history.push_back(std::move(vtu_pt));
6151
6152 //stress
6153 vtu_pt = make_unique<ValueTimeLineUnit>();
6154 vtu_pt->m_time = r5pars_.timesno;
6155 vtu_pt->m_fl = this->m_overall_stress;
6156 this->m_stress_history.push_back(std::move(vtu_pt));
6157
6158
6159//middle variables history
6160 vtu_pt = make_unique<ValueTimeLineUnit>();
6161 vtu_pt->m_time = r5pars_.timesno;
6162 vtu_pt->m_fl = this->m_cognitive_resource_use;
6163 this->m_cognitive_resouse_use_history.push_back(std::move(vtu_pt));
6164
6165//manifestation variables history
6166 //max stack length
6167 vtu_pt = make_unique<ValueTimeLineUnit>();
6168 vtu_pt->m_time = r5pars_.timesno;
6169 vtu_pt->m_int = this->m_max_length_of_alarms_stack;
6170 this->m_max_alarm_length_timeline.push_back(std::move(vtu_pt));
6171
6172 //time consumption multiplier
6173 vtu_pt = make_unique<ValueTimeLineUnit>();
6174 vtu_pt->m_time = r5pars_.timesno;
6175 vtu_pt->m_fl = this->m_cognitive_time_cost_multiplier;
6176 this->m_cognitive_time_cost_multiplier_history.push_back(std::move(vtu_pt));
6177
6178 //routine monitor
6179 vtu_pt = make_unique<ValueTimeLineUnit>();
6180 vtu_pt->m_time = r5pars_.timesno;
6181 vtu_pt->m_fl = this->m_routine_monitor_interval_multiplier;
6182 this->m_routine_monitor_interval_multiplier_history.push_back(std::move(vtu_pt));
6183
6184 //attention span
6185 vtu_pt = make_unique<ValueTimeLineUnit>();
6186 vtu_pt->m_time = r5pars_.timesno;
6187 vtu_pt->m_fl = this->m_attention_span;
6188 this->m_attention_span_history.push_back(std::move(vtu_pt));
6189
6190 //memory span
6191 vtu_pt = make_unique<ValueTimeLineUnit>();
6192 vtu_pt->m_time = r5pars_.timesno;
6193 vtu_pt->m_fl = this->m_memory_span;
6194 this->m_memory_span_history.push_back(std::move(vtu_pt));
6195
6196 //decay time of investigation items
6197 vtu_pt = make_unique<ValueTimeLineUnit>();
6198 vtu_pt->m_time = r5pars_.timesno;
6199 vtu_pt->m_fl = this->m_decay_time;
6200 this->m_decay_time_history.push_back(std::move(vtu_pt));
6201}
6202
6204 float fl;
6205 string str;
6206
6207 for (auto KU_itr = this->m_Knowledge_list.begin(); KU_itr != this->m_Knowledge_list.end(); KU_itr++) {
6208 fl = ((float) rand() / float(RAND_MAX));
6209 if (fl > (*KU_itr)->m_knowledge_strength) {
6210// (*KU_itr)->m_accessable_bl = false;
6211 str = "Disabled Knowledge Link: " + (*KU_itr)->m_ID;
6212 this->WriteAuxInfo(str);
6213 }
6214 }
6215}
6216
6218 /*
6219 fout <<"\n" << "Time: " << r5pars_.timesno << ":\n" << str << '\n';
6220 fout.close();
6221 */
6222 KnowledgeUnit *KU_pt;
6223 KnowledgeElement *KE_pt;
6224
6225 string file_name;
6226 file_name = g_sim.SScheduler.getOutputDirectory();
6227 file_name += "RMOutPut/";
6228 file_name += "ODM_Knowledge_Web.txt";
6229 ofstream fout(file_name.c_str(), ios::out);
6230 /*vector<SentenceUnit*>::iterator sent_itr;
6231 fout << "There are " << this->m_Semantic_list.size() + " sentences in total" + '\n';
6232 for(sent_itr = this->m_Semantic_list.begin(); sent_itr != this->m_Semantic_list.end(); sent_itr++)
6233 {
6234 fout << (*sent_itr)->m_ID << '\n';
6235 }*/
6236
6237 fout << "upstream phenomenon" << '\t'
6238 << "downstream phenomenon" << '\t'
6239 << "causal type" << '\t'
6240 << "inference type" << '\t'
6241 << "familiarity" << '\t'
6242 << "strength 1" << '\t'
6243 << "strength 2" << '\t'
6244 << "delta T1" << '\t'
6245 << "delta T2" << '\t'
6246 << "conditional phenomenon" << '\n';
6247
6248 for (auto KU_itr = this->m_Knowledge_list.begin(); KU_itr != this->m_Knowledge_list.end(); KU_itr++) {
6249 KU_pt = KU_itr->get();
6250
6251 if (KU_pt->m_Ancestor_pt->m_ID_Type == 401) {
6252 KE_pt = (KnowledgeElement *) (KU_pt->m_Ancestor_pt);
6253 fout << KE_pt->m_SentenceUnit_pt->m_ID << '\t';
6254 } else if (KU_pt->m_Ancestor_pt->m_ID_Type == 402) {
6255 fout << KU_pt->m_Ancestor_pt->m_ID << '\t';
6256 }
6257
6258 if (KU_pt->m_Descendant_pt->m_ID_Type == 401) {
6259 KE_pt = (KnowledgeElement *) (KU_pt->m_Descendant_pt);
6260 fout << KE_pt->m_SentenceUnit_pt->m_ID << '\t';
6261 } else if (KU_pt->m_Descendant_pt->m_ID_Type == 402) {
6262 fout << KU_pt->m_Descendant_pt->m_ID << '\t';
6263 }
6264 fout
6265 << KU_pt->m_causal_type << '\t'
6266 << KU_pt->m_inference_type << '\t'
6267 << KU_pt->m_knowledge_strength << '\t'
6268 << KU_pt->m_forward_retrieve_weight << '\t'
6269 << KU_pt->m_backward_retrieve_weight << '\t'
6270 << KU_pt->m_deltaT1 << '\t'
6271 << KU_pt->m_deltaT2 << '\t';
6272 if (KU_pt->m_Permission_pt != NULL) {
6273 if (KU_pt->m_Permission_pt->m_ID_Type == 401) {
6274 KE_pt = (KnowledgeElement *) (KU_pt->m_Permission_pt);
6275 fout << KE_pt->m_SentenceUnit_pt->m_ID;
6276 } else {
6277 fout << KU_pt->m_Permission_pt->m_ID;
6278 }
6279 }
6280
6281 fout << '\n';
6282 }
6283 fout.close();
6284}
Diagnostic reasoning engine — knowledge representation, mental model, and inference.
DisplayType
Definition: SimConstants.h:41
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
double m_change_ratio
Definition: Activation.h:19
void UpdateTheBaseLineValueAfterAChange(float _decay_lamda)
Definition: Activation.cpp:75
double m_old_activation
Definition: Activation.h:23
double m_activation
Definition: Activation.h:22
std::string getAlarmName()
int getDisplayedAlarmState()
int getIDOfRecentGeneratedES()
std::vector< IDElement * > m_antonym_list
IDElement * m_Indefinite_Concept_ID_pt
SystemAlarm * getAlarmFromMap(std::string)
SystemDisplay * getDisplayFromMap(std::string)
ControlPanelDisplay indicators
Definition: ControlPanel.h:53
ControlPanelAlarm alarms
Definition: ControlPanel.h:52
std::string getDisplayName()
int m_ID_Type
Definition: IDElement.h:15
std::string m_ID
Definition: IDElement.h:16
std::vector< std::shared_ptr< MentalSupportSystemState > > perceived_support_system_state
Definition: InfoChunk.h:146
std::vector< std::shared_ptr< MentalParameterValue > > perceived_parameter_value
Definition: InfoChunk.h:147
int ReturnPositionOfOneMentalParameterValue(MentalParameterValue *)
Definition: InfoChunk.cpp:2223
int ReturnPositionOfOneMentalAlarmInTheVector(MentalAlarm *)
Definition: InfoChunk.cpp:2240
std::vector< std::shared_ptr< MentalAlarm > > perceived_alarms
Definition: InfoChunk.h:144
std::vector< std::shared_ptr< MentalComponentState > > perceived_component_state
Definition: InfoChunk.h:145
int ReturnPositionOfOneMentalComponentStateInTheVector(MentalComponentState *)
Definition: InfoChunk.cpp:2189
int ReturnPositionOfOneMentalSupportSystemStateInTheVector(MentalSupportSystemState *)
Definition: InfoChunk.cpp:2206
Label * m_label_pt
Definition: Instantiation.h:21
std::vector< ConceptComposedUnit * > m_instance_list
Definition: Instantiation.h:23
bool m_invest_pause
Definition: Investigator.h:95
float m_last_active_time
Definition: Investigator.h:87
std::string m_note
Definition: Investigator.h:124
bool m_investigation_closed
Definition: Investigator.h:88
double m_investigation_initiate_time
Definition: Investigator.h:117
bool m_motivation
Definition: Investigator.h:92
bool m_invest_dormant
Definition: Investigator.h:94
std::string GetASimpleDescriptionOfThisInvestigator()
double m_effective_end
Definition: Investigator.h:118
SentenceUnit * GetSemanticSentenceOfThisInvestigator()
bool m_Happen_incomplete
Definition: Investigator.h:81
void ReopenThisInvestigator()
double m_effective_start
Definition: Investigator.h:119
std::vector< IDElement * > m_explanation_link_list
Definition: Investigator.h:145
Statement * m_possible_statement_pt
Definition: Investigator.h:131
IDElement * m_KElement_ID_pt
Definition: Investigator.h:129
bool m_Explain_incomplete
Definition: Investigator.h:82
bool m_active_investigation
Definition: Investigator.h:22
bool m_root_of_a_thought_line
Definition: Investigator.h:85
Statement * m_inconsistant_statement
Definition: Investigator.h:127
std::vector< IDElement * > m_downstream_ID_list
Definition: Investigator.h:144
bool CheckWhetherInAThoughtLine(std::string)
double m_investigation_cease_time
Definition: Investigator.h:116
std::vector< IDElement * > m_upperstream_ID_list
Definition: Investigator.h:143
int m_investigator_token
Definition: Investigator.h:99
void OneStepWorkOnThisInvestigator()
float CalculateFilteredPrioritizingScoreOfInvestigator()
std::vector< int > m_investigator_token_history
Definition: Investigator.h:139
std::vector< float > m_invest_token_endtime_history
Definition: Investigator.h:140
IDElement * m_SI_ID_pt
Definition: Investigator.h:128
std::vector< std::string > m_thoughtline_roots_list
Definition: Investigator.h:84
float GetInitiationTimeOrStatementTimeOrLastActiveTime()
Statement * m_Statement_pt
Definition: Investigator.h:130
SentenceUnit * m_SentenceUnit_pt
std::vector< KnowledgeElement * > M_KElement_list
Definition: KnowledgeNode.h:28
void ReadThisKNinfoFromFile(std::ifstream &)
IDElement * m_Descendant_pt
Definition: KnowledgeUnit.h:24
IDElement * m_Permission_pt
Definition: KnowledgeUnit.h:26
IDElement * m_Ancestor_pt
Definition: KnowledgeUnit.h:25
float m_knowledge_strength
Definition: KnowledgeUnit.h:32
double m_forward_retrieve_weight
Definition: KnowledgeUnit.h:31
void ReadKnowledgeUnitFromInputFile(std::ifstream &)
double m_backward_retrieve_weight
Definition: KnowledgeUnit.h:30
Definition: Label.h:13
std::vector< IDElement * > m_label_option_list
Definition: Label.h:21
IDElement * m_Concept_pt
Definition: MRAlarmUnit.h:39
void AddNewAlarmState(int, int, bool)
Definition: MRAlarmUnit.cpp:44
std::string m_alarm_indicator_name
Definition: MRAlarmUnit.h:31
void AddNewAlarmStateForFirstRoundCheck(int, int)
void AddNewState(int, int, bool)
void AddNewStateForFirstRoundCheck(int, int)
std::string Control_Value_Indicator_ID
std::string Component_State_Indicator_ID
void AddNewPositionValue(float, int, bool)
MRValueSchema * FoundAPositionReadingWithinTimeRange(float, float)
void AddNewRateForFirstRoundCheck(float, int)
std::string m_parameter_indicator_ID
void AddNewRate(float, int, bool)
void AddNewValue(float, int, bool)
IDElement * m_Concept_ID_pt
void AddNewValueForFirstRoundCheck(float, int)
MRValueSchema * FoundAValueReadingWithinTimeRange(float, float)
std::string m_parameter_rate_indicator_ID
float m_time_perceived
Definition: MRValueSchema.h:11
float m_perceived_value
Definition: MRValueSchema.h:14
int getObservedAlarmState()
Definition: MentalAlarm.cpp:33
TimeConstrainedModule time_constrained_load
Definition: Operator.h:132
ShortTermMemory memory
Definition: Operator.h:126
std::vector< std::string > indication_concept_ID_list
std::vector< int > m_position_tbi_SS_list
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_time_load_history
void CopySemanticInfoFromAnotherSemanticBase(ReasonMachine *)
void ReadKnowledgeBaseFromInputFile()
std::vector< std::unique_ptr< StringTimeIntervalUnit > > m_investigation_history
float m_initial_fatigue_level
int m_max_length_of_alarms_stack
float m_system_dynamic_level
void PrintSemanticBase()
std::unique_ptr< KBConcept > m_Concept_Base
Investigator * FindASimilarInvestigatorRecentlyResolved(Investigator *)
Investigator * FindAMatchInvestigatorByKnowledgeElement(KnowledgeElement *, int, int)
InvestigatorLink * FindInvestigatorLinkByID(std::string)
void RemoveItemFromDecayedItemList(IDElement *)
void AddItemToDecayedItemList(IDElement *)
void SavePSFandDynamicParametersToFile(std::string _path)
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_fatigue_history
std::string m_ID_buffer_invest_pt
float m_memory_span_base_value
void UpdateManifestationParameterAtEndOfATimeStep()
void ConvertRMStaticInfoToStringForm()
void ReOpenItemWithActivationLevelAboveAGivenValue(float)
KnowledgeUnit * FindKnowledgeUnitByID(std::string)
std::vector< Statement * > m_new_Statement_list
float m_overall_stress
std::vector< std::string > m_ID_discarded_invest_pool
std::vector< std::unique_ptr< Investigator > > m_investigator_pool
void AddANewKnowledgeUnit(KnowledgeUnit *)
void ErrorMessage(std::string)
void SaveInvestigationsToFile(std::string _path)
SentenceUnit * SearchSentenceByID(std::string)
void PrintKnowledgeWeb()
double m_alarm_disruption_time_consumption
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_cognitive_resouse_use_history
void EraseFromOngoingItemStack(std::string)
void AddNewInvestigatorLink(InvestigatorLink *)
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_max_alarm_length_timeline
std::vector< std::unique_ptr< InvestigatorLink > > m_investigator_link_pool
std::string m_ID_working_on_invest
std::vector< Statement * > m_temporary_statement_list
void RandomlyGenerateKnowledgeBug()
std::vector< Investigator * > m_undetermined_investigator_pool
void AutoIgnitionOfDecayedInvestigatorInitiatedByActivatingAStatement(Statement *)
void ActivationUpdateByRefreshAStatement(Statement *)
float m_cognitive_time_cost_base_multiplier
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_cognitive_load_history
void AddPSFandManifestationDataSet()
void AddOneInvestigatorByStatement(Statement *)
float m_decay_time_base_value
float m_routine_monitor_threshold
double m_decay_constant_lamda
int GetAComponentStateImediately(std::string MR_name)
std::vector< MentalAlarm * > m_tbi_A_list
Investigator * m_working_on_invest_pt
Statement * FindRecentStatementBySentence(SentenceUnit *)
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_attention_span_history
bool m_first_round_check_done
void OneStepWorkOnSelectedInvestigatorLink3100()
float m_cognitive_load
void OneStepOfReasonMachine()
std::vector< MentalComponentState * > m_tbi_C_list
void WaitOneStepThereIsOneOrMoreOperatorBranches()
std::vector< Investigator * > m_failed_investigator_pool
void AddToRMFeedbackStack(IDElement *)
std::vector< std::string > m_ongoing_item_stack
void AddDeltaToCognitiveLoad(float)
std::vector< std::string > m_ID_unresolved_invest_pool
float GetAParameterValueImediately(std::string)
void DecayOfForgottenInvestigator()
void AddANewStatement(Statement *)
std::vector< Investigator * > m_discarded_investigator_pool
void ActivationDecayofRM()
void ZeroAllTheInterestFromSymptomInvestigator()
std::vector< std::unique_ptr< SentenceUnit > > m_Semantic_list
void CopyStaticKNfromAnotherRM(ReasonMachine *)
void RemoveInvestigatorFromUnresolvedPool(Investigator *)
float m_load_stress_integration_of_time
KnowledgeElement * FindKnowledgeElementByID(std::string)
SentenceUnit * FindAnIndefiniteSentenceMatchTheInputSentence(SentenceUnit *)
void AddItemToOngoingItemStack(std::string)
void CopyReasonMachineFromAnotherRM(ReasonMachine *)
TimeConstrainedModule * m_time_constraint
std::vector< std::string > m_ID_cause_undertermined_invest_pool
std::vector< std::unique_ptr< StringTimeIntervalUnit > > m_thought_line_history
std::vector< Investigator * > m_unresolved_investigator_pool
void ClearTBIListsForRestart()
bool m_block_alarm_jam
KnowledgeElement * FindAKEbySentenceAndNegationSign(SentenceUnit *, bool)
std::vector< std::string > m_ID_feedback_stack
void SetAllSentenceActivationRatioToOne()
void CopyStaticKEfromAnotherRM(ReasonMachine *)
void ClearThisReasonMachine()
void ReadOperatorReasonMachineProfile()
void SaveThoughtLineHistory(std::string)
void EraseItemFromFeedbackStack(IDElement *)
float m_cognitive_resource_use
int FindThePositionInTheInvestigationHistory(std::string)
void PropagateActivationFromConceptToSemanticSentence()
InvestigatorLink * m_working_on_invest_link_pt
int GetAlarmStateImediately(std::string CP_name)
float m_diagnosis_complexity
std::vector< std::unique_ptr< Statement > > m_Statement_list
float m_expert_level
std::vector< int > m_position_tbi_A_list
void ReadSemanticSentencesFromInputFile()
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_cognitive_time_cost_multiplier_history
std::unique_ptr< RoutineMonitor > m_routine_monitor
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_diagnosis_complexity_history
IDElement * FindInvestigatorOrLinkByID(std::string)
void ReadKEBaseAndKNFromInputFile()
std::vector< MentalParameterValue * > m_tbi_P_list
float m_ability_of_integrating_evidence
std::vector< IDElement * > m_feedback_stack
std::vector< Investigator * > m_cause_undetermined_investigato_pool
std::unique_ptr< ProximityModel > m_proximity
KnowledgeElement * FindKnowledgeElementByStatement(Statement *)
std::vector< std::string > m_ID_undertermined_invest_pool
IDElement * m_reading_indication_ID_pt
void SaveRMHisoty(std::string)
std::vector< std::unique_ptr< KnowledgeNode > > m_KN_list
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_routine_monitor_interval_multiplier_history
float m_consumed_time
void CutTheLengthOfAlarmStack()
void CheckWhetherTheThoughtLineHasChanged()
ProblemSolvingStyle m_problem_solving_style
void AddConsumptedDeltaT(double)
float m_interuptiveness
Definition: ReasonMachine.h:62
Statement * FoundASimilarStatementInLast10Seconds(Statement *)
void WriteAuxInfo(std::string str)
int m_investigator_number
std::vector< std::unique_ptr< KnowledgeElement > > m_KE_list
std::string m_ID_reading_indication
float m_fatigue_level
std::unique_ptr< InstantiationBase > m_IB
std::vector< float > m_RM_token_endtime_history
Statement * FindStatementByID(std::string)
std::unique_ptr< MentalRepresentation > m_MR
std::vector< std::string > m_ID_temporary_statement_list
float m_routine_monitor_interval_multiplier
void OneRoundActivationSpreadingFromASentence(SentenceUnit *)
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_stress_history
void PrintMessage(std::string)
Investigator * FindInvestigatorByID(std::string)
std::vector< std::string > m_ID_resolved_invest_pool
std::vector< IDElement * > m_investigation_trace
int GetASupportSystemStateImediately(std::string MR_name)
void OneStepInterpretation20()
SentenceUnit * CheckExistInSemanticPoolBySentence(SentenceUnit *)
void SettingForVagabondStyle()
Investigator * FindASimilarOngoingInvestigator(Investigator *)
std::vector< std::string > m_decayed_item_ID_list
Definition: ReasonMachine.h:58
std::vector< std::unique_ptr< KnowledgeUnit > > m_Knowledge_list
void InitiationOfReasonMachineFromInputFile()
float CheckRemainingTimeForThisStep()
std::vector< std::string > m_ID_invest_trace
void SaveStatementsToFile(std::string _path)
std::unique_ptr< StringTimeIntervalUnit > m_current_thought_line_info
std::vector< std::string > m_ID_new_statement_list
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_cognitive_time_cost_multiplier_timeline
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_memory_span_history
int FindThePositionInTheThoughtLineHistory(IDElement *)
void FindCorrespondingStatementWithinTimeRange(SentenceUnit *, int, int)
std::unique_ptr< EventSchemaBase > m_event_schema_base
std::unique_ptr< PassiveAlarmLoadUnit > m_passive_alarm_load
std::vector< std::string > m_ID_succes_invest_pool
void UpdatePSFAtEndOfATimeStep()
void AddDeltaToSystemDynamics(float)
KnowledgeNode * FindKNByID(std::string)
std::vector< Investigator * > m_resolved_investigator_pool
std::string TranslateRMTokenToWords(int)
std::vector< std::string > m_ID_failed_invest_pool
virtual ~ReasonMachine()
void AddBackToUnresolvedInvestigationPool(Investigator *)
float m_attention_span
Definition: ReasonMachine.h:67
void ChangeRMTokenValue(int)
void MakeOneStepInferenceFromAStatement(Statement *)
int m_investigator_link_number
std::vector< IDElement * > m_decayed_item_pt_list
Definition: ReasonMachine.h:57
void SaveInvestigationLinkInfo(std::string)
void BalanceTimerWithUnconsumedTime()
float m_goofy_start_time
Definition: ReasonMachine.h:59
void BuildTheConnectionsWithinRM()
bool FindAMatchingInvestigatorForAStatement(Statement *)
void CrankASentenceUnitActivationToAGivenValue(SentenceUnit *, float)
double m_decay_lamda
float m_cognitive_time_cost_multiplier
void SaveSequenceInfoToFile()
std::unique_ptr< StringTimeIntervalUnit > m_current_investigation_info
std::string m_ID_working_on_invest_link
Investigator * m_buffer_invest_pt
std::vector< int > m_RM_Token_history
Statement * CheckWhetherASentenceIsTrueFromMR(SentenceUnit *, int, int)
void OneStepPrioritizeInvestigation30()
float m_attention_span_base_value
double m_Interpretation_time_consumption
void AddNewInvestigator(Investigator *)
std::vector< int > m_position_tbi_C_list
void OneStepWorkOnSelectedInvestigator3000()
void AddANewDiagnoseInvestigator(DiagnoseInvestigator *_diagnose_invest_pt)
void OneStepRoutineMonitor10()
std::vector< std::unique_ptr< ValueTimeLineUnit > > m_decay_time_history
bool WetherAnInvestigationItemBelongsToTheCurrentThoughtLine(IDElement *)
std::vector< int > m_position_tbi_P_list
std::vector< Investigator * > m_success_investigator_pool
std::vector< MentalSupportSystemState * > m_tbi_SS_list
SentenceUnit * InstantiateAnIndefiniteSentenceWithLabel(SentenceUnit *, IDElement *)
void FirstRoundCheckInterpretation()
std::string getOATDirectory()
Definition: Scheduler.cpp:622
std::string getOutputDirectory()
Definition: Scheduler.cpp:598
std::string getODMDirectory()
Definition: Scheduler.cpp:619
IDElement * m_object_pt
Definition: SentenceUnit.h:41
IDElement * m_process_pt
Definition: SentenceUnit.h:38
int m_sentence_type
Definition: SentenceUnit.h:34
double m_value
Definition: SentenceUnit.h:31
IDElement * m_state_pt
Definition: SentenceUnit.h:36
IDElement * m_comparison_pt
Definition: SentenceUnit.h:37
void ActivationPropagationFromConceptBottomUp(int)
IDElement * GetLabelOfThisSentence()
void CopyFromAnotherSentence(SentenceUnit *)
IDElement * m_attribute_pt
Definition: SentenceUnit.h:39
IDElement * m_subject_pt
Definition: SentenceUnit.h:40
void PropagateActivationToConceptUnitsTopDown(int)
InfoChunk perceived_info
std::vector< Statement * > m_downstream_statement_list
Definition: Statement.h:46
float m_confidence
Definition: Statement.h:34
std::vector< Statement * > m_upperstream_statement_list
Definition: Statement.h:45
void PrintThisStatement()
Definition: Statement.cpp:117
int m_operator
Definition: Statement.h:32
TimeRange m_time_range
Definition: Statement.h:40
double m_last_activated_time
Definition: Statement.h:36
int m_factual_type
Definition: Statement.h:33
std::string GetThisStatementWords()
Definition: Statement.cpp:159
SentenceUnit * m_sent_pt
Definition: Statement.h:43
void CopyAuxInfoFromUpperstreamStatement(Statement *)
Definition: Statement.cpp:206
IDElement * m_investigator_ID_pt
Definition: Statement.h:42
bool m_state
Definition: Statement.h:35
double m_time_generated
Definition: Statement.h:37
DisplayType getTypeOfDisplay()
float GetTimeBoundEarlier()
Definition: TimeRange.cpp:79
float m_start_time
Definition: TimeRange.h:21
float m_time_before
Definition: TimeRange.h:19
void CopyTimeRangeFromAnother(TimeRange &)
Definition: TimeRange.cpp:91
float m_time_after
Definition: TimeRange.h:18
float m_end_time
Definition: TimeRange.h:20
float GetTimeBoundLater()
Definition: TimeRange.cpp:26
struct @0 r5pars_
constexpr int FindMatchingStatement
Definition: RMTokens.h:24
constexpr int RetrieveNextLink
Definition: RMTokens.h:33
constexpr int GetCorrespondingKE
Definition: RMTokens.h:23
constexpr int RequestInfoRead
Definition: RMTokens.h:28
constexpr int ActiveThreshold
Definition: RMTokens.h:36
constexpr int EvaluateNewFeedback
Definition: RMTokens.h:34
constexpr int RoutineMonitor
Definition: RMTokens.h:15
constexpr int WorkOnInvestigator
Definition: RMTokens.h:17
constexpr int Prioritize
Definition: RMTokens.h:16
constexpr int WorkOnInvestigatorLink
Definition: RMTokens.h:18
constexpr int ODM
Definition: SimConstants.h:145
constexpr int OAT
Definition: SimConstants.h:144
constexpr int On
Definition: SimConstants.h:105
Scheduler SScheduler
Simulation scheduling, parses CLI options.
OperatorAT Action_Taker
Crew action execution model.
ControlPanel Indicator
Control room panel state.
OperatorDM Decision_Maker
Crew decision-making model.
BranchRecord Branch_center
Dynamic event tree state.