Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Macros | Typedefs | Functions
consistency.h File Reference
#include "gdatastructs.h"

Go to the source code of this file.

Macros

#define HIGHER_LEVEL   2
#define LOWER_LEVEL   3
#define NEW_DECISION   0
#define NIL_GOAL_RETRACTIONS   4
#define SAME_LEVEL   1

Typedefs

typedef struct agent_struct agent
typedef char Bool
typedef signed short goal_stack_level
typedef struct ms_change_struct ms_change
typedef struct slot_struct slot
typedef union symbol_union Symbol
typedef struct wme_struct wme

Functions

int active_production_type_at_goal (Symbol *goal)
Bool check_context_slot_decisions (agent *thisAgent, goal_stack_level level)
Bool decision_consistent_with_current_preferences (agent *thisAgent, Symbol *goal, slot *s)
void determine_highest_active_production_level_in_stack_apply (agent *thisAgent)
void determine_highest_active_production_level_in_stack_propose (agent *thisAgent)
Bool goal_stack_consistent_through_goal (agent *thisAgent, Symbol *goal)
Symbolhighest_active_goal_apply (agent *thisAgent, Symbol *start_goal, Bool noneOk)
Symbolhighest_active_goal_propose (agent *thisAgent, Symbol *start_goal, Bool noneOk)
Bool i_activity_at_goal (Symbol *goal)
void initialize_consistency_calculations_for_new_decision (agent *thisAgent)
Bool minor_quiescence_at_goal (agent *thisAgent, Symbol *goal)
void print_assertion (ms_change *msc)
void print_retraction (ms_change *msc)
void remove_current_decision (agent *thisAgent, slot *s)
void remove_operator_if_necessary (agent *thisAgent, slot *s, wme *w)

Macro Definition Documentation

#define HIGHER_LEVEL   2
#define LOWER_LEVEL   3
#define NEW_DECISION   0
#define NIL_GOAL_RETRACTIONS   4
#define SAME_LEVEL   1

Typedef Documentation

typedef struct agent_struct agent

Definition at line 41 of file consistency.h.

typedef char Bool

Definition at line 37 of file consistency.h.

typedef signed short goal_stack_level

Definition at line 38 of file consistency.h.

typedef struct ms_change_struct ms_change

Definition at line 42 of file consistency.h.

typedef struct slot_struct slot

Definition at line 39 of file consistency.h.

typedef union symbol_union Symbol

Definition at line 43 of file consistency.h.

typedef struct wme_struct wme

Definition at line 40 of file consistency.h.

Function Documentation

int active_production_type_at_goal ( Symbol goal)

Definition at line 526 of file consistency.cpp.

References i_activity_at_goal(), IE_PRODS, and PE_PRODS.

Referenced by determine_highest_active_production_level_in_stack_apply().

{
if (i_activity_at_goal(goal))
return IE_PRODS;
else
return PE_PRODS;
}
Bool check_context_slot_decisions ( agent thisAgent,
goal_stack_level  level 
)

Definition at line 332 of file consistency.cpp.

References slot_struct::changed, decision_consistent_with_current_preferences(), FALSE, agent_struct::highest_goal_whose_context_changed, symbol_union::id, identifier_struct::level, identifier_struct::lower_goal, identifier_struct::operator_slot, print_with_symbols(), remove_current_decision(), agent_struct::soar_verbose_flag, agent_struct::sysparams, TRACE_WM_CHANGES_SYSPARAM, TRUE, and slot_struct::wmes.

Referenced by goal_stack_consistent_through_goal().

