1 #include <portability.h>
44 #ifndef NO_TIMING_STUFF
45 #ifdef DETAILED_TIMING_STATS
46 thisAgent->timers_gds.start();
91 print(thisAgent,
"\n REMOVING: Operator from context slot (proposal no longer matches): ");
106 #ifndef NO_TIMING_STUFF
107 #ifdef DETAILED_TIMING_STATS
108 thisAgent->timers_gds.stop();
109 thisAgent->timers_gds_cpu_time[thisAgent->
current_phase].update(thisAgent->timers_gds);
123 byte current_impasse_type, new_impasse_type;
124 Symbol *current_impasse_attribute;
125 wme *current_operator;
127 Bool operator_in_slot, goal_is_impassed;
129 #ifdef DEBUG_CONSISTENCY_CHECK
131 printf(
" slot (s) isa context slot: ");
136 if (s->
impasse_id) printf(
" Impasse ID is set (non-NIL)\n");
143 operator_in_slot =
TRUE;
146 current_operator =
NIL;
147 operator_in_slot =
FALSE;
152 goal_is_impassed =
TRUE;
155 #ifdef DEBUG_CONSISTENCY_CHECK
156 printf(
" Goal is impassed: Impasse type: %d: ", current_impasse_type);
157 print_with_symbols(thisAgent,
" Impasse attribute: [%y]\n", current_impasse_attribute);
160 if ((operator_in_slot) &&
169 #ifdef DEBUG_CONSISTENCY_CHECK
170 printf(
" This is an operator no-change impasse.\n");
175 goal_is_impassed =
FALSE;
177 current_impasse_attribute =
NIL;
178 #ifdef DEBUG_CONSISTENCY_CHECK
179 printf(
" Goal is not impassed: ");
186 #ifdef DEBUG_CONSISTENCY_CHECK
187 printf(
" Impasse Type returned by run preference semantics: %d\n", new_impasse_type);
189 for (cand = candidates; cand; cand=cand->
next) {
190 printf(
" Preference for slot:");
195 printf(
"\n Candidate for slot:");
200 if (current_impasse_type != new_impasse_type) {
202 #ifdef DEBUG_CONSISTENCY_CHECK
203 printf(
" Impasse types are different: Returning FALSE, preferences are not consistent with prior decision.\n");
212 switch (new_impasse_type) {
221 if (operator_in_slot){
222 #ifdef DEBUG_CONSISTENCY_CHECK
223 printf(
" There is a WME in the operator slot:");
print_wme(current_operator);
230 #ifdef DEBUG_CONSISTENCY_CHECK
231 print_with_symbols(thisAgent,
" Operator slot ID [%y] and candidate ID [%y] are the same.\n",
232 current_operator->
value,
252 printf(
" No Impasse Needed but Impasse exists: remove impasse now\n");
253 printf(
"\n\n *************This should never be executed*******************\n\n");
265 printf(
"\n\n *************This should never be executed*******************\n\n");
270 #ifdef DEBUG_CONSISTENCY_CHECK
271 printf(
" Constraint Failure Impasse: Returning TRUE\n");
277 #ifdef DEBUG_CONSISTENCY_CHECK
278 printf(
" Conflict Impasse: Returning TRUE\n");
284 #ifdef DEBUG_CONSISTENCY_CHECK
285 printf(
" Tie Impasse: Returning TRUE\n");
291 #ifdef DEBUG_CONSISTENCY_CHECK
292 printf(
" No change Impasse: Returning TRUE\n");
298 printf(
"\n After switch................");
299 printf(
"\n\n *************This should never be executed*******************\n\n");
336 #ifdef DEBUG_CONSISTENCY_CHECK
346 #ifdef DEBUG_CONSISTENCY_CHECK
347 print_with_symbols(thisAgent,
" Looking at goal [%y] to see if its preferences have changed\n", goal);
354 #ifdef DEBUG_CONSISTENCY_CHECK
355 printf(
" This is a goal that either has subgoals or, if the bottom goal, has an operator in the slot\n");
358 #ifdef DEBUG_CONSISTENCY_CHECK
359 printf(
" This goal's preferences have changed.\n");
362 #ifdef DEBUG_CONSISTENCY_CHECK
363 print_with_symbols(thisAgent,
" The current preferences indicate that the decision at [%y] needs to be removed.\n", goal);
366 print_with_symbols(thisAgent,
"Removing state %y because of a failed consistency check.\n", goal);
374 #ifdef DEBUG_CONSISTENCY_CHECK
376 printf(
" This is a bottom goal with no operator in the slot\n");
440 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
442 print(thisAgent,
"In highest_active_goal_propose:\n");
457 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
458 print(thisAgent,
"WARNING: Returning NIL active goal because only NIL goal retractions are active.");
459 xml_generate_warning(thisAgent,
"WARNING: Returning NIL active goal because only NIL goal retractions are active.");
466 strncpy(msg,
"\n consistency.c: Error: Unable to find an active goal when not at quiescence.\n",
BUFFER_MSG_SIZE);
480 #if 0 //DEBUG_DETERMINE_LEVEL_PHASE
482 print(thisAgent,
"In highest_active_goal_apply :\n");
499 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
500 print(thisAgent,
"WARNING: Returning NIL active goal because only NIL goal retractions are active.");
501 xml_generate_warning(thisAgent,
"WARNING: Returning NIL active goal because only NIL goal retractions are active.");
508 strncpy(msg,
"\nconsistency.c: Error: Unable to find an active goal when not at quiescence.\n",
BUFFER_MSG_SIZE);
540 #ifndef NO_TIMING_STUFF
541 #ifdef DETAILED_TIMING_STATS
542 thisAgent->timers_gds.start();
546 #ifdef DEBUG_CONSISTENCY_CHECK
547 print(thisAgent,
"\nStart: CONSISTENCY CHECK at level %d\n", goal->
id.
level);
551 print_with_symbols(thisAgent,
"current_agent(highest_goal_whose_context_changed) = [%y]\n",
554 printf(
"Evidently, nothing has changed: not checking slots\n");
560 #ifdef DEBUG_CONSISTENCY_CHECK
561 printf(
"\nEnd: CONSISTENCY CHECK\n");
564 #ifndef NO_TIMING_STUFF
565 #ifdef DETAILED_TIMING_STATS
566 thisAgent->timers_gds.stop();
567 thisAgent->timers_gds_cpu_time[thisAgent->
current_phase].update(thisAgent->timers_gds);
584 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
585 printf(
"\nInitialize consistency calculations for new decision.\n");
614 int level_change_type, diff;
619 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
620 printf(
"\nDetermining the highest active level in the stack....\n");
626 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
627 printf(
"\n(Full) APPLY phase Quiescence has been reached...going to output\n");
656 print(thisAgent,
"\nWarning: reached max-elaborations; proceeding to output phase.");
657 xml_generate_warning(thisAgent,
"Warning: reached max-elaborations; proceeding to output phase.");
674 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
675 printf(
"\nHighest level of activity is....%d", thisAgent->
active_level);
696 switch (level_change_type)
699 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
700 print(thisAgent,
"\nOnly NIL goal retractions are active");
707 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
708 print(thisAgent,
"\nThis is a new decision....");
716 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
717 print(thisAgent,
"\nThe level is lower than the previous level....");
721 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
735 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
737 print(thisAgent,
"\nSaved production type: IE _PRODS");
739 print(thisAgent,
"\nSaved production type: PE _PRODS");
741 print(thisAgent,
"\nSaved production type: NONE");
745 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
746 print(thisAgent,
"\nRestoring production type from previous processing at this level");
766 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
767 print(thisAgent,
"\nThe level is the same as the previous level....");
770 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
771 printf(
"\nMinor quiescence at level %d", thisAgent->
active_level);
783 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
784 print(thisAgent,
"\nThe level is higher than the previous level....");
790 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
792 print(thisAgent,
"\n Saving current firing type as IE_PRODS");
794 print(thisAgent,
"\n Saving current firing type as PE_PRODS");
796 print(thisAgent,
"\n Saving current firing type as NO_SAVED_PRODS");
798 print(thisAgent,
"\n Unknown SAVED firing type???????");
804 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
805 printf(
"\nMinor quiescence at level %d", thisAgent->
active_level);
845 int level_change_type, diff;
849 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
850 printf(
"\n(Propose) Determining the highest active level in the stack....\n");
866 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
867 printf(
"\n Propose Phase Quiescence has been reached...going to decision\n");
888 print(thisAgent,
"\nWarning: reached max-elaborations; proceeding to decision phase.");
889 xml_generate_warning(thisAgent,
"Warning: reached max-elaborations; proceeding to decision phase.");
909 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
910 printf(
"\nHighest level of activity is....%d", thisAgent->
active_level);
929 switch (level_change_type) {
931 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
932 print(thisAgent,
"\nOnly NIL goal retractions are active");
939 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
940 print(thisAgent,
"\nThis is a new decision....");
947 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
948 print(thisAgent,
"\nThe level is lower than the previous level....");
962 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
963 print(thisAgent,
"\nThe level is the same as the previous level....");
970 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
971 print(thisAgent,
"\nThe level is higher than the previous level....");
977 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
979 print(thisAgent,
"\n Saving current firing type as IE_PRODS");
981 print(thisAgent,
"\n Saving current firing type as PE_PRODS");
983 print(thisAgent,
"\n Saving current firing type as NO_SAVED_PRODS");
985 print(thisAgent,
"\n Unknown SAVED firing type???????");
991 #ifdef DEBUG_DETERMINE_LEVEL_PHASE
992 printf(
"\nMinor quiescence at level %d", thisAgent->
active_level);