6#include "../Crew/OperatorDM.h"
7#include "../Crew/OperatorAT.h"
9#include "../Global/SimulationContext.h"
40 string file_name, name;
42 string str, str1, str2;
43 int n_Unit, i, j, n_member;
50 vector<IDElement*>::iterator ID_itr;
55 file_name +=
"KB_ODM_Instantiation_Base.txt";}
59 file_name +=
"KB_OAT_Instantiation_Base.txt";}
60 fin.open(file_name.c_str(), ios::in);
62 err_mes =
"can not find file: " + file_name;
69 if(str.compare(
"Number_of_Instantiation_Label_Groups:") != 0)
71 err_mes = str +
" is incorrectly in the position of Number_of_Instantiation_Label_Groups:";
75 for (i = 0; i < n_Unit; i++)
77 auto label_owned = std::make_unique<Label>();
78 label_pt = label_owned.get();
81 if(str.compare(
"Group_Name:") != 0)
83 err_mes = str +
" is incorrectly in the position of Group_Name:";
89 fin >> str >> n_member;
90 if(str.compare(
"Number_of_Members:") != 0)
92 err_mes = str +
" is incorrectly in the position of Number_of_Members:";
97 if(str.compare(
"Member_list:") != 0)
99 err_mes = str +
" is incorrectly in the position of Member_list:";
103 for(j = 0; j < n_member; j++)
110 err_mes =
"could not find " + name +
" in the concept base";
117 fin >> str >> n_Unit;
118 if(str.compare(
"Number_of_Instantiation_Groups:") != 0)
120 err_mes = str +
" is incorrectly in the position of Number_of_Instantiation_Label_Groups:";
124 for(i = 0; i < n_Unit; i++)
126 auto inst_owned = std::make_unique<Instantiation>();
127 Inst_pt = inst_owned.get();
129 if(str.compare(
"Indefinite_Concept:") != 0)
131 err_mes = str +
" is incorrectly in the position of Indefinite_Concept:";
137 err_mes = name +
" already existed in the list";
145 err_mes =
"could not find " + name +
" in the Concept Base";
150 if(str.compare(
"Corresponding_Basic_Group:") != 0)
152 err_mes = str +
" is incorrectly in the position of Corresponding_Basic_Group:";
160 err_mes =
"could not find " + name +
" in the Label list";
164 fin >> str >> n_member;
165 if(str.compare(
"Number_of_Member:") != 0)
167 err_mes = str +
" is incorrectly in the position of Number_of_Member:";
172 if(str.compare(
"Member_list:") != 0)
174 err_mes = str +
" is incorrectly in the position of Member_list:";
178 for(j=0; j<n_member; j++)
182 CC_pt = RM_pt->
m_Concept_Base->checkExistanceOfConceptComposedUnit(name);
185 err_mes =
"could not find " + name +
" in the concept base";
201 err_mes =
"could not find a label option for " + CC_pt->
m_ID;
213 cout <<
r5pars_.timesno <<
" " << str <<
" in InstantiationBase.cpp" <<
'\n';
214 ofstream fout(
"err messages.txt", ios::app);
215 fout <<
r5pars_.timesno <<
" " << str <<
'\n';
222 Label * label_pt = NULL;
225 if(
e->m_lable_name == name)
238 if(
e->m_indefinite_instance_pt->m_ID == name)
248 Label * lb_pt = NULL;
255 if(
e->m_indefinite_instance_pt == CC_pt)
259 lb_pt =
e->m_label_pt;
261 else if(lb_pt !=
e->m_label_pt )
263 this->
ErrorMessage(
"Error: " + _sent_pt->
m_ID +
" contains more than one indefinite items!");
279 if(
e->m_indefinite_instance_pt == CC_pt)
283 lb_pt =
e->m_label_pt;
285 else if(lb_pt !=
e->m_label_pt )
287 this->
ErrorMessage(
"Error: " + _sent_pt->
m_ID +
" contains more than one indefinite items!");
300 Label * found_label_group_pt = NULL;
304 if(found_label_group_pt != NULL)
break;
305 for(
auto *ID_e : label_e->m_label_option_list)
309 found_label_group_pt = label_e.get();
314 return found_label_group_pt;
330 auto label_owned = std::make_unique<Label>();
331 label_owned->CopyLabelInfoFromAnotherLabel(
e.get());
337 this->
ErrorMessage(
"this->m_instantiation_list.size() != 0");
341 auto inst_owned = std::make_unique<Instantiation>();
342 inst_owned->CopyInfoFromAnotherInstantiationGroup(
e.get());
352 e->ConvertLabelInfoToStringForm();
356 e->ConvertInstantiationInfoToString();
367 {
e->BuildConnectionsForThisLabel(_pt);}
371 {
e->BuildConnectionsForThisInstantiation(_pt);}
Diagnostic reasoning engine — knowledge representation, mental model, and inference.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
IDElement * m_Indefinite_Concept_ID_pt
bool CheckWhetherThisConceptContainASubConceptByPt(IDElement *)
IDElement * m_label_ID_pt
virtual ~InstantiationBase()
void ErrorMessage(std::string)
void ReadInstantiationBaseFromInputFile()
Label * CheckWhetherASentenceContainIndefiniteItem(SentenceUnit *)
std::vector< std::unique_ptr< Instantiation > > m_instantiation_list
void ConvertIBInfoToStringForm()
Instantiation * CheckExistanceOfInstantiationGroupByIndefiniteConceptName(std::string)
Label * FindLabelGroupByLabelID(IDElement *)
void BuildConnectionsForTheInstantiationBase(void *)
std::vector< std::unique_ptr< Label > > m_label_list
Label * CheckExistanceOfLabelGroupByName(std::string)
void CopyInstantiationBaseFromAnotherIB(InstantiationBase *_IB_pt)
ConceptComposedUnit * m_indefinite_instance_pt
std::vector< ConceptComposedUnit * > m_instance_list
std::string m_ID_lable_group_name
std::vector< IDElement * > m_label_option_list
std::unique_ptr< ReasonMachine > m_RM
std::unique_ptr< KBConcept > m_Concept_Base
std::string getOATDirectory()
std::string getODMDirectory()
Scheduler SScheduler
Simulation scheduling, parses CLI options.
OperatorAT Action_Taker
Crew action execution model.
OperatorDM Decision_Maker
Crew decision-making model.