{
Symbol *goal;
slot *s;
#ifdef DEBUG_CONSISTENCY_CHECK
print_with_symbols(thisAgent, " Highest goal with changed context: [%y]\n", thisAgent->highest_goal_whose_context_changed);
#endif
/* REW: begin 05.05.97 */
/* Check only those goals where preferences have changes that are at or above the level
of the consistency check */
for (goal=thisAgent->highest_goal_whose_context_changed; goal && goal->id.level <= level; goal=goal->id.lower_goal) {
/* REW: end 05.05.97 */
#ifdef DEBUG_CONSISTENCY_CHECK
print_with_symbols(thisAgent, " Looking at goal [%y] to see if its preferences have changed\n", goal);
#endif
s = goal->id.operator_slot;
if ((goal->id.lower_goal) ||
(s->wmes)) { /* If we are not at the bottom goal or if there is an operator in the
bottom goal's operator slot */
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" This is a goal that either has subgoals or, if the bottom goal, has an operator in the slot\n");
#endif
if (s->changed) { /* Only need to check a goal if its prefs have changed */
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" This goal's preferences have changed.\n");
#endif
#ifdef DEBUG_CONSISTENCY_CHECK
print_with_symbols(thisAgent, " The current preferences indicate that the decision at [%y] needs to be removed.\n", goal);
#endif
if ( thisAgent->soar_verbose_flag || thisAgent->sysparams[TRACE_WM_CHANGES_SYSPARAM] )
print_with_symbols(thisAgent, "Removing state %y because of a failed consistency check.\n", goal);
/* This doesn;t seem like it should be necessary but evidently it is: see 2.008 */
remove_current_decision(thisAgent, s);
return FALSE;
break; /* No need to continue once a decision is removed */
}
}
}
#ifdef DEBUG_CONSISTENCY_CHECK
else {
printf(" This is a bottom goal with no operator in the slot\n");
}
#endif
}
return TRUE;
}
Bool decision_consistent_with_current_preferences ( agent thisAgent,
Symbol goal,
slot s 
)

Definition at line 122 of file consistency.cpp.

References slot_struct::attr, attribute_of_existing_impasse(), CONFLICT_IMPASSE_TYPE, CONSTRAINT_FAILURE_IMPASSE_TYPE, FALSE, symbol_union::id, slot_struct::id, slot_struct::impasse_id, slot_struct::impasse_type, slot_struct::isa_context_slot, identifier_struct::isa_impasse, identifier_struct::lower_goal, preference_struct::next, preference_struct::next_candidate, NIL, NO_CHANGE_IMPASSE_TYPE, NONE_IMPASSE_TYPE, identifier_struct::operator_slot, print_preference(), print_with_symbols(), print_wme(), run_preference_semantics_for_consistency_check(), TIE_IMPASSE_TYPE, TRUE, type_of_existing_impasse(), wme_struct::value, preference_struct::value, and slot_struct::wmes.

Referenced by check_context_slot_decisions().

