diff --git a/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.cpp b/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.cpp index 14985bbf6c..68b40f1368 100644 --- a/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.cpp +++ b/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.cpp @@ -24,6 +24,7 @@ ebc_param_container::ebc_param_container(agent* new_agent, bool pEBC_settings[], pEBC_settings[SETTING_EBC_ALLOW_LOCAL_NEGATIONS] = true; pEBC_settings[SETTING_EBC_ALLOW_OPAQUE] = true; pEBC_settings[SETTING_EBC_ADD_LTM_LINKS] = false; + pEBC_settings[SETTING_AUTOMATICALLY_CREATE_SINGLETONS] = true; pMaxChunks = 50; pMaxDupes = 3; @@ -88,6 +89,8 @@ ebc_param_container::ebc_param_container(agent* new_agent, bool pEBC_settings[], add(interrupt_on_warning); interrupt_on_watched = new soar_module::boolean_param("explain-interrupt", setting_on(SETTING_EBC_INTERRUPT_WATCHED), new soar_module::f_predicate()); add(interrupt_on_watched); + automatically_create_singletons = new soar_module::boolean_param("automatically-create-singletons", setting_on(SETTING_AUTOMATICALLY_CREATE_SINGLETONS), new soar_module::f_predicate()); + add(automatically_create_singletons); // mechanisms mechanism_add_OSK = new soar_module::boolean_param("add-osk", setting_on(SETTING_EBC_ADD_OSK), new soar_module::f_predicate()); @@ -164,6 +167,10 @@ void ebc_param_container::update_ebc_settings(agent* thisAgent, soar_module::boo { thisAgent->explanationBasedChunker->ebc_settings[SETTING_EBC_INTERRUPT_WATCHED] = pChangedParam->get_value(); } + else if (pChangedParam == automatically_create_singletons) + { + thisAgent->explanationBasedChunker->ebc_settings[SETTING_AUTOMATICALLY_CREATE_SINGLETONS] = pChangedParam->get_value(); + } else if (pChangedParam == mechanism_add_OSK) { thisAgent->explanationBasedChunker->ebc_settings[SETTING_EBC_ADD_OSK] = pChangedParam->get_value(); @@ -243,6 +250,7 @@ void ebc_param_container::update_params(bool pEBC_settings[]) mechanism_add_OSK->set_value(pEBC_settings[SETTING_EBC_ADD_OSK] ? on : off); mechanism_add_ltm_links->set_value(pEBC_settings[SETTING_EBC_ADD_LTM_LINKS] ? on : off); allow_missing_negative_reasoning->set_value(pEBC_settings[SETTING_EBC_ALLOW_LOCAL_NEGATIONS] ? on : off); + automatically_create_singletons->set_value(pEBC_settings[SETTING_AUTOMATICALLY_CREATE_SINGLETONS] ? on : off); } void Explanation_Based_Chunker::print_chunking_summary() { @@ -337,6 +345,7 @@ void Explanation_Based_Chunker::print_chunking_settings() outputManager->printa_sf(thisAgent, "singleton %-%-%s\n", "Print all WME singletons"); outputManager->printa_sf(thisAgent, "%s %-%s\n", concatJustified("singleton", " ", 50).c_str(), "Add a WME singleton pattern"); outputManager->printa_sf(thisAgent, "%s %-%s\n", concatJustified("singleton -r", " ", 50).c_str(), "Remove a WME singleton pattern"); + outputManager->printa_sf(thisAgent, "automatically-create-singletons %-%s%-%s\n", capitalizeOnOff(ebc_params->automatically_create_singletons->get_value()), "Attempt creating singletons for every string attribute"); outputManager->printa_sf(thisAgent, "----------------- EBC Mechanisms ------------------\n"); outputManager->printa_sf(thisAgent, "add-ltm-links %-%s%-%s\n", capitalizeOnOff(ebc_params->mechanism_add_ltm_links->get_value()), "Recreate LTM links in original results"); outputManager->printa_sf(thisAgent, "add-osk %-%s%-%s\n", capitalizeOnOff(ebc_params->mechanism_add_OSK->get_value()), "Incorporate operator selection knowledge"); diff --git a/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.h b/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.h index 85f4e293e9..5881ba9a1e 100644 --- a/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.h +++ b/Core/SoarKernel/src/explanation_based_chunking/ebc_settings.h @@ -37,6 +37,7 @@ class ebc_param_container: public soar_module::param_container soar_module::boolean_param* interrupt_on_chunk; soar_module::boolean_param* interrupt_on_warning; soar_module::boolean_param* interrupt_on_watched; + soar_module::boolean_param* automatically_create_singletons; /* Mechanisms */ soar_module::boolean_param* mechanism_add_OSK; diff --git a/Core/SoarKernel/src/shared/enums.h b/Core/SoarKernel/src/shared/enums.h index b3f89bdd02..2befe7289a 100644 --- a/Core/SoarKernel/src/shared/enums.h +++ b/Core/SoarKernel/src/shared/enums.h @@ -152,6 +152,7 @@ enum ChunkingSettings { SETTING_EBC_ALLOW_LOCAL_NEGATIONS, SETTING_EBC_ALLOW_OPAQUE, SETTING_EBC_ADD_LTM_LINKS, + SETTING_AUTOMATICALLY_CREATE_SINGLETONS, num_ebc_settings }; diff --git a/Core/SoarKernel/src/soar_representation/working_memory.cpp b/Core/SoarKernel/src/soar_representation/working_memory.cpp index 625b2bddee..bbd0e59a49 100644 --- a/Core/SoarKernel/src/soar_representation/working_memory.cpp +++ b/Core/SoarKernel/src/soar_representation/working_memory.cpp @@ -245,6 +245,10 @@ void do_buffered_wm_changes(agent* thisAgent) } } #endif + if (thisAgent->explanationBasedChunker->ebc_settings[SETTING_AUTOMATICALLY_CREATE_SINGLETONS] && (w->attr->is_string() && !w->attr->sc->singleton.possible)) + { + thisAgent->explanationBasedChunker->add_new_singleton(ebc_any, w->attr, ebc_any); + } add_wme_to_rete(thisAgent, static_cast(c->first)); } for (c = thisAgent->wmes_to_remove; c != NIL; c = c->rest)