← Documentation
ADS-IDAC Engine 5.0.0
Investigator.cpp
Go to the documentation of this file.
1// Investigator.cpp: implementation of the Investigator class.
2//
4
5#include <algorithm>
6#include <memory>
7#include <sstream>
8#include <iostream>
9#include <fstream>
10
11#include "../Global/fmodule.h"
12#include "Investigator.h"
14#include "ReasonMachine.h"
15#include "RMTokens.h"
16#include "../Crew/OperatorDM.h"
17#include "../Global/SimulationContext.h"
18
19using namespace std;
20
21
22
24// Construction/Destruction
26
28 this->m_Happen_incomplete = false;
29 this->m_Explain_incomplete = false;
30 this->m_active_investigation = false;
32 this->m_last_active_time = r5pars_.timesno;
33 this->m_root_of_a_thought_line = false;
34 this->m_investigation_closed = false;
35 this->m_ID_Type = 301;
36 this->m_timer = 0;
37 //301--Investigator
38 //302--InvestigatorLink
39 this->m_explained = 1; //unknown not yet
40 this->m_Happen = 1; //unknown
41// this->m_investiage_status = 3; //idle
42 this->m_investigator_token = 0;
43 this->m_abort = false;
44 this->m_phenomenon_onging = true;
45 this->m_invest_pause = false; //if true, that means the operator worked on tracing the upperstream causes
46 this->m_invest_dormant = false;
47 this->m_read_value_or_rate_bl = 0; //0--read parameter value; 1--rate
48 this->m_KElement_ID_pt = NULL;
49 this->m_Statement_pt = NULL;
50 this->m_possible_statement_pt = NULL;
52 this->m_motivation = 0; //0--to verify a knowledge element; 1--to investigate a statement
53 this->m_read_requested_bl = 0;
54 this->m_effective_start = 0;
55 this->m_effective_end = 0;
58 this->m_SI_ID_pt = NULL;
60 this->m_inconsistant_statement = NULL;
61 this->m_has_moved_to_link = NULL;
64
65 m_ID_SI = "";
66 m_ID_KE = "";
67 m_ID_statement = "";
70 this->m_ID_has_move_to_link = "";
71
72}
73
75
76 this->m_investigator_token_history.clear();
78 this->m_read_indication_list.clear();
79 this->m_feedback_list.clear();
80 this->m_upperstream_ID_list.clear();
81 this->m_downstream_ID_list.clear();
82 this->m_explanation_link_list.clear();
84 this->m_rejected_explanation_list.clear();
85
86 this->m_ID_read_indication_list.clear();
87 this->m_ID_feedback_list.clear();
88 this->m_ID_upperstream_list.clear();
89 this->m_ID_downstream_list.clear();
90 this->m_ID_explanation_link_list.clear();
93}
94
96 bool sucess = false;
97 vector<KnowledgeElement *>::iterator KE_itr;
98 KnowledgeElement *KE_down_X_pt = NULL;
99 KnowledgeElement *KE_upper_X_pt = NULL;
100 KnowledgeElement *KE_perm_X_pt = NULL;
101 KnowledgeElement *KE_upper_pt = NULL;
102 KnowledgeElement *KE_down_pt = NULL;
103 KnowledgeElement *KE_perm_pt = NULL;
104 KnowledgeElement *KE_pt = NULL;
105 KnowledgeElement *KE_buffer_pt = NULL;
106 IDElement *label_down_pt = NULL;
107 IDElement *label_ID_pt = NULL;
108 IDElement *ID_pt;
109 IDElement *ID_pt2;
110 vector<IDElement *>::iterator label_itr;
111 Label *label_group_pt = NULL;
112 Label *label_group_down_pt = NULL;
113 Label *label_group_upper_pt = NULL;
114 Label *label_group_perm_pt = NULL;
115 SentenceUnit *sent_pt;
116 KnowledgeNode *KN_pt;
117 Investigator *invest_pt;
118 Investigator *permission_pt;
119 InvestigatorLink *invest_link_pt;
120 bool inference_direction_reverse_bl;
121 double time_start = 0;
122 double time_end = 0;
123 double time1, time2;
124 string ID_name;
125 stringstream conv;
126 int match_type = 0;
127 ReasonMachine *RM_pt;
128 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
129 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
130 else {}//add error message
131 int N_inference = 0;
132
133 if (this->m_ID == "Investigator_36") { this->PrintMessage(""); }
134
135 if (this->m_upperstream_ID_list.size() != 0) {
137 return;
138 }
139
140 if (this->m_Statement_pt != 0) {//add time range; time_end gets the statement time
142 && this->m_Statement_pt->m_time_range.m_end_time >= this->m_Statement_pt->m_time_range.m_time_before) {
143 time_end = this->m_Statement_pt->m_time_range.m_end_time;
144 }
145 else if (this->m_Statement_pt->m_time_range.m_time_before != 0) {
146 time_end = this->m_Statement_pt->m_time_range.m_time_before;
147 }
148 else {}//warning message
150 && this->m_Statement_pt->m_time_range.m_end_time >= this->m_Statement_pt->m_time_range.m_time_before) {
151 time_start = this->m_Statement_pt->m_time_range.m_start_time;
152 }
153 else if (this->m_Statement_pt->m_time_range.m_time_after != 0) {
154 time_start = this->m_Statement_pt->m_time_range.m_time_after;
155 }
156 else {}//warning message
157 }
158
159 if (this->m_KElement_ID_pt == 0) {
160 if (this->m_Statement_pt == 0) { return; }//warning message: void investigator
162 if (this->m_KElement_ID_pt
163 == NULL) { return; }//message here: could not found a corresponding concept in Knowledge base
164 this->m_effective_end = time_end;
165 this->m_effective_start = time_start;
166 }
167
168 if (time_start == 0 && time_end == 0) {
169 if (this->m_effective_start == 0 && this->m_effective_end == 0) {}// error message
170 else {
171 time_start = this->m_effective_start;
172 time_end = this->m_effective_end;
173 }
174 }
175 //check point
176 if (this->m_ID == "Investigator_26") {
177 this->PrintMessage("Check point");
178 }
179 //
180
181 KE_down_X_pt = NULL;
182 KE_down_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
184 if (sent_pt != NULL) {
185 //assign the KE_down_X_pt
186 KE_down_X_pt = RM_pt->FindAKEbySentenceAndNegationSign(sent_pt, KE_down_pt->m_negation);
187 if (KE_down_X_pt == NULL) {
188 this->ErrorMessage("Could not find a KE for " + sent_pt->m_ID);
189 return;
190 }
191 //assign the label_group_down_pt
192 label_group_down_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(sent_pt);
193 if (label_group_down_pt == NULL) {
194 this->ErrorMessage("Could not find the corresponding label group for " + sent_pt->m_ID);
195 return;
196 }
197 //assign the label_down_pt
198 label_down_pt = KE_down_pt->m_SentenceUnit_pt->GetLabelOfThisSentence();
199 label_ID_pt = label_down_pt;
200 if (label_down_pt == NULL) {
201 this->ErrorMessage("Could not find a label of " + KE_down_pt->m_ID);
202 return;
203 }
204 }
205
206 if (this->m_ID == "Investigator_26") { this->PrintMessage("Check"); }
207
208 for (auto KU_itr = RM_pt->m_Knowledge_list.begin(); KU_itr != RM_pt->m_Knowledge_list.end(); KU_itr++) {
209 if ((*KU_itr)->m_accessable_bl == false) { continue; }
210
211 if ((*KU_itr)->m_Descendant_pt->m_ID_Type != 401) { return; }//error message, the KnowledgeUnit format is not right;
212
213//-----------------------Search for the upperstream of the inference pathes
214 if (this->m_Happen != 3 && this->m_Happen != 4 && (*KU_itr)->m_inference_type != 0) {
215 match_type = 0;
216 ID_pt = NULL;
217 if ((*KU_itr)->m_inference_type == 1 || (*KU_itr)->m_inference_type == 3) {
218 //need to compare with the downstream of the KU
219 ID_pt = (*KU_itr)->m_Descendant_pt;
220 ID_pt2 = (*KU_itr)->m_Ancestor_pt;
221 inference_direction_reverse_bl = false;
222 } else if ((*KU_itr)->m_inference_type == 2 || (*KU_itr)->m_inference_type == 3) {
223 //need to compare witht the upperstream of the KU
224 ID_pt = (*KU_itr)->m_Ancestor_pt;
225 ID_pt2 = (*KU_itr)->m_Descendant_pt;
226 inference_direction_reverse_bl = true;
227 } else {
228 continue;
229 }
230
231 if (ID_pt == NULL) {
232 this->ErrorMessage("Error!");
233 return;
234 }
235
236 //compare whether it is a match
237 if (ID_pt->m_ID_Type == 401) {
238 KE_pt = (KnowledgeElement *) ID_pt;
239 if (KE_pt == KE_down_pt || KE_pt == KE_down_X_pt) {
240 match_type = 1;
241 } else {
242 match_type = 0;
243 }
244
245 } else if (ID_pt->m_ID_Type == 402) {
246 match_type = 0;
247 }
248
249 //if it is a match
250 if (match_type == 1) {
251 N_inference++;
252 //add an investigatorLink
253 {
254 auto invest_link_owned = make_unique<InvestigatorLink>();
255 invest_link_pt = invest_link_owned.get();
256 invest_link_pt->m_is_causal_path_bl = false;
257 invest_link_pt->m_is_inference_path_bl = true;
258 invest_link_pt->m_downstream_ID_pt = (IDElement *) this;
259 invest_link_pt->m_K_unit_pt = KU_itr->get();
260 invest_link_pt->m_operator = this->m_operator;
261 RM_pt->AddNewInvestigatorLink(invest_link_owned.release());
262 this->m_upperstream_ID_list.push_back(invest_link_pt);
263 }
264
265 if (ID_pt2->m_ID_Type == 401) {
266 KE_buffer_pt = (KnowledgeElement *) ID_pt2;
267 //firstly check whether it contains X concept
268 label_group_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(KE_buffer_pt->m_SentenceUnit_pt);
269 if (label_group_pt == NULL) {//O-O or O-X
270 KE_pt = KE_buffer_pt;
271 invest_link_pt->m_link_type = 1;
272 } else if (label_group_pt == label_group_down_pt) {//X-X
273 invest_link_pt->m_link_type = 1;
274 sent_pt = RM_pt->InstantiateAnIndefiniteSentenceWithLabel(KE_buffer_pt->m_SentenceUnit_pt, label_down_pt);
275 if (sent_pt == NULL) {
276 this->ErrorMessage("Error!");
277 return;
278 }
279 KE_pt = RM_pt->FindAKEbySentenceAndNegationSign(sent_pt, KE_buffer_pt->m_negation);
280 if (KE_pt == NULL) {
281 this->ErrorMessage("Error!");
282 return;
283 }
284 } else if (label_group_down_pt == NULL) {//X-O
285 invest_link_pt->m_link_type = 3;
286 for (label_itr = label_group_pt->m_label_option_list.begin();
287 label_itr != label_group_pt->m_label_option_list.end(); label_itr++) {
288 sent_pt = RM_pt->InstantiateAnIndefiniteSentenceWithLabel(KE_buffer_pt->m_SentenceUnit_pt, (*label_itr));
289 if (sent_pt == NULL) {
290 this->ErrorMessage("Error!");
291 return;
292 }
293 KE_pt = RM_pt->FindAKEbySentenceAndNegationSign(sent_pt, KE_buffer_pt->m_negation);
294 if (KE_pt == NULL) {
295 this->ErrorMessage("Error!");
296 return;
297 }
298 invest_pt = RM_pt->FindAMatchInvestigatorByKnowledgeElement(KE_pt, time1, time2);
299 if (invest_pt == NULL) {
300 auto invest_owned = make_unique<Investigator>();
301 invest_pt = invest_owned.get();
302 invest_pt->m_note = "by downstream";
303 invest_pt->m_motivation = 0;
304 invest_pt->m_KElement_ID_pt = (IDElement *) KE_pt;
306 invest_pt->m_effective_start = time_start;
307 invest_pt->m_effective_end = time_end;
308 invest_pt->m_operator = this->m_operator;
309 invest_pt->m_invest_dormant = true;
310 invest_pt->m_root_of_a_thought_line = false;
311 invest_pt->m_active_investigation = true;
312 RM_pt->AddNewInvestigator(invest_owned.release());
313 }
314 //link the permission investigator and the InvestigatorLink
315 invest_link_pt->m_upperstream_ID_list.push_back((IDElement *) invest_pt);
316 invest_pt->m_downstream_ID_list.push_back((IDElement *) invest_link_pt);
317 }
318 }
319
320 //create new investigator or link to new investigator
321 if (invest_link_pt->m_link_type == 1) {
322 invest_pt = RM_pt->FindAMatchInvestigatorByKnowledgeElement(KE_pt, time1, time2);
323 if (invest_pt == NULL) {
324 auto invest_owned = make_unique<Investigator>();
325 invest_pt = invest_owned.get();
326 invest_pt->m_note = "by downstream";
327 invest_pt->m_motivation = 0;
328 invest_pt->m_KElement_ID_pt = (IDElement *) KE_pt;
330 invest_pt->m_effective_start = time_start;
331 invest_pt->m_effective_end = time_end;
332 invest_pt->m_operator = this->m_operator;
333 invest_pt->m_invest_dormant = true;
334 invest_pt->m_root_of_a_thought_line = false;
335 invest_pt->m_active_investigation = true;
336 RM_pt->AddNewInvestigator(invest_owned.release());
337 }
338 //link the permission investigator and the InvestigatorLink
339 invest_link_pt->m_upperstream_ID_list.push_back((IDElement *) invest_pt);
340 invest_pt->m_downstream_ID_list.push_back((IDElement *) invest_link_pt);
341 }
342
343 } else if (ID_pt2->m_ID_Type == 402) {
344 KN_pt = (KnowledgeNode *) ID_pt2;
345 invest_link_pt->m_link_type = KN_pt->m_Node_Type;
346 for (KE_itr = KN_pt->M_KElement_list.begin(); KE_itr != KN_pt->M_KElement_list.end(); KE_itr++) {
347 invest_pt = RM_pt->FindAMatchInvestigatorByKnowledgeElement((*KE_itr), time1, time2);
348 if (invest_pt == NULL) {
349 auto invest_owned = make_unique<Investigator>();
350 invest_pt = invest_owned.get();
351 invest_pt->m_note = "by downstream";
352 invest_pt->m_motivation = 0;
353 invest_pt->m_KElement_ID_pt = (IDElement *) (*KE_itr);
355 invest_pt->m_effective_start = time_start;
356 invest_pt->m_effective_end = time_end;
357 invest_pt->m_operator = this->m_operator;
358 invest_pt->m_invest_dormant = true;
359 invest_pt->m_root_of_a_thought_line = false;
360 invest_pt->m_active_investigation = true;
361 RM_pt->AddNewInvestigator(invest_owned.release());
362 }
363 //link the permission investigator and the InvestigatorLink
364 invest_link_pt->m_upperstream_ID_list.push_back((IDElement *) invest_pt);
365 invest_pt->m_downstream_ID_list.push_back((IDElement *) invest_link_pt);
366 }
367 }
368 }// end of if(match_type == 1)
369 }
370
371
372//---------------------Search for the Causes
373
374 //this is strict ID comparison, might need to modify it to make the comparison more flexible
375 if ((*KU_itr)->m_causal_type == 0) { continue; }
376 if ((*KU_itr)->m_Descendant_pt->m_ID != this->m_KElement_ID_pt->m_ID
377 && (*KU_itr)->m_Descendant_pt != (IDElement *) KE_down_X_pt) { continue; }
378
379 label_ID_pt = label_down_pt;
380 label_group_pt = label_group_down_pt;
381 time1 = time_start - (*KU_itr)->m_deltaT2;
382 time2 = time_end - (*KU_itr)->m_deltaT1;
383
384 //create an InvestigatorLink
385 {
386 auto invest_link_owned = make_unique<InvestigatorLink>();
387 invest_link_pt = invest_link_owned.get();
388 invest_link_pt->m_K_unit_pt = KU_itr->get();
389 invest_link_pt->m_operator = this->m_operator;
390 //links between this investigator and the InvestigatorLink
391 this->m_upperstream_ID_list.push_back((IDElement *) invest_link_pt);
392 invest_link_pt->m_downstream_ID_pt = (IDElement *) this;
393 RM_pt->AddNewInvestigatorLink(invest_link_owned.release());
394 }
395
396 //Check whether the permission contains an indefinite concept if there is a condition
397 label_group_perm_pt = NULL;
398 if ((*KU_itr)->m_Permission_pt != NULL) {
399 KE_pt = (KnowledgeElement *) ((*KU_itr)->m_Permission_pt);
400 label_group_perm_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(KE_pt->m_SentenceUnit_pt);
401 if (label_group_perm_pt != NULL) {
402 if (label_group_pt == NULL) {
403 this->ErrorMessage(
404 "Error: The condition of this KnowledgeUnit has indefinite concept which is not in the downstream item!");
405 return;
406 } else if (label_group_pt != label_group_perm_pt) {
407 this->ErrorMessage("Error: This Knowledge Unit contains more than one indefinite groups!");
408 return;
409 }
410 }
411 }
412 //Get the KnowledgeElement of the permission if there is one
413 if (label_group_perm_pt != NULL) {
414 KE_pt = (KnowledgeElement *) ((*KU_itr)->m_Permission_pt);
415 sent_pt = RM_pt->InstantiateAnIndefiniteSentenceWithLabel(KE_pt->m_SentenceUnit_pt, label_down_pt);
416 KE_perm_pt = RM_pt->FindAKEbySentenceAndNegationSign(sent_pt, KE_pt->m_negation);
417 if (KE_perm_pt == NULL) {
418 this->ErrorMessage(
419 "Could not find a KE for " + sent_pt->m_ID); //should also add the negation infor in the error
420 return;
421 }
422 } else if ((*KU_itr)->m_Permission_pt != NULL) {
423 KE_perm_pt = (KnowledgeElement *) ((*KU_itr)->m_Permission_pt);
424 }
425
426 //build the investigator for the permission
427 if ((*KU_itr)->m_Permission_pt != NULL) {
428 //search whether there is an investigator match
429 //check point
430 if (KE_perm_pt->m_ID == "KE_MSI_OFF") {
431 this->PrintMessage("check point");
432 }
433 //
434 permission_pt = RM_pt->FindAMatchInvestigatorByKnowledgeElement(KE_perm_pt, time1, time2);
435 if (permission_pt == NULL) {
436 auto perm_owned = make_unique<Investigator>();
437 permission_pt = perm_owned.get();
438 permission_pt->m_motivation = 0;
439 permission_pt->m_note = "by downstream";
440 permission_pt->m_KElement_ID_pt = (IDElement *) KE_perm_pt;
442 permission_pt->m_effective_start = time1;
443 permission_pt->m_effective_end = time2;
444 permission_pt->m_operator = this->m_operator;
445 permission_pt->m_invest_dormant = true;
446 permission_pt->m_root_of_a_thought_line = false;
447 permission_pt->m_active_investigation = true;
448 RM_pt->AddNewInvestigator(perm_owned.release());
449 }
450 //link the permission investigator and the InvestigatorLink
451 invest_link_pt->m_condition_ID_pt = (IDElement *) permission_pt;
452 permission_pt->m_downstream_ID_list.push_back((IDElement *) invest_link_pt);
453 }
454
455 if ((*KU_itr)->m_Ancestor_pt->m_ID_Type == 401) {//ancestor is a KnowledgeElement
456
457 //Check whether the upperstream contains indefinite concept
458 KE_pt = (KnowledgeElement *) ((*KU_itr)->m_Ancestor_pt);
459 label_group_upper_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(KE_pt->m_SentenceUnit_pt);
460 if (label_group_upper_pt != NULL) {
461 if (label_group_down_pt != NULL) {
462 if (label_group_down_pt != label_group_upper_pt) {
463 if ((*KU_itr)->m_Descendant_pt != this->m_KElement_ID_pt) {
464 //this->ErrorMessage("Error: This Knowledge Unit contains more than one indefinite groups!");
465 //return;
466 }
467 }
468 }
469 }
470
471 //Get the KnowledgeElement of the upperstream and build the investigator for the upperstream
472 KE_upper_pt = NULL;
473 if (label_group_upper_pt != NULL && label_group_down_pt != NULL && label_group_upper_pt == label_group_down_pt) {
474 KE_pt = (KnowledgeElement *) ((*KU_itr)->m_Ancestor_pt);
475 sent_pt = RM_pt->InstantiateAnIndefiniteSentenceWithLabel(KE_pt->m_SentenceUnit_pt, label_down_pt);
476 KE_upper_pt = RM_pt->FindAKEbySentenceAndNegationSign(sent_pt, KE_pt->m_negation);
477 if (KE_upper_pt == NULL) {
478 this->ErrorMessage(
479 "Could not find a KE for" + sent_pt->m_ID); //should also add the negation infor in the error
480 return;
481 }
482 } else if (label_group_upper_pt == NULL) {
483 KE_upper_pt = (KnowledgeElement *) ((*KU_itr)->m_Ancestor_pt);
484 }
485
486 if (KE_upper_pt != NULL) {
487 //There is only one upperstream investigator
488 invest_link_pt->m_link_type = 1;
489 //
490 invest_pt = RM_pt->FindAMatchInvestigatorByKnowledgeElement(KE_upper_pt, time1, time2);
491 if (invest_pt == NULL) {// if there is no existing investigator, create a new investigator
492 auto invest_owned = make_unique<Investigator>();
493 invest_pt = invest_owned.get();
494 invest_pt->m_note = "by downstream";
495 invest_pt->m_motivation = 0;
496 invest_pt->m_KElement_ID_pt = (IDElement *) KE_upper_pt;
498 invest_pt->m_effective_start = time1;
499 invest_pt->m_effective_end = time2;
500 invest_pt->m_operator = this->m_operator;
501 invest_pt->m_invest_dormant = true;
502 invest_pt->m_root_of_a_thought_line = false;
503 invest_pt->m_active_investigation = true;
504 RM_pt->AddNewInvestigator(invest_owned.release());
505 }
506 //link the upperstream investigator and the InvestigatorLink
507 invest_link_pt->m_upperstream_ID_list.push_back((IDElement *) invest_pt);
508 invest_pt->m_downstream_ID_list.push_back((IDElement *) invest_link_pt);
509 } else if (label_group_upper_pt != NULL && label_group_upper_pt != label_group_down_pt) {
510 //There are more than one upperstream investigators
511 invest_link_pt->m_link_type = 3;
512
513 for (label_itr = label_group_upper_pt->m_label_option_list.begin();
514 label_itr != label_group_upper_pt->m_label_option_list.end(); label_itr++) {
515 KE_pt = (KnowledgeElement *) ((*KU_itr)->m_Ancestor_pt);
516 sent_pt = RM_pt->InstantiateAnIndefiniteSentenceWithLabel(KE_pt->m_SentenceUnit_pt, (*label_itr));
517 if (sent_pt == NULL) {
518 this->ErrorMessage("Error!");
519 return;
520 }
521 KE_upper_pt = RM_pt->FindAKEbySentenceAndNegationSign(sent_pt, KE_pt->m_negation);
522 if (KE_upper_pt == NULL) {
523 this->ErrorMessage("Error!");
524 return;
525 }
526 invest_pt = RM_pt->FindAMatchInvestigatorByKnowledgeElement(KE_upper_pt, time1, time2);
527 if (invest_pt == NULL) {// if there is no existing investigator, create a new investigator
528 auto invest_owned = make_unique<Investigator>();
529 invest_pt = invest_owned.get();
530 invest_pt->m_note = "by downstream";
531 invest_pt->m_motivation = 0;
532 invest_pt->m_KElement_ID_pt = (IDElement *) KE_upper_pt;
534 invest_pt->m_effective_start = time1;
535 invest_pt->m_effective_end = time2;
536 invest_pt->m_operator = this->m_operator;
537 invest_pt->m_invest_dormant = true;
538 invest_pt->m_root_of_a_thought_line = false;
539 invest_pt->m_active_investigation = true;
540 RM_pt->AddNewInvestigator(invest_owned.release());
541 }
542 //link the upperstream investigator and the InvestigatorLink
543 invest_link_pt->m_upperstream_ID_list.push_back((IDElement *) invest_pt);
544 invest_pt->m_downstream_ID_list.push_back((IDElement *) invest_link_pt);
545 }
546 }
547 } else if ((*KU_itr)->m_Ancestor_pt->m_ID_Type == 402) {//ancestor is a KnowledgeNode
548 KN_pt = (KnowledgeNode *) ((*KU_itr)->m_Ancestor_pt);
549 invest_link_pt->m_link_type = KN_pt->m_Node_Type; //2--and gate, 3--or gate
550
551 //adding the ancestor investigators
552 for (KE_itr = KN_pt->M_KElement_list.begin(); KE_itr != KN_pt->M_KElement_list.end(); KE_itr++) {
553 invest_pt = RM_pt->FindAMatchInvestigatorByKnowledgeElement((*KE_itr), time1, time2);
554 if (invest_pt == NULL) {// if there is no existing investigator, create a new investigator
555 auto invest_owned = make_unique<Investigator>();
556 invest_pt = invest_owned.get();
557 invest_pt->m_note = "by downstream";
558 invest_pt->m_motivation = 0;
559 invest_pt->m_KElement_ID_pt = (*KE_itr);
561 invest_pt->m_effective_start = time1;
562 invest_pt->m_effective_end = time2;
563 invest_pt->m_operator = this->m_operator;
564 invest_pt->m_invest_dormant = true;
565 invest_pt->m_root_of_a_thought_line = false;
566 invest_pt->m_active_investigation = true;
567 RM_pt->AddNewInvestigator(invest_owned.release());
568 }
569 invest_link_pt->m_upperstream_ID_list.push_back(invest_pt);
570 invest_pt->m_downstream_ID_list.push_back((IDElement *) invest_link_pt);
571 }
572 }
573 //update the InvestigatorLink
574 if (invest_link_pt->m_upperstream_ID_list.size() == 0) {
575 this->ErrorMessage("Error");
576 }
577 invest_link_pt->CheckThePathStatus3102();
578 }//end of the for loop of m_Knowledge_list
580
582 if (this->m_Happen == 1 && N_inference == 0) {
583 this->m_Happen = 2;
586 //initiate the feedback list
587 vector<IDElement *>::iterator ID_itr;
588 for (ID_itr = this->m_downstream_ID_list.begin(); ID_itr != this->m_downstream_ID_list.end(); ID_itr++) {
589 this->m_feedback_list.push_back(*ID_itr);
590 }
591 RM_pt->AddToRMFeedbackStack((IDElement *) this);
592 return;
593 }
594 }
597 //}
598}//end of member function
599
600/**********************************************************************\
601|Function Name : GetCorrespondingKE3001 |
602|Input Parameter: |
603|Return Value : |
604|Load Function : |
605|Global Variable: |
606| |
607|Description : map the statement in this Investigator with a |
608|Knowledge Element in Knowledge Base. This leads to 3012 or 3090 |
609\**********************************************************************/
611 string str;
612 stringstream conv;
613
614 string prompt;
615 ReasonMachine *RM_pt;
616 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
617 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
618 else {}//add error message
619
620 this->m_motivation = 1;
621 if (this->m_Statement_pt == NULL) {
622 //break mark
623 this->m_abort = true;
624 this->m_abort_reason = "void investigator, Investigator::GetCorrespondingKE3001()";
625 }
626
627 this->m_Happen = 3;
628
629 this->m_KElement_ID_pt = (IDElement *) (RM_pt->FindKnowledgeElementByStatement(this->m_Statement_pt));
630 if (this->m_KElement_ID_pt != NULL) {
631 //output text
632 prompt = "\n\n";
633 prompt += "found a knowledge element for this investigator: ";
634 prompt += this->m_KElement_ID_pt->m_ID;
635 prompt += "\n";
638 this->PrintMessage(prompt);
641
642 } else {
644 this->CloseThisInvestigator();
645 if (this->m_Happen_incomplete == false
646 && this->m_Explain_incomplete == false) { RM_pt->m_resolved_investigator_pool.push_back(this); }
649
650 conv.str("");
651 conv << r5pars_.timesno;
652 str = conv.str();
653 str += ": ";
654 str += "transfer out to prioritization";
655 this->m_note_list.push_back(str);
656
657 //output text
658 prompt = "\n\n";
659 prompt += "could not find a knowledge element corresponding to the statement in this investigator: \n";
660 prompt += this->m_Statement_pt->GetThisStatementWords();
661 prompt += "\n";
662 this->PrintMessage(prompt);
663
664 }
665}
666
668 bool success = false;
669 int i, j;
670 int type_int;
671 bool consistant_bl;
672 Statement *statement_found_pt, *statement_new_pt, *statement_match_pt;
673 Statement *statement_consistant_pt = NULL;
674 Statement *statement_inconsistant_pt = NULL;
675 KnowledgeElement *KE_pt;
676 KnowledgeElement *KE_down_pt, *KE_upper_pt;
677 vector<KnowledgeElement *>::iterator KE_itr;
678 vector<Statement *>::iterator statement_itr;
679 KnowledgeNode *KN_pt;
680 ReasonMachine *RM_pt = nullptr;
681 SentenceUnit *sent_origin_pt;
682 SentenceUnit *sent_found_pt;
683 SentenceUnit *sent_X_pt;
684 SentenceUnit *sent_input_pt;
685 SentenceUnit *sent_output_pt;
686 vector<SentenceUnit *>::iterator sent_itr, sent_input_itr, sent_output_itr;
687 vector<SentenceUnit *> input_sent_list;
688 vector<SentenceUnit *> output_sent_list;
689 vector<SentenceUnit *> comparing_sent_list;
690 vector<int>::iterator int_itr;
691 vector<int> type_list;
692 vector<IDElement *>::iterator label_ID_itr;
693 IDElement *label_origin_pt;
694 IDElement *ID_pt;
695 IDElement *ID_upper_pt, *ID_down_pt;
696 ConceptBasicUnit *CB_pt;
697 Label *label_group_origin_pt;
698 Label *label_group_buffer_pt;
699 vector<IDElement *> antonym_list;
700 vector<IDElement *>::iterator ID_itr;
701 string prompt, err_mes;
702 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
703 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
704 else {}//add error message
705
706 if (this->m_KElement_ID_pt == NULL) {
707 //output text
708 err_mes = "This is an empty investigator!";
709 this->ErrorMessage(err_mes);
710 //
711
712 this->m_abort = true;
713 this->m_abort_reason = "void investigator, Investigator::FindAMatchingStatement3002()";
715 this->CloseThisInvestigator();
716 }
717 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
718
719 //caution, the effective start time and the effective end time should not be both zero!
720 if (this->m_effective_start == 0 && this->m_effective_end == 0) {
721 //error message here, doesn't have a time range
722 err_mes = "This investigator doesn't have a time range";
723 this->ErrorMessage(err_mes);
724 }
725
726 if (this->m_ID == "Investigator_155") { this->PrintMessage(""); }
728 this->m_effective_start,
729 this->m_effective_end);
730 for (statement_itr = RM_pt->m_temporary_statement_list.begin();
731 statement_itr != RM_pt->m_temporary_statement_list.end(); statement_itr++) {
732 statement_match_pt = *statement_itr;
733 if (statement_match_pt != NULL) {
734 //check whether this new statement is consistant with this KE or not
735 consistant_bl = this->CheckWhetherTheFoundStatementConsistantWithKE(statement_match_pt);
736 if (statement_match_pt->m_sent_pt != KE_pt->m_SentenceUnit_pt
737 && statement_match_pt->m_state == false
738 && statement_match_pt->m_sent_pt->WhetherItIsBiState() == false) {
739 statement_match_pt = NULL;
740 }//could not tell
741
742 if (statement_match_pt != NULL) {
743 if (consistant_bl == true) {
744 if (statement_match_pt->m_factual_type == 1 || statement_match_pt->m_factual_type == 2) {
745 this->m_Statement_pt = statement_match_pt;
747 RM_pt->AddDeltaToCognitiveLoad(0.024);
748 //time consumption
750 return;
751 } else {
752 statement_consistant_pt = statement_match_pt;
753 }
754 } else {
755 statement_inconsistant_pt = statement_match_pt;
756 }
757 }
758 }
759 }
761 statement_match_pt = NULL;
762 sent_X_pt = NULL;
763 label_group_origin_pt = NULL;
764 sent_origin_pt = KE_pt->m_SentenceUnit_pt;
765 label_origin_pt = sent_origin_pt->GetLabelOfThisSentence();
766 if (label_origin_pt != NULL) {
767 sent_X_pt = RM_pt->FindAnIndefiniteSentenceMatchTheInputSentence(sent_origin_pt);
768 label_group_origin_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(sent_X_pt);
769 if (label_group_origin_pt == NULL) {
770 this->ErrorMessage("Error!");
771 }
772 }
773
774 switch (sent_origin_pt->m_sentence_type) {
775 case 1: ID_pt = sent_origin_pt->m_process_pt;
776 break;
777 case 2: ID_pt = sent_origin_pt->m_state_pt;
778 break;
779 case 3: ID_pt = sent_origin_pt->m_comparison_pt;
780 break;
781 case 4: ID_pt = sent_origin_pt->m_comparison_pt;
782 break;
783 case 5: ID_pt = sent_origin_pt->m_attribute_pt;
784 break;
785 default: break;
786 }
787 if (ID_pt->m_ID_Type == 001) {
788 CB_pt = (ConceptBasicUnit *) ID_pt;
789 antonym_list = CB_pt->m_antonym_list;
790 }
791
792 //Create the list of sentences to be compared against the KnowledgeElement in the knowledge base
793 comparing_sent_list.push_back(sent_origin_pt);
794 if (sent_X_pt != NULL) {
795 comparing_sent_list.push_back(sent_X_pt);
796 }
797 //add the antonym sentences
798 for (ID_itr = antonym_list.begin(); ID_itr != antonym_list.end(); ID_itr++) {
799 for (i = 1; i < 3; i++) {
800 bool have_buffer = false;
801 SentenceUnit sent_buffer;
802 if (i == 1) {
803 sent_buffer.CopyFromAnotherSentence(sent_origin_pt);
804 have_buffer = true;
805 } else if (i == 2 && sent_X_pt != NULL) {
806 sent_buffer.CopyFromAnotherSentence(sent_X_pt);
807 have_buffer = true;
808 }
809 if (have_buffer) {
810 switch (sent_origin_pt->m_sentence_type) {
811 case 1: sent_buffer.m_process_pt = (*ID_itr);
812 break;
813 case 2: sent_buffer.m_state_pt = (*ID_itr);
814 break;
815 case 3: sent_buffer.m_comparison_pt = (*ID_itr);
816 break;
817 case 4: sent_buffer.m_comparison_pt = (*ID_itr);
818 break;
819 case 5: sent_buffer.m_attribute_pt = (*ID_itr);
820 break;
821 }
822 sent_found_pt = RM_pt->CheckExistInSemanticPoolBySentence(&sent_buffer);
823 if (sent_found_pt != NULL) {
824 comparing_sent_list.push_back(sent_found_pt);
825 }
826 }
827 }// end of for(i=1; i<3; i++)
828 }
829
830 //Then comparing the sentences in the list with the KnowledgeElement in the KnowledgeUnit
831 for (auto KU_itr = RM_pt->m_Knowledge_list.begin(); KU_itr != RM_pt->m_Knowledge_list.end(); KU_itr++) {
832 if ((*KU_itr)->m_accessable_bl == false) { continue; }
833 ID_down_pt = NULL;
834 //a problem with m_inference_type being 3
835 if ((*KU_itr)->m_inference_type == 1 || (*KU_itr)->m_inference_type == 3) {
836 ID_down_pt = (*KU_itr)->m_Descendant_pt;
837 ID_upper_pt = (*KU_itr)->m_Ancestor_pt;
838 } else if ((*KU_itr)->m_inference_type == 2 || (*KU_itr)->m_inference_type == 3) {
839 ID_down_pt = (*KU_itr)->m_Ancestor_pt;
840 ID_upper_pt = (*KU_itr)->m_Descendant_pt;
841 } else {
842 continue;
843 }
844 if (ID_down_pt->m_ID_Type == 401) {
845 KE_down_pt = (KnowledgeElement *) ID_down_pt;
846 for (sent_itr = comparing_sent_list.begin(); sent_itr != comparing_sent_list.end(); sent_itr++) {
847 //check if match
848 if (KE_down_pt->m_SentenceUnit_pt == (*sent_itr)) {
849 //assign the value of the sent_out_pt
850 label_group_buffer_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem((*sent_itr));
851 if (label_group_buffer_pt != NULL) {
852 sent_found_pt = RM_pt->InstantiateAnIndefiniteSentenceWithLabel((*sent_itr), label_origin_pt);
853 if (sent_found_pt == NULL) {
854 this->ErrorMessage("Error!");
855 }
856 sent_output_pt = sent_found_pt;
857 } else {
858 sent_output_pt = *sent_itr;
859 }
860 //assign the value of the sent_input_pt
861 if (ID_upper_pt->m_ID_Type == 401) {
862 KE_upper_pt = (KnowledgeElement *) ID_upper_pt;
863 if (KE_upper_pt->m_negation == false && KE_down_pt->m_negation == false) { type_int = 1; }
864 else if (KE_upper_pt->m_negation == false && KE_down_pt->m_negation == true) { type_int = 2; }
865 else if (KE_upper_pt->m_negation == true && KE_down_pt->m_negation == false) { type_int = 3; }
866 else if (KE_upper_pt->m_negation == true && KE_down_pt->m_negation == true) { type_int = 4; }
867
868 sent_input_pt = NULL;
869 label_group_buffer_pt =
870 RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(KE_upper_pt->m_SentenceUnit_pt);
871 if (label_group_buffer_pt == NULL) {
872 sent_input_pt = KE_upper_pt->m_SentenceUnit_pt;
873 } else if (label_group_origin_pt != NULL) {
874 if (label_group_origin_pt == label_group_buffer_pt) {
875 sent_input_pt =
876 RM_pt->InstantiateAnIndefiniteSentenceWithLabel(KE_upper_pt->m_SentenceUnit_pt, label_origin_pt);
877 if (sent_input_pt == NULL) { this->ErrorMessage("Error!"); }
878 }
879
880 }
881 if (sent_input_pt != NULL) {
882 //add
883 if (sent_output_pt == NULL || sent_input_pt == NULL) {
884 this->ErrorMessage("Error!");
885 }
886 input_sent_list.push_back(sent_input_pt);
887 output_sent_list.push_back(sent_output_pt);
888 type_list.push_back(type_int);
889
890 }
891 if (label_group_buffer_pt != NULL && label_group_origin_pt == NULL) {
892 for (label_ID_itr = label_group_buffer_pt->m_label_option_list.begin();
893 label_ID_itr != label_group_buffer_pt->m_label_option_list.end(); label_ID_itr++) {
894 sent_input_pt =
895 RM_pt->InstantiateAnIndefiniteSentenceWithLabel(KE_upper_pt->m_SentenceUnit_pt, (*label_ID_itr));
896 if (sent_input_pt == NULL) { this->ErrorMessage("Error!"); }
897 //add
898 if (sent_output_pt == NULL || sent_input_pt == NULL) {
899 this->ErrorMessage("Error!");
900 }
901 input_sent_list.push_back(sent_input_pt);
902 output_sent_list.push_back(sent_output_pt);
903 type_list.push_back(type_int);
904 }
905 }
906 } else if (ID_upper_pt->m_ID_Type == 402) {
907 KN_pt = (KnowledgeNode *) ID_upper_pt;
908 for (KE_itr = KN_pt->M_KElement_list.begin(); KE_itr != KN_pt->M_KElement_list.end(); KE_itr++) {
909 KE_upper_pt = *KE_itr;
910 if (KE_upper_pt->m_negation == false && KE_down_pt->m_negation == false) { type_int = 1; }
911 else if (KE_upper_pt->m_negation == false && KE_down_pt->m_negation == true) { type_int = 2; }
912 else if (KE_upper_pt->m_negation == true && KE_down_pt->m_negation == false) { type_int = 3; }
913 else if (KE_upper_pt->m_negation == true && KE_down_pt->m_negation == true) { type_int = 4; }
914 sent_input_pt = KE_upper_pt->m_SentenceUnit_pt;
915 label_group_buffer_pt = RM_pt->m_IB->CheckWhetherASentenceContainIndefiniteItem(sent_input_pt);
916 if (label_group_buffer_pt != NULL) { this->ErrorMessage("Error!"); }
917 //add
918 if (sent_output_pt == NULL || sent_input_pt == NULL) {
919 this->ErrorMessage("Error!");
920 }
921 input_sent_list.push_back(sent_input_pt);
922 output_sent_list.push_back(sent_output_pt);
923 type_list.push_back(type_int);
924 }
925 }
926 }//end if match
927 }//end comparing_list
928 }
929 }//end of the KU list
930
931 sent_input_itr = input_sent_list.begin();
932 sent_output_itr = output_sent_list.begin();
933 int_itr = type_list.begin();
934 j = 1;
935 if (input_sent_list.size() != output_sent_list.size()
936 || input_sent_list.size() != type_list.size()) { this->ErrorMessage("Error!"); }
937
938 while (sent_input_itr != input_sent_list.end()) {
940 for (statement_itr = RM_pt->m_temporary_statement_list.begin();
941 statement_itr != RM_pt->m_temporary_statement_list.end(); statement_itr++) {
942 statement_found_pt = (*statement_itr);
943 statement_new_pt = NULL;
944 if (statement_found_pt != NULL) {
945 if (statement_found_pt->m_sent_pt != (*sent_input_itr)) {//antonym
946 if (statement_found_pt->m_state == true) {
947 auto stmt_owned = make_unique<Statement>();
948 statement_new_pt = stmt_owned.get();
949 statement_new_pt->m_sent_pt = (*sent_input_itr);
950 statement_new_pt->m_state = false;
951 statement_new_pt->CopyAuxInfoFromUpperstreamStatement(statement_found_pt);
952 if (statement_found_pt->m_factual_type == 1 || statement_found_pt->m_factual_type == 2) {
953 statement_new_pt->m_factual_type = 2;
954 }
955 else { statement_new_pt->m_factual_type = 3; }
956 statement_new_pt->m_operator = this->m_operator;
957 statement_new_pt->m_time_generated = r5pars_.timesno;
958 statement_new_pt->m_tbi_bl = false;
959 RM_pt->AddANewStatement(stmt_owned.release());
960 //
961 statement_new_pt->m_upperstream_statement_list.push_back(statement_found_pt);
962 statement_found_pt->m_downstream_statement_list.push_back(statement_new_pt);
963 } else if (statement_found_pt->m_sent_pt->WhetherItIsBiState() == true) {
964 auto stmt_owned = make_unique<Statement>();
965 statement_new_pt = stmt_owned.get();
966 statement_new_pt->m_sent_pt = (*sent_input_itr);
967 statement_new_pt->m_state = true;
968 statement_new_pt->CopyAuxInfoFromUpperstreamStatement(statement_found_pt);
969 if (statement_found_pt->m_factual_type == 1 || statement_found_pt->m_factual_type == 2) {
970 statement_new_pt->m_factual_type = 2;
971 }
972 else { statement_new_pt->m_factual_type = 3; }
973 statement_new_pt->m_operator = this->m_operator;
974 statement_new_pt->m_time_generated = r5pars_.timesno;
975 statement_new_pt->m_tbi_bl = false;
976 RM_pt->AddANewStatement(stmt_owned.release());
977 //
978 statement_new_pt->m_upperstream_statement_list.push_back(statement_found_pt);
979 statement_found_pt->m_downstream_statement_list.push_back(statement_new_pt);
980 } else { statement_new_pt = NULL; }//could not tell
981 } else {//the same as the comparing sentence
982 statement_new_pt = statement_found_pt;
983 }
984 //finished give value to the statement_new_pt
985
986 if (statement_new_pt != NULL) {
987 {
988 auto stmt_owned = make_unique<Statement>();
989 statement_match_pt = stmt_owned.get();
990 if (*sent_output_itr == NULL) {
991 this->ErrorMessage("Error!");
992 }
993 statement_match_pt->m_sent_pt = (*sent_output_itr);
994 statement_match_pt->CopyAuxInfoFromUpperstreamStatement(statement_new_pt);
995 if (statement_new_pt->m_factual_type == 1 || statement_new_pt->m_factual_type == 2) {
996 statement_match_pt->m_factual_type = 2;
997 }
998 else { statement_match_pt->m_factual_type = 3; }
999 statement_match_pt->m_operator = this->m_operator;
1000 statement_match_pt->m_time_generated = r5pars_.timesno;
1001 statement_match_pt->m_tbi_bl = false;
1002 //
1003 statement_match_pt->m_upperstream_statement_list.push_back(statement_new_pt);
1004 statement_new_pt->m_downstream_statement_list.push_back(statement_match_pt);
1005 if ((*int_itr) == 1 || (*int_itr) == 4) {
1006 statement_match_pt->m_state = statement_new_pt->m_state;
1007 } else {
1008 statement_match_pt->m_state = !statement_new_pt->m_state;
1009 }
1010 RM_pt->AddANewStatement(stmt_owned.release());
1011 }
1012
1013 //check whether this new statement is consistant with this KE or not
1014 consistant_bl = this->CheckWhetherTheFoundStatementConsistantWithKE(statement_match_pt);
1015 if (consistant_bl == false
1016 && statement_match_pt->m_sent_pt != KE_pt->m_SentenceUnit_pt
1017 && statement_match_pt->m_state == false
1018 && statement_match_pt->m_sent_pt->WhetherItIsBiState() == false) {
1019 statement_match_pt = NULL;
1020 }//could not tell
1021
1022 //finished checking the consistancy
1023 if (statement_match_pt != NULL) {
1025 if (consistant_bl == true) {
1026 if (statement_consistant_pt == NULL) {
1027 statement_consistant_pt = statement_match_pt;
1028 } else if (statement_match_pt->m_time_range.GetTimeBoundLater()
1029 > statement_consistant_pt->m_time_range.GetTimeBoundLater()) {
1030 statement_consistant_pt = statement_match_pt;
1031 }
1032 } else//consistancy false
1033 {
1034 if (statement_inconsistant_pt == NULL) {
1035 statement_inconsistant_pt = statement_match_pt;
1036 } else if (statement_match_pt->m_time_range.GetTimeBoundLater()
1037 > statement_inconsistant_pt->m_time_range.GetTimeBoundLater()) {
1038 statement_inconsistant_pt = statement_match_pt;
1039 }
1040 }
1041 }
1042 }//end of if(statement_new_pt != NULL)
1043 }//end of if(statement_found_pt != NULL)
1044 }//end of statement_itr
1045 j++;
1046 sent_input_itr++;
1047 sent_output_itr++;
1048 int_itr++;
1049 }
1050
1051 // to be modified
1052
1053 if (statement_consistant_pt != NULL) {//already find a consistant statement
1054 if (statement_consistant_pt->m_factual_type == 1 || statement_consistant_pt->m_factual_type == 2) {
1055 this->m_Statement_pt = statement_consistant_pt;
1056 RM_pt->AddDeltaToCognitiveLoad(0.024);
1058 } else {
1059 this->m_possible_statement_pt = statement_consistant_pt;
1061 }
1062 //to be added, token stuff
1063
1064 } else if (statement_inconsistant_pt != NULL) {
1065 this->m_inconsistant_statement = statement_inconsistant_pt;
1067 } else {
1069 }
1070
1071 //time consumption
1073 return;
1074}
1075
1077 //lead to 3012 if there is no corresponding indication for verifying the KE
1078 //lead to 3004 if there isn't enough information but it is possible to get it from new reading
1079 //lead to 3007 if there is enough informaiton found and a new statement is created
1080
1081 string prompt, err_mes;
1082 IDElement *ID_pt1 = NULL;
1083 IDElement *ID_pt2 = NULL;
1084 MRValueSchema *value_schema_pt = NULL;
1085 MRValueSchema *value_schema_pt1 = NULL;
1086 MRValueSchema *value_schema_pt2 = NULL;
1087 MRStateSchema *state_schema_pt = NULL;
1088 MRStateSchema *state_schema_pt1 = NULL;
1089 MRStateSchema *state_schema_pt2 = NULL;
1090 MRParameterUnit *MR_P_pt = NULL;
1091 MRComponentStateUnit *MR_C_pt = NULL;
1092 MRSupportSystemStateUnit *MR_SS_pt = NULL;
1093 MRAlarmUnit *MR_A_pt = NULL;
1094 KnowledgeElement *KE_pt = NULL;
1095 ReasonMachine *RM_pt = NULL;
1096 Statement *statement_pt = NULL;
1097 Statement *new_statement_pt = NULL;
1098 Statement *statement_consistant_pt = NULL;
1099 Statement *statement_inconsistant_pt = NULL;
1100 SentenceUnit *sent_pt = NULL;
1101 SentenceUnit *found_sent_pt = NULL;
1102 vector<Statement *>::iterator statement_itr;
1103 bool consistant_bl;
1104 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
1105 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
1106 else {}//add error message
1107
1108
1109 if (this->m_ID == "Investigator_32") { this->PrintMessage("Check!"); }
1110
1111 if (this->m_KElement_ID_pt == NULL) {
1112 this->m_abort = true;
1113 this->m_abort_reason = "void investigator, Investigator::FindAMatchingStatement3002()";
1114 return;
1115 }
1116 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
1117 ID_pt1 = RM_pt->m_MR->CheckExistenceByConceptStrict(KE_pt->m_SentenceUnit_pt->m_subject_pt);
1118 if (ID_pt1 == NULL) {//Couldn't find a corresponding MR item for this
1119 if (this->m_read_requested_bl == 1) {
1120 this->ErrorMessage("Error!");
1121 }
1122 if (this->m_possible_statement_pt != NULL || this->m_inconsistant_statement != NULL) {
1124 RM_pt->AddConsumptedDeltaT(0);
1125 } else {
1127 RM_pt->AddConsumptedDeltaT(0);
1128 return;
1129 }
1130 }
1131
1132 if (this->m_Statement_pt != NULL) {
1134 return;
1135 }
1136
1137 statement_consistant_pt = this->m_possible_statement_pt;
1138 statement_inconsistant_pt = this->m_inconsistant_statement;
1139
1140 if (this->m_read_requested_bl == true && this->m_Statement_pt == NULL) {//With new readings
1141 //check point
1142 if (this->m_ID == "Investigator_126") {
1143 this->PrintMessage("Check point");
1144 }
1146 this->m_effective_start,
1147 this->m_effective_end);
1149 this->m_effective_start,
1150 this->m_effective_end);
1151 for (statement_itr = RM_pt->m_temporary_statement_list.begin();
1152 statement_itr != RM_pt->m_temporary_statement_list.end(); statement_itr++) {
1153 statement_pt = *statement_itr;
1154 if (statement_pt != NULL) {
1155 consistant_bl = this->CheckWhetherTheFoundStatementConsistantWithKE(statement_pt);
1156 if (consistant_bl == false
1157 && statement_pt->m_sent_pt != KE_pt->m_SentenceUnit_pt
1158 && statement_pt->m_state == false
1159 && statement_pt->m_sent_pt->WhetherItIsBiState() == false) { statement_pt = NULL; }
1160 }
1161 if (statement_pt != NULL) {
1162 if (consistant_bl == true) {
1163 if (statement_consistant_pt == NULL) {
1164 statement_consistant_pt = statement_pt;
1165 } else if (statement_pt->m_time_range.GetTimeBoundLater()
1166 > statement_consistant_pt->m_time_range.GetTimeBoundLater()) {
1167 statement_consistant_pt = statement_pt;
1168 }
1169 } else//consistancy false
1170 {
1171 if (statement_inconsistant_pt == NULL) {
1172 statement_inconsistant_pt = statement_pt;
1173 } else if (statement_pt->m_time_range.GetTimeBoundLater()
1174 > statement_inconsistant_pt->m_time_range.GetTimeBoundLater()) {
1175 statement_inconsistant_pt = statement_pt;
1176 }
1177 }
1178 }
1179 }
1180
1181
1182 //finished checking
1183 if (statement_consistant_pt != NULL) {//already find a consistant statement
1184 if (statement_consistant_pt->m_factual_type == 1 || statement_consistant_pt->m_factual_type == 2) {
1185 this->m_Statement_pt = statement_consistant_pt;
1186 RM_pt->AddDeltaToCognitiveLoad(0.024);
1188 RM_pt->AddConsumptedDeltaT(0);
1189 return;
1190 }
1191 } else if (statement_inconsistant_pt != NULL) {
1192 this->m_inconsistant_statement = statement_inconsistant_pt;
1193 }
1194 }
1195
1196 switch (KE_pt->m_SentenceUnit_pt->m_sentence_type) {
1197 case 1:
1198 //
1199 statement_pt = NULL;
1200 new_statement_pt = NULL;
1201
1202 if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getTurnOnPt()
1203 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getTurnOffPt()
1204 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getOpenBiggerPt()
1205 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getCloseSmallerPt()
1206 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getIncreasePt()
1208 == RM_pt->m_Concept_Base->getDecreasePt()) {//it could be verified from control panel
1209 if (this->m_read_requested_bl == 0) {//want to request to read from Control Panel
1212 return;
1213 } else {
1214 if (statement_inconsistant_pt == NULL && statement_consistant_pt == NULL
1215 &&
1216 (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getTurnOnPt()
1217 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getTurnOffPt()
1218 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getOpenBiggerPt()
1219 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getCloseSmallerPt()
1220 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getIncreasePt()
1221 || KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getDecreasePt())) {
1222 this->m_Happen = 4;
1223 }
1225 return;
1226 //already checked the newly updated action statement
1227 }
1228 } else {//the process type isn't anyone of the reserved
1230 RM_pt->AddConsumptedDeltaT(0);
1231 return;
1232 }
1233 break;
1234 case 2:
1235 //add the situation that there is a gap between two observations
1236 statement_pt = NULL;
1237 state_schema_pt = NULL;
1238 state_schema_pt1 = NULL;
1239 state_schema_pt2 = NULL;
1240 if (ID_pt1 != NULL) {
1241 if (ID_pt1->m_ID_Type == 202) //component state
1242 {
1243 MR_C_pt = (MRComponentStateUnit *) ID_pt1;
1244 //state_schema_pt = MR_C_pt->CheckComponentStateWithinTimeRange(this->m_effective_start, this->m_effective_end);
1245 //if(state_schema_pt == NULL)
1246 //{
1247 state_schema_pt1 = MR_C_pt->CheckTheFirstComponentStateReadingAfterATime(this->m_effective_start);
1248 state_schema_pt2 = MR_C_pt->CheckLastComponentStateReadingBeforeATime(this->m_effective_end);
1249 //}
1250 } else if (ID_pt1->m_ID_Type == 203) // alarms
1251 {
1252 MR_A_pt = (MRAlarmUnit *) ID_pt1;
1253 //state_schema_pt = MR_A_pt->CheckAlarmStateWithinTimeRange(this->m_effective_start, this->m_effective_end);
1254 //if(state_schema_pt == NULL)
1255 //{
1256 state_schema_pt1 = MR_A_pt->CheckFirstAlarmStateAfterATime(this->m_effective_start);
1257 state_schema_pt2 = MR_A_pt->CheckLastAlarmStateBeforeATime(this->m_effective_end);
1258 //}
1259 } else if (ID_pt1->m_ID_Type == 204) // support system state
1260 {
1261 MR_SS_pt = (MRSupportSystemStateUnit *) ID_pt1;
1262 //state_schema_pt = MR_A_pt->CheckAlarmStateWithinTimeRange(this->m_effective_start, this->m_effective_end);
1263 //if(state_schema_pt == NULL)
1264 //{
1265 state_schema_pt1 = MR_SS_pt->CheckTheFirstSupportSystemStateReadingAfterATime(this->m_effective_start);
1266 state_schema_pt2 = MR_SS_pt->CheckLastSupportSystemStateReadingBeforeATime(this->m_effective_end);
1267 //}
1268 } else//error message
1269 {}
1270
1271 /*if(state_schema_pt != NULL)
1272 {
1273 statement_pt = new Statement();
1274 statement_pt->m_time_range.m_start_time = state_schema_pt->m_time_perceived;
1275 statement_pt->m_time_range.m_end_time = state_schema_pt->m_perceived_state;
1276
1277 }
1278 else*/
1279 if (state_schema_pt1 != NULL && state_schema_pt2 != NULL) {
1281 state_schema_pt = state_schema_pt1;
1282 if (state_schema_pt1->m_perceived_state == state_schema_pt2->m_perceived_state) {
1283 auto stmt_owned = make_unique<Statement>();
1284 statement_pt = stmt_owned.get();
1285 statement_pt->m_time_range.m_start_time = state_schema_pt1->m_time_perceived;
1286 statement_pt->m_time_range.m_end_time = state_schema_pt2->m_time_perceived;
1287 statement_pt->m_sent_pt = KE_pt->m_SentenceUnit_pt;
1288 if (KE_pt->m_SentenceUnit_pt->m_state_pt == RM_pt->m_Concept_Base->getONpt()) {
1289 statement_pt->m_state = state_schema_pt1->m_perceived_state;
1290 } else if (KE_pt->m_SentenceUnit_pt->m_state_pt == RM_pt->m_Concept_Base->getOFFpt()) {
1291 statement_pt->m_state = !state_schema_pt1->m_perceived_state;
1292 }
1293 statement_pt->m_confidence = 0.7;
1294 statement_pt->m_factual_type = 2;
1295 statement_pt->m_time_range.m_start_time = state_schema_pt1->m_time_perceived;
1296 statement_pt->m_time_range.m_end_time = state_schema_pt2->m_time_perceived;
1297 if (statement_pt->m_state == !KE_pt->m_negation) {
1298 this->m_Statement_pt = statement_pt;
1299 RM_pt->AddDeltaToCognitiveLoad(0.024);
1300 } else { this->m_inconsistant_statement = statement_pt; }
1301 RM_pt->AddANewStatement(stmt_owned.release());
1302 if (this->m_read_requested_bl == 0) {
1304 }
1306 return;
1307 } else {
1308 //just give up, could not determine from MR and Control Panel
1309 this->m_Happen = 2;
1312
1313 /*//initiate the feedback list
1314 for(ID_itr = this->m_downstream_ID_list.begin();ID_itr != this->m_downstream_ID_list.end(); ID_itr++)
1315 {
1316 this->m_feedback_list.push_back(*ID_itr);
1317 }
1318 RM_pt->m_feedback_stack.push_back((IDElement*)this);*/
1319 return;
1320 }
1321 } else if (state_schema_pt1 != NULL && state_schema_pt2 == NULL) {
1322 //want to request to read from Control Panel
1323 if (this->m_read_requested_bl == 0) {
1326 return;
1327 } else {
1328 //caution: not sure why to go to 3007?
1329 //this->ChangeInvestigatorToken(inv::CompareKEAndStatement);
1330 //this->ErrorMessage("Should have read it already. Error!");
1331 return;
1332 }
1333 } else {
1334 //just give up, could not determine from MR and Control Panel
1335 /*this->m_Happen = 2;
1336 this->ChangeInvestigatorToken(inv::ChooseDownstreamLink);
1337 this->AddTimeConsumptionInInvestigator(0);
1338
1339 //initiate the feedback list
1340 for(ID_itr = this->m_downstream_ID_list.begin();ID_itr != this->m_downstream_ID_list.end(); ID_itr++)
1341 {
1342 this->m_feedback_list.push_back(*ID_itr);
1343 }
1344 RM_pt->m_feedback_stack.push_back((IDElement*)this);*/
1346 return;
1347 }
1348 } else {
1350 RM_pt->AddConsumptedDeltaT(0);
1351 return;
1352 }
1353 break;
1354 case 3:
1355 //add the situation that there is a gap between two observations
1356 consistant_bl = false;
1357 value_schema_pt = NULL;
1358 value_schema_pt1 = NULL;
1359 value_schema_pt2 = NULL;
1360 if (ID_pt1 != NULL) {
1361 if (ID_pt1->m_ID_Type == 201) {
1362 MR_P_pt = (MRParameterUnit *) ID_pt1;
1363 if (KE_pt->m_negation == false) {
1365 this->m_effective_end,
1366 KE_pt->m_SentenceUnit_pt);
1367 }
1368 else {
1370 this->m_effective_end,
1371 KE_pt->m_SentenceUnit_pt);
1372 }
1373
1374 if (value_schema_pt != NULL) { consistant_bl = true; }
1375 else {//check the inconsistant situation
1376 if (KE_pt->m_negation == false) {
1378 this->m_effective_end,
1379 KE_pt->m_SentenceUnit_pt);
1380 }
1381 else {
1383 this->m_effective_end,
1384 KE_pt->m_SentenceUnit_pt);
1385 }
1386
1387 if (value_schema_pt != NULL) { consistant_bl = false; }
1388 }
1389 } else if (ID_pt1->m_ID_Type == 202) {
1390 MR_C_pt = (MRComponentStateUnit *) ID_pt1;
1391 if (KE_pt->m_negation == false) {
1392 value_schema_pt =
1394 this->m_effective_end,
1395 KE_pt->m_SentenceUnit_pt);
1396 }
1397 else {
1398 value_schema_pt =
1400 this->m_effective_end,
1401 KE_pt->m_SentenceUnit_pt);
1402 }
1403
1404 if (value_schema_pt != NULL) { consistant_bl = true; }
1405 else {//check the inconsistant situation
1406 if (KE_pt->m_negation == false) {
1407 value_schema_pt =
1409 this->m_effective_end,
1410 KE_pt->m_SentenceUnit_pt);
1411 }
1412 else {
1413 value_schema_pt =
1415 this->m_effective_end,
1416 KE_pt->m_SentenceUnit_pt);
1417 }
1418 if (value_schema_pt != NULL) { consistant_bl = false; }
1419 }
1420
1421 if (value_schema_pt == NULL) {
1422 value_schema_pt1 = MR_C_pt->FindTheLastPositionReadingBeforeATime(this->m_effective_start);
1423 value_schema_pt2 = MR_C_pt->FindTheFirstPositionReadingAfterATime(this->m_effective_end);
1424 }
1425 } else { this->ErrorMessage("Error!"); }
1426
1427 if (value_schema_pt != NULL && consistant_bl == true) {//find a consistant
1428 auto stmt_owned = make_unique<Statement>();
1429 this->m_Statement_pt = stmt_owned.get();
1431 this->m_Statement_pt->m_state = !KE_pt->m_negation;
1432 this->m_Statement_pt->m_time_range.m_start_time = value_schema_pt->m_time_perceived;
1433 this->m_Statement_pt->m_time_range.m_end_time = value_schema_pt->m_time_perceived;
1434 this->m_Statement_pt->m_factual_type = 1;
1435 this->m_Statement_pt->m_confidence = 1;
1437 RM_pt->AddANewStatement(stmt_owned.release());
1438 RM_pt->AddDeltaToCognitiveLoad(0.024);
1439 } else if (value_schema_pt != NULL && consistant_bl == false) {
1440 if (this->m_inconsistant_statement != NULL) {
1442 value_schema_pt = NULL;
1443 }
1444 }
1445 if (value_schema_pt != NULL) {
1446 auto stmt_owned = make_unique<Statement>();
1447 this->m_inconsistant_statement = stmt_owned.get();
1455 RM_pt->AddANewStatement(stmt_owned.release());
1456 }
1457 } else {
1458 if (value_schema_pt1 != NULL && value_schema_pt2
1459 != NULL) {//Caution about these codes, if the position is subjective to automatic control, this reasoning is faulted
1461 bool is_consistant = false;
1462 bool is_inconsistant = false;
1463 if (KE_pt->m_SentenceUnit_pt->m_comparison_pt == RM_pt->m_Concept_Base->getBiggerPt()) {
1464 if (value_schema_pt1->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1466 && value_schema_pt2->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1467 > KE_pt->m_SentenceUnit_pt->m_delta_value) {
1468 if (KE_pt->m_negation == false) { is_consistant = true; }
1469 else { is_inconsistant = true; }
1470 } else if (!(value_schema_pt1->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1472 && !(value_schema_pt2->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1473 > KE_pt->m_SentenceUnit_pt->m_delta_value)) {
1474 if (KE_pt->m_negation == false) { is_inconsistant = true; }
1475 else { is_consistant = true; }
1476 }
1477 } else if (KE_pt->m_SentenceUnit_pt->m_comparison_pt == RM_pt->m_Concept_Base->getEqualPt()) {
1478 if (value_schema_pt1->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1480 && KE_pt->m_SentenceUnit_pt->m_value - value_schema_pt1->m_perceived_value
1482 && value_schema_pt2->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1484 && KE_pt->m_SentenceUnit_pt->m_value - value_schema_pt2->m_perceived_value
1485 < KE_pt->m_SentenceUnit_pt->m_delta_value) {
1486 if (KE_pt->m_negation == false) { is_consistant = true; }
1487 else { is_inconsistant = true; }
1488 } else if (!(value_schema_pt1->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1490 && KE_pt->m_SentenceUnit_pt->m_value - value_schema_pt1->m_perceived_value
1492 && !(value_schema_pt2->m_perceived_value - KE_pt->m_SentenceUnit_pt->m_value
1494 && KE_pt->m_SentenceUnit_pt->m_value - value_schema_pt2->m_perceived_value
1495 < KE_pt->m_SentenceUnit_pt->m_delta_value)) {
1496 if (KE_pt->m_negation == false) { is_inconsistant = true; }
1497 else { is_consistant = true; }
1498 }
1499
1500 } else if (KE_pt->m_SentenceUnit_pt->m_comparison_pt
1501 == RM_pt->m_Concept_Base->getSmallerPt()) {//if both satisfied or not
1502 if (-value_schema_pt1->m_perceived_value + KE_pt->m_SentenceUnit_pt->m_value
1504 && -value_schema_pt2->m_perceived_value + KE_pt->m_SentenceUnit_pt->m_value
1505 > KE_pt->m_SentenceUnit_pt->m_delta_value) {
1506 is_consistant = true;
1507 } else if (!(-value_schema_pt1->m_perceived_value + KE_pt->m_SentenceUnit_pt->m_value
1509 && !(-value_schema_pt2->m_perceived_value + KE_pt->m_SentenceUnit_pt->m_value
1510 > KE_pt->m_SentenceUnit_pt->m_delta_value)) {
1511 is_inconsistant = true;
1512 }
1513 }
1514 //finished comparison
1515 if (is_consistant) {
1516 auto stmt_owned = make_unique<Statement>();
1517 this->m_Statement_pt = stmt_owned.get();
1519 this->m_Statement_pt->m_state = !KE_pt->m_negation;
1520 this->m_Statement_pt->m_time_range.m_start_time = value_schema_pt1->m_time_perceived;
1521 this->m_Statement_pt->m_time_range.m_end_time = value_schema_pt2->m_time_perceived;
1522 this->m_Statement_pt->m_factual_type = 1;
1523 this->m_Statement_pt->m_confidence = 1;
1525 RM_pt->AddANewStatement(stmt_owned.release());
1526 RM_pt->AddDeltaToCognitiveLoad(0.024);
1527
1529 RM_pt->AddConsumptedDeltaT(0.2);
1530 return;
1531 } else if (is_inconsistant) {
1532 auto stmt_owned = make_unique<Statement>();
1533 this->m_inconsistant_statement = stmt_owned.get();
1541 RM_pt->AddANewStatement(stmt_owned.release());
1542
1544 RM_pt->AddConsumptedDeltaT(0.2);
1545 return;
1546 }
1547 }
1548 }
1549
1550 if (this->m_Statement_pt != NULL) {
1552 RM_pt->AddConsumptedDeltaT(0.2);
1553 return;
1554 } else {
1555 if (this->m_read_requested_bl == 0) {
1556 if (this->m_effective_end >= r5pars_.timesno
1557 || (value_schema_pt1 != NULL && value_schema_pt2 == NULL)) {
1559 RM_pt->AddConsumptedDeltaT(0.2);
1560 return;
1561 } else {
1562 if (this->m_effective_end < r5pars_.timesno) { this->m_Happen_incomplete = true; }
1563
1565 RM_pt->AddConsumptedDeltaT(0.2);
1566 return;
1567 }
1568 } else { return; }
1569 }
1570 /*
1571 // MR_P_pt->CheckReadingWithinTimeRange(this->m_effective_start, this->m_effective_end);
1572 }
1573 else if(ID_pt1->m_ID_Type == 202)
1574 {
1575 MR_C_pt = (MRComponentStateUnit *)ID_pt1;
1576 value_schema_pt = MR_C_pt->CheckPositionReadingWithinTimeRange(this->m_effective_start, this->m_effective_end);
1577 }//To be added
1578 else
1579 {
1580 this->ErrorMessage("Error!");
1581 }//error message
1582
1583 if(value_schema_pt == NULL)
1584 {
1585 //change token value
1586
1587 //output text
1588 prompt = "There is no available information for this investigator on Mental Representation";
1589 this->PrintMessage(prompt);
1590 //
1591 this->ChangeInvestigatorToken(inv::VerifyFromControlPanel);
1592 RM_pt->AddConsumptedDeltaT(0.1);
1593 }
1594 else
1595 {
1596 //add a new statement
1597 SentenceUnit sent;
1598 sent.CopyFromAnotherSentence(KE_pt->m_SentenceUnit_pt);
1599 if( value_schema_pt->m_perceived_value > sent.m_value )
1600 {
1601 sent.m_comparison_pt = RM_pt->m_Concept_Base.getBiggerPt();
1602 }
1603 else if(value_schema_pt->m_perceived_value < sent.m_value)
1604 {
1605 sent.m_comparison_pt = RM_pt->m_Concept_Base.getSmallerPt();
1606 }
1607 else
1608 {
1609 sent.m_comparison_pt = RM_pt->m_Concept_Base.getEqualPt();
1610 }
1611 found_sent_pt = RM_pt->CheckExistInSemanticPoolBySentence(&sent);
1612 statement_pt = new Statement();
1613 this->m_Statement_pt = statement_pt;
1614 statement_pt->m_sent_pt = found_sent_pt;
1615 if(found_sent_pt == NULL)
1616 {
1617 statement_pt->m_sent_pt = KE_pt->m_SentenceUnit_pt;
1618 statement_pt->m_state = false;
1619 }
1620 statement_pt->m_investigator_ID_pt = (IDElement *)this;
1621 statement_pt->m_confidence = 1;
1622 statement_pt->m_factual_type = 1;
1623 statement_pt->m_time_range.m_start_time = value_schema_pt->m_time_perceived;
1624 statement_pt->m_time_range.m_end_time = value_schema_pt->m_time_perceived;
1625 RM_pt->AddANewStatement(statement_pt);
1626
1627 //change token value
1628
1629 //output text
1630 prompt = "Found matching information on Mental Representation, and a new statement is inferred: \n";
1631 prompt += statement_pt->GetThisStatementWords();
1632 this->PrintMessage(prompt);
1633 //
1634
1635 this->ChangeInvestigatorToken(inv::CompareKEAndStatement);
1636 RM_pt->AddConsumptedDeltaT(0.2);
1637 }*/
1638 } else {
1639 //output text
1640 prompt = "Could not verify this knowledge element from control panel, will dig more root causes. \n";
1641 this->PrintMessage(prompt);
1642 //
1644 RM_pt->AddConsumptedDeltaT(0);
1645 }
1646 break;
1647 case 4: ID_pt2 = RM_pt->m_MR->CheckExistenceByConceptStrict(KE_pt->m_SentenceUnit_pt->m_object_pt);
1648 if (ID_pt1 != NULL && ID_pt2 != NULL) {
1649 //
1650 if (this->m_read_requested_bl == 0) {
1653 return;
1654 }
1655 //
1656 if (ID_pt1->m_ID_Type == 201 && ID_pt2->m_ID_Type == 201) {
1657 MR_P_pt = (MRParameterUnit *) ID_pt1;
1658 value_schema_pt = MR_P_pt->CheckReadingWithinTimeRange(this->m_effective_start, this->m_effective_end);
1659
1660 MR_P_pt = (MRParameterUnit *) ID_pt2;
1661 value_schema_pt2 = MR_P_pt->CheckReadingWithinTimeRange(this->m_effective_start, this->m_effective_end);
1662
1663 if (value_schema_pt == NULL || value_schema_pt2 == NULL) {
1664 //output text
1665 prompt = "There is no available information for this investigator on Mental Representation";
1666 this->PrintMessage(prompt);
1667 //
1668 //this->ChangeInvestigatorToken(inv::VerifyFromControlPanel);
1670 } else {
1671 //add a new statement
1672 {
1673 auto stmt_owned = make_unique<Statement>();
1674 statement_pt = stmt_owned.get();
1675 this->m_Statement_pt = statement_pt;
1676 RM_pt->AddDeltaToCognitiveLoad(0.024);
1677 statement_pt->m_sent_pt = KE_pt->m_SentenceUnit_pt;
1678 statement_pt->m_investigator_ID_pt = (IDElement *) this;
1679 statement_pt->m_confidence = 1;
1680 statement_pt->m_factual_type = 1;
1681 statement_pt->m_time_range.m_start_time = value_schema_pt->m_time_perceived;
1682 statement_pt->m_time_range.m_end_time = value_schema_pt->m_time_perceived;
1683
1684 if (KE_pt->m_SentenceUnit_pt->m_comparison_pt == RM_pt->m_Concept_Base->getBiggerPt()) {
1685 if (value_schema_pt->m_perceived_value - value_schema_pt2->m_perceived_value
1686 > KE_pt->m_SentenceUnit_pt->m_delta_value) {
1687 statement_pt->m_state = true;
1688 } else {
1689 statement_pt->m_state = false;
1690 }
1691 } else if (KE_pt->m_SentenceUnit_pt->m_comparison_pt == RM_pt->m_Concept_Base->getSmallerPt()) {
1692 if (value_schema_pt2->m_perceived_value - value_schema_pt->m_perceived_value
1693 > KE_pt->m_SentenceUnit_pt->m_delta_value) {
1694 statement_pt->m_state = true;
1695 } else {
1696 statement_pt->m_state = false;
1697 }
1698 } else if (KE_pt->m_SentenceUnit_pt->m_comparison_pt == RM_pt->m_Concept_Base->getEqualPt()) {
1699 if (value_schema_pt->m_perceived_value - value_schema_pt2->m_perceived_value
1701 && value_schema_pt2->m_perceived_value - value_schema_pt->m_perceived_value
1702 < KE_pt->m_SentenceUnit_pt->m_delta_value) {
1703 statement_pt->m_state = true;
1704 } else {
1705 statement_pt->m_state = false;
1706 }
1707 }
1708 RM_pt->AddANewStatement(stmt_owned.release());
1709 }
1710
1711 //output text
1712 prompt = "Found matching information on Mental Representation, and a new statement is inferred: \n";
1713 prompt += statement_pt->GetThisStatementWords();
1714 this->PrintMessage(prompt);
1715 //
1716
1717 //change token value
1718 //this->ChangeInvestigatorToken(inv::CompareKEAndStatement);
1720 }
1721 } else {
1722 this->ErrorMessage("valve position comparison is not analyzed here");
1723 }//error message
1724 //caution, valve position comparison is not analyzed here
1725 } else {
1726 //output text
1727 prompt = "Could not verify this knowledge element from control panel, will dig more root causes. \n";
1728 this->PrintMessage(prompt);
1729 //
1730
1733 return;
1734 }
1735 break;
1736 default:
1737 //output text
1738 prompt = "There is no available information for this investigator on Mental Representation";
1739 this->PrintMessage(prompt);
1740 //
1743 break;
1744 }
1745}
1746
1748 string err_mes, prompt;
1750 ReasonMachine *RM_pt;
1751 bool consistant_bl;
1752 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
1753 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
1754 else {}//add error message
1755
1756 //a debugging check point
1757 if (this->m_ID == "Investigator_32") { this->PrintMessage("Check point!"); }
1758 //
1759 if (this->m_Statement_pt != NULL) {
1760 if ((this->m_Statement_pt->m_time_range.GetTimeBoundEarlier() <= this->m_effective_end
1761 && this->m_Statement_pt->m_time_range.GetTimeBoundEarlier() >= this->m_effective_start)
1762 ||
1763 (this->m_Statement_pt->m_time_range.GetTimeBoundLater() <= this->m_effective_end
1764 && this->m_Statement_pt->m_time_range.GetTimeBoundLater()
1765 >= this->m_effective_start)) {}//satisfy the requirement
1766 else { this->m_Statement_pt = NULL; }
1767 }
1768 //{this->m_Statement_pt = RM_pt->CheckWhetherASentenceIsTrueFromMR(KE_pt->m_SentenceUnit_pt, this->m_effective_start, this->m_effective_end);}
1769 if (this->m_read_requested_bl == 1) {
1770 if (this->m_Statement_pt != NULL) {
1771 if (this->m_Statement_pt->m_sent_pt == KE_pt->m_SentenceUnit_pt
1772 && this->m_Statement_pt->m_state != KE_pt->m_negation) {}
1773 else { this->WhetherItIsAvailablefromMR3003(); }
1774 } else { this->WhetherItIsAvailablefromMR3003(); }
1775 }
1776
1777 if (this->m_Happen == 1 || this->m_Happen == 2) {
1778 if (this->m_Statement_pt != NULL) {
1780 if (consistant_bl == true) {
1781 this->m_Happen = 3;
1783 } else {
1784 if (this->m_Statement_pt->m_sent_pt != KE_pt->m_SentenceUnit_pt && this->m_Statement_pt->m_state == false
1785 && this->m_Statement_pt->m_sent_pt->WhetherItIsBiState() == false) {
1786 this->m_Happen = 2;
1788 } else {
1790 this->m_Happen = 4;
1791 }
1792 //this->ErrorMessage("Check this situation!");
1793 }
1794 } else if (this->m_inconsistant_statement != NULL) {
1796 if (consistant_bl == false) {
1798 || this->m_inconsistant_statement->m_factual_type == 2) {
1801 RM_pt->AddDeltaToCognitiveLoad(0.024);
1802 this->m_Happen = 4;
1803 } else if (this->m_possible_statement_pt == NULL) {
1806 this->m_Happen = 2;
1807 }
1808 } else {
1809 this->ErrorMessage("Check this situation!");
1810 }
1811 } else {
1812 // {this->WhetherItIsAvailablefromMR3003();}
1813 this->m_Happen = 2;
1814 }
1815 }
1816 prompt = "\n\n";
1817 prompt += "Verification result: ";
1818 switch (this->m_Happen) {
1819 case 1: prompt += "Undetermined.";
1820 break;
1821 case 2: prompt += "Uncertain, could not tell.";
1822 break;
1823 case 3: prompt += "Yes, it happend.";
1824 break;
1825 case 4: prompt += "No, it didn't happen.";
1826 break;
1827 default: err_mes = "Investigator::m_Happen has an unrecognized value.";
1828 this->ErrorMessage(err_mes);
1829 }
1830
1831 prompt += "\n";
1832 prompt += "KE: ";
1833 prompt += this->GetKEandTimeRangeWords();
1834 prompt += "\n";
1835 prompt += "Statement: ";
1836 if (this->m_Statement_pt != NULL) {
1837 prompt += this->m_Statement_pt->GetThisStatementWords();
1838 } else {
1839 prompt += "NONE";
1840 }
1841 this->PrintMessage(prompt);
1842
1845 //initiate the feedback list
1846 vector<IDElement *>::iterator ID_itr;
1847 for (ID_itr = this->m_downstream_ID_list.begin(); ID_itr != this->m_downstream_ID_list.end(); ID_itr++) {
1848 this->m_feedback_list.push_back(*ID_itr);
1849 }
1850 RM_pt->AddToRMFeedbackStack((IDElement *) this);
1851}
1852
1854 string str;
1855 stringstream conv;
1856
1857 string prompt;
1858 ReasonMachine *RM_pt;
1859 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
1860 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
1861 else {}//add error message
1862
1863 if (this->m_ID == "Investigator_21") { this->PrintMessage(""); }
1864 if (this->m_invest_dormant == true) {
1865 this->m_invest_dormant = false;
1866 this->m_investigation_initiate_time = r5pars_.timesno;
1867 }
1868
1869 if (this->m_invest_pause == true) {
1870 this->m_invest_pause = false;
1871 }
1872
1873 this->m_last_active_time = r5pars_.timesno;
1874 if (this->m_investigation_closed == true) {
1876 if (RM_pt->m_feedback_stack.size() > 0 && this->m_Happen
1877 == 3) { this->InitiateBackwardPropagationOfConfidence(); }// think about this //no need for the HAMLET_B style
1878 this->CloseThisInvestigator();
1879 RM_pt->m_RM_Token = rm::Prioritize;
1880 return;
1881 }
1882 this->m_investigation_closed = false;
1884
1885 }
1886
1888 if (this->m_Statement_pt
1891 }
1892
1893 switch (this->m_investigator_token) {
1895 //leads to 3012 or 3090
1896 this->GetCorrespondingKE3001();
1897 break;
1899 //Use available statements to check the KE
1900 //leads to 3003 or 3007
1902 break;
1904 //check Mental Representation
1905 //leds to 3004 or 3007
1907 break;
1909 break;
1911 break;
1913 break;
1915 break;
1917 //to be modified
1919 break;
1921 break;
1923 break;
1925 break;
1927 break;
1928 default: RM_pt->ChangeRMTokenValue(rm::Prioritize);
1929 prompt = "\n\n";
1930 prompt = this->TranslateTokenIntoWords(this->m_investigator_token);
1931 this->PrintMessage(prompt);
1932 this->CloseThisInvestigator();
1933 conv.str("");
1934 conv << r5pars_.timesno;
1935 str = conv.str();
1936 str += ": transfer out: to prioritization";
1937 this->m_note_list.push_back(str);
1938 //error message
1939 break;
1940 }
1941}
1942
1944 //caution: if both the m_effective_start and m_effective_end are 0, consider it has not been initialized yet
1945//3004
1946 //1, whether this information is available on the control panel?
1947 //->the subject of the sentence is on the MR
1948 //->find a MR, is there a corresponding indicator name?
1949 string prompt, err_mes;
1950
1951 IDElement *ID_subject_pt;
1952 IDElement *ID_pt;
1953 KnowledgeElement *KE_pt;
1954 ReasonMachine *RM_pt;
1955 bool on_CP_bl;
1956 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
1957 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
1958 else {}//add error message
1959
1960 if (this->m_KElement_ID_pt == NULL) {//error message
1961 err_mes = "This is an empty investigator!";
1962 this->ErrorMessage(err_mes);
1963 return;
1964 }
1965 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
1966 ID_subject_pt = KE_pt->m_SentenceUnit_pt->m_subject_pt;
1967 ID_pt = RM_pt->m_MR->CheckExistenceByConceptStrict(ID_subject_pt);
1968 if (ID_pt == NULL) {
1969 //output text
1970 prompt = "\n\n";
1971 prompt = "There is no item on control panel that matches the subject for this knowledge element";
1972 this->PrintMessage(prompt);
1973 //
1976 return;
1977 }
1978 on_CP_bl = false;
1979
1980 switch (KE_pt->m_SentenceUnit_pt->m_sentence_type) {
1981 //Sentence type 1:
1982 //xxx increase, xxx decrease, xxx stable, xxx turn_on, xxx turn_off, xxx open_bigger, xxx close_smaller
1983 case 1:
1984 if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getIncreasePt()) { on_CP_bl = true; }
1985 else if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getDecreasePt()) { on_CP_bl = true; }
1986 else if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getStablePt()) { on_CP_bl = true; }
1987 else if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getTurnOnPt()) { on_CP_bl = true; }
1988 else if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getTurnOffPt()) { on_CP_bl = true; }
1989 else if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getOpenBiggerPt()) { on_CP_bl = true; }
1990 else if (KE_pt->m_SentenceUnit_pt->m_process_pt == RM_pt->m_Concept_Base->getCloseSmallerPt()) {
1991 on_CP_bl = true;
1992 }
1993 break;
1994 //Sentence type 2:
1995 //xxx is on, xxx is off
1996 case 2:
1997 if (KE_pt->m_SentenceUnit_pt->m_state_pt == RM_pt->m_Concept_Base->getONpt()) { on_CP_bl = true; }
1998 else if (KE_pt->m_SentenceUnit_pt->m_state_pt == RM_pt->m_Concept_Base->getOFFpt()) { on_CP_bl = true; }
1999 break;
2000 //Sentence type 3:
2001 //xxx > value, xxx < value
2002 case 3: on_CP_bl = true;
2003 break;
2004 //Sentence type 4:
2005 //xxx > yyy, xxx < yyy
2006 case 4: ID_pt = RM_pt->m_MR->CheckExistenceByConceptStrict(KE_pt->m_SentenceUnit_pt->m_object_pt);
2007 if (ID_pt != NULL) { on_CP_bl = true; }
2008 break;
2009 case 5: break;
2010
2011 }
2012 if (on_CP_bl == false) {
2013 //output text
2014 prompt = "\n\n";
2015 prompt +=
2016 "There is no item on control panel that matches the process concept or the object concept for this knowledge element";
2017 this->PrintMessage(prompt);
2018 //
2021 return;
2022 }
2023 //2, if fetch new infor from control panel, whether this infor is within the effective time range?
2024 if (this->m_effective_end
2025 < r5pars_.timesno) {//already past the time to read the information, this could not be verified any more
2026 //output text
2027 prompt = "\n\n";
2028 prompt += "Already passed the timing to read the information, this could not be verified any more!";
2029 this->PrintMessage(prompt);
2030 //
2031 this->m_Happen_incomplete = true;
2032 this->m_Happen = 2;
2035
2036 //initiate the feedback list
2037 vector<IDElement *>::iterator ID_itr;
2038 for (ID_itr = this->m_downstream_ID_list.begin(); ID_itr != this->m_downstream_ID_list.end(); ID_itr++) {
2039 this->m_feedback_list.push_back(*ID_itr);
2040 }
2041 RM_pt->AddToRMFeedbackStack((IDElement *) this);
2042 return;
2043 } else {
2044 //output text
2045 if (this->m_read_requested_bl == 0) {
2046 prompt = "\n\n";
2047 prompt += "It could be verified by getting new reading from control panel.";
2048 this->PrintMessage(prompt);
2049 //
2052 return;
2053 } else {
2055 return;
2056 }
2057 }
2058}
2059
2061 KnowledgeElement *KE_pt;
2062 ReasonMachine *RM_pt;
2063 IDElement *ID_pt;
2064 string prompt, err_mes;
2065 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
2066 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
2067 else {}//add error message
2068 bool not_existing_on_CP = false;
2069
2070 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
2071
2072 switch (KE_pt->m_SentenceUnit_pt->m_sentence_type) {
2073 case 4: ID_pt = (IDElement *) (RM_pt->m_MR->CheckExistenceByConceptStrict(KE_pt->m_SentenceUnit_pt->m_subject_pt));
2074 if (ID_pt == NULL) { not_existing_on_CP = true; }
2075 else {
2076 this->m_read_indication_list.push_back(ID_pt);
2077 }
2078 ID_pt = (IDElement *) (RM_pt->m_MR->CheckExistenceByConceptStrict(KE_pt->m_SentenceUnit_pt->m_object_pt));
2079 if (ID_pt == NULL) { not_existing_on_CP = true; }
2080 else {
2081 this->m_read_indication_list.push_back(ID_pt);
2082 prompt = "want to read the following indications from control panel: ";
2083 prompt += KE_pt->m_SentenceUnit_pt->m_subject_pt->m_ID;
2084 prompt += " , ";
2085 prompt += KE_pt->m_SentenceUnit_pt->m_object_pt->m_ID;
2086 this->PrintMessage(prompt);
2087 }
2088 break;
2089 default: ID_pt = (IDElement *) (RM_pt->m_MR->CheckExistenceByConceptStrict(KE_pt->m_SentenceUnit_pt->m_subject_pt));
2090 if (ID_pt == NULL) { not_existing_on_CP = true; }
2091 else {
2092 this->m_read_indication_list.push_back(ID_pt);
2093 prompt = "want to read the following indications from control panel: ";
2094 prompt += KE_pt->m_SentenceUnit_pt->m_subject_pt->m_ID;
2095 this->PrintMessage(prompt);
2096 }
2097 break;
2098 }
2099 if (not_existing_on_CP == true) {
2100 prompt = "There is no direct reading from control panel. Try to dig more info from upperstreams.";
2101 this->PrintMessage(prompt);
2103 } else {
2105 }
2107}
2108
2110 string str;
2111 stringstream conv;
2112
2113 string err_mes, prompt;
2114 ReasonMachine *RM_pt;
2115 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
2116 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
2117 else {}//add error message
2118
2119 if (this->m_ID == "Investigator_87") { this->PrintMessage(""); }
2120
2121 if (this->m_feedback_list.size() == 0) {
2122 prompt = "\n\n";
2123 prompt += "Finished feedback process.";
2124 this->PrintMessage(prompt);
2125
2127 RM_pt->EraseItemFromFeedbackStack((IDElement *) this);
2128 //if(RM_pt->m_problem_solving_style == VAGABOND)
2130 return;
2131 }
2132 //this is a prioritization process, to be modified.
2133 prompt = "\n\n";
2134 prompt += "feedback and move to a downstream investigator";
2135 this->PrintMessage(prompt);
2136
2137 this->m_invest_pause = true;
2138 RM_pt->m_working_on_invest_link_pt = (InvestigatorLink *) (*(this->m_feedback_list.rbegin()));
2140 this->m_feedback_list.pop_back();
2141 RM_pt->m_investigation_trace.push_back((IDElement *) this);
2142 RM_pt->ChangeRMTokenValue(rm::WorkOnInvestigatorLink); //jump out of this investigator
2143
2144 conv.str("");
2145 conv << r5pars_.timesno;
2146 str = conv.str();
2147 str += ": transfer out: to ";
2148 str += RM_pt->m_working_on_invest_link_pt->m_ID;
2149 this->m_note_list.push_back(str);
2150}
2151
2153 string prompt, err_mes;
2154 ReasonMachine *RM_pt;
2155 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
2156 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
2157 else {}//add error message
2158
2159 if (this->m_ID == "Investigator_68") { this->PrintMessage(""); }
2160
2161 int next_token_value;
2162 bool continue_investigation = false;
2163 prompt = "\n\n";
2164 switch (this->m_Happen) {
2165 case 1:
2166 //error message, should not be 1
2167 break;
2168 case 2:
2169 //can not determine whether it's happened
2170 if (RM_pt->m_problem_solving_style == ProblemSolvingStyle::HamletB && this->m_upperstream_ID_list.size() > 0) {
2172 next_token_value = inv::RetrieveNextLink;
2173 this->ChangeInvestigatorToken(next_token_value);
2174 } else {
2175 prompt += "could not determine whether the KE happened or not, close this investigator.";
2176 this->PrintMessage(prompt);
2177 next_token_value = inv::Undetermined;
2178 this->ChangeInvestigatorToken(next_token_value);
2179 this->CloseThisInvestigator();
2180 //this->AddTimeConsumptionInInvestigator(0.1)
2181 RM_pt->m_undetermined_investigator_pool.push_back(this);
2182 //could not determine whether the phenomenon specified in the KE happened or not
2183 //close this investigator;
2184 }
2185 break;
2186 case 3:
2187 if (this->m_explained == 1) {
2188 next_token_value = inv::SearchPossibleCauses;
2189 this->ChangeInvestigatorToken(next_token_value);
2190 } else if (this->m_explained == 3) {
2191 continue_investigation = this->WhetherContinueInvestigationAfterFoundExplanation();
2192 if (continue_investigation == true) {
2194 prompt += "continue the investigation eventhough there is one cause found";
2195 this->PrintMessage(prompt);
2196 next_token_value = inv::RetrieveNextLink;
2197 this->ChangeInvestigatorToken(next_token_value);
2198 } else {
2199 prompt += "Found the cause and close this investigator";
2200 this->PrintMessage(prompt);
2201 next_token_value = inv::CauseFound;
2202 this->ChangeInvestigatorToken(next_token_value);
2203 if (this->m_Happen_incomplete == false
2204 && this->m_Explain_incomplete == false) { RM_pt->m_resolved_investigator_pool.push_back(this); }
2205 this->CloseThisInvestigator();
2206 RM_pt->m_success_investigator_pool.push_back(this);
2207 RM_pt->m_resolved_investigator_pool.push_back(this);
2208 RM_pt->m_RM_Token = rm::Prioritize;
2209 this->InitiateBackwardPropagationOfConfidence(); // this is for GARDEN_PATH, VAGABOND, and NEUTRAL, but not for HAMLET
2210 }
2211 } else if (this->m_explained == 2) {
2213 prompt += "Close this investigator because the cause could not be determined";
2214 this->PrintMessage(prompt);
2215 next_token_value = inv::CauseUndetermined;
2216 this->ChangeInvestigatorToken(next_token_value);
2217 this->CloseThisInvestigator();
2218 if (this->m_Happen_incomplete == false
2219 && this->m_Explain_incomplete == false) { RM_pt->m_resolved_investigator_pool.push_back(this); }
2220 RM_pt->m_cause_undetermined_investigato_pool.push_back(this);
2221 RM_pt->m_resolved_investigator_pool.push_back(this);
2222 RM_pt->m_RM_Token = rm::Prioritize;
2223 } else if (this->m_explained == 4) {
2225 prompt += "close this investigator because the agent failed to expain the statement.";
2226 this->PrintMessage(prompt);
2227 next_token_value = inv::FailedToExplain;
2228 this->ChangeInvestigatorToken(next_token_value);
2229 this->CloseThisInvestigator();
2230 RM_pt->m_failed_investigator_pool.push_back(this);
2231 RM_pt->m_RM_Token = rm::Prioritize;
2232 }
2233 break;
2234 case 4:
2235 if (this->m_SI_ID_pt == NULL) {
2237 prompt += "close this investigator because the KE didn't happen";
2238 this->PrintMessage(prompt);
2239 next_token_value = inv::SuccessNotHappened;
2240 this->ChangeInvestigatorToken(next_token_value);
2241 this->CloseThisInvestigator();
2242 RM_pt->m_success_investigator_pool.push_back(this);
2243 RM_pt->m_RM_Token = rm::Prioritize;
2244 } else {
2245 next_token_value = inv::SearchPossibleCauses;
2246 this->ChangeInvestigatorToken(next_token_value);
2247 }
2248 break;
2249 default:
2250 //error message;
2251 this->ChangeInvestigatorToken(next_token_value);
2252 break;
2253 }
2254
2255 //jump out of this investigator
2257 RM_pt->m_investigation_trace.push_back((IDElement *) this);
2259 }
2260}
2261
2263 //to be modified
2264 //retrieve threshold, PSF slot
2265 //the current version is very simple, it calculates score for each unfinished investigatorlink
2266 //and get the one with the highest score
2267 string str;
2268 stringstream conv;
2269
2270 string prompt, err_mes;
2271 SymptomInvestigator *SI_pt;
2272 ReasonMachine *RM_pt;
2273 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
2274 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
2275 else {}//add error message
2276
2277 if (this->m_ID == "Investigator_41") { this->PrintMessage("check point!"); }
2278
2279 vector<IDElement *>::iterator ID_itr;
2280 double highest_score = 0;
2281 double score;
2282 bool prior_inference_link = false;
2283 bool replace_with_new = false;
2284 InvestigatorLink *invest_link_pt;
2285 InvestigatorLink *next_invest_link_pt = NULL;
2286 float delta_T;
2287
2288 if (this->m_timer > 0) {
2289 delta_T = RM_pt->CheckRemainingTimeForThisStep();
2290 if (delta_T >= this->m_timer) {
2291 RM_pt->AddConsumptedDeltaT(this->m_timer);
2292 this->m_timer = 0;
2293
2294 //
2295 prompt = "\n\n";
2296 prompt += "Retrieved one possible cause: ";
2297 prompt += ((InvestigatorLink *) this->m_has_moved_to_link)->GetASimpleDescriptionOfTheInvestigatorLink();
2298 this->PrintMessage(prompt);
2299
2300 conv.str("");
2301 conv << r5pars_.timesno;
2302 str = conv.str();
2303 str += "transfer out: to ";
2304 str += this->m_has_moved_to_link->m_ID;
2305 this->m_note_list.push_back(str);
2306
2307 RM_pt->m_investigation_trace.push_back((IDElement *) this);
2309
2310 if (RM_pt->m_problem_solving_style
2313
2314 ((InvestigatorLink *) this->m_has_moved_to_link)->m_invest_link_dormant = false;
2315 ((InvestigatorLink *) this->m_has_moved_to_link)->CrankTheNextLikelyRetrievedInvestigatorActivationToOne();
2316
2318 this->m_invest_pause = true;
2319 } else {
2320 this->m_timer -= delta_T;
2321 RM_pt->AddConsumptedDeltaT(delta_T);
2322 }
2323 return;
2324 }
2325
2327 RM_pt->m_event_schema_base->UpdateTheInterestForInvestigatorOrInvestigatorLink();
2328 RM_pt->AddDeltaToCognitiveLoad(0.24);
2329
2330 if (this->m_Happen == 1 || this->m_Happen == 2) { prior_inference_link = true; }
2331
2332 if (this->m_SI_ID_pt != NULL) {
2333 SI_pt = (SymptomInvestigator *) (this->m_SI_ID_pt);
2334 }
2335
2336 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
2337 invest_link_pt = (InvestigatorLink *) (*ID_itr);
2338
2339 if ((this->m_SI_ID_pt != NULL && this->m_Happen == 4) || (this->m_SI_ID_pt != NULL
2340 && this->m_downstream_ID_list.size() > 0)) {//it is forced to invesigate why a symptom not happen.
2341 if (SI_pt->CheckAKnowledgeUnitInTheList(invest_link_pt->m_K_unit_pt) != NULL) {
2342 invest_link_pt->m_SI_ID_pt = this->m_SI_ID_pt;
2343 this->m_has_moved_to_an_upperstream = true;
2344 if (invest_link_pt->m_path_status == 1) {
2345 next_invest_link_pt = invest_link_pt;
2346 next_invest_link_pt->m_SI_ID_pt = this->m_SI_ID_pt;
2347 next_invest_link_pt->m_invest_link_dormant = false;
2348 highest_score = invest_link_pt->CalculateBackwardRetrievalScore();
2349 break;
2350 }
2351 }
2352 }
2353
2354 //this is the normal investigation path
2355 if (invest_link_pt->m_path_status == 1) {
2356 replace_with_new = false;
2357 score = invest_link_pt->CalculateBackwardRetrievalScore();
2358 cout << '\n' << "retrieval score" << score;
2359 if (next_invest_link_pt == NULL) {
2360 replace_with_new = true;
2361 } else if ((invest_link_pt->m_is_inference_path_bl == next_invest_link_pt->m_is_inference_path_bl
2362 && prior_inference_link == true)
2363 || (invest_link_pt->m_is_causal_path_bl == next_invest_link_pt->m_is_causal_path_bl
2364 && prior_inference_link == false)) {
2365 if (score > highest_score) { replace_with_new = true; }
2366 } else {//one is causal link and one is inference link; prioritize inference link or causal link as required
2367 if (prior_inference_link == true && invest_link_pt->m_is_inference_path_bl == true
2368 && next_invest_link_pt->m_is_inference_path_bl == false) { replace_with_new = true; }
2369
2370 if (prior_inference_link == false && invest_link_pt->m_is_causal_path_bl == true
2371 && next_invest_link_pt->m_is_causal_path_bl == false) { replace_with_new = true; }
2372 }
2373
2374 if (replace_with_new == true) {
2375 highest_score = score;
2376 next_invest_link_pt = invest_link_pt;
2377 }
2378
2379 /*if(score > highest_score)
2380 {
2381 highest_score = score;
2382 next_invest_link_pt = invest_link_pt;
2383 }*/
2384 }
2385 }
2386 if (next_invest_link_pt == NULL) {//each possible explanation has already been explored
2387 //transfer to evaluation part: 3014
2388 prompt = "\n\n";
2389 prompt += "Every possible cause has already been investigated.";
2390 //
2391 this->PrintMessage(prompt);
2393 //time consumption
2395 } else {
2396 this->m_timer = min<float>(pow(1 / highest_score, 0.2), 5);
2397 this->m_has_moved_to_link = (IDElement *) next_invest_link_pt;
2398 }
2399}
2400
2401//DEL void Investigator::WhetherContinueThisInvestigation3016()
2402//DEL {//There is at least one explanation available
2403//DEL //PSF slot
2404//DEL //to be added
2405//DEL
2406//DEL }
2407
2409
2410}
2411
2413
2414}
2415
2416void Investigator::UpdateEffectiveEndTimeRangeFromStatement(double _endTime, bool _ongoing) {//to be added
2417 //this is one action that might propagate to other investigatorlinks/investigators without changing token value
2418 this->m_effective_end = _endTime;
2419 this->m_phenomenon_onging = _ongoing;
2420 this->UpdateEffectiveEndTimeRangeToUpperstream(_endTime, _ongoing);
2421}
2422
2424 this->m_effective_end = _endTime;
2425 this->m_phenomenon_onging = _ongoing;
2426 this->UpdateEffectiveEndTimeRangeToUpperstream(_endTime, _ongoing);
2427}
2428
2430 Investigator *invest_pt;
2431 InvestigatorLink *invest_link_pt;
2432 double time_end_update;
2433 vector<IDElement *>::iterator ID_itr;
2434 vector<IDElement *>::iterator ID_itr2;
2435 //to be modified, need to calculate the endtime using the input and the knowledge
2436 if (this->m_upperstream_ID_list.size() == 0) {
2437 return;
2438 }
2439 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
2440 invest_link_pt = (InvestigatorLink *) (*ID_itr);
2441 time_end_update = _endTime - invest_link_pt->m_K_unit_pt->m_deltaT1;
2442 if (invest_link_pt->m_condition_ID_pt != NULL) {
2443 invest_pt = (Investigator *) (invest_link_pt->m_condition_ID_pt);
2444 invest_pt->UpdateEffectiveEndTimeRangeFromDownstream(time_end_update, _ongoing);
2445 /*if(_ongoing = true && invest_pt->m_investigator_token == inv::ChooseDownstreamLink)
2446 {
2447 //active this investigator again
2448 invest_pt->m_investigator_token = inv::RequestInfoInit;
2449 }*/
2450 }
2451 if (r5pars_.timesno > 2640) { this->PrintMessage(""); }
2452 for (ID_itr2 = invest_link_pt->m_upperstream_ID_list.begin();
2453 ID_itr2 != invest_link_pt->m_upperstream_ID_list.end(); ID_itr2++) {
2454 invest_pt = (Investigator *) (*ID_itr2);
2455 invest_pt->UpdateEffectiveEndTimeRangeFromDownstream(time_end_update, _ongoing);
2456 }
2457 }
2458}
2459
2461
2462 MRParameterUnit *MR_P_pt;
2463 MRComponentStateUnit *MR_C_pt;
2464 MRSupportSystemStateUnit *MR_SS_pt;
2465 MRAlarmUnit *MR_A_pt;
2466
2467 string prompt, err_mes;
2468 ReasonMachine *RM_pt;
2469 IDElement *ID_pt;
2470 int operator_branch_num = 0;
2471
2472 if (this->m_operator == sim::Operator::ODM) {
2473 RM_pt = g_sim.Decision_Maker.m_RM.get();
2474 operator_branch_num = g_sim.Branch_center.getNumOfODMBranch();
2475 } else if (this->m_operator == sim::Operator::OAT) {
2476 RM_pt = g_sim.Action_Taker.m_RM.get();
2477 operator_branch_num = g_sim.Branch_center.getNumOfOATBranch();
2478 } else {}//add error message
2479
2480 if (operator_branch_num > 0) {
2482 return;
2483 }
2484
2485 //RM_pt->m_reading_indication_ID_pt = NULL;
2486 if (RM_pt->m_reading_indication_ID_pt != NULL) {
2487 //to be modified, add time consumption
2488 //the operator is stilling reading the indication
2489 RM_pt->m_consumed_time = RM_pt->m_time_length;
2490 } else
2491 //the operator finished the last indication reading
2492 {
2493 if (this->m_read_indication_list.size() == 0) {
2494 this->m_read_requested_bl = 1;
2495 //if(this->m_Statement_pt != NULL)
2496 //{//output txt
2497 prompt = "finished reading relevant indications";
2498 this->PrintMessage(prompt);
2499
2500 //to be modified
2503 return;
2504 //}
2505 /*else
2506 {
2507 prompt = "Compare the new reading with the KE";
2508 this->PrintMessage(prompt);
2509 this->ChangeInvestigatorToken(inv::CheckAvailableFromMR);
2510 return;
2511 }*/
2512
2513 } //need to verify the vector::rbegin()
2514 else {
2515 ID_pt = *(this->m_read_indication_list.rbegin());
2516 RM_pt->m_reading_indication_ID_pt = ID_pt;
2517 //output text
2518 prompt = "send request to read: ";
2519 if (r5pars_.timesno > 2128) { this->PrintMessage(""); }
2520 switch (ID_pt->m_ID_Type) {
2521 case 201: MR_P_pt = (MRParameterUnit *) ID_pt;
2522 if (this->m_read_value_or_rate_bl == 0
2523 && MR_P_pt->FoundAValueReadingWithinTimeRange(max<double>(this->m_effective_start, r5pars_.timesno - 5),
2524 this->m_effective_end) != NULL) {
2525 this->m_read_indication_list.pop_back();
2526 RM_pt->m_reading_indication_ID_pt = NULL;
2527 break;
2528 }
2529 if (this->m_read_value_or_rate_bl == 0) {//read parameter firstly
2530 MR_P_pt->ReadParameterValue(1);
2531 this->m_read_value_or_rate_bl = 1;
2532 prompt += MR_P_pt->m_parameter_indicator_ID;
2533 } else {//read rate secondly
2534 if (MR_P_pt->m_parameter_rate_indicator_ID.compare("NONE") != 0) { MR_P_pt->ReadParameterRate(1); }
2535 else { RM_pt->m_reading_indication_ID_pt = NULL; }
2536 this->m_read_value_or_rate_bl = 0;
2537 prompt += MR_P_pt->m_parameter_rate_indicator_ID;
2538 this->m_read_indication_list.pop_back();
2539 }
2540 break;
2541 case 202: MR_C_pt = (MRComponentStateUnit *) ID_pt;
2542 MR_C_pt->ReadComponentStateIndication(1);
2543 if (MR_C_pt->m_CS_type == 0) { prompt += MR_C_pt->Component_State_Indicator_ID; }
2544 else { prompt += MR_C_pt->Control_Value_Indicator_ID; }
2545 this->m_read_indication_list.pop_back();
2546 break;
2547 case 203: MR_A_pt = (MRAlarmUnit *) ID_pt;
2548 MR_A_pt->ReadAlarmIndication(1);
2549 prompt += MR_A_pt->m_alarm_indicator_name;
2550 this->m_read_indication_list.pop_back();
2551 break;
2552 case 204: MR_SS_pt = (MRSupportSystemStateUnit *) ID_pt;
2554 prompt += MR_SS_pt->Support_System_State_Indicator_ID;
2555 this->m_read_indication_list.pop_back();
2556 break;
2557 default:
2558 //error message
2559 break;
2560 }
2561 this->PrintMessage(prompt);
2563 }
2564 }
2565}
2566
2568 this->m_investigation_closed = true;
2569 ReasonMachine *RM_pt;
2570 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
2571 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
2572 else {}//add error message
2573 if (this->m_ID == "Investigator_378") { this->PrintMessage(""); }
2574 bool finished = false;
2575 this->m_investigation_cease_time = r5pars_.timesno;
2577 RM_pt->EraseFromOngoingItemStack(this->m_ID);
2579 }
2581}
2582
2584 double activation;
2585 KnowledgeElement *KE_pt;
2586 if (this->m_Statement_pt != NULL) {
2587 activation = this->m_Statement_pt->m_sent_pt->m_activation;
2588 } else if (this->m_KElement_ID_pt != NULL) {
2589 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
2590 activation = KE_pt->m_SentenceUnit_pt->m_activation;
2591 } else {}//error message, this investigator has neither the Statement nor the KnowledgeElement
2592 return activation;
2593}
2594
2596 //two options, 1, holistic evaluation; 2, only evaluate the new feedback
2597 //to be modified, add confidence level to the explanation
2598 string str;
2599 stringstream conv;
2600
2601 string prompt, err_mes;
2602 ReasonMachine *RM_pt;
2603 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
2604 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
2605 else {}//add error message
2606
2607 if (this->m_ID == "Investigator_1") { this->PrintMessage(""); }
2608
2609 //check point
2610 if (this->m_KElement_ID_pt->m_ID == "KE_MSLB_true") {
2611 this->PrintMessage("check point");
2612 }
2613 if (this->m_KElement_ID_pt->m_ID == "KE_load_increase") {
2614 this->PrintMessage("check point");
2615 }
2616 if (this->m_investigator_token_history.size() > 12) {
2617 this->PrintMessage("Check point");
2618 }
2619
2620 if (this->m_ID == "Investigator_25") {
2621 this->PrintMessage("Check point");
2622 }
2623
2624 if (this->m_ID == "Investigator_87" && r5pars_.timesno > 1031) {
2625 this->PrintMessage("Check point");
2626 }
2627 //
2628
2629 bool explained = false;
2630 bool unexplored_cause_exist = false;
2631 bool undetermined_cause_exist = false;
2632 bool need_to_feedback = false;
2633
2634 bool inference_exist = false;
2635 bool undetermined_inference_exist = false;
2636 bool unexplored_inference_exist = false;
2637 bool consistant_bl = false;
2638
2639 int i = 1;
2640 int Happen_buffer = 1;
2641 Statement *statement_pt;
2642 KnowledgeElement *KE_pt;
2643
2644 InvestigatorLink *invest_link_pt;
2645 vector<IDElement *>::iterator ID_itr;
2646 prompt = "\n\n Evaluation Process: \n";
2647
2648 //
2649 if (this->m_ID == "Investigator_630" && r5pars_.timesno > 3196) {
2650 this->PrintMessage("Check point!");
2651 }
2652 //
2653
2654 if (this->m_upperstream_ID_list.size() == 0) {
2655 this->m_explained = 2;
2656 RM_pt->AddDeltaToCognitiveLoad(0.024); //type 6
2657 if (this->m_Happen == 1) {
2658 this->m_Happen = 2;
2659 need_to_feedback = true;
2660 prompt += this->m_KElement_ID_pt->m_ID;
2661 prompt += " might happen, but could not be determined!";
2662 this->PrintMessage(prompt);
2663 } else {
2665 this->CloseThisInvestigator();
2666 RM_pt->m_cause_undetermined_investigato_pool.push_back(this);
2667 RM_pt->m_resolved_investigator_pool.push_back(this);
2669 RM_pt->m_investigation_trace.push_back((IDElement *) this);
2670
2671 conv.str("");
2672 conv << r5pars_.timesno;
2673 str = conv.str();
2674 str += ": transfer out: to prioritization";
2675 this->m_note_list.push_back(str);
2676 }
2677 } else {
2678 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
2679 conv.str("");
2680 conv << i;
2681 prompt += "Cause ";
2682 prompt += conv.str();
2683
2684 invest_link_pt = (InvestigatorLink *) (*ID_itr);
2685 //check the inference pathes
2686 if (invest_link_pt->m_is_inference_path_bl == true && (this->m_Happen == 1 || this->m_Happen == 2)) {
2687 inference_exist = true;
2688 if (invest_link_pt->m_path_status != 1) {
2689 if ((invest_link_pt->m_inference_direction_reverse_bl == false
2690 && (invest_link_pt->m_K_unit_pt->m_inference_type == 1
2691 || invest_link_pt->m_K_unit_pt->m_inference_type == 3))
2692 || (invest_link_pt->m_inference_direction_reverse_bl == true
2693 && (invest_link_pt->m_K_unit_pt->m_inference_type == 2
2694 || invest_link_pt->m_K_unit_pt->m_inference_type == 3))) {
2695 switch (invest_link_pt->m_path_status) {
2696 case 2: undetermined_inference_exist = true;
2697 break;
2698 case 3: Happen_buffer = 3;
2699 break;
2700 }
2701 }
2702 } else {
2703 unexplored_inference_exist = true;
2704 }
2705 }
2706 //New codes
2707 if (this->m_Happen == 1 && this->m_Statement_pt != NULL) {
2709 if (consistant_bl == true) { Happen_buffer = 3; }
2710 }
2711
2712 //check the causal path
2713 if (invest_link_pt->m_is_causal_path_bl == true) {
2714 prompt += invest_link_pt->GetASimpleDescriptionOfTheInvestigatorLink();
2715 prompt += " , ";
2716 switch (invest_link_pt->m_path_status) {
2717 case 1: prompt += "unexplored; \n";
2718 unexplored_cause_exist = true;
2719 break;
2720 case 2: prompt += "could not determined; \n";
2721 undetermined_cause_exist = true;
2722 if (this->CheckExistenceInPossibleExplanationList((IDElement *) invest_link_pt) == NULL) {
2723 this->m_possible_explanation_link_list.push_back((IDElement *) invest_link_pt);
2724 }
2725 break;
2726 case 3: prompt += "happened; \n";
2727 explained = true;
2728 if (this->CheckExistenceInExplanationList((IDElement *) invest_link_pt) == NULL) {
2729 this->m_explanation_link_list.push_back((IDElement *) invest_link_pt);
2730 }
2731 break;
2732 case 4: prompt += "didn't happen;\n";
2733 if (this->CheckExistenceInRejectedExplanationList((IDElement *) invest_link_pt) == NULL) {
2734 this->m_rejected_explanation_list.push_back((IDElement *) invest_link_pt);
2735 }
2736 break;
2737 default:
2738 //error message
2739 break;
2740 }
2741 }
2742 }
2743
2744 //forced investigation
2745 if ((this->m_downstream_ID_list.size() == 0 && this->m_Happen == 4 && this->m_SI_ID_pt != NULL)
2746 || (this->m_SI_ID_pt != NULL && this->m_downstream_ID_list.size() > 0)) {
2747 if (this->m_has_moved_to_an_upperstream == true) {//finished the tbi upperstream, then close this investigator
2748 //caution here: it is possible that the tbi uppersteam is not
2749 if (this->m_Happen == 1) {
2750 this->m_Happen = 2;
2751 }
2752 if (this->m_Happen == 4) {
2754 this->CloseThisInvestigator();
2755 RM_pt->m_success_investigator_pool.push_back(this);
2757 conv.str("");
2758 conv << r5pars_.timesno;
2759 str = conv.str();
2760 str += ": transfer out: to prioritization";
2761 this->m_note_list.push_back(str);
2762 return;
2763 }
2764 }
2765 //else
2766 //{
2767 // this->ChangeInvestigatorToken(inv::RetrieveNextLink);
2768 // RM_pt->ChangeRMTokenValue(rm::Prioritize);
2769 //}
2770 //return;
2771 }
2772
2773
2774 //finished the iteration of all the upperstreams
2775 //check inference
2776 if (this->m_Happen == 1 || this->m_Happen == 2 || Happen_buffer != 1) {
2777 if (Happen_buffer == 3) {
2778 this->m_Happen = 3;
2779 auto stmt_owned = make_unique<Statement>();
2780 statement_pt = stmt_owned.get();
2781 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
2782 statement_pt->m_sent_pt = KE_pt->m_SentenceUnit_pt;
2783 statement_pt->m_state = !(KE_pt->m_negation);
2784 statement_pt->m_time_range.m_time_after = this->m_effective_start;
2785 statement_pt->m_time_range.m_time_before = this->m_effective_end;
2786 statement_pt->m_time_generated = r5pars_.timesno;
2787 statement_pt->m_activation = 1;
2788 statement_pt->m_factual_type = 2;
2789 //caution: need to think more about the confidence
2790 statement_pt->m_confidence = 1;
2791 statement_pt->m_last_activated_time = r5pars_.timesno;
2792 this->m_Statement_pt = statement_pt;
2793 RM_pt->AddDeltaToCognitiveLoad(0.024);
2794 RM_pt->AddANewStatement(stmt_owned.release());
2795 need_to_feedback = true;
2796 } else if (unexplored_inference_exist == false && inference_exist == true) {
2797 if (undetermined_inference_exist == true) {
2798 this->m_Happen = 2;
2799 need_to_feedback = true;
2800 } else {
2801 this->m_Happen = 4;
2802 need_to_feedback = true;
2803 }
2804 }
2805 }
2806
2807 //check causal path
2808 prompt += "Conclusion: \n";
2809 if (unexplored_inference_exist == true && (this->m_Happen == 1 || this->m_Happen == 2)) {
2811 /*RM_pt->ChangeRMTokenValue(rm::Prioritize);
2812 RM_pt->m_investigation_trace.push_back((IDElement*)this);
2813 conv.str("");
2814 conv << r5pars_.timesno;
2815 str = conv.str();
2816 str += ": transfer out: to prioritization";
2817 this->m_note_list.push_back(str);*/
2818 } else if (explained == true) {
2819 prompt += "This investigator is explained. \n";
2820 this->PrintMessage(prompt);
2821 this->m_explained = 3;
2822 RM_pt->AddDeltaToCognitiveLoad(0.024); //type 6
2823 if ((this->m_Happen == 1 || this->m_Happen == 2) && inference_exist == false) {
2824 this->m_Happen = 3;
2825 auto stmt_owned = make_unique<Statement>();
2826 statement_pt = stmt_owned.get();
2827 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
2828 statement_pt->m_sent_pt = KE_pt->m_SentenceUnit_pt;
2829 statement_pt->m_state = !(KE_pt->m_negation);
2830 statement_pt->m_time_range.m_time_after = this->m_effective_start;
2831 statement_pt->m_time_range.m_time_before = this->m_effective_end;
2832 statement_pt->m_time_generated = r5pars_.timesno;
2833 statement_pt->m_activation = 1;
2834 statement_pt->m_factual_type = 3; // it is inferred from a happened upperstream
2835 //caution: need to think more about the confidence
2836 statement_pt->m_confidence = 0.7;
2837 statement_pt->m_last_activated_time = r5pars_.timesno;
2838 this->m_Statement_pt = statement_pt;
2839 RM_pt->AddDeltaToCognitiveLoad(0.024);
2840 RM_pt->AddANewStatement(stmt_owned.release());
2841 need_to_feedback = true;
2842 //add feedback to the downstream
2843 } else {
2845 }
2846 } else if (unexplored_cause_exist == true) {
2847 if (this->m_Happen != 4) {
2848 prompt += "This investigator has not been explained yet. \n";
2849 this->PrintMessage(prompt);
2853 RM_pt->m_investigation_trace.push_back((IDElement *) this);
2854
2855 conv.str("");
2856 conv << r5pars_.timesno;
2857 str = conv.str();
2858 str += ": transfer out: to prioritization";
2859 this->m_note_list.push_back(str);
2860 }
2861 } else {
2863 }
2864 } else if (undetermined_cause_exist == true) {
2865 prompt += "This investigator has uncertain cause(s)!";
2866 this->PrintMessage(prompt);
2867 this->m_explained = 2;
2868 RM_pt->AddDeltaToCognitiveLoad(0.024); //type 6
2869 if (this->m_Happen == 1) {
2870 this->m_Happen = 2;
2871 need_to_feedback = true;
2872 //add feedback to the downstream;
2873 } else {
2875 this->CloseThisInvestigator();
2876 if (this->m_Happen_incomplete == false
2877 && this->m_Explain_incomplete == false) { RM_pt->m_resolved_investigator_pool.push_back(this); }
2878 RM_pt->m_cause_undetermined_investigato_pool.push_back(this);
2880 RM_pt->m_investigation_trace.push_back((IDElement *) this);
2881
2882 conv.str("");
2883 conv << r5pars_.timesno;
2884 str = conv.str();
2885 str += ": transfer out: to prioritization";
2886 this->m_note_list.push_back(str);
2887 }
2888 } else {//at this point, already examined every possible explanation, and all of them failed
2889 prompt += "This investigator failed to get an explanation. \n";
2890 this->PrintMessage(prompt);
2891 this->m_explained = 4;
2892 RM_pt->AddDeltaToCognitiveLoad(0.024); //type 6
2893 if (this->m_Happen == 1 && undetermined_inference_exist == false) {
2894 this->m_Happen = 4;
2895 need_to_feedback = true;
2896 //add feedback to the downstream
2897 } else {
2899 this->CloseThisInvestigator();
2900 RM_pt->m_failed_investigator_pool.push_back(this);
2902 RM_pt->m_investigation_trace.push_back((IDElement *) this);
2903
2904 conv.str("");
2905 conv << r5pars_.timesno;
2906 str = conv.str();
2907 str += ": transfer out: to prioritization";
2908 this->m_note_list.push_back(str);
2909 }
2910 }
2911 }
2912
2913 if (need_to_feedback == true) {
2914 prompt = "The KE is newly verified, needs to feedback to the downstream.";
2915 this->PrintMessage(prompt);
2916
2918 //initiate the feedback list
2919 vector<IDElement *>::iterator ID_itr;
2920 for (ID_itr = this->m_downstream_ID_list.begin(); ID_itr != this->m_downstream_ID_list.end(); ID_itr++) {
2921 this->m_feedback_list.push_back(*ID_itr);
2922 }
2923 RM_pt->AddToRMFeedbackStack((IDElement *) this);
2924 return;
2925 }
2926
2927 //Add the proababilistic reasoning process
2928 float p_total = 0;
2929 float score_total = 0;
2930 float confidence = 0;
2931 if (this->m_Happen == 3 && unexplored_cause_exist == false) {
2932
2933 this->InitiateBackwardPropagationOfConfidence(); // All the HAMLET style should go through this
2934 prompt += "Found the cause and close this investigator";
2935 this->PrintMessage(prompt);
2937 if (this->m_Happen_incomplete == false
2938 && this->m_Explain_incomplete == false) { RM_pt->m_resolved_investigator_pool.push_back(this); }
2939 this->CloseThisInvestigator();
2940 RM_pt->m_success_investigator_pool.push_back(this);
2942 }
2943
2946 }
2947 /*
2948 //caution, the probability here is assigned arbitrarily
2949 if(this->m_Statement_pt->m_factual_type == 1 || this->m_Statement_pt->m_factual_type == 2)
2950 {
2951 if(this->m_explanation_link_list.size() > 0)
2952 {p_total = 0.1;}
2953 else
2954 {p_total = 0.8;}
2955 }
2956 else if(this->m_Statement_pt->m_factual_type == 3)
2957 {
2958 p_total = 0.1;
2959 }
2960 for(ID_itr = this->m_possible_explanation_link_list.begin(); ID_itr != this->m_possible_explanation_link_list.end(); ID_itr++)
2961 {
2962 invest_link_pt = (InvestigatorLink*)(*ID_itr);
2963 score_total += invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight;
2964 }
2965 for(ID_itr = this->m_possible_explanation_link_list.begin(); ID_itr != this->m_possible_explanation_link_list.end(); ID_itr++)
2966 {
2967 invest_link_pt = (InvestigatorLink*)(*ID_itr);
2968 confidence = (invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight/score_total)*p_total;
2969 RM_pt->m_buffer_invest_pt = this;
2970 invest_link_pt->BackwardPropagateConfidenceLevel(confidence);
2971 RM_pt->m_buffer_invest_pt = NULL;
2972 }
2973 */
2974
2975}
2976
2978 //to be modified
2979 ReasonMachine *RM_pt;
2980 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
2981 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
2982 else {}//add error message
2983
2984 bool continue_bl = false;
2985 bool stop_bl = false;
2986 bool unexplored_cause_exist = false;
2987 InvestigatorLink *invest_link_pt;
2988 vector<IDElement *>::iterator ID_itr;
2989 double score;
2990 double highest_score = 0;
2991 if (this->m_ID == "Investigator_338") { this->PrintMessage(""); }
2992 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
2993 invest_link_pt = (InvestigatorLink *) (*ID_itr);
2994 if (invest_link_pt->m_path_status == 1) {
2995 unexplored_cause_exist = true;
2996 score = invest_link_pt->CalculateBackwardRetrievalScore();
2997 if (score > highest_score) { highest_score = score; }
2998 }
2999 }
3000 //to be modified, add highest_score, current diagnosis confidence into this decision making.
3001 if (unexplored_cause_exist == false || this->m_explained == 4) {
3002 stop_bl = true;
3003 return false;
3004 }//stop if finishing all
3005
3008 {
3009 continue_bl = true;
3010 return true;
3011 }
3012
3014 continue_bl = false;
3015 return false;
3016 }
3017
3018 //set up the criteria
3019 if (highest_score > 0.006) {
3020 continue_bl = true;
3021 return true;
3022 }
3023 else {
3024 stop_bl = true;
3025 return false;
3026 }
3027}
3028
3030 KnowledgeElement *KE_pt;
3031 if (this->m_KElement_ID_pt != NULL) {
3032 KE_pt = (KnowledgeElement *) this->m_KElement_ID_pt;
3033 return KE_pt->m_SentenceUnit_pt;
3034 } else if (this->m_Statement_pt != NULL) {
3035 return this->m_Statement_pt->m_sent_pt;
3036 } else { return NULL; }//error message
3037}
3038
3040 ReasonMachine *RM_pt;
3041 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
3042 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
3043 else {}//add error message
3044 RM_pt->AddConsumptedDeltaT(_delta);
3045
3046}
3047
3049 //to be added
3050 float score = 0;
3051 if (this->m_invest_dormant == true || this->m_invest_pause == true) {
3052 return 0;
3053 }
3055 return score;
3056}
3057
3059 //to be added
3060 float s1, s2, s3, score;
3061 float deltaT;
3062 if (this->m_ID == "Investigator_308") { this->PrintMessage(""); }
3063 deltaT = r5pars_.timesno - this->m_investigation_initiate_time;
3064 s1 = 0.5 * (1 - exp(-deltaT / 300)) + 0.5;
3065 s2 = this->GetActivation();
3066 s3 = 0.5 + 0.5 * this->DetermineWhetherItsStillActivePhenomenon();
3067 score = s1 * s2 * s3;
3068 if (this->m_explained != 1)//if the explanation is already determined
3069 {
3070 score *= 0.5;
3071 }
3072 //
3073 score += 20 * this->m_interest_from_SymptomInvestigator;
3074 return score;
3075}
3076
3078 //to be modified
3079 if (this->m_phenomenon_onging == true) {
3080 return 1;
3081 } else {
3082 return 0;
3083 }
3084
3085}
3086
3088 string prompt;
3089 int old_token;
3090 old_token = this->m_investigator_token;
3092 this->m_invest_token_endtime_history.push_back(r5pars_.timesno);
3093 this->m_investigator_token = _token;
3094
3095 //output text
3096 prompt = "\n\n";
3097 prompt += "The investigator token moved from ";
3098 prompt += this->TranslateTokenIntoWords(old_token);
3099 prompt += " to ";
3100 prompt += this->TranslateTokenIntoWords(_token);
3101 this->PrintMessage(prompt);
3102}
3103
3105 cout << r5pars_.timesno << " " << str << " in Investigator.cpp" << '\n';
3106 ofstream fout("err messages.txt", ios::app);
3107 fout << r5pars_.timesno << " " << str << '\n';
3108 fout.close();
3109 //r5pars_.terminateall = true;
3110}
3111
3113 cout << "Time: " << r5pars_.timesno << ": " << str << '\n';
3114
3115 //test
3116 ofstream fout("RMI.txt", ios::app);
3117 fout << "Time: " << r5pars_.timesno << ": " << str << '\n';
3118 fout.close();
3119}
3120
3122 string str;
3123 stringstream conv;
3124 switch (_token) {
3125 case inv::GetCorrespondingKE: str = "GetCorrespondingKE3001";
3126 break;
3127 case inv::FindMatchingStatement: str = "FindAMatchingStatement3002";
3128 break;
3129 case inv::CheckAvailableFromMR: str = "WhetherItIsAvailablefromMR3003";
3130 break;
3131 case inv::VerifyFromControlPanel: str = "WhetherGetInfoFromControlPaneltoVerifyKE3004";
3132 break;
3133 case inv::RequestInfoInit: str = "RequestInfoFromControlPanelInititaion3005";
3134 break;
3135 case inv::RequestInfoRead: str = "RequestInfoFromControlPanelReading3006";
3136 break;
3137 case inv::CompareKEAndStatement: str = "CompareKEandStatement3007";
3138 break;
3139 case inv::ChooseDownstreamLink: str = "ChoseADownstreamInvestigatorLinkToFeedback3008";
3140 break;
3141 case inv::DecideWhetherToClose: str = "WhetherToCloseThisInvestigator3009";
3142 break;
3143 case inv::SearchPossibleCauses: str = "SearchForPossibleCauses3012";
3144 break;
3145 case inv::RetrieveNextLink: str = "RetrieveTheNextLikelyInvestigatorLink3013";
3146 break;
3147 case inv::EvaluateNewFeedback: str = "EvaluateAfterGetNewFeedback3014";
3148 break;
3149 case inv::NoMatchingKE: str = "3090: There is no corresponding knowledge element for this statement";
3150 break;
3151 default: conv.str("");
3152 conv << _token;
3153 str = conv.str();
3154 break;
3155 }
3156 return str;
3157}
3158
3160 //to be added
3161 string str;
3162 if (this->m_Happen == 1) {
3163 str = "An investigator to verify whether ";
3164 str += this->m_KElement_ID_pt->m_ID;
3165 str += " happened or not: ";
3166 str += this->GetKEandTimeRangeWords();
3167 } else if (this->m_Happen == 3) {
3168 if (this->m_motivation == 0) {
3169 str = "This investigator determined ";
3170 str += this->m_KElement_ID_pt->m_ID;
3171 str += " happened.";
3172 } else {
3173 str = "An investigator to find the cause of statement: ";
3174 str += this->m_Statement_pt->GetThisStatementWords();
3175 }
3176 } else if (this->m_Happen == 2) {
3177 str = "This investigator could not determine whether the KE happened or not: ";
3178 str += this->GetKEandTimeRangeWords();
3179 } else if (this->m_Happen == 4) {
3180 str = "This investigator determined the KE didn't happen: ";
3181 str += this->GetKEandTimeRangeWords();
3182 } else {
3183 str = "Error: unrecognized investigator::m_Happen";
3184 }
3185 return str;
3186}
3187
3189 //to be added
3190
3191 string str;
3192 stringstream conv;
3193 str = "Investigation Time Range: (";
3194 conv.str("");
3195 conv << this->m_effective_start;
3196 str += conv.str();
3197 str += " , ";
3198 conv.str("");
3199 conv << this->m_effective_end;
3200 str += conv.str();
3201 str += ")";
3202 return str;
3203}
3204
3206 string str;
3207 str = this->m_KElement_ID_pt->m_ID;
3208 str += ", ";
3209 str += this->GetKEandTimeRangeWords();
3210 return str;
3211
3212}
3213
3215 IDElement *found_ID_pt = NULL;
3216 vector<IDElement *>::iterator ID_itr;
3217 for (ID_itr = this->m_explanation_link_list.begin(); ID_itr != this->m_explanation_link_list.end(); ID_itr++) {
3218 if ((*ID_itr) == _ID_pt) {
3219 found_ID_pt = *ID_itr;
3220 }
3221 }
3222 return found_ID_pt;
3223}
3224
3226 IDElement *found_ID_pt = NULL;
3227 vector<IDElement *>::iterator ID_itr;
3228 for (ID_itr = this->m_possible_explanation_link_list.begin(); ID_itr != this->m_possible_explanation_link_list.end();
3229 ID_itr++) {
3230 if ((*ID_itr) == _ID_pt) {
3231 found_ID_pt = *ID_itr;
3232 }
3233 }
3234 return found_ID_pt;
3235}
3236
3238 IDElement *found_ID_pt = NULL;
3239 vector<IDElement *>::iterator ID_itr;
3240 for (ID_itr = this->m_rejected_explanation_list.begin(); ID_itr != this->m_rejected_explanation_list.end();
3241 ID_itr++) {
3242 if ((*ID_itr) == _ID_pt) {
3243 found_ID_pt = *ID_itr;
3244 }
3245 }
3246 return found_ID_pt;
3247}
3248
3250 Statement *new_statement_pt;
3251 vector<IDElement *>::iterator ID_itr;
3252 KnowledgeElement *KE_pt;
3253 InvestigatorLink *invest_link_pt;
3254 DiagnoseInvestigator *diagnose_invest_pt = NULL;
3255 EventSchemaUnit *ES_pt = NULL;
3256 float score_total, confidence;
3257 bool create_new_statement_bl = false;
3258 bool need_to_propagate_to_downstream_bl = false;
3259 float modified_p = _p;
3260
3261 ReasonMachine *RM_pt;
3262 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
3263 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
3264 else {}//add error message
3265
3266 if (this->m_ID == "Investigator_515") { this->ErrorMessage("check point"); }
3267
3268 if (this->m_Happen != 2) {
3269 this->ErrorMessage("Error!");
3270 // return;
3271 }
3272 if (r5pars_.timesno > 1022) { this->PrintMessage(""); }
3273
3274 //caution: think more about the modified_p
3275 this->m_independent_probability = _p;
3276 this->m_probability_update_time = r5pars_.timesno;
3277 //RM_pt->m_event_schema_base->UpdateTheInterestForInvestigatorOrInvestigatorLink();
3278
3279 KE_pt = (KnowledgeElement *) (this->m_KElement_ID_pt);
3280 if (this->m_possible_statement_pt == NULL && this->m_Statement_pt == NULL) {
3281 create_new_statement_bl = true;
3282 } else if (this->m_possible_statement_pt != NULL) {
3283 //To be added. It should be linked with the Event Schema
3285 && this->m_possible_statement_pt->m_state == !KE_pt->m_negation) {//just update the confidence of this statement
3289 need_to_propagate_to_downstream_bl = true;
3290 } else {
3292 RM_pt->m_buffer_used_bl = false;
3293 RM_pt->m_event_schema_base->UpdateTheInterestForInvestigatorOrInvestigatorLink();
3294 diagnose_invest_pt->UpdateForOtherEvidenceNotListedInEventSchema((IDElement *) this);
3295 /*if(RM_pt->m_buffer_used_bl == true)
3296 {this->m_independent_probability = 0;}*/
3297 //diagnose_invest_pt->UpdateThisDiagnoseWithAnConfirmedInvestigator(this);
3298 this->m_possible_statement_pt->m_confidence = diagnose_invest_pt->m_confidence;
3299 need_to_propagate_to_downstream_bl = true;
3300 }
3301 } else {
3302 create_new_statement_bl = true;
3304 && this->m_possible_statement_pt->m_state == KE_pt->m_negation) {
3305 modified_p = _p * (1 - this->m_possible_statement_pt->m_confidence);
3306 } else if (this->m_possible_statement_pt->m_sent_pt != KE_pt->m_SentenceUnit_pt
3307 && this->m_possible_statement_pt->m_state == !KE_pt->m_negation) {
3308 modified_p = _p * (1 - this->m_possible_statement_pt->m_confidence);
3309 }
3310 }
3311 }
3312
3313
3314 //create a new statement if required
3315 if (create_new_statement_bl == true) {
3316 //check whether there is a DiagnoseInvestigaor existing for this
3317 diagnose_invest_pt =
3318 RM_pt->m_event_schema_base->FindACorrespondingDiagnoseInvestigatorByKE((KnowledgeElement *) (this->m_KElement_ID_pt));
3319 if (diagnose_invest_pt != NULL) {//there is already a diagnose for this
3320 this->m_possible_statement_pt = diagnose_invest_pt->m_event_statement_pt;
3321 if (this->m_SI_ID_pt == NULL) {
3322 RM_pt->m_buffer_used_bl = false;
3323 RM_pt->m_event_schema_base->UpdateTheInterestForInvestigatorOrInvestigatorLink();
3324 diagnose_invest_pt->UpdateForOtherEvidenceNotListedInEventSchema((IDElement *) this);
3325 /*if(RM_pt->m_buffer_used_bl == true)
3326 {this->m_independent_probability = 0;}*/
3327 //diagnose_invest_pt->UpdateThisDiagnoseWithAnConfirmedInvestigator(this);
3328 }
3329 need_to_propagate_to_downstream_bl = true;
3330 create_new_statement_bl = false;
3331 } else {
3332 //Add a new statement with a probability
3333 auto stmt_owned = make_unique<Statement>();
3334 new_statement_pt = stmt_owned.get();
3335 new_statement_pt->m_factual_type = 4; // confidence propagated from the downstream
3336 new_statement_pt->m_sent_pt = KE_pt->m_SentenceUnit_pt;
3337 new_statement_pt->m_state = !(KE_pt->m_negation);
3338 new_statement_pt->m_confidence = modified_p;
3339 new_statement_pt->m_time_range.m_time_after = this->m_effective_start;
3340 new_statement_pt->m_time_range.m_time_before = this->m_effective_end;
3341 RM_pt->AddANewStatement(stmt_owned.release());
3342 this->m_possible_statement_pt = new_statement_pt;
3343
3344 ES_pt =
3345 RM_pt->m_event_schema_base->FindACorrespondingEventSchemaUnitByKE((KnowledgeElement *) (this->m_KElement_ID_pt));
3346 if (ES_pt != NULL) {//create a diagnose for this
3347 auto di_owned = make_unique<DiagnoseInvestigator>();
3348 diagnose_invest_pt = di_owned.get();
3349 diagnose_invest_pt->m_event_schema_pt = ES_pt;
3350 diagnose_invest_pt->m_event_statement_pt = new_statement_pt;
3351 RM_pt->m_event_schema_base->AddANewDiagnoseInvestigator(di_owned.release());
3352 RM_pt->m_buffer_used_bl = false;
3354 /*if(RM_pt->m_buffer_used_bl == true)
3355 {this->m_independent_probability = 0;}*/
3356 //work more on the confidence level during the initiation
3357 }
3358 new_statement_pt->m_diagnose_invest_ID_pt = diagnose_invest_pt;
3359 }
3360
3361
3362 //To be added, compare the new generated statement and link it to a diagnose_invest
3363 //maybe it should be done in the RM
3364 }
3365
3366 //probability propagate to downstream
3367 if (need_to_propagate_to_downstream_bl == true) {
3369 }
3370
3371 //propagate to upperstream
3372 bool undetermined_cause = false;
3373 InvestigatorLink *link_pt;
3374 if (RM_pt->m_problem_solving_style == ProblemSolvingStyle::HamletB) {//check whether it has finished going through each possible cause
3375 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
3376 link_pt = (InvestigatorLink *) (*ID_itr);
3377 if (link_pt->m_is_causal_path_bl == false) { continue; }
3378 if (link_pt->m_path_status == 1) {
3379 undetermined_cause = true;
3380 break;
3381 }
3382 }
3383
3384 if (undetermined_cause == true) {//pause this propagation
3385 this->m_paused_confidence_passing_list.push_back(_p);
3387 return;
3388 }
3389 }
3390 score_total = 0;
3391 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
3392 invest_link_pt = (InvestigatorLink *) (*ID_itr);
3393 if (invest_link_pt->m_is_causal_path_bl == false) { continue; }
3394 if (invest_link_pt->m_path_status == 2
3395 || (invest_link_pt->m_path_status == 3 && invest_link_pt->m_is_a_strong_inference == true)) {
3396 score_total += invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight;
3397 }
3398 }
3399 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
3400 invest_link_pt = (InvestigatorLink *) (*ID_itr);
3401 if (invest_link_pt->m_is_causal_path_bl == false) { continue; }
3402 if (invest_link_pt->m_path_status == 2
3403 || (invest_link_pt->m_path_status == 3 && invest_link_pt->m_is_a_strong_inference == true)) {
3404 confidence = (invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight / score_total) * modified_p;
3405 invest_link_pt->BackwardPropagateConfidenceLevel(confidence);
3406 }
3407 }
3408}
3409
3411
3412}
3413
3415 vector<IDElement *>::iterator ID_link_itr;
3416 vector<IDElement *>::iterator ID_invest_itr;
3417 Investigator *invest_pt;
3418 InvestigatorLink *link_pt;
3419 string str;
3420 this->PrintMessage("Downstream:" + this->m_KElement_ID_pt->m_ID);
3421 for (ID_link_itr = this->m_upperstream_ID_list.begin(); ID_link_itr != this->m_upperstream_ID_list.end();
3422 ID_link_itr++) {
3423 str = "";
3424 link_pt = (InvestigatorLink *) (*ID_link_itr);
3425 str += "--------";
3426 if (link_pt->m_K_unit_pt->m_inference_type == 1) {
3427 str += " A=>B";
3428 } else if (link_pt->m_K_unit_pt->m_inference_type == 2) {
3429 str += " A<=B";
3430 } else if (link_pt->m_K_unit_pt->m_inference_type == 3) {
3431 str += " A<=>B";
3432 }
3433
3434 if (link_pt->m_K_unit_pt->m_causal_type != 0) {
3435 str += "A->B";
3436 }
3437 str += "--------";
3438 this->PrintMessage(str);
3439 if (link_pt->m_link_type == 2) { str = "AND: "; }
3440 else if (link_pt->m_link_type == 3) { str = "OR :"; }
3441 else { str = ""; }
3442 for (ID_invest_itr = link_pt->m_upperstream_ID_list.begin(); ID_invest_itr != link_pt->m_upperstream_ID_list.end();
3443 ID_invest_itr++) {
3444 invest_pt = (Investigator *) (*ID_invest_itr);
3445 str += "..";
3446 if (invest_pt->m_KElement_ID_pt != NULL) {
3447 str += invest_pt->m_KElement_ID_pt->m_ID;
3448 } else if (invest_pt->m_Statement_pt != NULL) {
3449 str += invest_pt->m_Statement_pt->m_sent_pt->m_ID;
3450 }
3451 }
3452 this->PrintMessage(str);
3453 }
3454
3455}
3456
3457bool Investigator::CheckWhetherTheFoundStatementConsistantWithKE(Statement *statement_match_pt) {//the input has to contain the same sentence or the antonym.
3458 bool consistant_bl = false;
3460 if (statement_match_pt->m_sent_pt == KE_pt->m_SentenceUnit_pt) {
3461 if (statement_match_pt->m_state == !KE_pt->m_negation) {
3462 consistant_bl = true;
3463 } else {
3464 consistant_bl = false;
3465 }
3466 } else {//it should be a statement with antonym content
3467 if (statement_match_pt->m_state == true) {
3468 if (KE_pt->m_negation == false) {
3469 consistant_bl = false;
3470 } else {
3471 consistant_bl = true;
3472 }
3473 } else//m_state false
3474 {
3475 if (statement_match_pt->m_sent_pt->WhetherItIsBiState() == true) {//antonym and bi-state
3476 if (statement_match_pt->m_state == KE_pt->m_negation) {
3477 consistant_bl = true;
3478 } else {
3479 consistant_bl = false;
3480 }
3481 } else { consistant_bl = false; }//could not tell, caution!
3482 }
3483 }
3484 return consistant_bl;
3485}
3486
3488 this->m_Happen_incomplete = _invest_pt->m_Happen_incomplete;
3489 this->m_Explain_incomplete = _invest_pt->m_Explain_incomplete;
3491 this->CopyIDElementToRestartInfo((IDElement *) _invest_pt);
3494 /*
3495
3496 bool m_phenomenon_onging;
3497 bool m_abort;
3498 int m_operator;
3499 int m_investigator_token;
3500 int m_explained;
3501 //1--unknown yet;
3502 //2--could not be determined;
3503 //3--yes, explained;
3504 //4--No, fail to explain
3505 int m_Happen;
3506 //1--unknown
3507 //2--could not be determined from control panel;
3508 //3--yes;
3509 //4--no;
3510 int m_investiage_status;
3511 //1, active one;(waiting for checking control panel/or retrieving from memory)
3512 //2--following;
3513 //3--idle, wait to be investigated;
3514 //4--sucess explanation;
3515 //5--not the cause;
3516 */
3517 this->m_last_active_time = _invest_pt->m_last_active_time;
3519 this->m_read_requested_bl = _invest_pt->m_read_requested_bl;
3520 this->m_motivation = _invest_pt->m_motivation;
3522 this->m_invest_dormant = _invest_pt->m_invest_dormant;
3523 this->m_invest_pause = _invest_pt->m_invest_pause;
3524 this->m_phenomenon_onging = _invest_pt->m_phenomenon_onging;
3525 this->m_abort = _invest_pt->m_abort;
3526 this->m_operator = _invest_pt->m_operator;
3527 this->m_investigator_token = _invest_pt->m_investigator_token;
3528 this->m_explained = _invest_pt->m_explained;
3529 this->m_Happen = _invest_pt->m_Happen;
3531 this->m_timer = _invest_pt->m_timer;
3533// this->m_investiage_status = _invest_pt->m_investiage_status;
3534 /*
3535 double m_investigation_cease_time;
3536 double m_investigation_initiate_time;
3537 double m_effective_end;
3538 double m_effective_start;
3539 double m_end;
3540 float m_independent_probability;
3541 float m_interest_from_SymptomInvestigator;
3542 string m_note;
3543 string m_abort_reason;
3544 */
3547 this->m_effective_end = _invest_pt->m_effective_end;
3548 this->m_effective_start = _invest_pt->m_effective_start;
3551 this->m_note = _invest_pt->m_note;
3552 this->m_abort_reason = _invest_pt->m_abort_reason;
3553
3554 /*
3555 IDElement * m_SI_ID_pt;
3556 IDElement * m_KElement_ID_pt; //The sentence in the KElement is to be investigated
3557 Statement * m_Statement_pt; //The statement indicates whether the knowledge element happened;
3558 Statement * m_inconsistant_statement;
3559 Statement * m_possible_statement_pt;
3560
3561 string m_ID_SI;
3562 string m_ID_KE;
3563 string m_ID_statement;
3564 string m_ID_possible_statement;
3565 string m_ID_inconsit_statement;
3566 */
3567
3568 if (_invest_pt->m_has_moved_to_link != NULL) { this->m_ID_has_move_to_link = _invest_pt->m_has_moved_to_link->m_ID; }
3569 else { this->m_ID_has_move_to_link = _invest_pt->m_ID_has_move_to_link; }
3570
3571 if (_invest_pt->m_SI_ID_pt != NULL) { this->m_ID_SI = _invest_pt->m_SI_ID_pt->m_ID; }
3572 else { this->m_ID_SI = _invest_pt->m_ID_SI; }
3573
3574 if (_invest_pt->m_KElement_ID_pt != NULL) { this->m_ID_KE = _invest_pt->m_KElement_ID_pt->m_ID; }
3575 else { this->m_ID_KE = _invest_pt->m_ID_KE; }
3576
3577 if (_invest_pt->m_Statement_pt != NULL) { this->m_ID_statement = _invest_pt->m_Statement_pt->m_ID; }
3578 else { this->m_ID_statement = _invest_pt->m_ID_statement; }
3579
3580 if (_invest_pt->m_inconsistant_statement != NULL) {
3582 }
3583 else { this->m_ID_inconsist_statement = _invest_pt->m_ID_inconsist_statement; }
3584
3585 if (_invest_pt->m_possible_statement_pt != NULL) {
3587 }
3588 else { this->m_ID_possible_statement = _invest_pt->m_ID_possible_statement; }
3589
3590
3591 //if(this->m_waiting_indication_list.size() != 0)
3592 //{this->ErrorMessage("this->m_waiting_indication_list.size() != 0");return;}
3593 /*
3594 vector<int> m_investigator_token_history;
3595 vector<float> m_invest_token_endtime_history;
3596 vector<IDElement *> m_read_indication_list;
3597 vector<IDElement *> m_feedback_list;
3598 vector<IDElement *> m_upperstream_ID_list;
3599 vector<IDElement *> m_downstream_ID_list;
3600 vector<IDElement *> m_explanation_link_list;
3601 vector<IDElement *> m_possible_explanation_link_list;
3602 vector<IDElement *> m_rejected_explanation_list;
3603 //vector<IDElement *> m_waiting_indication_list;
3604 */
3605 if (this->m_investigator_token_history.size() != 0) {
3606 this->ErrorMessage("this->m_investigator_token_history.size() != 0");
3607 return;
3608 }
3609 if (this->m_invest_token_endtime_history.size() != 0) {
3610 this->ErrorMessage("this->m_invest_token_endtime_history.size() != 0");
3611 return;
3612 }
3613 if (this->m_read_indication_list.size() != 0) {
3614 this->ErrorMessage("m_read_indication_list.size() != 0");
3615 return;
3616 }
3617 if (this->m_feedback_list.size() != 0) {
3618 this->ErrorMessage("m_feedback_list.size() != 0");
3619 return;
3620 }
3621 if (this->m_upperstream_ID_list.size() != 0) {
3622 this->ErrorMessage("m_upperstream_ID_list.size() != 0");
3623 return;
3624 }
3625 if (this->m_downstream_ID_list.size() != 0) {
3626 this->ErrorMessage("m_downstream_ID_list.size() != 0");
3627 return;
3628 }
3629 if (this->m_explanation_link_list.size() != 0) {
3630 this->ErrorMessage("m_explanation_link_list.size() != 0");
3631 return;
3632 }
3633 if (this->m_possible_explanation_link_list.size() != 0) {
3634 this->ErrorMessage("this->m_possible_explanation_link_list.size() != 0");
3635 return;
3636 }
3637 if (this->m_rejected_explanation_list.size() != 0) {
3638 this->ErrorMessage("this->m_rejected_explanation_list.size() != 0");
3639 return;
3640 }
3641 if (this->m_thoughtline_roots_list.size() != 0) {
3642 this->ErrorMessage("this->m_thoughtline_roots_list.size() != 0");
3643 return;
3644 }
3645
3646 vector<int>::iterator int_itr;
3647 int i;
3648 for (int_itr = _invest_pt->m_investigator_token_history.begin();
3649 int_itr != _invest_pt->m_investigator_token_history.end(); int_itr++) {
3650 i = *int_itr;
3651 this->m_investigator_token_history.push_back(i);
3652 }
3653
3654 vector<IDElement *>::iterator ID_itr;
3655 vector<string>::iterator str_itr;
3656 string ID;
3657 vector<float>::iterator fl_itr;
3658 float fl;
3659 for (fl_itr = _invest_pt->m_paused_confidence_passing_list.begin();
3660 fl_itr != _invest_pt->m_paused_confidence_passing_list.end(); fl_itr++) {
3661 fl = *fl_itr;
3662 this->m_paused_confidence_passing_list.push_back(fl);
3663 }
3664 for (fl_itr = _invest_pt->m_invest_token_endtime_history.begin();
3665 fl_itr != _invest_pt->m_invest_token_endtime_history.end(); fl_itr++) {
3666 fl = *fl_itr;
3667 this->m_invest_token_endtime_history.push_back(fl);
3668 }
3669
3670 for (str_itr = _invest_pt->m_pause_confidence_propagation_ID_list.begin();
3671 str_itr != _invest_pt->m_pause_confidence_propagation_ID_list.end(); str_itr++) {
3672 ID = *str_itr;
3673 this->m_pause_confidence_propagation_ID_list.push_back(ID);
3674 }
3675
3676 for (str_itr = _invest_pt->m_thoughtline_roots_list.begin(); str_itr != _invest_pt->m_thoughtline_roots_list.end();
3677 str_itr++) {
3678 ID = *str_itr;
3679 this->m_thoughtline_roots_list.push_back(ID);
3680 }
3681
3682 if (_invest_pt->m_read_indication_list.size() != 0) {
3683 for (ID_itr = _invest_pt->m_read_indication_list.begin(); ID_itr != _invest_pt->m_read_indication_list.end();
3684 ID_itr++) {
3685 ID = (*ID_itr)->m_ID;
3686 this->m_ID_read_indication_list.push_back(ID);
3687 }
3688 } else {
3689 for (str_itr = _invest_pt->m_ID_read_indication_list.begin();
3690 str_itr != _invest_pt->m_ID_read_indication_list.end(); str_itr++) {
3691 ID = *str_itr;
3692 this->m_ID_read_indication_list.push_back(ID);
3693 }
3694 }
3695
3696 //
3697 if (_invest_pt->m_feedback_list.size() != 0) {
3698 for (ID_itr = _invest_pt->m_feedback_list.begin(); ID_itr != _invest_pt->m_feedback_list.end(); ID_itr++) {
3699 ID = (*ID_itr)->m_ID;
3700 this->m_ID_feedback_list.push_back(ID);
3701 }
3702 } else {
3703 for (str_itr = _invest_pt->m_ID_feedback_list.begin(); str_itr != _invest_pt->m_ID_feedback_list.end(); str_itr++) {
3704 ID = *str_itr;
3705 this->m_ID_feedback_list.push_back(ID);
3706 }
3707 }
3708
3709 if (_invest_pt->m_upperstream_ID_list.size() != 0) {
3710 for (ID_itr = _invest_pt->m_upperstream_ID_list.begin(); ID_itr != _invest_pt->m_upperstream_ID_list.end();
3711 ID_itr++) {
3712 ID = (*ID_itr)->m_ID;
3713 this->m_ID_upperstream_list.push_back(ID);
3714 }
3715 } else {
3716 for (str_itr = _invest_pt->m_ID_upperstream_list.begin(); str_itr != _invest_pt->m_ID_upperstream_list.end();
3717 str_itr++) {
3718 ID = *str_itr;
3719 this->m_ID_upperstream_list.push_back(ID);
3720 }
3721 }
3722
3723 if (_invest_pt->m_downstream_ID_list.size() != 0) {
3724 for (ID_itr = _invest_pt->m_downstream_ID_list.begin(); ID_itr != _invest_pt->m_downstream_ID_list.end();
3725 ID_itr++) {
3726 ID = (*ID_itr)->m_ID;
3727 this->m_ID_downstream_list.push_back(ID);
3728 }
3729 } else {
3730 for (str_itr = _invest_pt->m_ID_downstream_list.begin(); str_itr != _invest_pt->m_ID_downstream_list.end();
3731 str_itr++) {
3732 ID = *str_itr;
3733 this->m_ID_downstream_list.push_back(ID);
3734 }
3735 }
3736
3737 if (_invest_pt->m_explanation_link_list.size() != 0) {
3738 for (ID_itr = _invest_pt->m_explanation_link_list.begin(); ID_itr != _invest_pt->m_explanation_link_list.end();
3739 ID_itr++) {
3740 ID = (*ID_itr)->m_ID;
3741 this->m_ID_explanation_link_list.push_back(ID);
3742 }
3743 } else {
3744 for (str_itr = _invest_pt->m_ID_explanation_link_list.begin();
3745 str_itr != _invest_pt->m_ID_explanation_link_list.end(); str_itr++) {
3746 ID = *str_itr;
3747 this->m_ID_explanation_link_list.push_back(ID);
3748 }
3749 }
3750
3751 if (_invest_pt->m_possible_explanation_link_list.size() != 0) {
3752 for (ID_itr = _invest_pt->m_possible_explanation_link_list.begin();
3753 ID_itr != _invest_pt->m_possible_explanation_link_list.end(); ID_itr++) {
3754 ID = (*ID_itr)->m_ID;
3755 this->m_ID_possible_explanation_link_list.push_back(ID);
3756 }
3757 } else {
3758 for (str_itr = _invest_pt->m_ID_possible_explanation_link_list.begin();
3759 str_itr != _invest_pt->m_ID_possible_explanation_link_list.end(); str_itr++) {
3760 ID = *str_itr;
3761 this->m_ID_possible_explanation_link_list.push_back(ID);
3762 }
3763 }
3764
3765 if (_invest_pt->m_rejected_explanation_list.size() != 0) {
3766 for (ID_itr = _invest_pt->m_rejected_explanation_list.begin();
3767 ID_itr != _invest_pt->m_rejected_explanation_list.end(); ID_itr++) {
3768 ID = (*ID_itr)->m_ID;
3769 this->m_ID_rejected_explanation_list.push_back(ID);
3770 }
3771 } else {
3772 for (str_itr = _invest_pt->m_ID_rejected_explanation_list.begin();
3773 str_itr != _invest_pt->m_ID_rejected_explanation_list.end(); str_itr++) {
3774 ID = *str_itr;
3775 this->m_ID_rejected_explanation_list.push_back(ID);
3776 }
3777 }
3778
3779 if (this->m_note_list.size() > 0) { this->ErrorMessage("this->m_note_list.size() > 0"); }
3780
3781 if (_invest_pt->m_note_list.size() > 100) { this->PrintMessage(""); }
3782 for (str_itr = _invest_pt->m_note_list.begin(); str_itr != _invest_pt->m_note_list.end(); str_itr++) {
3783 this->m_note_list.push_back(*str_itr);
3784 }
3785
3786}
3787
3789 ReasonMachine *RM_pt;
3790 RM_pt = (ReasonMachine *) _pt;
3791 //Statement * m_inconsistant_statement;
3792 if (this->m_ID_inconsist_statement.compare("") != 0) {
3794 if (this->m_inconsistant_statement == NULL) {
3795 this->ErrorMessage("this->m_inconsistant_statement == NULL");
3796 return;
3797 }
3798 }
3799
3800 //
3801 if (this->m_ID_has_move_to_link.compare("") != 0) {
3803 if (this->m_has_moved_to_link == NULL) {
3804 this->ErrorMessage("this->m_has_moved_to_link == NULL");
3805 return;
3806 }
3807 this->m_ID_has_move_to_link = "";
3808 }
3809
3810
3811 //IDElement * m_SI_ID_pt;
3812 if (this->m_ID_SI.compare("") != 0) {
3813 this->m_SI_ID_pt = RM_pt->m_event_schema_base->FindSymtomInvestigatorByID(this->m_ID_SI);
3814 if (this->m_SI_ID_pt == NULL) {
3815 this->ErrorMessage("this->m_SI_ID_pt == NULL");
3816 return;
3817 }
3818 }
3819 //IDElement * m_KElement_ID_pt;
3820 if (this->m_ID_KE.compare("") != 0) {
3822 if (this->m_KElement_ID_pt == NULL) {
3823 this->ErrorMessage("this->m_KElement_ID_pt == NULL");
3824 return;
3825 }
3826
3827 }
3828
3829 //Statement * m_Statement_pt;
3830 if (this->m_ID_statement.compare("") != 0) {
3831 this->m_Statement_pt = RM_pt->FindStatementByID(this->m_ID_statement);
3832 if (this->m_Statement_pt == NULL) {
3833 this->ErrorMessage("this->m_Statement_pt == NULL");
3834 return;
3835 }
3836 }
3837
3838 //Statement * m_possible_statement_pt;
3839 if (this->m_ID_possible_statement.compare("") != 0) {
3841 if (this->m_possible_statement_pt == NULL) {
3842 this->ErrorMessage("this->m_possible_statement_pt == NULL");
3843 return;
3844 }
3845 }
3846
3847 //vector<IDElement *> m_feedback_list;
3848 vector<string>::iterator str_itr;
3849 IDElement *ID_pt;
3850 for (str_itr = this->m_ID_feedback_list.begin(); str_itr != this->m_ID_feedback_list.end(); str_itr++) {
3851 ID_pt = (IDElement *) (RM_pt->FindInvestigatorLinkByID(*str_itr));
3852 if (ID_pt == NULL) {
3853 this->ErrorMessage("could not find " + *str_itr);
3854 return;
3855 }
3856 this->m_feedback_list.push_back(ID_pt);
3857 }
3858
3859 //vector<IDElement *> m_upperstream_ID_list;
3860 for (str_itr = this->m_ID_upperstream_list.begin(); str_itr != this->m_ID_upperstream_list.end(); str_itr++) {
3861 ID_pt = (IDElement *) (RM_pt->FindInvestigatorLinkByID(*str_itr));
3862 if (ID_pt == NULL) {
3863 this->ErrorMessage("could not find " + *str_itr);
3864 return;
3865 }
3866 this->m_upperstream_ID_list.push_back(ID_pt);
3867 }
3868
3869 //vector<IDElement *> m_downstream_ID_list;
3870 for (str_itr = this->m_ID_downstream_list.begin(); str_itr != this->m_ID_downstream_list.end(); str_itr++) {
3871 ID_pt = (IDElement *) (RM_pt->FindInvestigatorLinkByID(*str_itr));
3872 if (ID_pt == NULL) {
3873 this->ErrorMessage("could not find " + *str_itr);
3874 return;
3875 }
3876 this->m_downstream_ID_list.push_back(ID_pt);
3877 }
3878
3879 //vector<IDElement *> m_explanation_link_list;
3880 for (str_itr = this->m_ID_explanation_link_list.begin(); str_itr != this->m_ID_explanation_link_list.end();
3881 str_itr++) {
3882 ID_pt = (IDElement *) (RM_pt->FindInvestigatorLinkByID(*str_itr));
3883 if (ID_pt == NULL) {
3884 this->ErrorMessage("could not find " + *str_itr);
3885 return;
3886 }
3887 this->m_explanation_link_list.push_back(ID_pt);
3888 }
3889
3890 //vector<IDElement *> m_possible_explanation_link_list;
3891 for (str_itr = this->m_ID_possible_explanation_link_list.begin();
3892 str_itr != this->m_ID_possible_explanation_link_list.end(); str_itr++) {
3893 ID_pt = (IDElement *) (RM_pt->FindInvestigatorLinkByID(*str_itr));
3894 if (ID_pt == NULL) {
3895 this->ErrorMessage("could not find " + *str_itr);
3896 return;
3897 }
3898 this->m_possible_explanation_link_list.push_back(ID_pt);
3899 }
3900
3901 //vector<IDElement *> m_rejected_explanation_list;
3902 for (str_itr = this->m_ID_rejected_explanation_list.begin(); str_itr != this->m_ID_rejected_explanation_list.end();
3903 str_itr++) {
3904 ID_pt = (IDElement *) (RM_pt->FindInvestigatorLinkByID(*str_itr));
3905 if (ID_pt == NULL) {
3906 this->ErrorMessage("could not find " + *str_itr);
3907 return;
3908 }
3909 this->m_rejected_explanation_list.push_back(ID_pt);
3910 }
3911
3912 //vector<IDElement *> m_read_indication_list;
3913 for (str_itr = this->m_ID_read_indication_list.begin(); str_itr != this->m_ID_read_indication_list.end(); str_itr++) {
3914 ID_pt = RM_pt->m_MR->FindMRUnitByID(*str_itr);
3915 if (ID_pt == NULL) {
3916 this->ErrorMessage("could not find a MR unit for this indication");
3917 return;
3918 }
3919 this->m_read_indication_list.push_back(ID_pt);
3920 }
3921
3922}
3923
3925 bool found = false;
3926 vector<string>::iterator str_itr;
3927 vector<IDElement *>::iterator ID_itr;
3928 InvestigatorLink *link_pt;
3929
3930 if (this->m_ID.compare(_line_ID) == 0) { return; } //there is a loop
3931
3932 for (str_itr = this->m_thoughtline_roots_list.begin(); str_itr != this->m_thoughtline_roots_list.end(); str_itr++) {
3933 if (_line_ID.compare(*str_itr) == 0) { found = true; }
3934 }
3935
3936 if (found == true) { return; }
3937
3938 //
3939 if (this->m_ID == "Investigator_23") { this->PrintMessage("check"); }
3940
3941 this->m_thoughtline_roots_list.push_back(_line_ID);
3942 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
3943 link_pt = (InvestigatorLink *) (*ID_itr);
3944 link_pt->AttachThoughtLineToThisLink(_line_ID);
3945 }
3946
3947}
3948
3950 vector<IDElement *>::iterator ID_itr;
3951 InvestigatorLink *link_pt;
3952 vector<string>::iterator str_itr;
3953
3954 if (this->m_root_of_a_thought_line == true) {
3955 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
3956 link_pt = (InvestigatorLink *) (*ID_itr);
3957 link_pt->AttachThoughtLineToThisLink(this->m_ID);
3958 }
3959 }
3960
3961 for (str_itr = this->m_thoughtline_roots_list.begin(); str_itr != this->m_thoughtline_roots_list.end(); str_itr++) {
3962 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
3963 link_pt = (InvestigatorLink *) (*ID_itr);
3964 link_pt->AttachThoughtLineToThisLink(*str_itr);
3965 }
3966 }
3967 return;
3968
3969}
3970
3972 bool within = false;
3973 if (this->m_ID.compare(_line_ID) == 0) {
3974 within = true;
3975 return within;
3976 }
3977
3978 vector<string>::iterator str_itr;
3979 for (str_itr = this->m_thoughtline_roots_list.begin(); str_itr != this->m_thoughtline_roots_list.end(); str_itr++) {
3980 if (_line_ID.compare(*str_itr) == 0) { within = true; }
3981 }
3982 return within;
3983}
3984
3986 float invest_time = this->m_investigation_initiate_time;
3987 if (this->m_Statement_pt != NULL) {
3988 invest_time = max<double>(invest_time, this->m_Statement_pt->m_time_generated);
3989 } else if (this->m_possible_statement_pt != NULL) {
3990 invest_time = max<double>(invest_time, this->m_possible_statement_pt->m_time_generated);
3991 }
3992
3993 invest_time = max(invest_time, this->m_last_active_time);
3994 return invest_time;
3995}
3996
3998 float p_total = 0;
3999 float score_total = 0;
4000 float confidence = 0;
4001 vector<IDElement *>::iterator ID_itr;
4002 InvestigatorLink *invest_link_pt;
4003 string rm_aux_info;
4004
4005 ReasonMachine *RM_pt;
4006 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
4007 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
4008 else {}//add error message
4009 if (this->m_ID == "Investigator_3") { this->PrintMessage("Check"); }
4010
4011 if (this->m_Happen != 3) { return; }
4012 if (this->m_Statement_pt == NULL) { return; }
4013 else if (this->m_Statement_pt->m_factual_type == 3
4014 && this->m_Statement_pt->m_confidence < 0.95)//make sure it does propagate from an observed phenomenon
4015 { return; }
4016
4017 if (this->m_Statement_pt->m_factual_type == 1 || this->m_Statement_pt->m_factual_type == 2
4018 || this->m_Statement_pt->m_confidence >= 0.95) {
4019 if (this->m_explanation_link_list.size() > 0) { p_total = 0.2 * pow(0.5, this->m_explanation_link_list.size()); }
4020 else { p_total = 0.9; }
4021 }
4022
4023 score_total = 0;
4024 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
4025 invest_link_pt = (InvestigatorLink *) (*ID_itr);
4026 if (invest_link_pt->m_is_causal_path_bl == false) { continue; }
4027 if (invest_link_pt->m_path_status == 4) { continue; }
4028 if (invest_link_pt->m_path_status == 2
4029 || (invest_link_pt->m_path_status == 3 && invest_link_pt->m_is_a_strong_inference == true)) {
4030 score_total += invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight;
4031 }
4032 }
4033
4034 if (score_total == 0) { return; }
4035
4036 rm_aux_info = "Propagating confidence from an observable syptom. Starts from " + this->m_ID;
4037 RM_pt->WriteAuxInfo(rm_aux_info);
4038 if (this->m_ID == "Investigator_621") { this->PrintMessage(""); }
4039
4040 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
4041 invest_link_pt = (InvestigatorLink *) (*ID_itr);
4042 if (invest_link_pt->m_is_causal_path_bl == false) { continue; }
4043 if (invest_link_pt->m_path_status == 4) { continue; }
4044 if (invest_link_pt->m_path_status == 2
4045 || (invest_link_pt->m_path_status == 3 && invest_link_pt->m_is_a_strong_inference == true)) {
4046 confidence = (invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight / score_total) * p_total;
4047 RM_pt->m_buffer_invest_pt = this;
4048 invest_link_pt->BackwardPropagateConfidenceLevel(confidence);
4049 RM_pt->m_buffer_invest_pt = NULL;
4050 }
4051 }
4052
4053 if (RM_pt->m_problem_solving_style
4054 != ProblemSolvingStyle::HamletB) { RM_pt->m_event_schema_base->RemoveAllTheCaseAssociatedWithAnInvestigator((IDElement *) this); }
4055}
4056
4058 ReasonMachine *RM_pt;
4059 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
4060 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
4061 else {}//add error message
4062 if (this->m_ID == "Investigator_34") { this->PrintMessage(""); }
4063
4065 if (this->m_upperstream_ID_list.size()
4066 > this->m_ID_possible_explanation_link_list.size() + this->m_rejected_explanation_list.size()
4067 + this->m_explanation_link_list.size()) {
4069 } else { this->PrintMessage(""); }
4070 }
4071
4072 this->m_investigation_closed = false;
4075 this->m_last_active_time = r5pars_.timesno;
4076
4077 SentenceUnit *sent_pt;
4078 sent_pt = this->GetSemanticSentenceOfThisInvestigator();
4079 if (sent_pt->m_activation < 1) {
4080 RM_pt->CrankASentenceUnitActivationToAGivenValue(sent_pt, 1.0);
4081 }
4082}
4083
4085 SentenceUnit *sent_pt;
4086
4087 ReasonMachine *RM_pt;
4088 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
4089 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
4090 else {}//add error message
4091
4092 sent_pt = this->GetSemanticSentenceOfThisInvestigator();
4093 if (sent_pt != NULL) {
4094 RM_pt->CrankASentenceUnitActivationToAGivenValue(sent_pt, 1.0);
4095 }
4096}
4097
4099 InvestigatorLink *link_pt;
4100 if (this->m_invest_pause == false) {
4102 } else {
4103 link_pt = (InvestigatorLink *) this->m_has_moved_to_link;
4104 if (link_pt != NULL) { link_pt->BoostActivationOfThisLinkByActiveDiagnosisInvestigation(); }
4105 }
4106}
4107
4109 if (this->m_ID == "Investigator_90") { this->PrintMessage(""); }
4110 InvestigatorLink *link_pt;
4111 if (this->m_invest_pause == false) {
4113 this->m_last_active_time = r5pars_.timesno;
4114
4116 } else {
4117 link_pt = (InvestigatorLink *) this->m_has_moved_to_link;
4118 if (link_pt != NULL) { link_pt->BoostAttentionOfThisFromDiagnosisInvestigation(_i, _vagabond_reset); }
4119 }
4120}
4121
4123// vector<InvestigatorLink *>::iterator link_itr;
4124 vector<IDElement *>::iterator ID_itr;
4125 vector<string>::iterator str_itr;
4126 Investigator *invest_pt;
4127 ReasonMachine *RM_pt;
4128 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
4129 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
4130 else {}//add error message
4131
4132 InvestigatorLink *link_pt;
4133 this->m_Happen_incomplete = true;
4134
4135 for (ID_itr = this->m_downstream_ID_list.begin(); ID_itr != this->m_downstream_ID_list.end(); ID_itr++) {
4136 link_pt = (InvestigatorLink *) (*ID_itr);
4137 link_pt->UpdateMHappenIncomplete();
4138 }
4139
4140 for (str_itr = this->m_thoughtline_roots_list.begin(); str_itr != this->m_thoughtline_roots_list.end(); str_itr++) {
4141 invest_pt = RM_pt->FindInvestigatorByID(*str_itr);
4142 if (invest_pt != NULL) {
4143 invest_pt->m_Explain_incomplete = true;
4144 }
4145 }
4146}
4147
4149 vector<IDElement *>::iterator ID_itr;
4150 InvestigatorLink *link_pt;
4151 bool mark_happen_change = false;
4152 bool mark_explain_change = false;
4153
4154 if (this->m_Happen_incomplete == true) { return; }
4155
4156 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
4157 link_pt = (InvestigatorLink *) (*ID_itr);
4158 if (link_pt->m_Happen_incomplete == true) {
4159 if (link_pt->m_is_inference_path_bl == true) { mark_happen_change = true; }
4160 if (link_pt->m_is_causal_path_bl == true) { mark_explain_change = true; }
4161 }
4162 }
4163
4164 if (mark_happen_change == true && this->m_Happen != 3) {
4166 }
4167
4168 if (mark_explain_change == true) {
4169 this->m_Explain_incomplete = true;
4170 }
4171}
4172
4174 float score_total;
4175 float confidence;
4176
4177 vector<string>::iterator str_itr;
4178 vector<float>::iterator fl_itr;
4179 vector<IDElement *>::iterator ID_itr;
4180 InvestigatorLink *invest_link_pt;
4181 Investigator *invest_pt;
4182
4183 ReasonMachine *RM_pt;
4184 if (this->m_operator == sim::Operator::ODM) { RM_pt = g_sim.Decision_Maker.m_RM.get(); }
4185 else if (this->m_operator == sim::Operator::OAT) { RM_pt = g_sim.Action_Taker.m_RM.get(); }
4186 else {}//add error message
4187
4188 if (this->m_pause_confidence_propagation_ID_list.size() != this->m_paused_confidence_passing_list.size()) {
4189 this->ErrorMessage(
4190 "this->m_pause_confidence_propagation_ID_list.size() != this->m_paused_confidence_passing_list.size()");
4191 }
4192
4193 while (this->m_pause_confidence_propagation_ID_list.size() > 0) {
4194 str_itr = this->m_pause_confidence_propagation_ID_list.begin();
4195 fl_itr = this->m_paused_confidence_passing_list.begin();
4196
4197 invest_pt = RM_pt->FindInvestigatorByID(*str_itr);
4198 if (invest_pt == NULL) {
4199 this->ErrorMessage(
4200 "unable to find the Investigator for the FinishThePausedConfidencePropagationBeforeCloseInvestigation");
4201 }
4202
4203 score_total = 0;
4204 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
4205 invest_link_pt = (InvestigatorLink *) (*ID_itr);
4206 if (invest_link_pt->m_is_causal_path_bl == false) { continue; }
4207 if (invest_link_pt->m_path_status == 2
4208 || (invest_link_pt->m_path_status == 3 && invest_link_pt->m_is_a_strong_inference == true)) {
4209 score_total += invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight;
4210 }
4211 }
4212 for (ID_itr = this->m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++) {
4213 invest_link_pt = (InvestigatorLink *) (*ID_itr);
4214 if (invest_link_pt->m_is_causal_path_bl == false) { continue; }
4215 if (invest_link_pt->m_path_status == 2
4216 || (invest_link_pt->m_path_status == 3 && invest_link_pt->m_is_a_strong_inference == true)) {
4217 RM_pt->m_buffer_invest_pt = invest_pt;
4218 confidence = (invest_link_pt->m_K_unit_pt->m_backward_retrieve_weight / score_total) * (*fl_itr);
4219 invest_link_pt->BackwardPropagateConfidenceLevel(confidence);
4220 RM_pt->m_buffer_invest_pt = NULL;
4221 }
4222 }
4223 this->m_pause_confidence_propagation_ID_list.erase(str_itr);
4224 this->m_paused_confidence_passing_list.erase(fl_itr);
4225 }
4226}
Diagnostic reasoning engine — knowledge representation, mental model, and inference.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
double m_activation
Definition: Activation.h:22
int getNumOfOATBranch()
int getNumOfODMBranch()
std::vector< IDElement * > m_antonym_list
void InitiationOfthisDiagnoseInvestigator(float, IDElement *)
void UpdateForOtherEvidenceNotListedInEventSchema(IDElement *)
EventSchemaUnit * m_event_schema_pt
void CopyIDElementToRestartInfo(IDElement *)
Definition: IDElement.cpp:23
int m_ID_Type
Definition: IDElement.h:15
std::string m_ID
Definition: IDElement.h:16
std::vector< IDElement * > m_feedback_list
Definition: Investigator.h:142
std::string m_ID_possible_statement
Definition: Investigator.h:137
void UpdateHappenExplainIncomeplete()
void UpdateEffectiveEndTimeRangeFromDownstream(double, bool)
void PrintCausalOrInferenceLink()
bool m_invest_pause
Definition: Investigator.h:95
void ChoseADownstreamInvestigatorLinkToFeedback3018()
float m_last_active_time
Definition: Investigator.h:87
void AttachThoughtLineToThisInvestigator(std::string)
void InitiateBackwardPropagationOfConfidence()
std::vector< std::string > m_ID_read_indication_list
Definition: Investigator.h:150
std::string m_ID_SI
Definition: Investigator.h:134
void WhetherItIsAvailablefromMR3003()
std::string m_note
Definition: Investigator.h:124
void RetrieveTheNextLikelyInvestigatorLink3013()
void MarkMHappenIncompleteTrue()
std::vector< IDElement * > m_rejected_explanation_list
Definition: Investigator.h:147
std::vector< std::string > m_ID_explanation_link_list
Definition: Investigator.h:154
void BackwardPropagateConfidenceLevel(float _p)
bool m_phenomenon_onging
Definition: Investigator.h:96
bool m_investigation_closed
Definition: Investigator.h:88
double m_investigation_initiate_time
Definition: Investigator.h:117
std::vector< IDElement * > m_read_indication_list
Definition: Investigator.h:141
IDElement * CheckExistenceInPossibleExplanationList(IDElement *)
void AddTimeConsumptionInInvestigator(double)
bool m_motivation
Definition: Investigator.h:92
bool m_invest_dormant
Definition: Investigator.h:94
void BoostAttentionofThisByDiagnosisInvestigation(float, bool)
bool WhetherContinueInvestigationAfterFoundExplanation()
void BuildTheConnectionsToThisInvestigator(void *)
void WhetherToCloseThisInvestigator3009()
void ExtendTheThoughtLineToUpperstream()
std::vector< float > m_paused_confidence_passing_list
Definition: Investigator.h:79
void FinishThePausedConfidencePropagationBeforeCloseInvestigation()
std::string GetASimpleDescriptionOfThisInvestigator()
double m_effective_end
Definition: Investigator.h:118
SentenceUnit * GetSemanticSentenceOfThisInvestigator()
void EvaluateAfterGetNewFeedback3014()
void PrintMessage(std::string)
void ErrorMessage(std::string)
std::string m_abort_reason
Definition: Investigator.h:125
void CompareKEandStatement3007()
bool m_Happen_incomplete
Definition: Investigator.h:81
std::string GetInvestigationKEandTimeRange()
void ReopenThisInvestigator()
std::string m_ID_has_move_to_link
Definition: Investigator.h:25
void FindAMatchingStatement3002()
void ChangeInvestigatorToken(int)
std::vector< std::string > m_note_list
Definition: Investigator.h:159
double m_effective_start
Definition: Investigator.h:119
void UpdateEffectiveEndTimeRangeFromStatement(double, bool)
std::vector< IDElement * > m_possible_explanation_link_list
Definition: Investigator.h:146
float m_probability_update_time
Definition: Investigator.h:18
std::vector< IDElement * > m_explanation_link_list
Definition: Investigator.h:145
std::string m_ID_statement
Definition: Investigator.h:136
void WhetherToCloseThisInvestigator3019()
std::string TranslateTokenIntoWords(int)
bool CheckWhetherTheFoundStatementConsistantWithKE(Statement *)
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
std::vector< std::string > m_ID_feedback_list
Definition: Investigator.h:151
bool m_root_of_a_thought_line
Definition: Investigator.h:85
void CrankTheActivationToOne()
Statement * m_inconsistant_statement
Definition: Investigator.h:127
bool m_read_requested_bl
Definition: Investigator.h:91
std::vector< IDElement * > m_downstream_ID_list
Definition: Investigator.h:144
std::vector< std::string > m_ID_upperstream_list
Definition: Investigator.h:152
float m_last_time_of_refreshing_inference_item
Definition: Investigator.h:16
bool CheckWhetherInAThoughtLine(std::string)
float m_independent_probability
Definition: Investigator.h:121
IDElement * m_has_moved_to_link
Definition: Investigator.h:26
void SearchForPossibleCauses3012()
double m_investigation_cease_time
Definition: Investigator.h:116
std::vector< IDElement * > m_upperstream_ID_list
Definition: Investigator.h:143
std::vector< std::string > m_pause_confidence_propagation_ID_list
Definition: Investigator.h:78
float DetermineWhetherItsStillActivePhenomenon()
bool m_has_moved_to_an_upperstream
Definition: Investigator.h:90
std::vector< std::string > m_ID_rejected_explanation_list
Definition: Investigator.h:156
void CopyInvestigatorInfoFromAnother(Investigator *)
int m_investigator_token
Definition: Investigator.h:99
void WhetherGetInfoFromControlPaneltoVerifyKE3004()
float m_interest_from_SymptomInvestigator
Definition: Investigator.h:122
void OneStepWorkOnThisInvestigator()
std::vector< std::string > m_ID_possible_explanation_link_list
Definition: Investigator.h:155
std::string m_ID_inconsist_statement
Definition: Investigator.h:133
IDElement * CheckExistenceInExplanationList(IDElement *)
std::string m_ID_KE
Definition: Investigator.h:135
float CalculateFilteredPrioritizingScoreOfInvestigator()
std::vector< int > m_investigator_token_history
Definition: Investigator.h:139
void ForwardPropagateConfidenceLevel(float _p)
std::vector< float > m_invest_token_endtime_history
Definition: Investigator.h:140
IDElement * m_SI_ID_pt
Definition: Investigator.h:128
std::string GetKEandTimeRangeWords()
std::vector< std::string > m_thoughtline_roots_list
Definition: Investigator.h:84
void RequestInfoFromControlPanelInititaion3005()
bool m_read_value_or_rate_bl
Definition: Investigator.h:93
void BoostActivationOfThisByActiveDiagnosisInvestigation()
virtual ~Investigator()
std::vector< std::string > m_ID_downstream_list
Definition: Investigator.h:153
void GetCorrespondingKE3001()
float CalculatePriorityScoreEvenDormantOrPaused()
float GetInitiationTimeOrStatementTimeOrLastActiveTime()
Statement * m_Statement_pt
Definition: Investigator.h:130
double GetActivation()
void CloseThisInvestigator()
void RequestInfoFromControlPanelReading3006()
IDElement * CheckExistenceInRejectedExplanationList(IDElement *)
void ChoseADownstreamInvestigatorLinkToFeedback3008()
void UpdateEffectiveEndTimeRangeToUpperstream(double, bool)
SentenceUnit * m_SentenceUnit_pt
std::vector< KnowledgeElement * > M_KElement_list
Definition: KnowledgeNode.h:28
double m_backward_retrieve_weight
Definition: KnowledgeUnit.h:30
Definition: Label.h:13
std::vector< IDElement * > m_label_option_list
Definition: Label.h:21
MRStateSchema * CheckFirstAlarmStateAfterATime(float _end)
MRStateSchema * CheckLastAlarmStateBeforeATime(float _start)
void ReadAlarmIndication(double)
std::string m_alarm_indicator_name
Definition: MRAlarmUnit.h:31
MRValueSchema * FindAPositionReadingConsistantWithASentenceWithinTimeRange(float _start, float _end, SentenceUnit *_sent_pt)
MRValueSchema * FindTheFirstPositionReadingAfterATime(float _end)
MRValueSchema * FindTheLastPositionReadingBeforeATime(float _start)
MRStateSchema * CheckTheFirstComponentStateReadingAfterATime(float _end)
MRValueSchema * FindAPositionReadingInconsitantWithASentenceWithinTimeRange(float _start, float _end, SentenceUnit *_sent_pt)
std::string Control_Value_Indicator_ID
void ReadComponentStateIndication(double)
MRStateSchema * CheckLastComponentStateReadingBeforeATime(float _start)
std::string Component_State_Indicator_ID
MRValueSchema * FindAReadingConsistantWithASentenceWithinTimeRange(float _start, float _end, SentenceUnit *_sent_pt)
void ReadParameterRate(double)
std::string m_parameter_indicator_ID
MRValueSchema * FoundAValueReadingWithinTimeRange(float, float)
std::string m_parameter_rate_indicator_ID
void ReadParameterValue(double)
MRValueSchema * FindAReadingInconsistantWithASentenceWithinTimeRange(float _start, float _end, SentenceUnit *_sent_pt)
MRValueSchema * CheckReadingWithinTimeRange(double, double)
float m_time_perceived
Definition: MRStateSchema.h:11
bool m_perceived_state
Definition: MRStateSchema.h:12
MRStateSchema * CheckLastSupportSystemStateReadingBeforeATime(float _start)
MRStateSchema * CheckTheFirstSupportSystemStateReadingAfterATime(float _end)
float m_time_perceived
Definition: MRValueSchema.h:11
float m_perceived_value
Definition: MRValueSchema.h:14
std::unique_ptr< ReasonMachine > m_RM
Definition: Operator.h:55
std::unique_ptr< KBConcept > m_Concept_Base
Investigator * FindAMatchInvestigatorByKnowledgeElement(KnowledgeElement *, int, int)
InvestigatorLink * FindInvestigatorLinkByID(std::string)
void RemoveItemFromDecayedItemList(IDElement *)
void EraseFromOngoingItemStack(std::string)
void AddNewInvestigatorLink(InvestigatorLink *)
std::vector< Statement * > m_temporary_statement_list
std::vector< Investigator * > m_undetermined_investigator_pool
void AutoIgnitionOfDecayedInvestigatorInitiatedByActivatingAStatement(Statement *)
void WaitOneStepThereIsOneOrMoreOperatorBranches()
std::vector< Investigator * > m_failed_investigator_pool
void AddToRMFeedbackStack(IDElement *)
void AddDeltaToCognitiveLoad(float)
void AddANewStatement(Statement *)
void ZeroAllTheInterestFromSymptomInvestigator()
void RemoveInvestigatorFromUnresolvedPool(Investigator *)
KnowledgeElement * FindKnowledgeElementByID(std::string)
SentenceUnit * FindAnIndefiniteSentenceMatchTheInputSentence(SentenceUnit *)
void AddItemToOngoingItemStack(std::string)
KnowledgeElement * FindAKEbySentenceAndNegationSign(SentenceUnit *, bool)
void EraseItemFromFeedbackStack(IDElement *)
InvestigatorLink * m_working_on_invest_link_pt
std::vector< IDElement * > m_feedback_stack
std::vector< Investigator * > m_cause_undetermined_investigato_pool
KnowledgeElement * FindKnowledgeElementByStatement(Statement *)
IDElement * m_reading_indication_ID_pt
float m_consumed_time
ProblemSolvingStyle m_problem_solving_style
void AddConsumptedDeltaT(double)
void WriteAuxInfo(std::string str)
std::unique_ptr< InstantiationBase > m_IB
Statement * FindStatementByID(std::string)
std::unique_ptr< MentalRepresentation > m_MR
Investigator * FindInvestigatorByID(std::string)
std::vector< IDElement * > m_investigation_trace
SentenceUnit * CheckExistInSemanticPoolBySentence(SentenceUnit *)
std::vector< std::unique_ptr< KnowledgeUnit > > m_Knowledge_list
float CheckRemainingTimeForThisStep()
void FindCorrespondingStatementWithinTimeRange(SentenceUnit *, int, int)
std::unique_ptr< EventSchemaBase > m_event_schema_base
std::vector< Investigator * > m_resolved_investigator_pool
void AddBackToUnresolvedInvestigationPool(Investigator *)
void ChangeRMTokenValue(int)
void CrankASentenceUnitActivationToAGivenValue(SentenceUnit *, float)
Investigator * m_buffer_invest_pt
void AddNewInvestigator(Investigator *)
std::vector< Investigator * > m_success_investigator_pool
SentenceUnit * InstantiateAnIndefiniteSentenceWithLabel(SentenceUnit *, IDElement *)
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
float m_delta_value
Definition: SentenceUnit.h:33
bool WhetherItIsBiState()
IDElement * m_comparison_pt
Definition: SentenceUnit.h:37
IDElement * GetLabelOfThisSentence()
void CopyFromAnotherSentence(SentenceUnit *)
IDElement * m_attribute_pt
Definition: SentenceUnit.h:39
IDElement * m_subject_pt
Definition: SentenceUnit.h:40
IDElement * m_diagnose_invest_ID_pt
Definition: Statement.h:44
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
int m_operator
Definition: Statement.h:32
bool m_tbi_bl
Definition: Statement.h:39
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
KnowledgeUnit * CheckAKnowledgeUnitInTheList(KnowledgeUnit *_KU_pt)
float GetTimeBoundEarlier()
Definition: TimeRange.cpp:79
float m_start_time
Definition: TimeRange.h:21
float m_time_before
Definition: TimeRange.h:19
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 VerifyFromControlPanel
Definition: RMTokens.h:26
constexpr int RequestInfoInit
Definition: RMTokens.h:27
constexpr int FindMatchingStatement
Definition: RMTokens.h:24
constexpr int RetrieveNextLink
Definition: RMTokens.h:33
constexpr int CauseUndetermined
Definition: RMTokens.h:43
constexpr int CauseFound
Definition: RMTokens.h:44
constexpr int SuccessNotHappened
Definition: RMTokens.h:39
constexpr int DecideWhetherToClose
Definition: RMTokens.h:31
constexpr int CheckAvailableFromMR
Definition: RMTokens.h:25
constexpr int ChooseDownstreamLink
Definition: RMTokens.h:30
constexpr int GetCorrespondingKE
Definition: RMTokens.h:23
constexpr int RequestInfoRead
Definition: RMTokens.h:28
constexpr int Undetermined
Definition: RMTokens.h:40
constexpr int NoMatchingKE
Definition: RMTokens.h:41
constexpr int CompareKEAndStatement
Definition: RMTokens.h:29
constexpr int ActiveThreshold
Definition: RMTokens.h:36
constexpr int FailedToExplain
Definition: RMTokens.h:45
constexpr int CauseUndeterminedFeedback
Definition: RMTokens.h:42
constexpr int SearchPossibleCauses
Definition: RMTokens.h:32
constexpr int EvaluateNewFeedback
Definition: RMTokens.h:34
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
OperatorAT Action_Taker
Crew action execution model.
OperatorDM Decision_Maker
Crew decision-making model.
BranchRecord Branch_center
Dynamic event tree state.