{
byte current_impasse_type, new_impasse_type;
Symbol *current_impasse_attribute;
wme *current_operator;
preference *candidates, *cand;
Bool operator_in_slot, goal_is_impassed;
#ifdef DEBUG_CONSISTENCY_CHECK
if (s->isa_context_slot) {
printf(" slot (s) isa context slot: ");
print_with_symbols(thisAgent, " Slot Identifier [%y] and attribute [%y]\n", s->id, s->attr);
}
/* printf(" Address of s: %x\n", s); */
printf(" s->impasse_type: %d\n", s->impasse_type);
if (s->impasse_id) printf(" Impasse ID is set (non-NIL)\n");
#endif
/* Determine the current operator/impasse in the slot*/
if (goal->id.operator_slot->wmes) {
/* There is an operator in the slot */
current_operator = goal->id.operator_slot->wmes;
operator_in_slot = TRUE;
} else {
/* There is not an operator in the slot */
current_operator = NIL;
operator_in_slot = FALSE;
}
if (goal->id.lower_goal){
/* the goal is impassed */
goal_is_impassed = TRUE;
current_impasse_type = type_of_existing_impasse(thisAgent, goal);
current_impasse_attribute = attribute_of_existing_impasse(thisAgent, goal);
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" Goal is impassed: Impasse type: %d: ", current_impasse_type);
print_with_symbols(thisAgent, " Impasse attribute: [%y]\n", current_impasse_attribute);
#endif
/* Special case for an operator no-change */
if ((operator_in_slot) &&
(current_impasse_type == NO_CHANGE_IMPASSE_TYPE)) {
/* Operator no-change impasse: run_preference_semantics will return 0
and we only want to blow away this operator if another is better
than it (checked in NONE_IMPASSE_TYPE switch) or if another kind
of impasse would be generated (e.g., OPERATOR_TIE). So, we set
the impasse type here to 0; that way we'll know that we should be
comparing a previous decision for a unique operator against the
current preference semantics. */
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" This is an operator no-change impasse.\n");
#endif
current_impasse_type = NONE_IMPASSE_TYPE;
}
} else {
goal_is_impassed = FALSE;
current_impasse_type = NONE_IMPASSE_TYPE;
current_impasse_attribute = NIL;
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" Goal is not impassed: ");
#endif
}
/* Determine the new impasse type, based on the preferences that exist now */
new_impasse_type = run_preference_semantics_for_consistency_check (thisAgent, s, &candidates);
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" Impasse Type returned by run preference semantics: %d\n", new_impasse_type);
for (cand = candidates; cand; cand=cand->next) {
printf(" Preference for slot:");
print_preference(thisAgent, cand);
}
for (cand = candidates; cand; cand=cand->next_candidate) {
printf("\n Candidate for slot:");
print_preference(thisAgent, cand);
}
#endif
if (current_impasse_type != new_impasse_type) {
/* Then there is an inconsistency: no more work necessary */
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" Impasse types are different: Returning FALSE, preferences are not consistent with prior decision.\n");
#endif
return FALSE;
}
/* in these cases, we know that the new impasse and the old impasse *TYPES* are the same. We
just want to check and make the actual impasses/decisions are the same. */
switch (new_impasse_type) {
/* There are four cases to consider when NONE_IMPASSE_TYPE is returned: */
/* 1. Previous operator and operator returned by run_pref_sem are the same.
In this case, return TRUE (decision remains consistent) */
/* This next if is meant to test that there actually is something in the slot but
I'm nut quite certain that it will not always be true? */
if (operator_in_slot){
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" There is a WME in the operator slot:"); print_wme(current_operator);
#endif
/* Because of indifferent preferences, we need to compare all possible candidates
with the current decision */
for (cand = candidates; cand; cand=cand->next_candidate) {
if (current_operator->value == cand->value) {
#ifdef DEBUG_CONSISTENCY_CHECK
print_with_symbols(thisAgent, " Operator slot ID [%y] and candidate ID [%y] are the same.\n",
current_operator->value,
cand->value);
#endif
return TRUE;
}
}
/* 2. A different operator is indicated for the slot than the one that is
currently installed. In this case, we return FALSE (the decision is
not consistent with the preferences). */
/* Now we know that the decision is inconsistent */
return FALSE;
/* 3. A single operator is suggested when an impasse existed previously.
In this case, return FALSE so that the impasse can be removed. */
} else { /* There is no operator in the slot */
if (goal->id.lower_goal) { /* But there is an impasse */
if (goal->id.lower_goal->id.isa_impasse) printf("This goal is an impasse\n");
printf(" No Impasse Needed but Impasse exists: remove impasse now\n");
printf("\n\n *************This should never be executed*******************\n\n");
return FALSE;
}
}
/* 4. This is the bottom goal in the stack and there is no operator or
impasse for the operator slot created yet. We shouldn't call this
routine in this case (this condition is checked before
decision_consistent_with_current_preferences is called) but, for
completeness' sake, we check this condition and return TRUE
(because no decision has been made at this level, there is no
need to remove anything). */
printf("\n\n *************This should never be executed*******************\n\n");
return TRUE;
break;
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" Constraint Failure Impasse: Returning TRUE\n");
#endif
return TRUE;
break;
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" Conflict Impasse: Returning TRUE\n");
#endif
return TRUE;
break;
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" Tie Impasse: Returning TRUE\n");
#endif
return TRUE;
break;
#ifdef DEBUG_CONSISTENCY_CHECK
printf(" No change Impasse: Returning TRUE\n");
#endif
return TRUE;
break;
}
printf("\n After switch................");
printf("\n\n *************This should never be executed*******************\n\n");
return TRUE;
}
void determine_highest_active_production_level_in_stack_apply ( agent thisAgent)

Definition at line 611 of file consistency.cpp.

