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

Go to the source code of this file.

Typedefs

typedef struct action_struct action
typedef struct agent_struct agent
typedef char Bool
typedef struct condition_struct condition
typedef struct instantiation_struct instantiation

Functions

void calculate_compile_time_o_support (condition *lhs, action *rhs)
void calculate_support_for_instantiation_preferences (agent *thisAgent, instantiation *inst)
void dougs_calculate_support_for_instantiation_preferences (agent *thisAgent, instantiation *inst)

Typedef Documentation

typedef struct action_struct action

Definition at line 27 of file osupport.h.

typedef struct agent_struct agent

Definition at line 28 of file osupport.h.

typedef char Bool

Definition at line 24 of file osupport.h.

typedef struct condition_struct condition

Definition at line 26 of file osupport.h.

Definition at line 25 of file osupport.h.

Function Documentation

void calculate_compile_time_o_support ( condition lhs,
action rhs 
)
void calculate_support_for_instantiation_preferences ( agent thisAgent,
instantiation inst 
)

Definition at line 267 of file osupport.cpp.

References wme_struct::acceptable, ACCEPTABLE_PREFERENCE_TYPE, production_struct::action_list, add_to_growable_string(), wme_struct::attr, action_struct::attr, condition_struct::bt, DECLARED_I_SUPPORT, DECLARED_O_SUPPORT, production_struct::declared_support, FALSE, free_growable_string(), get_symbol_from_rete_loc(), wme_struct::id, action_struct::id, symbol_union::id, preference_struct::inst_next, identifier_struct::isa_goal, identifier_struct::level, MAKE_ACTION, make_blank_growable_string(), production_struct::name, action_struct::next, condition_struct::next, NIL, agent_struct::o_support_calculation_type, preference_struct::o_supported, agent_struct::operator_symbol, POSITIVE_CONDITION, action_struct::preference_type, instantiation_struct::preferences_generated, print_with_symbols(), instantiation_struct::prod, instantiation_struct::rete_token, rhs_value_is_reteloc(), rhs_value_is_symbol(), rhs_value_to_reteloc_field_num(), rhs_value_to_reteloc_levels_up(), rhs_value_to_string(), rhs_value_to_symbol(), agent_struct::soar_verbose_flag, symbol_to_string(), text_of_growable_string(), instantiation_struct::top_of_instantiated_conditions, TRUE, action_struct::type, condition_struct::type, UNDECLARED_SUPPORT, wme_struct::value, bt_info_struct::wme_, xml_generate_verbose(), and xml_generate_warning().

Referenced by fill_in_new_instantiation_stuff().

{
preference *pref;
wme *w;
/* RCHONG: begin 10.11 */
action *act;
Bool o_support,op_elab;
Bool operator_proposal;
char action_attr[50];
int pass;
wme *lowest_goal_wme;
/* RCHONG: end 10.11 */
/* REW: begin 09.15.96 */
if (thisAgent->soar_verbose_flag == TRUE) {
printf("\n in calculate_support_for_instantiation_preferences:");
xml_generate_verbose(thisAgent, "in calculate_support_for_instantiation_preferences:");
}
o_support = FALSE;
op_elab = FALSE;
o_support = TRUE;
o_support = FALSE;
/*
check if the instantiation is proposing an operator. if it
is, then this instantiation is i-supported.
*/
operator_proposal = FALSE;
for (act = inst->prod->action_list; act != NIL ; act = act->next) {
if ((act->type == MAKE_ACTION) &&
if ((strcmp(rhs_value_to_string (thisAgent, act->attr, action_attr, 50),
"operator") == NIL) &&
/* REW: 09.30.96. Bug fix (next line was
operator_proposal == TRUE;) */
operator_proposal = TRUE;
o_support = FALSE;
break;
}
}
}
if (operator_proposal == FALSE) {
/*
an operator wasn't being proposed, so now we need to test if
the operator is being tested on the LHS.
i'll need to make two passes over the wmes that pertain to
this instantiation. the first pass looks for the lowest goal
identifier. the second pass looks for a wme of the form:
(<lowest-goal-id> ^operator ...)
if such a wme is found, then this o-support = TRUE; FALSE otherwise.
this code is essentially identical to that in
p_node_left_addition() in rete.c.
BUGBUG this check only looks at positive conditions. we
haven't really decided what testing the absence of the
operator will do. this code assumes that such a productions
(instantiation) would get i-support.
*/
lowest_goal_wme = NIL;
for (pass = 0; pass != 2; pass++) {
for (c=inst->top_of_instantiated_conditions; c!=NIL; c=c->next) {
w = c->bt.wme_;
if (pass == 0) {
if (w->id->id.isa_goal == TRUE) {
if (lowest_goal_wme == NIL)
lowest_goal_wme = w;
else {
if (w->id->id.level > lowest_goal_wme->id->id.level)
lowest_goal_wme = w;
}
}
}
else {
if ((w->attr == thisAgent->operator_symbol) &&
(w->acceptable == FALSE) &&
(w->id == lowest_goal_wme->id)) {
if (thisAgent->o_support_calculation_type == 3 || thisAgent->o_support_calculation_type == 4) {
/* iff RHS has only operator elaborations
then it's IE_PROD, otherwise PE_PROD, so
look for non-op-elabs in the actions KJC 1/00 */
for (act = inst->prod->action_list;
act != NIL ; act = act->next) {
if (act->type == MAKE_ACTION) {
if ((rhs_value_is_symbol(act->id)) &&
(rhs_value_to_symbol(act->id) == w->value)) {
op_elab = TRUE;
} else if ( thisAgent->o_support_calculation_type == 4
op_elab = TRUE;
} else {
/* this is not an operator elaboration */
o_support = TRUE;
}
}
}
} else {
o_support = TRUE;
break;
}
}
}
}
}
}
}
}
/* KJC 01/00: Warn if operator elabs mixed w/ applications */
if ( (thisAgent->o_support_calculation_type == 3
|| thisAgent->o_support_calculation_type == 4 )
&& (o_support == TRUE)) {
if (op_elab == TRUE ) {
/* warn user about mixed actions */
if ( thisAgent->o_support_calculation_type == 3 ) {
print_with_symbols(thisAgent, "\nWARNING: operator elaborations mixed with operator applications\nget o_support in prod %y", inst->prod->name);
add_to_growable_string(thisAgent, &gs, "WARNING: operator elaborations mixed with operator applications\nget o_support in prod ");
add_to_growable_string(thisAgent, &gs, symbol_to_string(thisAgent, inst->prod->name, true, 0, 0));
free_growable_string(thisAgent, gs);
o_support = TRUE;
} else if ( thisAgent->o_support_calculation_type == 4 ) {
print_with_symbols(thisAgent, "\nWARNING: operator elaborations mixed with operator applications\nget i_support in prod %y", inst->prod->name);
add_to_growable_string(thisAgent, &gs, "WARNING: operator elaborations mixed with operator applications\nget i_support in prod ");
add_to_growable_string(thisAgent, &gs, symbol_to_string(thisAgent, inst->prod->name, true, 0, 0));
free_growable_string(thisAgent, gs);
o_support = FALSE;
}
}
}
/*
assign every preference the correct support
*/
for (pref=inst->preferences_generated; pref!=NIL; pref=pref->inst_next)
pref->o_supported = o_support;
}
void dougs_calculate_support_for_instantiation_preferences ( agent thisAgent,
instantiation inst 
)

