Skip to content

Commit

Permalink
new setting that makes soar turn any string attribute into a singleto…
Browse files Browse the repository at this point in the history
…n pattern, set to "on" by default
  • Loading branch information
scijones committed Mar 22, 2024
1 parent 018a547 commit 71e1167
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<boolean>());
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<boolean>());
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<boolean>());
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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", "<type> <attribute> <type>", 50).c_str(), "Add a WME singleton pattern");
outputManager->printa_sf(thisAgent, "%s %-%s\n", concatJustified("singleton -r", "<type> <attribute> <type>", 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Core/SoarKernel/src/shared/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
4 changes: 4 additions & 0 deletions Core/SoarKernel/src/soar_representation/working_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wme_struct*>(c->first));
}
for (c = thisAgent->wmes_to_remove; c != NIL; c = c->rest)
Expand Down

0 comments on commit 71e1167

Please sign in to comment.