{
Symbol * goal;
int level_change_type, diff;
/* KJC 04/05 - moved phase printing to init_soar: do_one_top_level_phase, case APPLY */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nDetermining the highest active level in the stack....\n");
#endif
{
/* This is quiescence */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\n(Full) APPLY phase Quiescence has been reached...going to output\n");
#endif
/* Need to determine if this quiescence is also a minor quiescence,
otherwise, an inconsistent decision could get retained here (because
the consistency check was never run). (2.008). Therefore, if
in the previous preference phase, IE_PRODS fired, then force a
consistency check over the entire stack (by checking at the
bottom goal). */
if (minor_quiescence_at_goal(thisAgent, thisAgent->bottom_goal))
{
}
/* regardless of the outcome, we go to the output phase */
return;
}
/* Not Quiescence */
/* Check for Max ELABORATIONS EXCEEDED */
if (thisAgent->e_cycles_this_d_cycle >=
static_cast<uint64_t>(thisAgent->sysparams[MAX_ELABORATIONS_SYSPARAM]))
{
print(thisAgent, "\nWarning: reached max-elaborations; proceeding to output phase.");
xml_generate_warning(thisAgent, "Warning: reached max-elaborations; proceeding to output phase.");
}
return;
}
/* Save the old goal and level (must save level explicitly in case goal is NIL) */
thisAgent->previous_active_goal = thisAgent->active_goal;
thisAgent->previous_active_level = thisAgent->active_level;
/* Determine the new highest level of activity */
thisAgent->active_goal = highest_active_goal_apply(thisAgent, thisAgent->top_goal, FALSE);
if (thisAgent->active_goal)
thisAgent->active_level = thisAgent->active_goal->id.level;
else
thisAgent->active_level = 0; /* Necessary for get_next_retraction */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nHighest level of activity is....%d", thisAgent->active_level);
printf("\n Previous level of activity is....%d", thisAgent->previous_active_level);
#endif
if (!thisAgent->active_goal)
/* Only NIL goal retractions */
level_change_type = NIL_GOAL_RETRACTIONS;
else if (thisAgent->previous_active_level == 0)
level_change_type = NEW_DECISION;
else
{
diff = thisAgent->active_level - thisAgent->previous_active_level;
if (diff == 0)
level_change_type = SAME_LEVEL;
else if (diff > 0)
level_change_type = LOWER_LEVEL;
else
level_change_type = HIGHER_LEVEL;
}
switch (level_change_type)
{
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nOnly NIL goal retractions are active");
#endif
thisAgent->FIRING_TYPE = IE_PRODS;
//thisAgent->current_phase = PREFERENCE_PHASE;
break;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThis is a new decision....");
#endif
/* in APPLY phase, we can test for ONC here, check ms_o_assertions */
// KJC: thisAgent->current_phase = PREFERENCE_PHASE;
break;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThe level is lower than the previous level....");
#endif
/* Is there a minor quiescence at the previous level? */
if (minor_quiescence_at_goal(thisAgent, thisAgent->previous_active_goal)) {
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nMinor quiescence at level %d", thisAgent->previous_active_level);
#endif
{
break;
}
}
/* else: check if return to interrupted level */
goal = thisAgent->active_goal;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nSaved production type: IE _PRODS");
print(thisAgent, "\nSaved production type: PE _PRODS");
print(thisAgent, "\nSaved production type: NONE");
#endif
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nRestoring production type from previous processing at this level");
#endif
thisAgent->FIRING_TYPE = goal->id.saved_firing_type;
// KJC 04.05 commented the next line after reworking the phases in init_soar.cpp
// thisAgent->current_phase = DETERMINE_LEVEL_PHASE;
// Reluctant to make this a recursive call, but somehow we need to go thru
// and determine which level we should start with now that we've
// returned from a lower level (solved a subgoal or changed the conditions).
// We could return a flag instead and test it everytime thru loop in APPLY.
break;
}
/* else: just do a preference phase */
//KJC: thisAgent->current_phase = PREFERENCE_PHASE;
break;
case SAME_LEVEL:
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThe level is the same as the previous level....");
#endif
if (minor_quiescence_at_goal(thisAgent, thisAgent->active_goal)) {
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nMinor quiescence at level %d", thisAgent->active_level);
#endif
if (!goal_stack_consistent_through_goal(thisAgent, thisAgent->active_goal)) {
break;
}
}
//thisAgent->current_phase = PREFERENCE_PHASE;
break;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThe level is higher than the previous level....");
#endif
goal = thisAgent->previous_active_goal;
goal->id.saved_firing_type = thisAgent->FIRING_TYPE;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\n Saving current firing type as IE_PRODS");
else if (goal->id.saved_firing_type == PE_PRODS)
print(thisAgent, "\n Saving current firing type as PE_PRODS");
else if (goal->id.saved_firing_type == NO_SAVED_PRODS)
print(thisAgent, "\n Saving current firing type as NO_SAVED_PRODS");
else
print(thisAgent, "\n Unknown SAVED firing type???????");
#endif
/* run consistency check at new active level *before* firing any
productions there */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nMinor quiescence at level %d", thisAgent->active_level);
#endif
if (!goal_stack_consistent_through_goal(thisAgent, thisAgent->active_goal))
{
break;
}
/* If the decision is consistent, then just start processing at this level */
//thisAgent->current_phase = PREFERENCE_PHASE;
break;
}
}
void determine_highest_active_production_level_in_stack_propose ( agent thisAgent)

