Exemplo n.º 1
0
void Solver::printClauseUsefulnessStats()
{
    vec<Clause*> backupLearnts;
    backupLearnts = learnts;
    sort(backupLearnts, gainedSorter());

    fprintf(stderr, "c Cleaning clauses (clean number %d). Current Clause usefulness stats:\n", cleanNo);
    for(int i = 0; i < backupLearnts.size(); i++) {
        Clause* c = backupLearnts[i];
        dumpFile << "INSERT INTO clean_data(runID, cleanno, idx, glue, conflicts, props, bogoprops, decisions) VALUES("
        << runID << " ,"
        << cleanNo << " ,"
        << c->getIndex() << ","
        << c->activity()  << ","
        << c->getNumConflicted()  << ","
        << c->getGainedProps()  << ","
        << c->getGainedBogoProps() << ","
        << c->getGainedDecisions()
        << ");" << std::endl;

        //c->clearStats();
    }
    fprintf(stderr, "c End of this round of database cleaning\n");
    cleanNo++;
    dumpFile << "INSERT INTO clean_run(runID, cleanno, time) VALUES("
    << runID << ","
    << cleanNo << ","
    << conflicts << ");" << std::endl;
}
Exemplo n.º 2
0
bool Solver::handleConflict(Clause& c, int& num_props)
{
    if (backup.running
        && c.learnt()
        && backup.stage == 0
        && decisionLevel() > 0
    ) {
        #ifdef DEBUG_CONFLICTS
        printf("clause orig:");printClause(c);
        //printf("orig pointer: %p\n", &c);
        #endif //#ifdef DEBUG_CONFLICTS

        #ifdef RESTORE_FULL
        printf("Learnt clause %p wanted to make a conflict! declevel: %d trail: %d\n", &c, decisionLevel(), trail.size());
        //printClause(c);
        #endif
        backup.order_heap = order_heap;
        backup.detachedClause = &c;
        backup.stage = 1;

        //Save misc state
        backup.propagations = propagations;
        backup.bogoProps = bogoProps;
        backup.decisions = decisions;
        backup.simpDB_props = simpDB_props;
        backup.num_props = num_props;
        backup.random_seed = random_seed;
        backup.polarity = polarity;
        return false;
    }

    if (backup.running
        && c.learnt()
        && backup.stage == 1
        && decisionLevel() > 0
        && &c == backup.detachedClause
    ) {
        #ifdef RESTORE_FULL
        printf("Skipping over conflicting with clause %p\n", backup.detachedClause);
        #endif
        return false;
    }

    if (backup.running
        && c.learnt()
        && backup.stage == 2
        && decisionLevel() > 0
    ) {
        #ifdef DEBUG_CONFLICTS
        printf("clause final:");
        printClause(c);
        #endif //#ifdef DEBUG_CONFLICTS

        //printf("final pointer: %p\n", &c);
        assert(&c == backup.detachedClause);
        backup.stage = 0;
        #ifdef RESTORE_FULL
        printf("Now clause %p is making the conflict it wanted to make earlier. declevel: %d trail: %d \n", backup.detachedClause, decisionLevel(), trail.size());
        //printClause(*backup.detachedClause);
        #endif
        assert(backup.decisions <= decisions);
        assert(backup.propagations <= propagations);

        c.getGainedProps() += (propagations + num_props - backup.propagations - backup.num_props);
        c.getGainedBogoProps() += (bogoProps - backup.bogoProps);
        c.getGainedDecisions() += (decisions - backup.decisions);
        #ifdef DEBUG_DECLEVELGAIN
        if (backup.decisions < decisions) {
            fprintf(stderr, "gained declevel: %d\n", (int)(decisions - backup.decisions));
        }
        #endif //DEBUG_DECLEVELGAIN
        c.getNumConflicted()++;

        //Restore misc state
        propagations = backup.propagations;
        bogoProps = backup.bogoProps;
        decisions = backup.decisions;
        simpDB_props = backup.simpDB_props;
        random_seed = backup.random_seed;
        polarity = backup.polarity;
        num_props = backup.num_props;

        order_heap = backup.order_heap;
        backup.detachedClause = NULL;
    }

    if (backup.stage == 1) {
        #ifdef DEBUG_CONFLICTS
        printf("clause middle:");
        printClause(c);
        //printf("middle pointer: %p\n", &c);
        #endif //#ifdef DEBUG_CONFLICTS
    }

    return true;
}