1 #include <portability.h>
47 #include "soar_TraceNames.h"
53 using namespace soar_TraceNames;
72 #define add_results_if_needed(thisAgent, sym) \
73 { if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE) \
74 if ( ((sym)->id.level >= thisAgent->results_match_goal_level) && \
75 ((sym)->id.tc_num != thisAgent->results_tc_number) ) \
76 add_results_for_id(thisAgent, sym); }
93 if (p->
id!=pref->
id)
continue;
184 if ((*sym)->id.smem_lti !=
NIL)
187 (*sym)->id.variablization = (*sym);
202 prefix[0] =
static_cast<char>(tolower((*sym)->id.name_letter));
205 (*sym)->id.variablization = var;
239 for (; cond!=
NIL; cond=cond->
next) {
240 switch (cond->
type) {
256 Symbol *id, *attr, *val, *ref;
258 if (!pref)
return NIL;
259 allocate_with_pool (thisAgent, &thisAgent->
action_pool, &a);
380 next_in_bucket, prev_in_bucket);
387 cc, next_in_bucket, prev_in_bucket);
461 print_string (thisAgent,
"\n\n*** Adding Grounded Negated Conditions ***\n");
514 *dest_top = first_cc;
515 *dest_bottom = prev_cc;
528 list *instantiations_with_nots,
532 not_struct *n1, *n2, *new_not, *collected_nots;
535 collected_nots =
NIL;
536 while (instantiations_with_nots) {
537 c = instantiations_with_nots;
538 instantiations_with_nots = c->
rest;
543 if (n1->
s1->
id.
tc_num != tc_of_grounds)
continue;
544 if (n1->
s2->
id.
tc_num != tc_of_grounds)
continue;
546 for (n2=collected_nots; n2!=
NIL; n2=n2->
next) {
547 if ((n2->
s1 == n1->
s1) && (n2->
s2 == n1->
s2))
break;
548 if ((n2->
s1 == n1->
s2) && (n2->
s2 == n1->
s1))
break;
552 allocate_with_pool (thisAgent, &thisAgent->
not_pool, &new_not);
553 new_not->
next = collected_nots;
554 collected_nots = new_not;
555 new_not->
s1 = n1->
s1;
557 new_not->
s2 = n1->
s2;
562 return collected_nots;
586 for (n=nots; n!=
NIL; n=n->
next) {
596 for (c=conds; c!=
NIL; c=c->
next) {
619 strncpy (msg,
"chunk.c: Internal error: couldn't add Not test to chunk\n",
BUFFER_MSG_SIZE);
649 for (cc=all_ccs; cc!=
NIL; cc=cc->
next) {
700 for (cc=top_cc; cc!=
NIL; cc=cc->
next) {
706 for (cc=top_cc; cc!=
NIL; cc=cc->
next) {
724 for (cc=top_cc; cc!=
NIL; cc=cc->
next) {
743 for (result_p=results; result_p!=
NIL; result_p=result_p->
next_result) {
753 p->
inst = chunk_inst;
755 inst_next, inst_prev);
783 #define BUFFER_GEN_CHUNK_NAME_SIZE 512
785 #define BUFFER_IMPASS_NAME_SIZE 32
799 if (p->
id->
id.
level > lowest_result_level)
806 switch (impasse_type) {
808 #ifdef DEBUG_CHUNK_NAMES
809 print (
"Warning: impasse_type is NONE_IMPASSE_TYPE during chunk creation.\n");
810 xml_generate_warning(thisAgent,
"Warning: impasse_type is NONE_IMPASSE_TYPE during chunk creation.");
828 #ifdef DEBUG_CHUNK_NAMES
831 print (
"Warning: Failed to find ^attribute impasse wme.\n");
840 #ifdef DEBUG_CHUNK_NAMES
841 print (
"Warning: ^attribute impasse wme has unexpected value.\n");
849 #ifdef DEBUG_CHUNK_NAMES
852 print (
"Warning: encountered unknown impasse_type: %d.\n", impasse_type);
859 #ifdef DEBUG_CHUNK_NAMES
860 print (
"Warning: Failed to determine impasse type.\n");
869 static_cast<long unsigned int>(thisAgent->
chunk_count++),
879 uint64_t collision_count;
882 print (thisAgent,
"Warning: generated chunk name already exists. Will find unique name.\n");
883 xml_generate_warning(thisAgent,
"Warning: generated chunk name already exists. Will find unique name.");
887 static_cast<long unsigned int>(thisAgent->
chunk_count++),
891 static_cast<long unsigned int>(collision_count++)
899 return generated_name;
917 std::ostringstream message;
919 print(thisAgent, message.str().c_str());
931 std::ostringstream message;
933 print(thisAgent, message.str().c_str());
982 Bool print_name, print_prod;
983 byte rete_addition_result;
987 bool reliable =
true;
993 #ifndef NO_TIMING_STUFF
994 #ifdef DETAILED_TIMING_STATS
995 soar_process_timer local_timer;
1013 #ifndef NO_TIMING_STUFF
1014 #ifdef DETAILED_TIMING_STATS
1015 local_timer.start();
1020 if (!results)
goto chunking_done;
1056 temp_explain_chunk.
conds = NULL;
1057 temp_explain_chunk.
actions = NULL;
1059 temp_explain_chunk.
name[0] =
'\0';
1100 variablize = !dont_variablize && reliable &&
should_variablize(thisAgent, inst);
1116 print( thisAgent,
"\nWarning: LTI validation failed, creating justification instead." );
1155 print (thisAgent,
"\n");
1160 xml_att_val(thisAgent, kProduction_Name, prod_name);
1171 print_string (thisAgent,
" Warning: chunk has no grounds, ignoring it.");
1184 print (thisAgent,
"\nWarning: reached max-chunks! Halting system.");
1209 print (thisAgent,
"\nUnable to reorder this chunk:\n ");
1211 print (thisAgent,
"\n -->\n ");
1213 print (thisAgent,
"\n\nThis error is likely caused by the reasons outlined section 4 of the Soar\n");
1214 print (thisAgent,
"manual, subsection \"revising the substructure of a previous result\".\n");
1215 print (thisAgent,
"\n");
1216 print (thisAgent,
"Check that the rules are not revising substructure of a result matched only\n");
1217 print (thisAgent,
"through the local state.\n");
1242 condition *inst_lhs_top = 0, *inst_lhs_bottom = 0;
1251 chunk_inst->
prod = prod;
1254 chunk_inst->
nots = nots;
1273 temp_explain_chunk.
conds = new_top;
1339 chunk_inst->
next = (*custom_inst_list);
1340 (*custom_inst_list) = chunk_inst;
1346 #ifndef NO_TIMING_STUFF
1347 #ifdef DETAILED_TIMING_STATS
1349 thisAgent->timers_chunking_cpu_time[thisAgent->
current_phase].update(local_timer);
1356 #ifndef NO_TIMING_STUFF
1357 #ifdef DETAILED_TIMING_STATS
1359 thisAgent->timers_chunking_cpu_time[thisAgent->
current_phase].update(local_timer);