src/solver.cpp
//Beware. Cannot be called while Searcher is running.
Beware. Cannot be called while Searcher is running.
Beware . Cannot be called while Searcher is running .
bool Solver::renumber_variables(bool must_renumber)
{
    assert(okay());
    assert(decisionLevel() == 0);
    if (nVars() == 0) {
        return okay();
    }
    if (!must_renumber
        && calc_renumber_saving() < 0.2
    ) {
        return okay();
    }
    #ifdef USE_GAUSS
    solver->clear_gauss_matrices();
    #endif
    double myTime = cpuTime();
    clauseCleaner->remove_and_clean_all();
    if (!xorclauses.empty()) {
        if (!clean_xor_clauses_from_duplicate_and_set_vars())
            return false;
    }
    vector<uint32_t> outerToInter(nVarsOuter());
    vector<uint32_t> interToOuter(nVarsOuter());
    size_t numEffectiveVars =
        calculate_interToOuter_and_outerToInter(outerToInter, interToOuter);
    vector<uint32_t> interToOuter2(nVarsOuter()*2);
    for(size_t i = 0; i < nVarsOuter(); i++) {
        interToOuter2[i*2] = interToOuter[i]*2;
        interToOuter2[i*2+1] = interToOuter[i]*2+1;
    }
    renumber_clauses(outerToInter);
    CNF::updateVars(outerToInter, interToOuter);
    PropEngine::updateVars(outerToInter, interToOuter, interToOuter2);
    Searcher::updateVars(outerToInter, interToOuter);
#ifdef USE_BREAKID
    if (breakid) {
        breakid->updateVars(outerToInter, interToOuter);
    }
#endif
    if (conf.doStamp) {
        stamp.updateVars(outerToInter, interToOuter2, seen);
    }
    varReplacer->updateVars(outerToInter, interToOuter);
    if (conf.doCache) {
        implCache.updateVars(seen, outerToInter, interToOuter2, numEffectiveVars);
    }
    datasync->updateVars(outerToInter, interToOuter);
    test_renumbering();
    test_reflectivity_of_renumbering();
    const double time_used = cpuTime() - myTime;
    if (conf.verbosity) {
        cout
        << "c [renumber]"
        << conf.print_times(time_used)
        << endl;
    }
    if (sqlStats) {
        sqlStats->time_passed_min(
            solver
            , "renumber"
            , time_used
        );
    }
    if (conf.doSaveMem) {
        save_on_var_memory(numEffectiveVars);
    }
    return okay();
}
bool Solver :: renumber_variables ( bool must_renumber ) { assert ( okay ( ) ) ; assert ( decisionLevel ( ) == 0 ) ; if ( nVars ( ) == 0 ) { return okay ( ) ; } if ( ! must_renumber && calc_renumber_saving ( ) < 0.2 ) { return okay ( ) ; } #ifdef USE_GAUSS solver -> clear_gauss_matrices ( ) ; #endif double myTime = cpuTime ( ) ; clauseCleaner -> remove_and_clean_all ( ) ; if ( ! xorclauses . empty ( ) ) { if ( ! clean_xor_clauses_from_duplicate_and_set_vars ( ) ) return false ; } vector < uint32_t > outerToInter ( nVarsOuter ( ) ) ; vector < uint32_t > interToOuter ( nVarsOuter ( ) ) ; size_t numEffectiveVars = calculate_interToOuter_and_outerToInter ( outerToInter , interToOuter ) ; vector < uint32_t > interToOuter2 ( nVarsOuter ( ) * 2 ) ; for ( size_t i = 0 ; i < nVarsOuter ( ) ; i ++ ) { interToOuter2 [ i * 2 ] = interToOuter [ i ] * 2 ; interToOuter2 [ i * 2 + 1 ] = interToOuter [ i ] * 2 + 1 ; } renumber_clauses ( outerToInter ) ; CNF :: updateVars ( outerToInter , interToOuter ) ; PropEngine :: updateVars ( outerToInter , interToOuter , interToOuter2 ) ; Searcher :: updateVars ( outerToInter , interToOuter ) ; #ifdef USE_BREAKID if ( breakid ) { breakid -> updateVars ( outerToInter , interToOuter ) ; } #endif if ( conf . doStamp ) { stamp . updateVars ( outerToInter , interToOuter2 , seen ) ; } varReplacer -> updateVars ( outerToInter , interToOuter ) ; if ( conf . doCache ) { implCache . updateVars ( seen , outerToInter , interToOuter2 , numEffectiveVars ) ; } datasync -> updateVars ( outerToInter , interToOuter ) ; test_renumbering ( ) ; test_reflectivity_of_renumbering ( ) ; const double time_used = cpuTime ( ) - myTime ; if ( conf . verbosity ) { cout << " " << conf . print_times ( time_used ) << endl ; } if ( sqlStats ) { sqlStats -> time_passed_min ( solver , " " , time_used ) ; } if ( conf . doSaveMem ) { save_on_var_memory ( numEffectiveVars ) ; } return okay ( ) ; }
Beware.
Beware .
//outerToInter[10] = 0 ---> what was 10 is now 0. //Create temporary outerToInter2 //Update sub-elements' vars //Tests //Print results //NOTE order heap is now wrong, but that's OK, it will be restored from //backed up activities and then rebuilt at the start of Searcher