11#include "../Scheduler/Scheduler.h"
12#include "../Global/TermConversions.h"
16#include "../Crew/OperatorDM.h"
17#include "../Crew/OperatorAT.h"
18#include "../Global/SimulationContext.h"
83 string directory, str, str1, str2, str_ID, file_name;
91 int i, j, n_Unit, n_type, n_member;
97 file_name +=
"KB_ODM_Concept_Base.txt";}
101 file_name +=
"KB_OAT_Concept_Base.txt";}
104 err_mes =
"could not identify the operator in KBConcept::ReadKBConceptInfoFromInputFile()";
108 fin.open(file_name.c_str(), ios::in);
110 err_mes =
"File: " + file_name +
" cound not be found";
118 fin >> str >> n_Unit;
119 for (i = 0; i < n_Unit; i++){
120 fin >> str1 >> str2 >> n_type;
123 if (ConceptBasicUnit_pt1 != NULL)
125 err_mes = str1 +
" already existed";
130 auto basic_owned = std::make_unique<ConceptBasicUnit>();
131 basic_owned->m_ID = str1;
132 basic_owned->m_content = str2;
133 basic_owned->m_concept_type = n_type;
139 fin >> str >> n_Unit;
141 if(str.compare(
"No_of_Composed_Concept") != 0)
143 err_mes =
"format error at No_of_Composed_Concept";
146 for (i = 0; i < n_Unit; i++)
152 if ((ConceptBasicUnit_pt != NULL) || (ConceptComposedUnit_pt != NULL))
154 err_mes = str_ID +
" Already Existed " +
"Error location: KBConcept::ReadKBConceptInfoFromInputFile";
158 auto composed_owned = std::make_unique<ConceptComposedUnit>();
159 ConceptComposedUnit_pt = composed_owned.get();
160 ConceptComposedUnit_pt->
m_ID = str_ID;
167 err_mes =
"Core concept of " + str_ID +
":" + str +
" does not exist";
174 for (j = 0; j < n_member; j++){
177 if(ConceptBasicUnit_pt != 0)
184 if (ConceptComposedUnit_pt2 == NULL)
186 err_mes =
"specification concept of " + str_ID +
":" + str +
" does not exist";
379 vector<IDElement *> antonym_list;
386 bool IsAntonyms=
true;
392 string directory, str, str1, file_name, ID_str1, ID_str2;
399 vector<string> antonym_group;
400 vector<string>::iterator str_itr1, str_itr2;
401 int i, j, n_Unit, n1;
407 file_name +=
"KB_ODM_Antonym_Base.txt";}
411 file_name +=
"KB_OAT_Antonym_Base.txt";}
414 err_mes =
"could not identify the operator in KBConcept::ReadAntonymBaseFromInputFile()";
418 fin.open(file_name.c_str(), ios::in);
420 err_mes =
"file: " + file_name +
" cound not be found";
427 fin >> str >> n_Unit;
428 for(i = 0; i<n_Unit; i++)
432 antonym_group.clear();
433 for(j = 0; j < n1; j++)
436 antonym_group.push_back(str);
439 for(str_itr1 = antonym_group.begin(); str_itr1 != antonym_group.end(); str_itr1++)
443 if(ConceptB_pt1 == NULL)
445 err_mes =
"Could not find" + ID_str1 +
"Location: KBConcept::ReadAntonymBaseFromInputFile()";
449 for(str_itr2 = antonym_group.begin(); str_itr2 != antonym_group.end(); str_itr2++)
453 if(ConceptB_pt2 == NULL)
455 err_mes =
"Could not find" + ID_str2 +
"Location: KBConcept::ReadAntonymBaseFromInputFile()";
458 if(ID_str1 != ID_str2)
484 ratio = pow(B_pt->m_change_ratio,
float(1/n));
503 e->ActivationDecay(_lamda);
508 e->ActivationDecay(_lamda);
530 ratio = pow(C_pt1->m_change_ratio,
float(1/n));
538 (*C_itr1)->ResetChangeRatio();
547 vector<ConceptComposedUnit *>::iterator C_itr;
548 vector<IDElement *>::iterator ID_itr;
550 double ratio1, ratio2;
559 ratio2 = pow(ratio1,
float(1/n));
568 (*C_itr)->ResetChangeRatio();
576 vector<ConceptBasicUnit *>::iterator B_itr;
580 if((*B_itr) == _B_pt)
588 vector<ConceptComposedUnit *>::iterator C_itr;
593 if((*C_itr) == _C_pt)
629 vector<ConceptBasicUnit *>::iterator B_itr;
640 vector<ConceptComposedUnit *>::iterator C_itr;
653 e->m_change_ratio = 1;
662 e->m_change_ratio = 1;
680 if(
e->m_activation !=
e->m_old_activation)
682 e->UpdateChangeRatio();
690 cout <<
r5pars_.timesno <<
" " << str <<
" in KBConcept.cpp" <<
'\n';
691 ofstream fout(
"err messages.txt", ios::app);
692 fout <<
r5pars_.timesno <<
" " << str <<
'\n';
720 this->
ErrorMessage(
"The Basic Concept List is not empty and not ready for the copy action!");
724 auto bc_owned = std::make_unique<ConceptBasicUnit>();
725 bc_owned->CopyConceptBasicUnitToRestartInfo(
e.get());
733 this->
ErrorMessage(
"The Composit Concept List is not empty and not ready for the copy action!");
738 auto cc_owned = std::make_unique<ConceptComposedUnit>();
739 cc_owned->CopyInfoFromAnotherConceptComposedUnit(
e.get());
746 this->
ErrorMessage(
"The data array is not empty at the begining!");
751 auto data_owned = std::make_unique<KBConceptBaseDataSetUnit>();
752 data_owned->CopyFromAnotherKBConceptBaseDataSetUnit(
e.get());
763 vector<string >::iterator ID_itr;
776 this->
ErrorMessage(
"Problem with reconstructing the antonym pointers");
783 this->
ErrorMessage(
"could not find the antonym concept " + (*ID_itr));
811 this->
ErrorMessage(
"could not find the antonym concept " + (*ID_itr));
821 this->
ErrorMessage(
"Problem with reconstructing the antonym pointers");
828 this->
ErrorMessage(
"could not find the antonym concept " + (*ID_itr));
854 this->
ErrorMessage(
"Could not find the corresponding label for the concept " + CC_pt->
m_ID);
865 e->ConvertPointerConnectionToStringForm();
872 vector<string>::iterator str_itr;
890 {this->
ErrorMessage(
"could not find BasicConceptUnit " + *str_itr);
return;}
934 {this->
ErrorMessage(
"could not find the antonym concept " + *str_itr);
return;}
942 {this->
ErrorMessage(
"could not find the defining concept " + *str_itr);
return;}
957 auto data_owned = std::make_unique<KBConceptBaseDataSetUnit>();
976 data_unit->
m_value_list.push_back(s->m_activation_baseline);
983 vector<float>::iterator fl_itr;
991 ofstream fout(_path.c_str(), ios::out);
995 fout <<
"Time" <<
'\t';
998 fout <<
e->m_ID <<
'\t';
1003 fout <<
e->m_ID <<
'\t';
1008 fout << s->m_ID <<
'\t';
1009 fout << s->m_ID +
": base_line" <<
'\t';
1016 fout <<
e->m_data_time <<
'\t';
1017 for(fl_itr =
e->m_value_list.begin(); fl_itr !=
e->m_value_list.end(); fl_itr++)
1019 fout << (*fl_itr) <<
'\t';
1044 e->m_old_activation =
e->m_activation;
1049 e->m_old_activation =
e->m_activation;
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void ChangeActivationByRatio(float)
std::vector< std::string > m_antonym_ID_list
std::vector< IDElement * > m_antonym_list
IDElement * m_Indefinite_Concept_ID_pt
std::vector< IDElement * > m_Spec_array
bool CheckWhetherContainThisConceptDirectly(IDElement *)
std::vector< std::string > m_ID_antonym_list
std::string m_ID_indefinite
std::vector< IDElement * > m_antonym_list
std::vector< std::string > m_ID_spec_list
IDElement * m_label_ID_pt
std::vector< float > m_value_list
void ActivationDecayOfConcept(double)
std::vector< ConceptBasicUnit * > m_BasicConcept_updated_list
std::vector< IDElement * > getAntonymList(IDElement *)
void CleanConceptBasicUnitUpdateList()
IDElement * m_increase_pt
bool CheckExistingInConceptBasicUnitUpdateList(ConceptBasicUnit *)
void SetActivationChangeOfConceptComposedUnitsBackToOne()
void PropagateActivationFromBasicConceptToComposedConcept()
IDElement * getTurnOffPt()
std::vector< ConceptComposedUnit * > m_ComposedConcept_updated_list
void ReconstructThePointerLinks(void *)
void ReadKBConceptInfoFromInputFile()
void CopyStaticKBConceptFromAnother(KBConcept *)
void ConvertConnectionToStringForm()
IDElement * getDecreasePt()
std::vector< std::unique_ptr< ConceptComposedUnit > > m_ComposedConcept_list
void SetAllConceptActivationChangeBackToOneAndCleanTheUpdateList()
IDElement * m_close_smaller_pt
bool CheckExistingInConceptComposedUnitUpdateList(ConceptComposedUnit *)
bool checkWhetherAntonyms(IDElement *, IDElement *)
IDElement * m_turn_off_pt
void PropagateActivationAmongConceptsTopDown()
void SaveActivationToOldActivationVariable()
void CleanConceptComposedUnitUpdateList()
ConceptComposedUnit * checkExistanceOfConceptComposedUnit(std::string)
IDElement * getTurnOnPt()
IDElement * getOpenBiggerPt()
void BuidConnectionsWithinKBConcept()
IDElement * m_decrease_pt
IDElement * FindConceptByID(std::string)
void AddDataSetOfTheConceptBase()
ConceptBasicUnit * checkExistanceOfConceptBasicUnit(std::string)
void SetActivationChangeOfConceptBasicUnitsBackToOne()
IDElement * getIncreasePt()
IDElement * m_open_bigger_pt
void ReadAntonymBaseFromInputFile()
void PropagateActivationAmongComposedConceptBottomUp()
IDElement * getBiggerPt()
void ChangeActivationByConceptID(IDElement *, double)
IDElement * getCloseSmallerPt()
void SaveConceptActivationIntoOutputFile(std::string)
IDElement * getStablePt()
void FillTheConceptCompsedUnitUpdateList()
IDElement * CheckExistanceOfConcept(std::string)
std::vector< std::unique_ptr< KBConceptBaseDataSetUnit > > m_data_array
std::vector< std::unique_ptr< ConceptBasicUnit > > m_BasicConcept_list
void ErrorMessage(std::string)
IDElement * getSmallerPt()
std::unique_ptr< ReasonMachine > m_RM
std::vector< std::unique_ptr< SentenceUnit > > m_Semantic_list
std::unique_ptr< InstantiationBase > m_IB
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.