1 #include <portability.h>
33 #include "soar_TraceNames.h"
56 ((sym)->var.tc_num == (tc)) );
89 action *first_action, *last_action;
94 remaining_actions = *action_list;
98 while (remaining_actions) {
101 a = remaining_actions;
110 if (prev_a) prev_a->
next = a->
next;
else remaining_actions = a->
next;
112 if (last_action) last_action->
next = a;
else first_action = a;
118 if (remaining_actions) {
120 print (thisAgent,
"Error: production %s has a bad RHS--\n",
122 print (thisAgent,
" Either it creates structure not connected to anything\n");
123 print (thisAgent,
" else in WM, or it tries to pass an unbound variable as\n");
124 print (thisAgent,
" an argument to a function.\n");
127 last_action->
next = remaining_actions;
129 first_action = remaining_actions;
139 *action_list = first_action;
218 print (thisAgent,
"\n");
227 cons *c, *prev_c, *next_c;
248 subtest =
static_cast<char *
>(c->
first);
266 subtest =
static_cast<char *
>(c->
first);
270 saved->
next = old_sts;
276 prev_c->
rest = next_c;
292 saved->
next = old_sts;
308 for (c=conds_list; c!=
NIL; c=c->
next) {
310 #ifdef CONSIDER_NEGATIVE
334 "Internal error: arg to reverse_direction_of_relational_test\n",
BUFFER_MSG_SIZE);
353 st = tests_to_restore;
361 if (! is_id_field)
break;
373 bound_vars_tc_number) ||
374 (st->
var == referent)) {
380 bound_vars_tc_number) ||
381 (st->
var == referent)) {
392 if (prev_st) prev_st->
next = next_st;
else tests_to_restore = next_st;
400 return tests_to_restore;
412 for (cond=conds_list; cond!=
NIL; cond=cond->
next) {
413 #ifdef CONSIDER_NEGATIVE
429 if (tests_to_restore) {
431 print (thisAgent,
"\nWarning: in production %s,\n",
433 print (thisAgent,
" ignoring test(s) whose referent is unbound:\n");
480 list *starting_list) {
492 return starting_list;
501 return starting_list;
506 (thisAgent, static_cast<char *>(c->
first), tc, starting_list);
507 return starting_list;
515 return starting_list;
522 list *starting_list) {
529 (thisAgent, c, tc, starting_list);
539 return starting_list;
543 list *new_bound_vars;
547 new_bound_vars =
NIL;
548 for (c=cond_list; c!=
NIL; c=c->
next)
553 for (c=cond_list; c!=
NIL; c=c->
next) {
569 for (c=cond_list; c!=
NIL; c=c->
next) {
593 Bool allow_printing_warnings) {
595 list *new_vars_from_value_slot;
596 list *new_vars_from_id_slot;
599 Bool found_goal_impasse_test;
602 new_vars_from_value_slot =
NIL;
603 for (cond=cond_list; cond!=
NIL; cond=cond->
next)
606 &new_vars_from_value_slot);
609 new_vars_from_id_slot =
NIL;
610 for (cond=cond_list; cond!=
NIL; cond=cond->
next)
613 &new_vars_from_id_slot);
617 for (c=new_vars_from_id_slot; c!=
NIL; c=c->
rest)
618 static_cast<Symbol *>(c->
first)->var.tc_num = 0;
622 for (c=new_vars_from_id_slot; c!=
NIL; c=c->
rest) {
623 found_goal_impasse_test =
FALSE;
624 for (cond=cond_list; cond!=
NIL; cond=cond->
next) {
627 static_cast<symbol_union *>(c->
first)))
630 found_goal_impasse_test =
TRUE;
634 if (! found_goal_impasse_test) {
635 print (thisAgent,
"\nWarning: On the LHS of production %s, identifier ",
638 static_cast<Symbol *>(c->
first));
654 return new_vars_from_id_slot;
667 #define MAX_COST 10000005
668 #define BF_FOR_ACCEPTABLE_PREFS 8
669 #define BF_FOR_VALUES 8
670 #define BF_FOR_ATTRIBUTES 8
729 list *root_vars_not_bound_yet) {
734 if ((! root_vars_not_bound_yet) &&
766 root_vars_not_bound_yet))
769 root_vars_not_bound_yet))
774 root_vars_not_bound_yet)) {
786 if (static_cast<Symbol *>(c->
first)->var.tc_num != tc)
return MAX_COST;
801 list *root_vars_not_bound_yet) {
803 int64_t min_cost, cost;
809 for (c=candidates; c!=
NIL; c=c->
next) {
810 if (c==chosen)
continue;
812 if (cost < min_cost) {
814 if (cost <= 1)
break;
849 int64_t min_cost = 0;
852 remaining_conds = *top_of_conds;
863 while (remaining_conds) {
865 min_cost_conds =
NIL;
867 for (cond=remaining_conds; cond!=
NIL; cond=cond->
next) {
869 if ((! min_cost_conds) || (cost < min_cost)) {
871 min_cost_conds = cond;
873 }
else if (cost==min_cost) {
875 min_cost_conds = cond;
885 print (thisAgent,
"Warning: in production %s,\n",
887 print (thisAgent,
" The LHS conditions are not all connected.\n");
906 bound_vars_tc_number, roots);
907 if (cost < min_cost) {
909 min_cost_conds = cond;
921 min_cost_conds = cond;
938 min_cost_conds = cond;
944 min_cost_conds = cond;
951 chosen = min_cost_conds;
953 if (!first_cond) first_cond = chosen;
962 bound_vars_tc_number,
TRUE);
966 bound_vars_tc_number,
977 for (c=roots; c!=
NIL; c=c->
rest)
978 if (static_cast<Symbol *>(c->
first)->var.tc_num != bound_vars_tc_number)
986 *top_of_conds = first_cond;
987 *bottom_of_conds = last_cond;
1110 "Error: production %s has an unbound referent in negated relational test %s",
1129 for (c=cond_list; ret && c!=
NIL; c=c->
next) {
1138 for (c=cond_list; ret && c!=
NIL; c=c->
next) {
1161 for (cond = *lhs_top; cond !=
NIL; cond = cond->
next) {
1193 for (cond = *lhs_top; cond!=
NIL; cond=cond->
next) {
1205 print (thisAgent,
" The LHS has no roots.\n");