Definition at line 842 of file consistency.cpp.

{
Symbol * goal;
int level_change_type, diff;
/* KJC 04/05 - moved phase printing to init_soar: do_one_top_level_phase, case APPLY */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\n(Propose) Determining the highest active level in the stack....\n");
#endif
// KJC 01.24.06 Changed logic for testing for IE prods. Was incorrectly
// checking only the bottom goal. Need to check at all levels. A previous
// code change required #define, but it was never defined.
/* We are only checking for i_assertions, not o_assertions, since we don't
* want operators to fire in the proposal phase
*/
if (!(thisAgent->ms_retractions || thisAgent->ms_i_assertions))
{
if (minor_quiescence_at_goal(thisAgent, thisAgent->bottom_goal))
{
/* This is minor quiescence */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\n Propose Phase Quiescence has been reached...going to decision\n");
#endif
/* Force a consistency check over the entire stack (by checking at
the bottom goal). */
/* Decision phase is always next */
return;
}
}
/* Not Quiescence, there are elaborations ready to fire at some level. */
/* Check for Max ELABORATIONS EXCEEDED */
if (thisAgent->e_cycles_this_d_cycle >=
static_cast<uint64_t>(thisAgent->sysparams[MAX_ELABORATIONS_SYSPARAM])) {
print(thisAgent, "\nWarning: reached max-elaborations; proceeding to decision phase.");
xml_generate_warning(thisAgent, "Warning: reached max-elaborations; proceeding to decision phase.");
}
return;
}
/* not Max Elaborations */
/* Save the old goal and level (must save level explicitly in case
goal is NIL) */
thisAgent->previous_active_goal = thisAgent->active_goal;
thisAgent->previous_active_level = thisAgent->active_level;
/* Determine the new highest level of activity */
thisAgent->active_goal = highest_active_goal_propose(thisAgent, thisAgent->top_goal, FALSE);
if (thisAgent->active_goal)
thisAgent->active_level = thisAgent->active_goal->id.level;
else
thisAgent->active_level = 0; /* Necessary for get_next_retraction */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nHighest level of activity is....%d", thisAgent->active_level);
printf("\n Previous level of activity is....%d", thisAgent->previous_active_level);
#endif
if (!thisAgent->active_goal)
/* Only NIL goal retractions */
level_change_type = NIL_GOAL_RETRACTIONS;
else if (thisAgent->previous_active_level == 0)
level_change_type = NEW_DECISION;
else {
diff = thisAgent->active_level - thisAgent->previous_active_level;
if (diff == 0)
level_change_type = SAME_LEVEL;
else if (diff > 0)
level_change_type = LOWER_LEVEL;
else
level_change_type = HIGHER_LEVEL;
}
switch (level_change_type) {
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nOnly NIL goal retractions are active");
#endif
thisAgent->FIRING_TYPE = IE_PRODS;
//thisAgent->current_phase = PREFERENCE_PHASE;
break;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThis is a new decision....");
#endif
thisAgent->FIRING_TYPE = IE_PRODS;
//thisAgent->current_phase = PREFERENCE_PHASE;
break;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThe level is lower than the previous level....");
#endif
/* There is always a minor quiescence at the previous level
in the propose phase, so check for consistency. */
break;
}
/* else: just do a preference phase */
thisAgent->FIRING_TYPE = IE_PRODS;
// thisAgent->current_phase = PREFERENCE_PHASE;
break;
case SAME_LEVEL:
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThe level is the same as the previous level....");
#endif
thisAgent->FIRING_TYPE = IE_PRODS;
// thisAgent->current_phase = PREFERENCE_PHASE;
break;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\nThe level is higher than the previous level....");
#endif
goal = thisAgent->previous_active_goal;
goal->id.saved_firing_type = thisAgent->FIRING_TYPE;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "\n Saving current firing type as IE_PRODS");
else if (goal->id.saved_firing_type == PE_PRODS)
print(thisAgent, "\n Saving current firing type as PE_PRODS");
else if (goal->id.saved_firing_type == NO_SAVED_PRODS)
print(thisAgent, "\n Saving current firing type as NO_SAVED_PRODS");
else
print(thisAgent, "\n Unknown SAVED firing type???????");
#endif
/* run consistency check at new active level *before* firing any
productions there */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nMinor quiescence at level %d", thisAgent->active_level);
#endif
if (!goal_stack_consistent_through_goal(thisAgent, thisAgent->active_goal)) {
break;
}
/* If the decision is consistent, then just keep processing
at this level */
thisAgent->FIRING_TYPE = IE_PRODS;
// thisAgent->current_phase = PREFERENCE_PHASE;
break;
}
}
Bool goal_stack_consistent_through_goal ( agent thisAgent,
Symbol goal 
)

