← Documentation
ADS-IDAC Engine 5.0.0
SymptomInvestigator.cpp
Go to the documentation of this file.
1// SymptomInvestigator.cpp: implementation of the SymptomInvestigator class.
2//
4
5#include <memory>
7#include "ReasonMachine.h"
8#include "../Crew/OperatorDM.h"
9#include "../Crew/OperatorAT.h"
10#include "Label.h"
11#include "SentenceUnit.h"
12#include "InvestigatorLink.h"
13#include "KnowledgeUnit.h"
14#include "KnowledgeElement.h"
15#include "../Global/SimulationContext.h"
16using namespace std;
17
18
20// Construction/Destruction
22
24{
25 this->m_event_symptom_pt = NULL;
26 this->m_symptom_KE_pt = NULL;
27 this->m_ID_Type = 501;
29 this->m_label_ID_pt = NULL;
30 this->m_last_case_end_time = 0;
31 this->m_DI_ID_pt = NULL;
32 this->m_ID_DI = "";
33 this->m_ID_lable = "";
34 this->m_ID_esu = "";
35 this->m_ID_KE = "";
36 this->m_opposite_KE_ID = "";
37 this->m_need_to_invest_opposite_bl = false;
39 this->m_opposite_KE_pt = NULL;
40
41}
42
44{
45 this->m_ongoing_invest_list.clear();
46 this->m_ongoing_invest_link_list.clear();
47 this->m_ID_ongoing_invest_list.clear();
49
50 // unique_ptr vectors auto-delete their elements
51}
52
54{
55 vector<Investigator *>::iterator invest_itr;
56 Investigator * invest_pt;
57 Label * label_group_pt;
58 bool need_inst_bl = false;
59 SentenceUnit * sent_pt;
60 SymptomCase * case_pt;
61 //
62 ReasonMachine * RM_pt;
63 if (this->m_operator == sim::Operator::ODM)
64 {RM_pt = g_sim.Decision_Maker.m_RM.get();}
65 else if (this->m_operator == sim::Operator::OAT)
66 {RM_pt = g_sim.Action_Taker.m_RM.get();}
67 else
68 {this->ErrorMessage("Error!");}//add error message
69
70 //Firstly assign value to the m_symptom_KE_pt
71 if(this->m_event_symptom_pt == NULL)
72 {this->ErrorMessage("Error!");}//add error message
73
74 if(this->m_label_ID_pt == NULL)
75 {
76 //caution here, even though the schema doesn't contain indefinite concept, the event_symptom might contain one
78 }
79 else
80 {
81 //caution: there is one situation not included in the current codes. The sentence contains one different indefinite concept or more than one indefinite concept
82 //These codes only consider that the sentence contains the same indefinite concept consistant with the event schema
83 label_group_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(this->m_event_symptom_pt->m_symptom_KE_pt->m_SentenceUnit_pt);
84 if(label_group_pt != NULL)
85 {
86 if(RM_pt->m_IB->FindLabelGroupByLabelID(this->m_label_ID_pt) == label_group_pt)
87 {
88 need_inst_bl = true;
89 }
90 else
91 {
92 this->ErrorMessage("The codes is not ready for this situation yet!");
93 }
94 }
95
96 if(need_inst_bl == true)
97 {
99 if(sent_pt == NULL)
100 {this->ErrorMessage("Error!");}
102 if(this->m_symptom_KE_pt == NULL)
103 {this->ErrorMessage("Error!");}
104 }
105 else
106 {
108 }
109 }
110
111 //
112 bool new_case_bl;
113 for(auto &invest_e : RM_pt->m_investigator_pool)
114 {
115 new_case_bl = false;
116 invest_pt = invest_e.get();
117 if(invest_pt->m_KElement_ID_pt == (IDElement *)(this->m_symptom_KE_pt))
118 {
119 //caution: all the symptoms have to be observable
120 if(invest_pt->m_Happen == 3)
121 {
122 new_case_bl = true;
123 }
124 }
125 else if(invest_pt->m_KElement_ID_pt == NULL)
126 {
127 if(invest_pt->m_Statement_pt != NULL)
128 {
130 {new_case_bl = true;}
131 }
132 }
133 if(new_case_bl == true)
134 {
135 auto case_owned = make_unique<SymptomCase>();
136 case_pt = case_owned.get();
137 case_pt->m_finished_bl =false;
138 case_pt->m_invest_pt = invest_pt;
139 this->m_candidate_case_list.push_back(std::move(case_owned));
140 this->TrackOneInvestigationCase(case_pt);
141 }
142 }
143
144
145}
146
148{
149 cout << r5pars_.timesno << " " << str << " in SymptomInvestigator.cpp" << '\n';
150 ofstream fout("err messages.txt", ios::app);
151 fout << r5pars_.timesno << " " << str << '\n';
152 fout.close();
153 //r5pars_.terminateall = true;
154}
155
157{
158 Investigator * invest_pt;
159 Investigator * unfinished_invest_pt = NULL;
160 Investigator * problem_invest_pt = NULL;
161 Investigator * problem_permission_invest_pt = NULL;
162 KnowledgeUnit * KU_stuck_pt = NULL;
163 bool consistant_bl = true;
164 bool finished_bl = true;
165 bool jump_out_bl = false;
166 bool found_bl;
167 //vector<InvestigatorLink *>::iterator invest_link_itr;
168 vector<IDElement *>::iterator link_ID_itr;
169 vector<KnowledgeUnit *>::iterator KU_itr;
170 InvestigatorLink * invest_link_pt;
171 InvestigatorLink * unfinished_invest_link_pt = NULL;
172
173 invest_pt = _case_pt->m_invest_pt;
174 for(KU_itr = this->m_event_symptom_pt->m_KU_list.begin(); KU_itr != this->m_event_symptom_pt->m_KU_list.end() && jump_out_bl == false; KU_itr++)
175 {
176 if(invest_pt->m_Happen == 4)
177 {
178 problem_invest_pt = invest_pt;
179 jump_out_bl = true; //caution here, maybe need to investigate more?
180 continue;
181 }
182
183
184 if(invest_pt->m_investigator_token < 3013)
185 {
186 unfinished_invest_pt = invest_pt;
187 jump_out_bl = true;
188 continue;
189 }
190
191 //find an InvestigatorLink that matches the path specified in the prototype
192 found_bl = false;
193 for(link_ID_itr = invest_pt->m_upperstream_ID_list.begin(); link_ID_itr != invest_pt->m_upperstream_ID_list.end() && found_bl == false; link_ID_itr++)
194 {
195 invest_link_pt = (InvestigatorLink*)(*link_ID_itr);
196 if(invest_link_pt->m_K_unit_pt == (*KU_itr))
197 {
198 found_bl = true;
199 }
200 }
201 if(found_bl == false)
202 {this->ErrorMessage("Error!");}
203 //Examine this path
204 if(invest_link_pt->m_invest_link_dormant == true)
205 {
206 unfinished_invest_link_pt = invest_link_pt;
207 jump_out_bl = true;
208 continue;
209 }
210
211 if(invest_link_pt->m_path_status == 4)
212 {
213 jump_out_bl = true;
214 KU_stuck_pt = (*KU_itr);
215
216 if(invest_link_pt->m_condition_ID_pt != NULL)
217 {
218 invest_pt = (Investigator*)(invest_link_pt->m_condition_ID_pt);
219 {
220 if(invest_pt->m_Happen == 4)
221 {
222 problem_permission_invest_pt = invest_pt;
223 jump_out_bl = true;
224 }
225 }
226 }
227 }
228 invest_pt = NULL;
229 if(invest_link_pt->m_upperstream_ID_list.size() > 1)
230 {this->ErrorMessage("This situation is beyond the current codes!");}
231 else
232 {
233 invest_pt = (Investigator *)(*(invest_link_pt->m_upperstream_ID_list.begin()));
234 }
235 if(invest_pt->m_Happen == 4)
236 {
237 jump_out_bl = true;
238 KU_stuck_pt = (*KU_itr);
239 problem_invest_pt = invest_pt;
240 }
241 }
242
243 //attach information to the _case_pt
244 _case_pt->m_problem_invest_pt = problem_invest_pt;
245 _case_pt->m_stuck_KU_pt = KU_stuck_pt;
246 _case_pt->m_problem_permission_invest_pt = problem_permission_invest_pt;
247
248 if(jump_out_bl == true)
249 {
250 _case_pt->m_finished_bl = false;
251 }
252 else
253 {
254
255 _case_pt->m_consistant_bl = true;
256 _case_pt->m_finished_bl = true;
257 _case_pt->m_confirmed_time = r5pars_.timesno;
258 this->m_last_case_end_time = r5pars_.timesno;
259 //check point
260 if(this->m_symptom_KE_pt->m_ID == "KE_air_ejector_radiation_>_10")
261 {
262 this->ErrorMessage("check point");
263 }
264 this->MoveCaseFromCandidateTo(_case_pt, this->m_confirmed_case_list);
268 }
269
270 if(problem_invest_pt != NULL)
271 {
272
273 _case_pt->m_consistant_bl = false;
274 _case_pt->m_finished_bl = true;
275 this->m_last_case_end_time = r5pars_.timesno;
277 }
278
279 if(problem_permission_invest_pt != NULL)
280 {
281
282 _case_pt->m_consistant_bl = false;
283 _case_pt->m_finished_bl = true;
284 this->m_last_case_end_time = r5pars_.timesno;
285 if(_case_pt->m_invest_pt->m_Happen == 4)
286 {
287 _case_pt->m_exception_time = r5pars_.timesno;
288 }
289 this->MoveCaseFromCandidateTo(_case_pt, this->m_exception_case_list);
290 }
291
292 if(unfinished_invest_pt != NULL && unfinished_invest_link_pt != NULL)
293 {
294 _case_pt->m_finished_bl = false;
295 }
296}
297
299{
300 for(auto &e : this->m_candidate_case_list)
301 {
302 if(e->m_invest_pt == _invest_pt)
303 {
304 return e.get();
305 }
306 }
307 return NULL;
308}
309
310
312{
313 SymptomCase * case_pt;
314 std::size_t i = 0;
315 //
316 if (this->m_symptom_KE_pt->m_ID == "KE_SG_C_pres_decrease")
317 {
318 this->PrintMessage("check");
319 }
320 //
321 this->m_ongoing_invest_link_list.clear();
322 this->m_ongoing_invest_list.clear();
323 i = 0;
324 //check point
325 if(r5pars_.timesno > 900)
326 {
327 i = 0;
328 }
329 //
330 while(i < this->m_candidate_case_list.size())
331 {
332 case_pt = this->m_candidate_case_list[i].get();
333 if(case_pt->m_finished_bl == false)
334 {
335 this->TrackOneInvestigationCase(case_pt);
336 if(case_pt->m_unfinished_invest_pt != NULL)
337 {
338 this->m_ongoing_invest_list.push_back(case_pt->m_unfinished_invest_pt);
339 }
340
341 if(case_pt->m_unfinished_invest_link_pt != NULL)
342 {
344 }
345 }
346 else
347 {
348 this->ErrorMessage("Error!");
349 }
350 if(case_pt->m_finished_bl == false)
351 {
352 i++;
353 }
354 }
355}
356
358{
359 Investigator * invest_pt;
360 Investigator * new_invest_pt;
361 Investigator * root_invest_pt = NULL;
362 Investigator * Happen_invest_pt = NULL;
363 vector<KnowledgeUnit *>::reverse_iterator KU_ritr;
364 DiagnoseInvestigator * DI_pt;
365
366 Investigator * invest_buffer_pt;
367 Investigator * unfinished_invest_pt = NULL;
368 Investigator * problem_invest_pt = NULL;
369 Investigator * problem_permission_invest_pt = NULL;
370 KnowledgeUnit * KU_stuck_pt = NULL;
371 KnowledgeElement * KE_buffer_pt;
372 bool consistant_bl = true;
373 bool finished_bl = true;
374 bool jump_out_bl = false;
375 bool discard_bl = false;
376 bool found_bl = false;
377 bool match_bl = false;
378 int int_buffer;
379 //vector<InvestigatorLink *>::iterator invest_link_itr;
380 vector<IDElement *>::iterator link_ID_itr;
381 vector<IDElement *>::iterator invest_ID_itr;
382 vector<KnowledgeUnit *>::iterator KU_itr;
383 InvestigatorLink * invest_link_pt;
384 InvestigatorLink * unfinished_invest_link_pt = NULL;
385
386 string rm_aux_info;
387
388 ReasonMachine * RM_pt;
389 if (this->m_operator == sim::Operator::ODM)
390 {RM_pt = g_sim.Decision_Maker.m_RM.get();}
391 else if (this->m_operator == sim::Operator::OAT)
392 {RM_pt = g_sim.Action_Taker.m_RM.get();}
393 else
394 {this->ErrorMessage("Error!");}//add error message
395
396 if(RM_pt->m_buffer_invest_pt == NULL)
397 {match_bl = true;}
398
399 invest_pt = _case_pt->m_invest_pt;
400
401 if(invest_pt->m_KElement_ID_pt != NULL)
402 {
403 if(invest_pt->m_KElement_ID_pt->m_ID == "KE_PRZ_level_decrease" && r5pars_.timesno > 1900 && invest_pt->m_Happen ==4 )
404 {
405 this->PrintMessage("Check point!");
406 }
407 }
408
409 if(invest_pt->m_ID == "Investigator_535")
410 {this->PrintMessage("");}
411
412 //add the codes for the investigation of the trend opposite to expectation
413 if(_case_pt->m_invest_opposite_bl == true)
414 {
415 switch (invest_pt->m_Happen)
416 {
417 case 1:
418 if(invest_pt->m_investigation_closed == true)
419 {
420 invest_pt->ReopenThisInvestigator();
421 }
422 _case_pt->m_unfinished_invest_pt = invest_pt;
423 //continue;
424 break;
425 case 2:
426 //discard, check whether it is available on the control panel
427 _case_pt->m_finished_bl = true;
428 _case_pt->m_rejection_time = r5pars_.timesno;
429 this->m_last_case_end_time = r5pars_.timesno;
430 this->MoveCaseFromCandidateTo(_case_pt, this->m_discarded_case_list);
431 break;
432 case 3:
433 if(invest_pt->m_explained == 3 || invest_pt->m_explained == 2)
434 {//it explained the opposite trend. move this investigator to the exception list
435 _case_pt->m_finished_bl = true;
436 _case_pt->m_exception_time = r5pars_.timesno;
437 this->m_last_case_end_time = r5pars_.timesno;
438 this->MoveCaseFromCandidateTo(_case_pt, this->m_exception_case_list);
439 }
440 else if(invest_pt->m_explained == 4)
441 {
442 _case_pt->m_finished_bl = true;
443 _case_pt->m_rejection_time = r5pars_.timesno;
444 this->m_last_case_end_time = r5pars_.timesno;
445 this->MoveCaseFromCandidateTo(_case_pt, this->m_rejected_case_list);
447 }
448 else if(invest_pt->m_explained == 1)
449 {
450 if(invest_pt->m_investigation_closed == true)
451 {
452 invest_pt->ReopenThisInvestigator();
453 }
454 _case_pt->m_unfinished_invest_pt = invest_pt;
455 }
456 break;
457 case 4:
458 //remove the need of investigating the opposite trend becasue it's no more there.
459 _case_pt->m_finished_bl = true;
460 _case_pt->m_rejection_time = r5pars_.timesno;
461 this->m_last_case_end_time = r5pars_.timesno;
462 this->MoveCaseFromCandidateTo(_case_pt, this->m_discarded_case_list);
464 break;
465 }
466
467 return;
468 }
469 //
470
471 for(KU_itr = this->m_event_symptom_pt->m_KU_list.begin(); KU_itr != this->m_event_symptom_pt->m_KU_list.end() && jump_out_bl == false; KU_itr++)
472 {
473 if(invest_pt == _case_pt->m_invest_pt)
474 {
475 if(invest_pt->m_Happen == 2)
476 {
477 jump_out_bl = true;
478 discard_bl = true;
479 break;
480 }
481 }
482 if(invest_pt == RM_pt->m_buffer_invest_pt)
483 {match_bl = true;}
484
485 if(invest_pt->m_Happen == 4)
486 {// Not happen
487 problem_invest_pt = invest_pt;
488 if(invest_pt->m_SI_ID_pt == NULL)
489 {
490 jump_out_bl = true;
491 continue;
492 }
493 }
494
495 if((invest_pt->m_explained == 1 && invest_pt->m_investigator_token != 3014 && invest_pt->m_investigator_token < 3029) || invest_pt->m_Happen == 1)
496 {//Have not investigated yet
497 if(invest_pt->m_invest_pause == false)
498 {//ongoing
499 unfinished_invest_pt = invest_pt;
500 jump_out_bl = true;
501 continue;
502 }
503 else if(invest_pt->m_investigator_token == 3008)
504 {//feedback to downstream
505 unfinished_invest_pt = invest_pt;
506 jump_out_bl = true;
507 continue;
508 }
509 else
510 {
511 for(link_ID_itr = invest_pt->m_upperstream_ID_list.begin(); link_ID_itr != invest_pt->m_upperstream_ID_list.end(); link_ID_itr++)
512 {//forced investigation situation
513 invest_link_pt = (InvestigatorLink*)(*link_ID_itr);
514 if(invest_link_pt->m_path_status == 1 && invest_link_pt->m_is_inference_path_bl == true)
515 {
516 invest_link_pt->m_invest_link_dormant = false;
517 invest_link_pt->m_SI_ID_pt = (IDElement*)this;
518 unfinished_invest_link_pt = invest_link_pt;
519 jump_out_bl = true;
520 break;
521 }
522 }
523 }
524 }
525
526 if(jump_out_bl == true)
527 {break;}
528
529 //find an InvestigatorLink that matches the path specified in the prototype
530 found_bl = false;
531 for(link_ID_itr = invest_pt->m_upperstream_ID_list.begin(); link_ID_itr != invest_pt->m_upperstream_ID_list.end() && found_bl == false; link_ID_itr++)
532 {
533 invest_link_pt = (InvestigatorLink*)(*link_ID_itr);
534 if(invest_link_pt->m_K_unit_pt == (*KU_itr))
535 {
536 found_bl = true;
537 break;
538 }
539 }
540
541 if(found_bl == false)
542 {this->ErrorMessage("Error!");}
543 //link_ID_itr = invest_pt->m_upperstream_ID_list.begin();
544 invest_link_pt = (InvestigatorLink*)(*link_ID_itr);
545 //Examine this path
546 if(invest_link_pt->m_path_status == 1 && invest_link_pt->m_invest_link_dormant == false)
547 {
548 int_buffer = invest_link_pt->m_invest_link_Token;
549 invest_link_pt->CheckThePathStatus3102();
550 if(invest_link_pt->m_invest_link_Token == 3101 && int_buffer == 3102)
551 {invest_link_pt->m_invest_link_Token = int_buffer;}
552 }
553 if(invest_link_pt->m_invest_link_dormant == true || invest_link_pt->m_path_status == 1)
554 {
555 if(invest_link_pt->m_invest_link_dormant == true)
556 {unfinished_invest_pt = invest_pt;}
557 else
558 {unfinished_invest_link_pt = invest_link_pt;}
559 //unfinished_invest_pt = invest_pt;
560 //think about this, need to modify, only activate this link when the DI is conscious to the operator
561 //unfinished_invest_link_pt->m_invest_link_dormant = false;
562 jump_out_bl = true;
563 break;//continue;
564 }
565
566 if(invest_link_pt->m_path_status == 4)
567 {
568 KU_stuck_pt = (*KU_itr);
569 //if(invest_link_pt->m_SI_ID_pt == NULL)
570 //{
571 // jump_out_bl = true;
572 //}
573 if(invest_link_pt->m_condition_ID_pt != NULL)
574 {
575 invest_pt = (Investigator*)(invest_link_pt->m_condition_ID_pt);
576 {
577 if(invest_pt->m_Happen == 4)
578 {
579 problem_permission_invest_pt = invest_pt;
580 if(invest_pt->m_SI_ID_pt == NULL)
581 {
582 jump_out_bl = true;
583 }
584 }
585 }
586 }
587 }
588 //the situation that m_path_status == 2 is not included here
589 invest_pt = NULL;
590 if(invest_link_pt->m_upperstream_ID_list.size() > 1)
591 {
592 if(this->m_label_ID_pt == NULL)
593 {
594 this->ErrorMessage("This situation is beyond the current codes!");
595 }
596 else
597 {
598 for(invest_ID_itr = invest_link_pt->m_upperstream_ID_list.begin(); invest_ID_itr != invest_link_pt->m_upperstream_ID_list.end() && invest_pt == NULL; invest_ID_itr++)
599 {
600 invest_buffer_pt = (Investigator *)(*invest_ID_itr);
601 KE_buffer_pt = (KnowledgeElement *)(invest_buffer_pt->m_KElement_ID_pt);
602 if(KE_buffer_pt->m_SentenceUnit_pt->GetLabelOfThisSentence() == this->m_label_ID_pt)
603 {
604 invest_pt = invest_buffer_pt;
605 }
606 }
607 if(invest_pt == NULL)
608 {
609 this->ErrorMessage("Error!");
610 }
611 }
612 }
613 else
614 {
615 invest_pt = (Investigator *)(*(invest_link_pt->m_upperstream_ID_list.begin()));
616 }
617 if(invest_pt->m_Happen == 4)
618 {
619 KU_stuck_pt = (*KU_itr);
620 problem_invest_pt = invest_pt;
621 if(invest_pt->m_SI_ID_pt == NULL)
622 {
623 jump_out_bl = true;
624 }
625 }
626 }
627 //unfinished Investigator and InvestigatorLink are marked
628 //this mark will be used in function 3013 and 3101 for retrieving prob calculation
629 //this is also used for 0030 prioritization process.
630
631 //attach information to the _case_pt
632 _case_pt->m_problem_invest_pt = problem_invest_pt;
633 _case_pt->m_stuck_KU_pt = KU_stuck_pt;
634 _case_pt->m_problem_permission_invest_pt = problem_permission_invest_pt;
635
636 if(unfinished_invest_pt != NULL)
637 {
638 if(unfinished_invest_pt->m_investigation_closed == true )
639 {
640 //if(unfinished_invest_pt->m_SI_ID_pt == (IDElement *)this)
641 if(unfinished_invest_pt->m_SI_ID_pt != NULL)
642 {
643 unfinished_invest_pt->ReopenThisInvestigator();
644 _case_pt->m_unfinished_invest_pt = unfinished_invest_pt;
645 }
646 else
647 {
648 jump_out_bl = true;
649 discard_bl = true;
650 }
651 }
652
653 }
654 else
655 {_case_pt->m_unfinished_invest_pt = NULL;}
656 _case_pt->m_unfinished_invest_link_pt = unfinished_invest_link_pt;
657
658 if(jump_out_bl == true)
659 {
660 if(discard_bl == true)
661 {
662 _case_pt->m_finished_bl = true;
663 _case_pt->m_rejection_time = r5pars_.timesno;
664 this->m_last_case_end_time = r5pars_.timesno;
665 // Determine target list, then move from candidate in one operation
666 vector<unique_ptr<SymptomCase>> *move_target = &this->m_discarded_case_list;
667 if(_case_pt->m_invest_pt->m_Happen == 3 && unfinished_invest_pt != NULL)
668 {
669 if(unfinished_invest_pt->m_investigator_token > 3029 && ((DiagnoseInvestigator*)(this->m_DI_ID_pt))->m_confidence > 0.2)
670 {
671 if(_case_pt->m_invest_pt->m_ID == "Investigator_3")
672 {_case_pt = _case_pt;}//check point
673 move_target = &this->m_voided_case_list;
674 if(_case_pt->m_invest_pt == NULL)
675 {
676 this->PrintMessage("");
677 }
678 else if(_case_pt->m_ID_invest == "Investigator_278" || _case_pt->m_invest_pt->m_ID == "Investigator_278")
679 {
680 this->PrintMessage("");
681 }
682 }
683 }
684 this->MoveCaseFromCandidateTo(_case_pt, *move_target);
685
686 //generate a new one??
687 //create a new investigator
688 if(this->m_rejected_case_list.size() == 0)
689 {return;}
690 {
691 auto invest_owned = make_unique<Investigator>();
692 new_invest_pt = invest_owned.get();
693 new_invest_pt->m_note = "by event schema";
694 new_invest_pt->m_motivation = 0;
695 new_invest_pt->m_effective_start = r5pars_.timesno;
696 new_invest_pt->m_effective_end = r5pars_.timesno + 60;
697 new_invest_pt->m_KElement_ID_pt = this->m_symptom_KE_pt;
698 new_invest_pt->m_invest_dormant = false;
699 new_invest_pt->m_investigator_token = 3002;
700 new_invest_pt->m_Happen = 1;
702 new_invest_pt->m_operator = this->m_operator;
703 new_invest_pt->m_SI_ID_pt = (IDElement *)this;
704 new_invest_pt->m_root_of_a_thought_line = true;
705 new_invest_pt->m_active_investigation = true;
706 RM_pt->AddNewInvestigator(invest_owned.release());
707 }
708
709 return;
710 }
711
712 _case_pt->m_finished_bl = false;
713 if(_case_pt->m_invest_pt->m_Happen == 4 && _case_pt->m_invest_pt->m_SI_ID_pt == NULL )
714 {
715 _case_pt->m_finished_bl = true;
716 _case_pt->m_rejection_time = r5pars_.timesno;
717 this->m_last_case_end_time = r5pars_.timesno;
718 this->MoveCaseFromCandidateTo(_case_pt, this->m_rejected_case_list);
719
720 if(_case_pt->m_invest_pt->m_Statement_pt != NULL && _case_pt->m_invest_pt->m_KElement_ID_pt != NULL)
721 {
722 if(_case_pt->m_invest_pt->m_KElement_ID_pt->m_ID == this->m_symptom_KE_pt->m_ID)
723 {
724 if(_case_pt->m_invest_pt->m_Statement_pt->m_state != this->m_symptom_KE_pt->m_negation)
725 {
726 this->m_need_to_invest_opposite_bl = true;
727 this->m_opposite_KE_pt = RM_pt->FindAKEbySentenceAndNegationSign(problem_invest_pt->m_Statement_pt->m_sent_pt, false);
728 if(this->m_opposite_KE_pt == NULL)
729 {this->ErrorMessage("this->m_opposite_KE_pt == NULL");}
730 else
731 {this->m_opposite_KE_ID = this->m_opposite_KE_pt->m_ID;}
732 }
733 }
734 }
735 }
736 else if(problem_permission_invest_pt != NULL)
737 {
738 _case_pt->m_finished_bl = true;
739 _case_pt->m_exception_time = r5pars_.timesno;
740 this->m_last_case_end_time = r5pars_.timesno;
741 if(_case_pt->m_invest_pt->m_Happen == 4)
742 {
743 _case_pt->m_exception_time = r5pars_.timesno;
744 }
745 this->MoveCaseFromCandidateTo(_case_pt, this->m_exception_case_list);
746 }
747 }
748 else
749 {
750 if(problem_permission_invest_pt != NULL)
751 {
752
753 _case_pt->m_consistant_bl = false;
754 _case_pt->m_finished_bl = true;
755 this->m_last_case_end_time = r5pars_.timesno;
756 if(_case_pt->m_invest_pt->m_Happen == 4)
757 {
758 _case_pt->m_exception_time = r5pars_.timesno;
759 this->MoveCaseFromCandidateTo(_case_pt, this->m_exception_case_list);
760 }
761 else
762 {
763 this->MoveCaseFromCandidateTo(_case_pt, this->m_discarded_case_list);
764 }
765 }
766 else if(problem_invest_pt != NULL)
767 {
768 _case_pt->m_consistant_bl = false;
769 _case_pt->m_finished_bl = true;
770 if(_case_pt->m_invest_pt->m_Happen == 4)
771 {
772 _case_pt->m_rejection_time = r5pars_.timesno;
773 this->m_last_case_end_time = r5pars_.timesno;
774 this->MoveCaseFromCandidateTo(_case_pt, this->m_rejected_case_list);
775 if(_case_pt->m_invest_pt->m_SI_ID_pt != NULL)
776 {
777 ((DiagnoseInvestigator*)(this->m_DI_ID_pt))->m_n_hard_setback++;
778 if(((DiagnoseInvestigator*)(this->m_DI_ID_pt))->m_n_hard_setback >= 1 )
779 {((DiagnoseInvestigator*)(this->m_DI_ID_pt))->m_terminate_investigation = true;}
780 }
781 }
782 else
783 {
784 this->m_last_case_end_time = r5pars_.timesno;
786 }
787
788 if(problem_invest_pt->m_Happen == 4 && problem_invest_pt->m_Statement_pt != NULL)
789 {
790 if(problem_invest_pt->m_Statement_pt->m_state == true)
791 {
792 this->m_need_to_invest_opposite_bl = true;
793 this->m_opposite_KE_pt = RM_pt->FindAKEbySentenceAndNegationSign(problem_invest_pt->m_Statement_pt->m_sent_pt, false);
794 if(this->m_opposite_KE_pt == NULL)
795 {this->ErrorMessage("this->m_opposite_KE_pt == NULL");}
796 else
797 {this->m_opposite_KE_ID = this->m_opposite_KE_pt->m_ID;}
798 }
799 }
800
801 }
802 else if(invest_pt->m_independent_probability != 0)
803 {
804 if(match_bl == true)
805 {
806 if(invest_pt->m_probability_update_time - r5pars_.timesno < 0.0001 && invest_pt->m_probability_update_time - r5pars_.timesno > -0.0001)
807 {
808 //aux information
809 rm_aux_info = "Confirming evidence: " + _case_pt->m_invest_pt->m_ID;
810 RM_pt->WriteAuxInfo(rm_aux_info);
811 //
812
813 RM_pt->m_buffer_used_bl = true;
814 _case_pt->m_path_confidence = invest_pt->m_independent_probability;
815 if(RM_pt->m_buffer_invest_pt == NULL)
816 {invest_pt->m_independent_probability = 0;}
817 _case_pt->m_consistant_bl = true;
818 _case_pt->m_finished_bl = true;
819 _case_pt->m_confirmed_time = r5pars_.timesno;
820 this->m_last_case_end_time = r5pars_.timesno;
821 this->MoveCaseFromCandidateTo(_case_pt, this->m_confirmed_case_list);
822 if(this->m_independent_symptom_probability < _case_pt->m_path_confidence)
824
825 this->m_need_to_invest_opposite_bl = false;
826 this->m_opposite_KE_ID = "";
827 this->m_opposite_KE_pt = NULL;
828 }
829 }
830 }
831 else
832 {
833 _case_pt->m_finished_bl = false;
834 if(invest_pt->m_Happen == 1)
835 {
836 _case_pt->m_unfinished_invest_pt = invest_pt;
837 return;
838 }
839 //the links between the symptom and the root cause have been iterated. Waiting for examing the alternative causes
840 //start from the root cause invest
841 root_invest_pt = invest_pt;
842 //check whether it is the root invest
843 if(root_invest_pt == NULL)
844 {return;}
845 DI_pt = (DiagnoseInvestigator*)(this->m_DI_ID_pt);
846
847 if(root_invest_pt->m_KElement_ID_pt != DI_pt->m_event_KE_pt && root_invest_pt->m_KElement_ID_pt->m_ID != DI_pt->m_event_KE_pt->m_ID)
848 {this->ErrorMessage("Check this place!"); return;}
849 //Find the last Investigator which was confirmed Happened
850
851 Happen_invest_pt = _case_pt->m_invest_pt;
852 invest_pt = invest_pt = _case_pt->m_invest_pt;
853 for(KU_itr = this->m_event_symptom_pt->m_KU_list.begin(); KU_itr != this->m_event_symptom_pt->m_KU_list.end(); KU_itr++)
854 {
855 if(invest_pt->m_Happen == 3)
856 {Happen_invest_pt = invest_pt;}
857 //find a link
858 found_bl = false;
859 for(link_ID_itr = invest_pt->m_upperstream_ID_list.begin(); link_ID_itr != invest_pt->m_upperstream_ID_list.end(); link_ID_itr++)
860 {
861 invest_link_pt = (InvestigatorLink*)(*link_ID_itr);
862 if(invest_link_pt->m_K_unit_pt == *KU_itr)
863 {
864 found_bl = true;
865 break;
866 }
867 }
868 if(found_bl == false)
869 {this->ErrorMessage("Check this situation!"); return;}
870
871 if(invest_link_pt->m_upperstream_ID_list.size() > 1)
872 {
873 if(this->m_label_ID_pt == NULL)
874 {this->ErrorMessage("This situation is beyond the current codes!"); return;}
875 else
876 {
877 invest_pt = NULL;
878 for(invest_ID_itr = invest_link_pt->m_upperstream_ID_list.begin(); invest_ID_itr != invest_link_pt->m_upperstream_ID_list.end() && invest_pt == NULL; invest_ID_itr++)
879 {
880 invest_buffer_pt = (Investigator *)(*invest_ID_itr);
881 KE_buffer_pt = (KnowledgeElement *)(invest_buffer_pt->m_KElement_ID_pt);
882 if(KE_buffer_pt->m_SentenceUnit_pt->GetLabelOfThisSentence() == this->m_label_ID_pt)
883 {invest_pt = invest_buffer_pt;}
884 }
885 if(invest_pt == NULL)
886 {this->ErrorMessage("Error!"); return;}
887 }
888 }
889 else
890 {invest_pt = (Investigator *)(*(invest_link_pt->m_upperstream_ID_list.begin()));}
891 }
892
893
894 //iterate from the Happened invest, find an unfinished invest or unfinished invest_link
895 if(Happen_invest_pt == NULL)
896 {this->ErrorMessage("Check this situation!"); return;}
897 jump_out_bl = false;
898 invest_pt = Happen_invest_pt;
899 while(unfinished_invest_pt == NULL && unfinished_invest_link_pt == NULL && jump_out_bl == false)
900 {
901 //iteration start with invest_pt, chek the invest_pt first
902 //invest_pt should not be dormant
903 if(invest_pt->m_invest_pause == false && (invest_pt->m_Happen == 1 || invest_pt->m_Happen == 3))
904 {unfinished_invest_pt = invest_pt; break;}
905
906 //Go find an upperstream investigatorLink
907 found_bl = false;
908 for(link_ID_itr = invest_pt->m_upperstream_ID_list.begin(); link_ID_itr != invest_pt->m_upperstream_ID_list.end(); link_ID_itr++)
909 {
910 invest_link_pt = (InvestigatorLink*)(*link_ID_itr);
911 if(invest_link_pt->m_invest_link_dormant == true)
912 {continue;}
913 if(invest_link_pt->m_path_status != 1)
914 {continue;}
915 if(invest_link_pt->m_invest_link_pause == false)
916 {unfinished_invest_link_pt = invest_link_pt; break;}
917 else
918 {found_bl = true; break;}
919 }
920 if(unfinished_invest_link_pt != NULL)
921 {break;}
922
923 if(found_bl == false)
924 {this->ErrorMessage("Check this situation!"); return;}
925
926 //Go find an upperstream investigator
927 found_bl = false;
928
929 if(invest_link_pt->m_condition_ID_pt != NULL)
930 {
931 invest_pt = (Investigator*)(invest_link_pt->m_condition_ID_pt);
932 if(invest_pt->m_invest_dormant == false && invest_pt->m_Happen == 1)
933 {
934 if(invest_pt->m_invest_pause == false)
935 {unfinished_invest_pt = invest_pt;break;}
936 else
937 {found_bl = true; break;}
938 }
939 }
940 invest_ID_itr = invest_link_pt->m_upperstream_ID_list.begin();
941 while(invest_ID_itr != invest_link_pt->m_upperstream_ID_list.end() && found_bl == false)
942 {
943 invest_pt = (Investigator*)(*invest_ID_itr);
944 if(invest_pt->m_invest_dormant == true)
945 {invest_ID_itr ++;continue;}
946 if(invest_pt->m_Happen != 1)
947 {invest_ID_itr ++;continue;}
948 if(invest_pt->m_invest_pause == false)
949 {unfinished_invest_pt = invest_pt;break;}
950 else
951 {found_bl = true; break;}
952 invest_ID_itr ++;
953 }
954
955 if(unfinished_invest_pt != NULL)
956 {break;}
957 if(found_bl == false)
958 {this->ErrorMessage("Check this situation!"); return;}
959
960 if(invest_pt->m_invest_pause == false && (invest_pt->m_Happen == 1 || invest_pt->m_Happen == 3))
961 {unfinished_invest_pt = invest_pt; break;}
962 }
963 _case_pt->m_unfinished_invest_pt = unfinished_invest_pt;
964 _case_pt->m_unfinished_invest_link_pt = unfinished_invest_link_pt;
965 }
966 }
967}
968
970{
971
972 if(_case_pt->m_invest_pt->m_ID == "Investigator_322")
973 {this->PrintMessage("");}
974
975 for(auto it = this->m_candidate_case_list.begin(); it != this->m_candidate_case_list.end(); ++it)
976 {
977 if(it->get() == _case_pt)
978 {
979 this->m_candidate_case_list.erase(it);
980 return;
981 }
982 }
983}
984
985void SymptomInvestigator::MoveCaseFromCandidateTo(SymptomCase *_case_pt, vector<unique_ptr<SymptomCase>> &_target)
986{
987 for(auto it = this->m_candidate_case_list.begin(); it != this->m_candidate_case_list.end(); ++it)
988 {
989 if(it->get() == _case_pt)
990 {
991 _target.push_back(std::move(*it));
992 this->m_candidate_case_list.erase(it);
993 return;
994 }
995 }
996}
997
999{
1000 float rejection_time = 0;
1001 for(auto &e : this->m_rejected_case_list)
1002 {
1003 if(e->m_rejection_time > rejection_time)
1004 {
1005 rejection_time = e->m_rejection_time;
1006 }
1007 }
1008 return rejection_time;
1009}
1010
1012{
1013 vector<KnowledgeUnit *>::iterator KU_itr;
1014 KnowledgeUnit * found_KU_pt = NULL;
1015
1016 for(KU_itr = this->m_event_symptom_pt->m_KU_list.begin(); KU_itr != this->m_event_symptom_pt->m_KU_list.end() && found_KU_pt == NULL; KU_itr++)
1017 {
1018 if((*KU_itr) == _KU_pt)
1019 {
1020 found_KU_pt = (*KU_itr);
1021 }
1022 }
1023 return found_KU_pt;
1024}
1025
1027{
1028 float confirm_time = 0;
1029 SymptomCase * case_pt = NULL;
1030 if(this->m_confirmed_case_list.size() == 0)
1031 {
1032 this->ErrorMessage("Error!");
1033 }
1034 case_pt = this->m_confirmed_case_list.rbegin()->get();
1035 confirm_time = case_pt->m_confirmed_time;
1036 return confirm_time;
1037}
1038
1040{
1041 // << "\n";
1042 //cout << "Time: " << r5pars_.timesno << ":\n" << str << '\n';
1043 cout << ":\n" << str << '\n';
1044
1045 //test
1046 ofstream fout("RMI.txt", ios::app);
1047 fout <<"\n" << "Time: " << r5pars_.timesno << ":\n" << str << '\n';
1048 fout.close();
1049}
1050
1051
1053{
1054 this->CopyIDElementToRestartInfo((IDElement*)_si_pt);
1055/*
1056 int m_operator;
1057 float m_independent_symptom_probability;
1058 float m_attention_level;
1059 float m_last_case_end_time;
1060*/
1061 this->m_operator = _si_pt->m_operator;
1063 this->m_attention_level = _si_pt->m_attention_level;
1067/*
1068 IDElement * m_label_ID_pt;
1069 EventSymptomUnit * m_event_symptom_pt;
1070 KnowledgeElement * m_symptom_KE_pt;
1071
1072 string m_ID_lable;
1073 string m_ID_esu;
1074 string m_ID_KE;
1075*/
1076
1077 if(_si_pt->m_opposite_KE_pt != NULL)
1078 {this->m_opposite_KE_ID = _si_pt->m_opposite_KE_pt->m_ID;}
1079 else
1080 {this->m_opposite_KE_ID = _si_pt->m_opposite_KE_ID;}
1081
1082 if(_si_pt->m_DI_ID_pt != NULL)
1083 {this->m_ID_DI = _si_pt->m_DI_ID_pt->m_ID;}
1084 else
1085 {this->m_ID_DI = _si_pt->m_ID_DI;}
1086
1087 if(_si_pt->m_label_ID_pt != NULL)
1088 {this->m_ID_lable = _si_pt->m_label_ID_pt->m_ID;}
1089 else
1090 {this->m_ID_lable = _si_pt->m_ID_lable;}
1091
1092 if(_si_pt->m_event_symptom_pt != NULL)
1093 {this->m_ID_esu = _si_pt->m_event_symptom_pt->m_ID;}
1094 else
1095 {this->m_ID_esu = _si_pt->m_ID_esu;}
1096
1097 if(_si_pt->m_symptom_KE_pt != NULL)
1098 {this->m_ID_KE = _si_pt->m_symptom_KE_pt->m_ID;}
1099 else
1100 {this->m_ID_KE = _si_pt->m_ID_KE;}
1101
1102 if(this->m_ongoing_invest_list.size() != 0)
1103 {this->ErrorMessage("this->m_ongoing_invest_list.size() != 0");return;}
1104 if(this->m_ongoing_invest_link_list.size() != 0)
1105 {this->ErrorMessage("this->m_ongoing_invest_link_list.size() != 0");return;}
1106/*
1107 vector<Investigator *> m_ongoing_invest_list;
1108 vector<InvestigatorLink *> m_ongoing_invest_link_list;
1109
1110 vector<string> m_ID_ongoing_invest_list;
1111 vector<string> m_ID_ongoing_invest_link_list;
1112*/
1113 vector<string>::iterator str_itr;
1114 string ID;
1115 vector<Investigator *>::iterator invest_itr;
1116 if(_si_pt->m_ongoing_invest_list.size() != 0)
1117 {
1118 for(invest_itr = _si_pt->m_ongoing_invest_list.begin(); invest_itr != _si_pt->m_ongoing_invest_list.end(); invest_itr++)
1119 {
1120 ID = (*invest_itr)->m_ID;
1121 this->m_ID_ongoing_invest_list.push_back(ID);
1122 }
1123 }
1124 else
1125 {
1126 for(str_itr = _si_pt->m_ID_ongoing_invest_list.begin(); str_itr != _si_pt->m_ID_ongoing_invest_list.end(); str_itr++)
1127 {
1128 ID = *str_itr;
1129 this->m_ID_ongoing_invest_list.push_back(ID);
1130 }
1131 }
1132
1133 vector<InvestigatorLink *>::iterator link_itr;
1134 if(_si_pt->m_ongoing_invest_link_list.size() != 0)
1135 {
1136 for(link_itr = _si_pt->m_ongoing_invest_link_list.begin(); link_itr != _si_pt->m_ongoing_invest_link_list.end(); link_itr++)
1137 {
1138 ID = (*link_itr)->m_ID;
1139 this->m_ID_ongoing_invest_link_list.push_back(ID);
1140 }
1141 }
1142 else
1143 {
1144 for(str_itr = _si_pt->m_ID_ongoing_invest_link_list.begin(); str_itr != _si_pt->m_ID_ongoing_invest_link_list.end(); str_itr++)
1145 {
1146 ID = *str_itr;
1147 this->m_ID_ongoing_invest_link_list.push_back(ID);
1148 }
1149 }
1150/*
1151 vector<SymptomCase *> m_candidate_case_list; //contain all the symptom cases
1152 vector<SymptomCase *> m_confirmed_case_list; //there is a possible path from the event to the symptom
1153 vector<SymptomCase *> m_rejected_case_list; //the symptom doesn't happen at all
1154 vector<SymptomCase *> m_inconsistant_case_list;//the symptom happen, but path is blocked in the middel
1155 vector<SymptomCase *> m_exception_case_list;//One or more permission KE is not satisfied and block the path
1156 vector<SymptomCase *> m_partial_consistant_case_list;//The path is partially satisfied from the event, but not reached to the symptom
1157*/
1158 for(auto &e : _si_pt->m_discarded_case_list)
1159 {
1160 auto sc_pt = make_unique<SymptomCase>();
1161 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1162 this->m_discarded_case_list.push_back(std::move(sc_pt));
1163 }
1164
1165 for(auto &e : _si_pt->m_voided_case_list)
1166 {
1167 auto sc_pt = make_unique<SymptomCase>();
1168 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1169 this->m_voided_case_list.push_back(std::move(sc_pt));
1170 }
1171
1172 for(auto &e : _si_pt->m_candidate_case_list)
1173 {
1174 auto sc_pt = make_unique<SymptomCase>();
1175 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1176 this->m_candidate_case_list.push_back(std::move(sc_pt));
1177 }
1178 for(auto &e : _si_pt->m_confirmed_case_list)
1179 {
1180 auto sc_pt = make_unique<SymptomCase>();
1181 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1182 this->m_confirmed_case_list.push_back(std::move(sc_pt));
1183 }
1184 for(auto &e : _si_pt->m_rejected_case_list)
1185 {
1186 auto sc_pt = make_unique<SymptomCase>();
1187 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1188 this->m_rejected_case_list.push_back(std::move(sc_pt));
1189 }
1190 for(auto &e : _si_pt->m_inconsistant_case_list)
1191 {
1192 auto sc_pt = make_unique<SymptomCase>();
1193 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1194 this->m_inconsistant_case_list.push_back(std::move(sc_pt));
1195 }
1196 for(auto &e : _si_pt->m_exception_case_list)
1197 {
1198 auto sc_pt = make_unique<SymptomCase>();
1199 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1200 this->m_exception_case_list.push_back(std::move(sc_pt));
1201 }
1202 for(auto &e : _si_pt->m_partial_consistant_case_list)
1203 {
1204 auto sc_pt = make_unique<SymptomCase>();
1205 sc_pt->CopySymptomCaseInfoFromAnother(e.get());
1206 this->m_partial_consistant_case_list.push_back(std::move(sc_pt));
1207 }
1208
1209}
1210
1212{
1213 ReasonMachine * RM_pt;
1214 RM_pt = (ReasonMachine *)_pt;
1215 //
1216 this->m_DI_ID_pt = RM_pt->m_event_schema_base->FindDiagnoseInvestigatorByID(this->m_ID_DI);
1217 if(this->m_DI_ID_pt == NULL)
1218 {this->ErrorMessage("this->m_label_ID_pt == NULL"); return;}
1219
1220 //IDElement * m_label_ID_pt;
1221 if(this->m_ID_lable.compare("") != 0)
1222 {
1223 this->m_label_ID_pt = RM_pt->m_Concept_Base->FindConceptByID(this->m_ID_lable);
1224 if(this->m_label_ID_pt == NULL)
1225 {this->ErrorMessage("this->m_label_ID_pt == NULL"); return;}
1226 }
1227
1228 //KnowledgeElement * m_symptom_KE_pt;
1229 if(this->m_ID_KE.compare("") != 0)
1230 {
1231 this->m_symptom_KE_pt = RM_pt->FindKnowledgeElementByID(this->m_ID_KE);
1232 if(this->m_symptom_KE_pt == NULL)
1233 {this->ErrorMessage("could not find the symptom KE" + this->m_ID_KE); return;}
1234 }
1235
1236 if(this->m_opposite_KE_ID.compare("") != 0)
1237 {
1239 if(this->m_opposite_KE_pt == NULL)
1240 {this->ErrorMessage("could not find the symptom KE" + this->m_opposite_KE_ID); return;}
1241 }
1242
1243 //EventSymptomUnit * m_event_symptom_pt;
1244 if(this->m_ID_esu.compare("") != 0)
1245 {
1246 this->m_event_symptom_pt = RM_pt->m_event_schema_base->FindEventSymptomUnitByID(this->m_ID_esu);
1247 if(this->m_event_symptom_pt == NULL)
1248 {this->ErrorMessage("could not find this EventSymptomUnit" + this->m_ID_esu); return;}
1249 }
1250
1251 Investigator * invest_pt;
1252 InvestigatorLink * link_pt;
1253 vector<string>::iterator str_itr;
1254 for(str_itr = this->m_ID_ongoing_invest_list.begin(); str_itr != this->m_ID_ongoing_invest_list.end(); str_itr++)
1255 {
1256 invest_pt = RM_pt->FindInvestigatorByID(*str_itr);
1257 if(invest_pt == NULL)
1258 {this->ErrorMessage("could not find this investigator " + *str_itr); return;}
1259 this->m_ongoing_invest_list.push_back(invest_pt);
1260 }
1261 this->m_ID_ongoing_invest_list.clear();
1262
1263 for(str_itr = this->m_ID_ongoing_invest_link_list.begin(); str_itr != this->m_ID_ongoing_invest_link_list.end(); str_itr++)
1264 {
1265 link_pt = RM_pt->FindInvestigatorLinkByID(*str_itr);
1266 if(link_pt == NULL)
1267 {this->ErrorMessage("could not find this InvestigatorLink " + *str_itr); return;}
1268 this->m_ongoing_invest_link_list.push_back(link_pt);
1269 }
1270 this->m_ID_ongoing_invest_link_list.clear();
1271
1272/*
1273 vector<SymptomCase *> m_candidate_case_list; //contain all the symptom cases
1274 vector<SymptomCase *> m_confirmed_case_list; //there is a possible path from the event to the symptom
1275 vector<SymptomCase *> m_rejected_case_list; //the symptom doesn't happen at all
1276 vector<SymptomCase *> m_inconsistant_case_list;//the symptom happen, but path is blocked in the middel
1277 vector<SymptomCase *> m_exception_case_list;//One or more permission KE is not satisfied and block the path
1278 vector<SymptomCase *> m_partial_consistant_case_list;//The path is partially satisfied from the event, but not reached to the symptom
1279
1280*/
1281 for(auto &e : this->m_candidate_case_list)
1282 {e->BuildConnectionsForThisSymptomCase(_pt);}
1283
1284 for(auto &e : this->m_confirmed_case_list)
1285 {e->BuildConnectionsForThisSymptomCase(_pt);}
1286
1287 for(auto &e : this->m_rejected_case_list)
1288 {e->BuildConnectionsForThisSymptomCase(_pt);}
1289
1290 for(auto &e : this->m_inconsistant_case_list)
1291 {e->BuildConnectionsForThisSymptomCase(_pt);}
1292
1293 for(auto &e : this->m_exception_case_list)
1294 {e->BuildConnectionsForThisSymptomCase(_pt);}
1295
1296 for(auto &e : this->m_partial_consistant_case_list)
1297 {e->BuildConnectionsForThisSymptomCase(_pt);}
1298
1299 for(auto &e : this->m_discarded_case_list)
1300 {e->BuildConnectionsForThisSymptomCase(_pt);}
1301
1302 for(auto &e : this->m_voided_case_list)
1303 {e->BuildConnectionsForThisSymptomCase(_pt);}
1304
1305}
1306
1308{
1309 vector<Investigator *>::iterator invest_itr;
1310 vector<InvestigatorLink *>::iterator link_itr;
1311
1312 for(invest_itr = this->m_ongoing_invest_list.begin(); invest_itr != this->m_ongoing_invest_list.end(); invest_itr++)
1313 {
1314 (*invest_itr)->BoostActivationOfThisByActiveDiagnosisInvestigation();
1315 }
1316
1317 for(link_itr = this->m_ongoing_invest_link_list.begin(); link_itr != this->m_ongoing_invest_link_list.end(); link_itr++)
1318 {
1319 (*link_itr)->BoostActivationOfThisLinkByActiveDiagnosisInvestigation();
1320 }
1321}
Diagnostic reasoning engine — knowledge representation, mental model, and inference.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
document e
KnowledgeElement * m_event_KE_pt
std::vector< KnowledgeUnit * > m_KU_list
KnowledgeElement * m_symptom_KE_pt
void CopyIDElementToRestartInfo(IDElement *)
Definition: IDElement.cpp:23
int m_ID_Type
Definition: IDElement.h:15
std::string m_ID
Definition: IDElement.h:16
bool m_invest_pause
Definition: Investigator.h:95
std::string m_note
Definition: Investigator.h:124
bool m_investigation_closed
Definition: Investigator.h:88
bool m_motivation
Definition: Investigator.h:92
bool m_invest_dormant
Definition: Investigator.h:94
double m_effective_end
Definition: Investigator.h:118
void ReopenThisInvestigator()
double m_effective_start
Definition: Investigator.h:119
float m_probability_update_time
Definition: Investigator.h:18
IDElement * m_KElement_ID_pt
Definition: Investigator.h:129
bool m_active_investigation
Definition: Investigator.h:22
bool m_root_of_a_thought_line
Definition: Investigator.h:85
float m_independent_probability
Definition: Investigator.h:121
std::vector< IDElement * > m_upperstream_ID_list
Definition: Investigator.h:143
int m_investigator_token
Definition: Investigator.h:99
float m_interest_from_SymptomInvestigator
Definition: Investigator.h:122
IDElement * m_SI_ID_pt
Definition: Investigator.h:128
Statement * m_Statement_pt
Definition: Investigator.h:130
SentenceUnit * m_SentenceUnit_pt
Definition: Label.h:13
std::unique_ptr< ReasonMachine > m_RM
Definition: Operator.h:55
std::unique_ptr< KBConcept > m_Concept_Base
InvestigatorLink * FindInvestigatorLinkByID(std::string)
std::vector< std::unique_ptr< Investigator > > m_investigator_pool
KnowledgeElement * FindKnowledgeElementByID(std::string)
KnowledgeElement * FindAKEbySentenceAndNegationSign(SentenceUnit *, bool)
void WriteAuxInfo(std::string str)
std::unique_ptr< InstantiationBase > m_IB
Investigator * FindInvestigatorByID(std::string)
std::unique_ptr< EventSchemaBase > m_event_schema_base
Investigator * m_buffer_invest_pt
void AddNewInvestigator(Investigator *)
SentenceUnit * InstantiateAnIndefiniteSentenceWithLabel(SentenceUnit *, IDElement *)
IDElement * GetLabelOfThisSentence()
SentenceUnit * m_sent_pt
Definition: Statement.h:43
bool m_state
Definition: Statement.h:35
Investigator * m_invest_pt
Definition: SymptomCase.h:30
float m_exception_time
Definition: SymptomCase.h:22
Investigator * m_unfinished_invest_pt
Definition: SymptomCase.h:31
std::string m_ID_invest
Definition: SymptomCase.h:37
KnowledgeUnit * m_stuck_KU_pt
Definition: SymptomCase.h:27
InvestigatorLink * m_unfinished_invest_link_pt
Definition: SymptomCase.h:32
Investigator * m_problem_permission_invest_pt
Definition: SymptomCase.h:28
Investigator * m_problem_invest_pt
Definition: SymptomCase.h:29
float m_rejection_time
Definition: SymptomCase.h:24
bool m_consistant_bl
Definition: SymptomCase.h:20
bool m_invest_opposite_bl
Definition: SymptomCase.h:13
float m_path_confidence
Definition: SymptomCase.h:25
bool m_finished_bl
Definition: SymptomCase.h:21
float m_confirmed_time
Definition: SymptomCase.h:23
void RemoveADeterminedCaseFromCandiateList(SymptomCase *_case_pt)
std::vector< std::unique_ptr< SymptomCase > > m_voided_case_list
std::vector< std::unique_ptr< SymptomCase > > m_partial_consistant_case_list
void PrintMessage(std::string str)
void CopySymptomInvestigatorInfoFromAnother(SymptomInvestigator *)
EventSymptomUnit * m_event_symptom_pt
void TrackOneInvestigationCase(SymptomCase *_case_pt)
std::vector< Investigator * > m_ongoing_invest_list
KnowledgeElement * m_symptom_KE_pt
std::vector< InvestigatorLink * > m_ongoing_invest_link_list
std::vector< std::unique_ptr< SymptomCase > > m_candidate_case_list
std::vector< std::unique_ptr< SymptomCase > > m_exception_case_list
std::vector< std::unique_ptr< SymptomCase > > m_inconsistant_case_list
void MoveCaseFromCandidateTo(SymptomCase *_case_pt, std::vector< std::unique_ptr< SymptomCase > > &_target)
std::vector< std::string > m_ID_ongoing_invest_link_list
KnowledgeElement * m_opposite_KE_pt
void ErrorMessage(std::string)
std::vector< std::unique_ptr< SymptomCase > > m_rejected_case_list
std::vector< std::unique_ptr< SymptomCase > > m_confirmed_case_list
void BuildConnectionsForThisSymptomInvestigator(void *)
KnowledgeUnit * CheckAKnowledgeUnitInTheList(KnowledgeUnit *_KU_pt)
std::vector< std::unique_ptr< SymptomCase > > m_discarded_case_list
void InitiallyCompareAnInvestigationTraceWithThePrototype(SymptomCase *)
SymptomCase * FindASymptomCaseByInvestigator(Investigator *_invest_pt)
std::vector< std::string > m_ID_ongoing_invest_list
struct @0 r5pars_
constexpr int ODM
Definition: SimConstants.h:145
constexpr int OAT
Definition: SimConstants.h:144
OperatorAT Action_Taker
Crew action execution model.
OperatorDM Decision_Maker
Crew decision-making model.