Skip to content

Commit

Permalink
Merge pull request #442 from SoarGroup/singletons-setting-unit-tests-fix
Browse files Browse the repository at this point in the history
Singletons setting unit tests fix
  • Loading branch information
scijones committed May 1, 2024
2 parents 873fc7e + 4fc44ac commit d0dfcc8
Show file tree
Hide file tree
Showing 42 changed files with 266 additions and 216 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ sp {answer*process-column*apply*write-result*t1012-1
(<c1> -^new-digit1 <n1> ^digit2 <d1> ^digit1 { <d2> < <d1> }
^next-column <n2>)
(<o1> ^name process-column)
(<t1> ^one-fact <o2> ^one-fact <o3>)
(<n2> ^new-digit1 <n3> ^digit1 { <d3> < <o3> } ^next-column <n4>)
(<t1> ^one-fact <o2>)
(<n2> ^new-digit1 <n3> ^digit1 { <d3> < <o2> } ^next-column <n4>)
(<n4> ^new-digit1 <n5> ^digit1 { <d4> >= <o2> })
(<a3> ^add10-facts <a4> ^add10-facts <a5>)
(<a4> ^digit1 <d2> ^digit-10 { <d5> >= <d1> })
(<a5> ^digit1 <d3> ^digit-10 { <d6> >= <o3> })
(<a5> ^digit1 <d3> ^digit-10 { <d6> >= <o2> })
(<a2> ^subtraction-facts <s2> ^subtraction-facts <s3>
^subtraction-facts <s4>)
(<s2> ^digit2 <d1> ^digit1 <d5> ^result <r1>)
(<s3> ^digit2 <o3> ^digit1 <d6> ^result <n3>)
(<s3> ^digit2 <o2> ^digit1 <d6> ^result <n3>)
(<s4> ^digit2 <o2> ^digit1 <d4> ^result <n5>)
-->
(<c1> ^result <r1> +)
Expand All @@ -37,15 +37,15 @@ sp {answer*compute-result*apply*add-ten*OpNoChange*t1010-1
^digit1 { <d2> < <d1> } ^current-column <c1> ^arithmetic <a1>
^arithmetic <a2>)
(<o1> ^name compute-subtraction-borrow-result)
(<t1> ^one-fact <o2> ^one-fact <o3>)
(<t1> ^one-fact <o2>)
(<c1> ^next-column <n1>)
(<n1> ^new-digit1 <n2> ^digit1 { <d3> < <o3> } ^next-column <n3>)
(<n1> ^new-digit1 <n2> ^digit1 { <d3> < <o2> } ^next-column <n3>)
(<n3> ^new-digit1 <n4> ^digit1 { <d4> >= <o2> })
(<a1> ^add10-facts <a3> ^add10-facts <a4>)
(<a3> ^digit1 <d2> ^digit-10 <d5>)
(<a4> ^digit1 <d3> ^digit-10 { <d6> >= <o3> })
(<a4> ^digit1 <d3> ^digit-10 { <d6> >= <o2> })
(<a2> ^subtraction-facts <s2> ^subtraction-facts <s3>)
(<s2> ^digit2 <o3> ^digit1 <d6> ^result <n2>)
(<s2> ^digit2 <o2> ^digit1 <d6> ^result <n2>)
(<s3> ^digit2 <o2> ^digit1 <d4> ^result <n4>)
-->
(<s1> ^digit1 <d2> - ^digit1 <d5> +)
Expand All @@ -58,13 +58,13 @@ sp {answerx2*compute-result*apply*borrow*t1009-2
(<c1> -^new-digit1 <n1> ^digit2 <d1> ^digit1 { <d2> < <d1> }
^next-column <n2>)
(<o1> ^name process-column)
(<t1> ^one-fact <o2> ^one-fact <o3>)
(<n2> ^digit1 { <d3> < <o3> } ^next-column <n3>)
(<t1> ^one-fact <o2>)
(<n2> ^digit1 { <d3> < <o2> } ^next-column <n3>)
(<n3> ^new-digit1 <n4> ^digit1 { <d4> >= <o2> })
(<a2> ^add10-facts <a4>)
(<a4> ^digit1 <d3> ^digit-10 { <d5> >= <o3> })
(<a4> ^digit1 <d3> ^digit-10 { <d5> >= <o2> })
(<a3> ^subtraction-facts <s2> ^subtraction-facts <s3>)
(<s2> ^digit2 <o3> ^digit1 <d5> ^result <r1>)
(<s2> ^digit2 <o2> ^digit1 <d5> ^result <r1>)
(<s3> ^digit2 <o2> ^digit1 <d4> ^result <n4>)
-->
(<n2> ^new-digit1 <r1> +)
Expand All @@ -74,14 +74,14 @@ sp {answer*compute-result*apply*borrow*OpNoChange*t1009-1
(state <s1> ^operator <o1> ^top-state <t1> ^current-column <c1>
^arithmetic <a1> ^arithmetic <a2>)
(<o1> ^name compute-subtraction-borrow-result)
(<t1> ^one-fact <o2> ^one-fact <o3>)
(<t1> ^one-fact <o2>)
(<c1> ^next-column <n1>)
(<n1> ^digit1 { <d1> < <o3> } ^next-column <n2>)
(<n1> ^digit1 { <d1> < <o2> } ^next-column <n2>)
(<n2> ^new-digit1 <n3> ^digit1 { <d2> >= <o2> })
(<a2> ^add10-facts <a3>)
(<a3> ^digit1 <d1> ^digit-10 { <d3> >= <o3> })
(<a3> ^digit1 <d1> ^digit-10 { <d3> >= <o2> })
(<a1> ^subtraction-facts <s2> ^subtraction-facts <s3>)
(<s2> ^digit2 <o3> ^digit1 <d3> ^result <r1>)
(<s2> ^digit2 <o2> ^digit1 <d3> ^result <r1>)
(<s3> ^digit2 <o2> ^digit1 <d2> ^result <n3>)
-->
(<n1> ^new-digit1 <r1> +)
Expand All @@ -94,8 +94,8 @@ sp {answerx3*compute-result*apply*borrow*t1007-2
(<c1> -^new-digit1 <n1> ^digit2 <d1> ^digit1 { <d2> < <d1> }
^next-column <n2>)
(<o1> ^name process-column)
(<t1> ^one-fact <o2> ^one-fact <o3>)
(<n2> ^digit1 { <d3> < <o3> } ^next-column <n3>)
(<t1> ^one-fact <o2>)
(<n2> ^digit1 { <d3> < <o2> } ^next-column <n3>)
(<n3> ^digit1 { <d4> >= <o2> })
(<a2> ^subtraction-facts <s2>)
(<s2> ^digit2 <o2> ^digit1 <d4> ^result <r1>)
Expand All @@ -107,9 +107,9 @@ sp {answerx2*compute-result*apply*borrow*OpNoChange*t1007-1
(state <s1> ^operator <o1> ^top-state <t1> ^current-column <c1>
^arithmetic <a1>)
(<o1> ^name compute-subtraction-borrow-result)
(<t1> ^one-fact <o2> ^one-fact <o3>)
(<t1> ^one-fact <o2>)
(<c1> ^next-column <n1>)
(<n1> ^digit1 { <d1> < <o3> } ^next-column <n2>)
(<n1> ^digit1 { <d1> < <o2> } ^next-column <n2>)
(<n2> ^digit1 { <d2> >= <o2> })
(<a1> ^subtraction-facts <s2>)
(<s2> ^digit2 <o2> ^digit1 <d2> ^result <r1>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sp {answer*selection*select*success-evaluation-becomes-best-preference*t28-1
(state <s1> ^name blocks-world ^object <o1> ^object <o2>
^object { <o3> <> <o2> <> <o1> } ^object { <o4> <> <o1> <> <o3> }
^problem-space <p1> ^desired <d1> ^ontop <o5> ^ontop <o6>
^ontop <o7> ^operator <o14> +)
^ontop <o7> ^operator <o11> +)
(<o1> ^name C ^type block)
(<o2> ^name table ^type table)
(<o3> ^name B ^type block)
Expand All @@ -12,25 +12,21 @@ sp {answer*selection*select*success-evaluation-becomes-best-preference*t28-1
(<o5> ^top-block <o4> ^bottom-block { <b1> <> <o3> })
(<o6> ^top-block <o1> ^bottom-block { <b2> <> <o2> })
(<o7> ^top-block <o3> ^bottom-block { <b3> <> <o1> })
(<d1> ^ontop <o8> ^ontop <o9> ^ontop <o10> ^ontop <o11> ^ontop <o12>
^ontop <o13>)
(<d1> ^ontop <o8> ^ontop <o9> ^ontop <o10>)
(<o8> ^top-block <o4> ^bottom-block <o3>)
(<o9> ^top-block <o4> ^bottom-block <o3>)
(<o10> ^top-block <o3> ^bottom-block <o1>)
(<o11> ^top-block <o1> ^bottom-block <o2>)
(<o12> ^top-block <o3> ^bottom-block <o1>)
(<o13> ^top-block <o1> ^bottom-block <o2>)
(<o14> ^destination <o2> ^moving-block <o1> ^name move-block)
(<o9> ^top-block <o3> ^bottom-block <o1>)
(<o10> ^top-block <o1> ^bottom-block <o2>)
(<o11> ^destination <o2> ^moving-block <o1> ^name move-block)
-->
(<s1> ^operator <o14> >)
(<s1> ^operator <o11> >)
}

sp {answer*selection*select*success-evaluation-becomes-best-preference*t26-2

(state <s1> ^name blocks-world ^object <o1> ^object <o2>
^object { <> <o3> <o3> <> <o1> } ^object { <o4> <> <o1> <> <o3> }
^problem-space <p1> ^desired <d1> ^ontop <o5> ^ontop <o6>
^ontop <o7> ^operator <o14> +)
^ontop <o7> ^operator <o11> +)
(<o1> ^name C ^type block)
(<o2> ^name table ^type table)
(<o3> ^name B ^type block)
Expand All @@ -39,17 +35,13 @@ sp {answer*selection*select*success-evaluation-becomes-best-preference*t26-2
(<o5> ^top-block <o4> ^bottom-block { <b1> <> <o3> })
(<o6> ^top-block <o1> ^bottom-block { <> <b2> <b2> })
(<o7> ^top-block <o3> ^bottom-block { <> <b3> <b3> })
(<d1> ^ontop <o8> ^ontop <o9> ^ontop <o10> ^ontop <o11> ^ontop <o12>
^ontop <o13>)
(<d1> ^ontop <o8> ^ontop <o9> ^ontop <o10>)
(<o8> ^top-block <o4> ^bottom-block <o3>)
(<o9> ^top-block <o4> ^bottom-block <o3>)
(<o10> ^top-block <o3> ^bottom-block <o1>)
(<o11> ^top-block <o1> ^bottom-block <o2>)
(<o12> ^top-block <o3> ^bottom-block <o1>)
(<o13> ^top-block <o1> ^bottom-block <o2>)
(<o14> ^destination <o2> ^moving-block <o1> ^name move-block)
(<o9> ^top-block <o3> ^bottom-block <o1>)
(<o10> ^top-block <o1> ^bottom-block <o2>)
(<o11> ^destination <o2> ^moving-block <o1> ^name move-block)
-->
(<s1> ^operator <o14> >)
(<s1> ^operator <o11> >)
}

sp {answer*evaluate-operator*elaborate*symbolic-evaluation*from-subgoal*Tie*t26-1
Expand All @@ -71,14 +63,10 @@ sp {answer*evaluate-operator*elaborate*symbolic-evaluation*from-subgoal*Tie*t26-
(<o5> ^top-block <m1> ^bottom-block { <b2> <> <d1> })
(<o6> ^top-block <o2> ^bottom-block { <b3> <> <m1> })
(<e1> ^desired <d2>)
(<d2> ^ontop <o7> ^ontop <o8> ^ontop <o9> ^ontop <o10> ^ontop <o11>
^ontop <o12>)
(<d2> ^ontop <o7> ^ontop <o8> ^ontop <o9>)
(<o7> ^top-block <o3> ^bottom-block <o2>)
(<o8> ^top-block <o3> ^bottom-block <o2>)
(<o9> ^top-block <o2> ^bottom-block <m1>)
(<o10> ^top-block <m1> ^bottom-block <d1>)
(<o11> ^top-block <o2> ^bottom-block <m1>)
(<o12> ^top-block <m1> ^bottom-block <d1>)
(<o8> ^top-block <o2> ^bottom-block <m1>)
(<o9> ^top-block <m1> ^bottom-block <d1>)
-->
(<e1> ^symbolic-value success)
}
Expand All @@ -88,7 +76,7 @@ sp {answer*selection*select*success-evaluation-becomes-best-preference*t20-2
(state <s1> ^name blocks-world ^object { <> <o1> <o1> } ^object <o2>
^object { <> <o3> <o3> <> <o1> } ^object { <o4> <> <o1> <> <o3> }
^problem-space <p1> ^desired <d1> ^ontop <o5> ^ontop <o6>
^ontop <o7> ^operator <o14> +)
^ontop <o7> ^operator <o11> +)
(<o1> ^name C ^type block)
(<o2> ^name table ^type table)
(<o3> ^name B ^type block)
Expand All @@ -97,17 +85,13 @@ sp {answer*selection*select*success-evaluation-becomes-best-preference*t20-2
(<o5> ^top-block <o4> ^bottom-block { <b1> <> <o3> })
(<o6> ^top-block <o1> ^bottom-block { <> <b2> <b2> })
(<o7> ^top-block <o3> ^bottom-block { <> <b3> <b3> })
(<d1> ^ontop <o8> ^ontop <o9> ^ontop <o10> ^ontop <o11> ^ontop <o12>
^ontop <o13>)
(<d1> ^ontop <o8> ^ontop <o9> ^ontop <o10>)
(<o8> ^top-block <o4> ^bottom-block <o3>)
(<o9> ^top-block <o4> ^bottom-block <o3>)
(<o10> ^top-block <o3> ^bottom-block <o1>)
(<o11> ^top-block <o1> ^bottom-block <o2>)
(<o12> ^top-block <o3> ^bottom-block <o1>)
(<o13> ^top-block <o1> ^bottom-block <o2>)
(<o14> ^destination <o2> ^moving-block <o1> ^name move-block)
(<o9> ^top-block <o3> ^bottom-block <o1>)
(<o10> ^top-block <o1> ^bottom-block <o2>)
(<o11> ^destination <o2> ^moving-block <o1> ^name move-block)
-->
(<s1> ^operator <o14> >)
(<s1> ^operator <o11> >)
}

sp {answer*evaluate-operator*elaborate*symbolic-evaluation*from-subgoal*Tie*t20-1
Expand All @@ -129,14 +113,10 @@ sp {answer*evaluate-operator*elaborate*symbolic-evaluation*from-subgoal*Tie*t20-
(<o5> ^top-block <m1> ^bottom-block { <b2> <> <d1> })
(<o6> ^top-block <o2> ^bottom-block { <b3> <> <m1> })
(<e1> ^desired <d2>)
(<d2> ^ontop <o7> ^ontop <o8> ^ontop <o9> ^ontop <o10> ^ontop <o11>
^ontop <o12>)
(<d2> ^ontop <o7> ^ontop <o8> ^ontop <o9>)
(<o7> ^top-block <o3> ^bottom-block <o2>)
(<o8> ^top-block <o3> ^bottom-block <o2>)
(<o9> ^top-block <o2> ^bottom-block <m1>)
(<o10> ^top-block <m1> ^bottom-block <d1>)
(<o11> ^top-block <o2> ^bottom-block <m1>)
(<o12> ^top-block <m1> ^bottom-block <d1>)
(<o8> ^top-block <o2> ^bottom-block <m1>)
(<o9> ^top-block <m1> ^bottom-block <d1>)
-->
(<e1> ^symbolic-value success)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
sp {answer*blocks-world*apply*operator*move-block*change-ontop*OpNoChange*t4-1
(state <s1> ^inplace-object <i1> ^clear <i1> ^operator <o1> ^ontop <o2>
^clear <t1>)
(<o1> ^name move-block ^destination <d1>)
(<o2> ^bottom-block <d1> ^top-block { <t1> <> <i1> }
^bottom-block { <b1> <> <i1> })
(<o1> ^name move-block ^destination { <d1> <> <i1> })
(<o2> ^bottom-block <d1> ^top-block { <t1> <> <i1> })
-->
(<o2> ^bottom-block <i1> + ^bottom-block <b1> -)
(<o2> ^bottom-block <i1> + ^bottom-block <d1> -)
}


Expand Down
Loading

0 comments on commit d0dfcc8

Please sign in to comment.