Definition at line 537 of file consistency.cpp.

References check_context_slot_decisions(), agent_struct::current_phase, agent_struct::highest_goal_whose_context_changed, symbol_union::id, identifier_struct::level, print(), and print_with_symbols().

Referenced by determine_highest_active_production_level_in_stack_apply(), and determine_highest_active_production_level_in_stack_propose().

{
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
thisAgent->timers_gds.start();
#endif
#endif
#ifdef DEBUG_CONSISTENCY_CHECK
print(thisAgent, "\nStart: CONSISTENCY CHECK at level %d\n", goal->id.level);
/* Just a bunch of debug stuff for now */
print_with_symbols(thisAgent, "current_agent(highest_goal_whose_context_changed) = [%y]\n",
} else {
printf("Evidently, nothing has changed: not checking slots\n");
}
#endif
test = check_context_slot_decisions(thisAgent, goal->id.level);
#ifdef DEBUG_CONSISTENCY_CHECK
printf("\nEnd: CONSISTENCY CHECK\n");
#endif
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
thisAgent->timers_gds.stop();
thisAgent->timers_gds_cpu_time[thisAgent->current_phase].update(thisAgent->timers_gds);
#endif
#endif
return test;
}
Symbol* highest_active_goal_apply ( agent thisAgent,
Symbol start_goal,
Bool  noneOk 
)

Definition at line 474 of file consistency.cpp.

References abort_with_fatal_error(), BUFFER_MSG_SIZE, symbol_union::id, identifier_struct::lower_goal, identifier_struct::ms_i_assertions, identifier_struct::ms_o_assertions, identifier_struct::ms_retractions, NIL, agent_struct::nil_goal_retractions, print(), print_assertion(), print_retraction(), and xml_generate_warning().

Referenced by determine_highest_active_production_level_in_stack_apply(), and do_preference_phase().

