14#include "../Crew/OperatorDM.h"
15#include "../Crew/OperatorAT.h"
16#include "../Global/SimulationContext.h"
142 vector<IDElement *>::iterator ID_itr;
144 bool want_to_exam_condition_now =
false;
145 float highest_score = 0;
147 string prompt, err_mes, str;
161 prompt +=
"Retrieving the next Investigator from the InvestigatorLink:\n";
171 for(ID_itr = this->
m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr ++)
175 prompt +=
"\nRetrieve Score: ";
184 if(next_invest_pt == NULL)
186 next_invest_pt = invest_pt;
187 highest_score = score;
189 else if(score > highest_score)
191 next_invest_pt = invest_pt;
192 highest_score = score;
196 prompt += conv.str();
203 want_to_exam_condition_now =
true;
215 if(want_to_exam_condition_now ==
true)
217 next_invest_pt = invest_pt;
218 prompt +=
"Condition KE needs to be investigated!\n";
219 highest_score = score;
224 prompt +=
"\nRetrieve Score: ";
225 if(score > highest_score)
227 next_invest_pt = invest_pt;
232 prompt += conv.str();
239 if(next_invest_pt != NULL)
250 prompt +=
"The retrieved one: ";
263 str +=
": transfer out: to ";
277 string prompt, err_mes;
279 vector<IDElement *>::iterator ID_itr;
282 bool status_determined =
false;
283 bool unknown_cause_exist =
false;
284 bool all_cause_not_happen =
true;
285 bool all_cause_happen =
true;
286 int condition_status = 3;
289 bool has_a_strong_inference =
false;
290 bool has_a_determined_cause =
false;
302 if(this->
m_ID ==
"InvestigatorLink_60")
311 condition_status = invest_pt->
m_Happen;
312 prompt +=
"Condition: ";
317 if(condition_status == 3 || condition_status == 2)
321 prompt +=
"happend\n";
333 prompt +=
"unknown\n";
334 unknown_cause_exist =
true;
335 all_cause_happen =
false;
336 all_cause_not_happen =
false;
340 status_determined =
true;
344 prompt +=
"could not be determined\n";
345 all_cause_happen =
false;
346 all_cause_not_happen =
false;
350 status_determined =
true;
356 prompt +=
"happened\n";
357 all_cause_not_happen =
false;
361 status_determined =
true;
365 {has_a_strong_inference =
true;}
367 {has_a_determined_cause =
true;}
374 prompt +=
"did not happen\n";
375 all_cause_happen =
false;
379 status_determined =
true;
388 if(all_cause_not_happen ==
true)
390 prompt +=
"All the causes did not happen\n";
393 else if(unknown_cause_exist ==
true)
395 prompt +=
"Still more to investigate\n";
400 prompt +=
"One or more causes could not be determined\n";
405 if(condition_status == 2)
407 if(next_status == 1 || next_status == 3)
412 else if(condition_status == 4)
414 prompt +=
"The condition is not satisfied\n";
417 else if(condition_status == 1)
419 prompt +=
"The condition is not known\n";
423 if(condition_status == 3 && this->
m_link_type == 2 && all_cause_happen ==
true)
425 prompt +=
"This inference path goes through.\n";
434 if(has_a_strong_inference ==
true)
440 if(has_a_determined_cause ==
false)
454 if(unknown_cause_exist ==
true )
482 vector<IDElement *>::iterator ID_itr;
517 prompt +=
"Feedback to the downstream investigator";
528 str +=
": transfer out: to ";
539 double highest_activation = 0;
541 vector<IDElement*>::iterator ID_itr;
561 if(activation > highest_activation)
563 highest_activation = activation;
588 float highest_score = 0;
589 vector<IDElement *>::iterator ID_itr;
592 if(this->
m_ID ==
"InvestigatorLink_64")
614 for(ID_itr = this->
m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++)
618 if(score > highest_score)
620 highest_score = score;
653 str +=
": transfer out: to prioritization";
669 vector<IDElement *>::iterator ID_itr;
671 str =
"InvestigatorLink Information: \n";
673 str +=
"Upperstream of this inference Path ";
676 str +=
", OR GATE:\n";
680 str +=
", AND GATE: \n";
686 for(ID_itr = this->
m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++)
694 str +=
"Downstream of this inference path:\n";
703 str+=
"Condition of this inference path:\n";
713 cout <<
"Time: " <<
r5pars_.timesno <<
":\n" << str <<
'\n';
716 ofstream fout(
"RMI.txt", ios::app);
717 fout <<
"\n" <<
"Time: " <<
r5pars_.timesno <<
":\n" << str <<
'\n';
723 cout <<
r5pars_.timesno <<
" " << str <<
" in InvestigatorLink.cpp" <<
'\n';
724 ofstream fout(
"err messages.txt", ios::app);
725 fout <<
r5pars_.timesno <<
" " << str <<
'\n';
732 float confidence = 0;
733 vector<IDElement *>::iterator ID_itr;
735 int number_of_strong_reference = 0;
736 bool unexplored_cause =
false;
750 {number_of_strong_reference++;}
778 unexplored_cause =
false;
779 for(ID_itr = this->
m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++)
783 {unexplored_cause =
true;
break;}
786 if(unexplored_cause ==
true)
817 vector<IDElement *>::iterator ID_itr;
819 for(ID_itr = this->
m_confirmed_invest_ID_list.begin(); ID_itr != this->m_confirmed_invest_ID_list.end() && found_ID_pt == NULL; ID_itr++)
821 if((*ID_itr) == _ID_pt)
823 found_ID_pt = (*ID_itr);
832 vector<IDElement *>::iterator ID_itr;
834 for(ID_itr = this->
m_possible_invest_ID_list.begin(); ID_itr != this->m_possible_invest_ID_list.end() && found_ID_pt == NULL; ID_itr++)
836 if((*ID_itr) == _ID_pt)
838 found_ID_pt = (*ID_itr);
847 vector<IDElement *>::iterator ID_itr;
849 for(ID_itr = this->
m_rejected_invest_ID_list.begin(); ID_itr != this->m_rejected_invest_ID_list.end() && found_ID_pt == NULL; ID_itr++)
851 if((*ID_itr) == _ID_pt)
853 found_ID_pt = (*ID_itr);
924 {this->
ErrorMessage(
"this->m_invest_link_Token_history.size() != 0");
return;}
926 {this->
ErrorMessage(
"this->m_link_token_endtime_history.size() != 0");
return;}
928 {this->
ErrorMessage(
"this->m_upperstream_ID_list.size() != 0");
return;}
930 {this->
ErrorMessage(
"this->m_explanation_ID_list.size() != 0");
return;}
932 {this->
ErrorMessage(
"this->m_confirmed_invest_ID_list.size() != 0");
return;}
934 {this->
ErrorMessage(
"this->m_rejected_invest_ID_list.size() != 0");
return;}
936 {this->
ErrorMessage(
"this->m_possible_invest_ID_list.size() != 0");
return;}
938 {this->
ErrorMessage(
"this->m_thoughtline_roots_list.size() > 0");}
943 vector<int>::iterator int_itr;
951 vector<float>::iterator fl_itr;
971 vector<IDElement *>::iterator ID_itr;
972 vector<string>::iterator str_itr;
991 ID = (*ID_itr)->m_ID;
1008 ID = (*ID_itr)->m_ID;
1025 ID = (*ID_itr)->m_ID;
1042 ID = (*ID_itr)->m_ID;
1059 ID = (*ID_itr)->m_ID;
1089 {this->
ErrorMessage(
"this->m_has_moved_to_invest == NULL");
return;}
1094 if(this->
m_ID_KU.compare(
"") != 0)
1116 if(this->
m_ID_SI.compare(
"") != 0)
1131 vector<string>::iterator str_itr;
1135 for(str_itr = this->
m_ID_upperstream_list.begin(); str_itr != this->m_ID_upperstream_list.end(); str_itr++)
1139 {this->
ErrorMessage(
"could not find the investigator " + *str_itr);
return;}
1143 for(str_itr = this->
m_ID_explanation_list.begin(); str_itr != this->m_ID_explanation_list.end(); str_itr++)
1147 {this->
ErrorMessage(
"could not find the investigator " + *str_itr);
return;}
1155 {this->
ErrorMessage(
"could not find the investigator " + *str_itr);
return;}
1163 {this->
ErrorMessage(
"could not find the investigator " + *str_itr);
return;}
1171 {this->
ErrorMessage(
"could not find the investigator " + *str_itr);
return;}
1179 vector<string>::iterator str_itr;
1180 vector<IDElement *>::iterator ID_itr;
1183 if(this->
m_ID.compare(_line_ID) == 0)
1188 if(_line_ID.compare(*str_itr) == 0)
1197 for(ID_itr = this->
m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr++)
1213 bool within =
false;
1215 vector<string>::iterator str_itr;
1218 if(_line_ID.compare(*str_itr) == 0)
1241 vector<IDElement *>::iterator ID_itr;
1243 bool want_to_exam_condition_now =
false;
1244 float highest_score = 0;
1246 string prompt, err_mes, str;
1257 for(ID_itr = this->
m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr ++)
1268 if(next_invest_pt == NULL)
1270 next_invest_pt = invest_pt;
1271 highest_score = score;
1273 else if(score > highest_score)
1275 next_invest_pt = invest_pt;
1276 highest_score = score;
1288 if(score > highest_score)
1290 next_invest_pt = invest_pt;
1296 if(next_invest_pt != NULL)
1313 if(invest_pt != NULL)
1329 if(invest_pt != NULL)
1338 vector<IDElement *>::iterator ID_itr;
1340 bool want_to_exam_condition_now =
false;
1341 float highest_score = 0;
1343 string prompt, err_mes, str;
1354 for(ID_itr = this->
m_upperstream_ID_list.begin(); ID_itr != this->m_upperstream_ID_list.end(); ID_itr ++)
1365 if(next_invest_pt == NULL)
1367 next_invest_pt = invest_pt;
1368 highest_score = score;
1370 else if(score > highest_score)
1372 next_invest_pt = invest_pt;
1373 highest_score = score;
1385 if(score > highest_score)
1387 next_invest_pt = invest_pt;
1393 if(next_invest_pt != NULL)
1402 vector<IDElement *>::iterator ID_itr;
1403 bool mark_change =
false;
1412 {mark_change =
true;}
1419 {mark_change =
true;}
1422 if(mark_change ==
true)
1440 float confidence, _p;
1441 vector<IDElement *>::iterator ID_itr;
1444 int number_of_strong_reference = 0;
1445 bool unexplored_cause =
false;
1447 vector<string>::iterator str_itr;
1448 vector<float>::iterator fl_itr;
1463 this->
ErrorMessage(
"this->m_pause_confidence_propagation_ID_list.size() != this->m_paused_confidence_passing_list.size()");
1470 {number_of_strong_reference++;}
1480 if(buffer_invest_pt == NULL)
1532 double highest_activation = 0;
1534 vector<IDElement*>::iterator ID_itr;
1554 if(activation > highest_activation)
1556 highest_activation = activation;
1560 return highest_activation;
Diagnostic reasoning engine — knowledge representation, mental model, and inference.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void CopyIDElementToRestartInfo(IDElement *)
float GetActivationOfthisLink()
void OneStepWorkOnThisInvestigatorLink()
float m_link_last_activated_time
std::vector< std::string > m_thoughtline_roots_list
std::vector< std::string > m_ID_explanation_list
std::vector< std::string > m_pause_confidence_propagation_ID_list
std::vector< float > m_paused_confidence_passing_list
IDElement * CheckExistenceInTheRejectedInvestList(IDElement *_ID_pt)
bool m_inference_direction_reverse_bl
std::vector< std::string > m_ID_confirmed_invest_list
IDElement * m_condition_ID_pt
std::vector< std::string > m_ID_possible_invest_list
void ResetTheLastActivationTimeOfTheNextToBeRetrievedInvestigator()
void BoostActivationOfThisLinkByActiveDiagnosisInvestigation()
KnowledgeUnit * m_K_unit_pt
bool CheckWhetherInAThoughtLine(std::string)
IDElement * CheckExistenceInTheConfirmedInvestList(IDElement *_ID_pt)
bool m_invest_link_dormant
std::vector< std::string > m_ID_upperstream_list
void ErrorMessage(std::string)
bool m_is_inference_path_bl
bool m_has_feedback_to_downstream
void ChangeInvestigatorLinkToken(int)
std::vector< IDElement * > m_confirmed_invest_ID_list
std::string GetASimpleDescriptionOfTheInvestigatorLink()
float m_interest_from_SymptomInvestigator
double CalculateBackwardRetrievalScore()
void PrintMessage(std::string)
std::vector< IDElement * > m_possible_invest_ID_list
std::string m_ID_downstream
void FeedBackToDownstreamInvestigator310331043105()
void CrankTheNextLikelyRetrievedInvestigatorActivationToOne()
virtual ~InvestigatorLink()
std::vector< std::string > m_note_list
void CheckThePathStatus3102()
void CopyInvestigatorLinkInfoFromAnother(InvestigatorLink *)
void UpdateMHappenIncomplete()
void TransferOutOfThisInvestigatorLink3110()
bool m_is_a_strong_inference
void FinishThePausedConfidencePropagationBeforeCloseInvestigatorLink()
std::vector< int > m_invest_link_Token_history
std::unique_ptr< Activation > m_dummy_activation
std::string m_ID_has_moved_to_invest
void SetAdummyActivation()
std::vector< std::string > m_ID_rejected_invest_list
std::vector< IDElement * > m_explanation_ID_list
IDElement * m_downstream_ID_pt
void AttachThoughtLineToThisLink(std::string)
float GetDownstreamInitiationTimeOrStatementTime()
void BuildConnectionsToThisInvestigatorLink(void *)
void BackwardPropagateConfidenceLevel(float _p)
IDElement * m_has_moved_to_invest
std::vector< IDElement * > m_upperstream_ID_list
std::vector< float > m_link_token_endtime_history
void RetrieveTheNextLikelyInvestigator3101()
void AddTimeConsumptionInInvestigatorLink(double)
float CalculateFilteredPrioritizingScoreOfInvestigatorLink()
void MarkMHappenIncompleteTrue()
void BoostAttentionOfThisFromDiagnosisInvestigation(float, bool)
std::vector< IDElement * > m_rejected_invest_ID_list
IDElement * CheckExistenceInThePossibleInvestList(IDElement *_ID_pt)
std::string m_ID_condition
void UpdateHappenExplainIncomeplete()
void AttachThoughtLineToThisInvestigator(std::string)
void BackwardPropagateConfidenceLevel(float _p)
void BoostAttentionofThisByDiagnosisInvestigation(float, bool)
std::string GetASimpleDescriptionOfThisInvestigator()
IDElement * m_KElement_ID_pt
void CrankTheActivationToOne()
float m_interest_from_SymptomInvestigator
void BoostActivationOfThisByActiveDiagnosisInvestigation()
float CalculatePriorityScoreEvenDormantOrPaused()
float GetInitiationTimeOrStatementTimeOrLastActiveTime()
Statement * m_Statement_pt
SentenceUnit * m_SentenceUnit_pt
double m_backward_retrieve_weight
std::unique_ptr< ReasonMachine > m_RM
KnowledgeUnit * FindKnowledgeUnitByID(std::string)
void EraseFromOngoingItemStack(std::string)
Investigator * m_working_on_invest_pt
void AddToRMFeedbackStack(IDElement *)
void ZeroAllTheInterestFromSymptomInvestigator()
void EraseItemFromFeedbackStack(IDElement *)
ProblemSolvingStyle m_problem_solving_style
void AddConsumptedDeltaT(double)
Investigator * FindInvestigatorByID(std::string)
std::vector< IDElement * > m_investigation_trace
std::unique_ptr< EventSchemaBase > m_event_schema_base
void ChangeRMTokenValue(int)
Investigator * m_buffer_invest_pt
constexpr int FeedbackDetermined
constexpr int RetrieveNextInvestigator
constexpr int FeedbackUndetermined
constexpr int FeedbackPartial
constexpr int CheckPathStatus
constexpr int TransferOut
constexpr int GetCorrespondingKE
constexpr int WorkOnInvestigator
OperatorAT Action_Taker
Crew action execution model.
OperatorDM Decision_Maker
Crew decision-making model.