Example #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;
}
Example #2
0
lbool Solver::search(int nof_conflicts, int nof_learnts)
{
    assert(ok);
    int         backtrack_level;
    int         conflictsC = 0;
    vec<Lit>    learnt_clause;
    int nblevels=0,nbCC=0,merged=0;
    starts++;
    bool first = true;

    for (;;){
        Clause* confl = propagate();

        //Conflict at a later stage.
        if (backup.running
            && confl != NULL
            && backup.stage == 1
        ) {
            #ifdef RESTORE_FULL
            printf("Somebody else (maybe bin clause) did the conflict -- stage is one, going 2\n");
            #endif
            fullCancelUntil(backup.level, backup.sublevel);
            backup.stage = 2;
            continue;
        }

        if (confl != NULL){
            assert(backup.stage == 0);

            // CONFLICT
            conflicts++; conflictsC++;cons++;nbCC++;
            if (decisionLevel() == 0) return l_False;

            first = false;

            learnt_clause.clear();
            analyze(confl, learnt_clause, backtrack_level,nblevels,merged);


            conf4Stats++;
            nbDecisionLevelHistory.push(nblevels);
            totalSumOfDecisionLevel += nblevels;

            cancelUntil(backtrack_level);
            assert(value(learnt_clause[0]) == l_Undef);

            if (learnt_clause.size() == 1){
              assert(decisionLevel() == 0);
              uncheckedEnqueue(learnt_clause[0]);
              nbUn++;
            }else{
              Clause* c = Clause_new(learnt_clause, clIndex++, conflicts, true);
              dumpFile << "INSERT INTO clausedata(runID, idx, timeofcreation, size) VALUES("
              << runID << ","
              << c->getIndex() << ","
              << c->getTimeOfCreation() << ","
              << c->size()
              << ");" << std::endl;

              learnts.push(c);
              c->setActivity(nblevels); // LS
              if(nblevels<=2) nbDL2++;
              if(c->size()==2) nbBin++;
              attachClause(*c);

              uncheckedEnqueue(learnt_clause[0], c);

              if (backup.running
                  && backup.stage == 0
              ) {
                  saveState();
                  #ifdef RESTORE
                  printf("Saving state after conflict at dec level: %d, sublevel: %d\n", decisionLevel(), trail.size());
                  #endif
              }
            }
              varDecayActivity();
        }else{
            if (backup.stage == 0
              && nbDecisionLevelHistory.isvalid()
              && ((nbDecisionLevelHistory.getavg()*0.7) > (totalSumOfDecisionLevel / conf4Stats))
            ) {
              nbDecisionLevelHistory.fastclear();
              progress_estimate = progressEstimate();
              cancelUntil(0);
              return l_Undef;
            }

            // Simplify the set of problem clauses:
            if (backup.stage == 0
                && decisionLevel() == 0 && !simplify()
            ) {
                return l_False;
            }

            Lit next = lit_Undef;

            if (backup.stage == 0
                && ((cons-curRestart * nbclausesbeforereduce) >=0)
            ) {
                curRestart = (conflicts/ nbclausesbeforereduce)+1;
                reduceDB();
                nbclausesbeforereduce += 500;
            }

            if (next == lit_Undef){
                // New variable decision:
                decisions++;
                next = pickBranchLit(polarity_mode, random_var_freq);

                if (next == lit_Undef)
                    // Model found:
                    return l_True;
            }

            // Increase decision level and enqueue 'next'
            assert(value(next) == l_Undef);
            newDecisionLevel();
            uncheckedEnqueue(next);

            if (backup.running
                && backup.stage == 0
            ) {
                saveState();
                #ifdef RESTORE
                printf("Saving state after pickbranch at dec level: %d, sublevel: %d\n", decisionLevel(), trail.size());
                printf("sublevel: %d, level: %d, qhead:%d\n", trail.size(), decisionLevel(), qhead);
                #endif
            }
        }
    }
}
Example #3
0
AntecedentStruct<BaseDefs> AntecedentStruct<BaseDefs>::makeClause(Clause clause) {
	AntecedentStruct<BaseDefs> antecedent;
	antecedent.type = kTypeClause;
	antecedent.identifier.clause = clause.getIndex();
	return antecedent;
}