{
Symbol *goal;
for (goal=start_goal; goal; goal=goal->id.lower_goal) {
#if 0 //DEBUG_DETERMINE_LEVEL_PHASE
/* Debugging only */
print(thisAgent, "In highest_active_goal_apply :\n");
#endif
/* If there are any active productions at this goal, return the goal */
if ((goal->id.ms_i_assertions) || (goal->id.ms_o_assertions)
|| (goal->id.ms_retractions)) return goal;
}
/* This routine should only be called when !quiescence. However, there is
still the possibility that the only active productions are retractions
that matched in a NIL goal. If so, then we just return the bottom goal.
If not, then all possibilities have been exausted and we have encounted
an unrecoverable error. */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "WARNING: Returning NIL active goal because only NIL goal retractions are active.");
xml_generate_warning(thisAgent, "WARNING: Returning NIL active goal because only NIL goal retractions are active.");
#endif
if (thisAgent->nil_goal_retractions)
return NIL;
if (!noneOk) {
char msg[BUFFER_MSG_SIZE];
strncpy(msg, "\nconsistency.c: Error: Unable to find an active goal when not at quiescence.\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
return NIL;
}
Symbol* highest_active_goal_propose ( agent thisAgent,
Symbol start_goal,
Bool  noneOk 
)

Definition at line 434 of file consistency.cpp.

References abort_with_fatal_error(), BUFFER_MSG_SIZE, symbol_union::id, identifier_struct::lower_goal, identifier_struct::ms_i_assertions, identifier_struct::ms_retractions, NIL, agent_struct::nil_goal_retractions, print(), print_assertion(), print_retraction(), and xml_generate_warning().

Referenced by determine_highest_active_production_level_in_stack_propose(), and do_preference_phase().

{
Symbol *goal;
for (goal=start_goal; goal; goal=goal->id.lower_goal) {
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
/* Debugging only */
print(thisAgent, "In highest_active_goal_propose:\n");
#endif
/* If there are any active productions at this goal, return the goal */
if ((goal->id.ms_i_assertions) || (goal->id.ms_retractions)) return goal;
}
/* This routine should only be called when !quiescence. However, there is
still the possibility that the only active productions are retractions
that matched in a NIL goal. If so, then we just return the bottom goal.
If not, then all possibilities have been exausted and we have encounted
an unrecoverable error. */
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
print(thisAgent, "WARNING: Returning NIL active goal because only NIL goal retractions are active.");
xml_generate_warning(thisAgent, "WARNING: Returning NIL active goal because only NIL goal retractions are active.");
#endif
if (thisAgent->nil_goal_retractions)
return NIL;
if (!noneOk) {
char msg[BUFFER_MSG_SIZE];
strncpy(msg, "\n consistency.c: Error: Unable to find an active goal when not at quiescence.\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
return NIL;
}
Bool i_activity_at_goal ( Symbol goal)

Definition at line 386 of file consistency.cpp.

References FALSE, symbol_union::id, identifier_struct::ms_i_assertions, identifier_struct::ms_retractions, and TRUE.

Referenced by active_production_type_at_goal(), and minor_quiescence_at_goal().

{
/* print_with_symbols("\nLooking for I-activity at goal: %y\n", goal); */
if (goal->id.ms_i_assertions)
return TRUE;
if (goal->id.ms_retractions)
return TRUE;
/* printf("\nNo instantiation found. Returning FALSE\n"); */
return FALSE;
}
void initialize_consistency_calculations_for_new_decision ( agent thisAgent)

Definition at line 580 of file consistency.cpp.

References agent_struct::active_goal, agent_struct::active_level, symbol_union::id, identifier_struct::lower_goal, NIL, NO_SAVED_PRODS, identifier_struct::saved_firing_type, and agent_struct::top_goal.

Referenced by do_one_top_level_phase().

{
Symbol *goal;
#ifdef DEBUG_DETERMINE_LEVEL_PHASE
printf("\nInitialize consistency calculations for new decision.\n");
#endif
/* No current activity level */
thisAgent->active_level = 0;
thisAgent->active_goal = NIL;
/* Clear any interruption flags on the goals....*/
for(goal=thisAgent->top_goal; goal; goal=goal->id.lower_goal)
}
Bool minor_quiescence_at_goal ( agent thisAgent,
Symbol goal 
)

Definition at line 408 of file consistency.cpp.

References FALSE, agent_struct::FIRING_TYPE, i_activity_at_goal(), IE_PRODS, and TRUE.

Referenced by determine_highest_active_production_level_in_stack_apply(), and determine_highest_active_production_level_in_stack_propose().

{
if ((thisAgent->FIRING_TYPE == IE_PRODS) &&
(!i_activity_at_goal(goal)))
/* firing IEs but no more to fire == minor quiescence */
return TRUE;
else
return FALSE;
}
void print_assertion ( ms_change msc)
void print_retraction ( ms_change msc)
void remove_current_decision ( agent thisAgent,
slot s 
)

Definition at line 305 of file consistency.cpp.

References slot_struct::attr, do_buffered_wm_and_ownership_changes(), symbol_union::id, slot_struct::id, identifier_struct::lower_goal, print_with_symbols(), remove_existing_context_and_descendents(), remove_wmes_for_context_slot(), agent_struct::sysparams, TRACE_OPERAND2_REMOVALS_SYSPARAM, and slot_struct::wmes.

Referenced by check_context_slot_decisions().

{
if (!s->wmes)
if (thisAgent->sysparams[TRACE_OPERAND2_REMOVALS_SYSPARAM]) print_with_symbols(thisAgent, "\n REMOVING CONTEXT SLOT: Slot Identifier [%y] and attribute [%y]\n", s->id, s->attr);
if (s->id)
if (thisAgent->sysparams[TRACE_OPERAND2_REMOVALS_SYSPARAM]) print_with_symbols(thisAgent, "\n Decision for goal [%y] is inconsistent. Replacing it with....\n", s->id);
/* If there is an operator in the slot, remove it */
/* If there are any subgoals, remove those */
}
void remove_operator_if_necessary ( agent thisAgent,
slot s,
wme w 
)

Definition at line 41 of file consistency.cpp.

{
/* REW: begin 11.25.96 */
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
thisAgent->timers_gds.start();
#endif
#endif
/* REW: end 11.25.96 */
/* printf("Examining slot (next)\n");
for (next = s; next; next=next->next){
print_with_symbols("Slot ID: [%y]\n", next->id);
print_with_symbols("Slot Attr: [%y]\n", next->attr);
}
printf("Examining slot (prev)\n");
for (prev = s->prev; prev; prev=prev->prev){
print_with_symbols("Slot ID: [%y]\n", prev->id);
print_with_symbols("Slot Attr: [%y]\n", prev->attr);
}
printf("Examining slot WMEs\n");
for (slot_wmes=s->wmes; slot_wmes; slot_wmes=slot_wmes->next){
print_wme(thisAgent, slot_wmes);
}
printf("Examining acceptable preference WMEs\n");
for (slot_wmes=s->acceptable_preference_wmes; slot_wmes; slot_wmes=slot_wmes->next){
print_wme(thisAgent, slot_wmes);
}
if (thisAgent->highest_goal_whose_context_changed) print_with_symbols("Highest goal with changed context: [%y]\n", thisAgent->highest_goal_whose_context_changed);
print_with_symbols("Slot ID: [%y]\n", s->id);
print_with_symbols("Slot Attr: [%y]\n", s->attr);
if (s->isa_context_slot) printf("this is a context slot.\n");
if (s->impasse_id) print_with_symbols("Impasse: [%y]\n", s->impasse_id);
if (s->acceptable_preference_changed) printf("Acceptable pref changed\n");
print_with_symbols("WME ID: [%y]\n", w->id);
print_with_symbols("WME Attr: [%y]\n", w->attr);
print_with_symbols("WME Value: [%y]\n", w->value);
if (w->value->id.isa_operator) printf("This is an operator\n");
print_with_symbols("s->id->id.operator_slot->id: [%y]\n", s->id->id.operator_slot->id); */
if (s->wmes) { /* If there is something in the context slot */
if (s->wmes->value == w->value) { /* The WME in the context slot is WME whose pref changed */
print(thisAgent, "\n REMOVING: Operator from context slot (proposal no longer matches): ");
print_wme(thisAgent, w);
}
if (s->id->id.lower_goal)
{
if ( thisAgent->soar_verbose_flag || thisAgent->sysparams[TRACE_WM_CHANGES_SYSPARAM] )
print_with_symbols(thisAgent, "Removing state %y because of an operator removal.\n", s->id->id.lower_goal);
}
}
}
/* REW: begin 11.25.96 */
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
thisAgent->timers_gds.stop();
thisAgent->timers_gds_cpu_time[thisAgent->current_phase].update(thisAgent->timers_gds);
#endif
#endif
/* REW: end 11.25.96 */
}