Definition at line 490 of file osupport.cpp.

References ACCEPTABLE_PREFERENCE_TYPE, wme_struct::attr, preference_struct::attr, condition_struct::bt, FALSE, get_new_tc_number(), wme_struct::id, preference_struct::id, symbol_union::id, IDENTIFIER_SYMBOL_TYPE, preference_struct::inst_next, instantiation_struct::match_goal, condition_struct::next, NIL, agent_struct::o_support_tc, preference_struct::o_supported, agent_struct::operator_symbol, POSITIVE_CONDITION, preference_is_binary(), instantiation_struct::preferences_generated, preference_struct::referent, REQUIRE_PREFERENCE_TYPE, identifier_struct::tc_num, instantiation_struct::top_of_instantiated_conditions, TRUE, preference_struct::type, condition_struct::type, preference_struct::value, and bt_info_struct::wme_.

Referenced by fill_in_new_instantiation_stuff().

{
Symbol *match_state;
Bool rule_2_or_3, anything_added;
preference *rhs, *pref;
wme *w;
condition *lhs, *c;
rhs = inst->preferences_generated;
match_state = inst->match_goal;
/* --- First, check whether rule 2 or 3 applies. --- */
rule_2_or_3 = FALSE;
for (c=lhs; c!=NIL; c=c->next) {
if (c->type!=POSITIVE_CONDITION) continue;
w = c->bt.wme_;
if ((w->id==match_state)&&(w->attr==thisAgent->operator_symbol)) {
rule_2_or_3 = TRUE;
break;
}
}
/* --- Initialize all pref's according to rules 2 and 3 --- */
for (pref=rhs; pref!=NIL; pref=pref->inst_next)
pref->o_supported = rule_2_or_3;
/* --- If they didn't apply, check rule 4 --- */
if (! rule_2_or_3) {
thisAgent->o_support_tc = get_new_tc_number(thisAgent);
/* BUGBUG With Doug's scheme, o_support_tc no longer needs to be a
global variable -- it could simply be local to this procedure */
anything_added = FALSE;
/* --- look for RHS operators, add 'em (starting points) to the TC --- */
for (pref=rhs; pref!=NIL; pref=pref->inst_next) {
if ((pref->id==match_state) &&
(pref->attr==thisAgent->operator_symbol) &&
(pref->value->common.symbol_type==IDENTIFIER_SYMBOL_TYPE)) {
pref->value->id.tc_num = thisAgent->o_support_tc;
anything_added = TRUE;
}
}
/* --- Keep adding stuff to the TC until nothing changes anymore --- */
while (anything_added) {
anything_added = FALSE;
for (pref=rhs; pref!=NIL; pref=pref->inst_next) {
if (pref->id->id.tc_num != thisAgent->o_support_tc) continue;
if (pref->o_supported) continue; /* already added this thing */
pref->o_supported = TRUE;
anything_added = TRUE;
if (pref->value->common.symbol_type==IDENTIFIER_SYMBOL_TYPE)
pref->value->id.tc_num = thisAgent->o_support_tc;
if ((preference_is_binary(pref->type)) &&
(pref->referent->common.symbol_type==IDENTIFIER_SYMBOL_TYPE))
pref->referent->id.tc_num = thisAgent->o_support_tc;
}
}
}
/* --- Finally, use rule 1, which overrides all the other rules. --- */
for (pref=rhs; pref!=NIL; pref=pref->inst_next)
if ((pref->id==match_state) &&
(pref->attr==thisAgent->operator_symbol))
pref->o_supported = FALSE;
}