Esempio n. 1
0
inline PropResult PropEngine::propNormalClause(
    watch_subarray_const::const_iterator i
    , watch_subarray::iterator &j
    , const Lit p
    , PropBy& confl
) {
    //Blocked literal is satisfied, so clause is satisfied
    if (value(i->getBlockedLit()) == l_True) {
        *j++ = *i;
        return PROP_NOTHING;
    }

    //Dereference pointer
    propStats.bogoProps += 4;
    const ClOffset offset = i->get_offset();
    Clause& c = *cl_alloc.ptr(offset);

    PropResult ret = prop_normal_helper(c, offset, j, p);
    if (ret != PROP_TODO)
        return ret;

    // Did not find watch -- clause is unit under assignment:
    *j++ = *i;
    if (value(c[0]) == l_False) {
        return handle_normal_prop_fail(c, offset, confl);
    }

    //Update stats
    #ifdef STATS_NEEDED
    c.stats.propagations_made++;
    if (c.red())
        propStats.propsLongRed++;
    else
        propStats.propsLongIrred++;
    #endif

    enqueue(c[0], PropBy(offset));
    update_glue(c);

    return PROP_SOMETHING;
}
Esempio n. 2
0
inline
bool PropEngine::propNormalClauseAnyOrder(
    watch_subarray_const::const_iterator i
    , watch_subarray::iterator &j
    , const Lit p
    , PropBy& confl
) {
    //Blocked literal is satisfied, so clause is satisfied
    const Lit blocker = i->getBlockedLit();
    if (value(blocker) == l_True) {
        *j++ = *i;
        return true;
    }
    if (update_bogoprops) {
        propStats.bogoProps += 4;
    }
    const ClOffset offset = i->get_offset();
    Clause& c = *cl_alloc.ptr(offset);

    #ifdef SLOW_DEBUG
    assert(!c.getRemoved());
    assert(!c.freed());
    #endif

    #ifdef STATS_NEEDED
    c.stats.clause_looked_at++;
    c.stats.visited_literals++;
    #endif

    // Make sure the false literal is data[1]:
    if (c[0] == ~p) {
        std::swap(c[0], c[1]);
    }

    assert(c[1] == ~p);

    // If 0th watch is true, then clause is already satisfied.
    const Lit first = c[0];
    if (first != blocker && value(first) == l_True) {
        *j = Watched(offset, first);
        j++;
        return true;
    }

    // Look for new watch:
    #ifdef STATS_NEEDED
    uint numLitVisited = 2;
    #endif
    for (Lit *k = c.begin() + 2, *end2 = c.end()
        ; k != end2
        ; k++
        #ifdef STATS_NEEDED
        , numLitVisited++
        #endif
    ) {
        //Literal is either unset or satisfied, attach to other watchlist
        if (value(*k) != l_False) {
            c[1] = *k;
            //propStats.bogoProps += numLitVisited/10;
            #ifdef STATS_NEEDED
            c.stats.visited_literals+= numLitVisited;
            #endif
            *k = ~p;
            watches[c[1].toInt()].push(Watched(offset, c[0]));
            return true;
        }
    }
    #ifdef STATS_NEEDED
    //propStats.bogoProps += numLitVisited/10;
    c.stats.visited_literals+= numLitVisited;
    #endif

    // Did not find watch -- clause is unit under assignment:
    *j++ = *i;
    if (value(first) == l_False) {
        confl = PropBy(offset);
        #ifdef VERBOSE_DEBUG_FULLPROP
        cout << "Conflict from ";
        for(size_t i = 0; i < c.size(); i++) {
            cout  << c[i] << " , ";
        }
        cout << endl;
        #endif //VERBOSE_DEBUG_FULLPROP

        //Update stats
        #ifdef STATS_NEEDED
        c.stats.conflicts_made++;
        c.stats.sum_of_branch_depth_conflict += decisionLevel() + 1;
        #endif
        if (c.red())
            lastConflictCausedBy = ConflCausedBy::longred;
        else
            lastConflictCausedBy = ConflCausedBy::longirred;

        qhead = trail.size();
        return false;
    } else {

        //Update stats
        #ifdef STATS_NEEDED
        c.stats.propagations_made++;
        if (c.red())
            propStats.propsLongRed++;
        else
            propStats.propsLongIrred++;
        #endif
        enqueue<update_bogoprops>(c[0], PropBy(offset));
        update_glue(c);
    }

    return true;
}