Beispiel #1
0
void Explanation_Based_Chunker::add_additional_constraints()
{
    constraint* lConstraint = NULL;
    test eq_copy = NULL, constraint_test = NULL;

    for (constraint_list::iterator iter = constraints->begin(); iter != constraints->end();)
    {
        lConstraint = *iter;
        condition* lOperationalCond = lConstraint->eq_test->identity ? lConstraint->eq_test->identity->get_operational_cond() : NULL;
        condition* lOperationalConstraintCond = lConstraint->constraint_test->identity ? lConstraint->constraint_test->identity->get_operational_cond() : NULL;

        if (lOperationalCond && !lConstraint->eq_test->identity->literalized())
        {
            constraint_test = copy_test(thisAgent, lConstraint->constraint_test, true);
            attach_relational_test(constraint_test, lOperationalCond, lConstraint->eq_test->identity->get_operational_field());
        }
        else if (lOperationalConstraintCond && !lConstraint->constraint_test->identity->literalized())
        {
            eq_copy = copy_test(thisAgent, lConstraint->eq_test, true);
            constraint_test = copy_test(thisAgent, lConstraint->constraint_test, true);
            invert_relational_test(&eq_copy, &constraint_test);
            attach_relational_test(constraint_test, lOperationalConstraintCond, lConstraint->constraint_test->identity->get_operational_field());
            deallocate_test(thisAgent, eq_copy);
        }
        ++iter;
    }
    clear_cached_constraints();
}
Beispiel #2
0
void Explanation_Based_Chunker::add_additional_constraints()
{
    constraint* lConstraint = NULL;
    test eq_copy = NULL, constraint_test = NULL;

    dprint_header(DT_CONSTRAINTS, PrintBefore, "Adding %u transitive constraints from non-operational conditions...\n", static_cast<uint64_t>(constraints->size()));

    for (constraint_list::iterator iter = constraints->begin(); iter != constraints->end();)
    {
        lConstraint = *iter;
        condition* lOperationalCond = lConstraint->eq_test->identity ? lConstraint->eq_test->identity->get_operational_cond() : NULL;
        condition* lOperationalConstraintCond = lConstraint->constraint_test->identity ? lConstraint->constraint_test->identity->get_operational_cond() : NULL;
        dprint(DT_CONSTRAINTS, "Attempting to add constraint %t %g to %t %g: ", lConstraint->constraint_test, lConstraint->constraint_test, lConstraint->eq_test, lConstraint->eq_test);

        if (lOperationalCond && !lConstraint->eq_test->identity->literalized())
        {
            constraint_test = copy_test(thisAgent, lConstraint->constraint_test, true);
            attach_relational_test(constraint_test, lOperationalCond, lConstraint->eq_test->identity->get_operational_field());
            dprint(DT_CONSTRAINTS, "...constraint added.  Condition is now %l\n", lOperationalCond);
        }
        else if (lOperationalConstraintCond && !lConstraint->constraint_test->identity->literalized())
        {
            eq_copy = copy_test(thisAgent, lConstraint->eq_test, true);
            constraint_test = copy_test(thisAgent, lConstraint->constraint_test, true);
            invert_relational_test(&eq_copy, &constraint_test);
            attach_relational_test(constraint_test, lOperationalConstraintCond, lConstraint->constraint_test->identity->get_operational_field());
            deallocate_test(thisAgent, eq_copy);
            dprint(DT_CONSTRAINTS, "...complement of constraint added.  Condition is now %l\n", lOperationalConstraintCond);
        } else {
            dprint(DT_CONSTRAINTS, "...did not add constraint:\n    eq_test: %t %g, literalized = %s\n    reltest: %t %g, literalized = %s\n",
                lConstraint->eq_test, lConstraint->eq_test, (lConstraint->eq_test->identity && lConstraint->eq_test->identity->literalized()) ? "true" : "false",
                    lConstraint->constraint_test, lConstraint->constraint_test, (lConstraint->constraint_test->identity && lConstraint->constraint_test->identity->literalized()) ? "true" : "false");
        }
        ++iter;
    }
    clear_cached_constraints();

    dprint_header(DT_CONSTRAINTS, PrintAfter, "Done adding transitive constraints.\n");
}