| 899 | ------------------------------------------------------------- */ |
| 900 | |
| 901 | int64_t cost_of_adding_condition(agent* thisAgent, |
| 902 | condition* cond, |
| 903 | tc_number tc, |
| 904 | list* root_vars_not_bound_yet) |
| 905 | { |
| 906 | cons* c; |
| 907 | int64_t result; |
| 908 | |
| 909 | /* --- handle the common simple case quickly up front --- */ |
| 910 | if ((! root_vars_not_bound_yet) && |
| 911 | (cond->type == POSITIVE_CONDITION) && |
| 912 | (test_is_blank_or_equality_test(cond->data.tests.id_test)) && |
| 913 | (test_is_blank_or_equality_test(cond->data.tests.attr_test)) && |
| 914 | (test_is_blank_or_equality_test(cond->data.tests.value_test)) && |
| 915 | (! test_is_blank_test(cond->data.tests.id_test)) && |
| 916 | (! test_is_blank_test(cond->data.tests.attr_test)) && |
| 917 | (! test_is_blank_test(cond->data.tests.value_test))) |
| 918 | { |
| 919 | |
| 920 | if (! symbol_is_constant_or_marked_variable |
| 921 | (referent_of_equality_test(cond->data.tests.id_test), tc)) |
| 922 | { |
| 923 | return MAX_COST; |
| 924 | } |
| 925 | if (symbol_is_constant_or_marked_variable |
| 926 | (referent_of_equality_test(cond->data.tests.attr_test), tc)) |
| 927 | result = get_cost_of_possible_multi_attribute |
| 928 | (thisAgent, referent_of_equality_test(cond->data.tests.attr_test)); |
| 929 | else |
| 930 | { |
| 931 | result = BF_FOR_ATTRIBUTES; |
| 932 | } |
| 933 | |
| 934 | if (! symbol_is_constant_or_marked_variable |
| 935 | (referent_of_equality_test(cond->data.tests.value_test), tc)) |
| 936 | { |
| 937 | if (cond->test_for_acceptable_preference) |
| 938 | { |
| 939 | result = result * BF_FOR_ACCEPTABLE_PREFS; |
| 940 | } |
| 941 | else |
| 942 | { |
| 943 | result = result * BF_FOR_VALUES; |
| 944 | } |
| 945 | } |
| 946 | return result; |
| 947 | } /* --- end of common simple case --- */ |
| 948 | |
| 949 | if (cond->type == POSITIVE_CONDITION) |
| 950 | { |
| 951 | /* --- for pos cond's, check what's bound, etc. --- */ |
| 952 | if (! test_covered_by_bound_vars(cond->data.tests.id_test, tc, |
| 953 | root_vars_not_bound_yet)) |
| 954 | { |
| 955 | return MAX_COST; |
| 956 | } |
| 957 | if (test_covered_by_bound_vars(cond->data.tests.attr_test, tc, |
| 958 | root_vars_not_bound_yet)) |
no test coverage detected