/*********************************************************************************** CryptoMiniSat -- Copyright (c) 2009 Mate Soos This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . **************************************************************************************************/ #ifndef FAILEDVARSEARCHER_H #define FAILEDVARSEARCHER_H #include #include using std::map; #include "SolverTypes.h" #include "Clause.h" #include "BitArray.h" class Solver; class TwoLongXor { public: const bool operator==(const TwoLongXor& other) const { if (var[0] == other.var[0] && var[1] == other.var[1] && inverted == other.inverted) return true; return false; } const bool operator<(const TwoLongXor& other) const { if (var[0] < other.var[0]) return true; if (var[0] > other.var[0]) return false; if (var[1] < other.var[1]) return true; if (var[1] > other.var[1]) return false; if (inverted < other.inverted) return true; if (inverted > other.inverted) return false; return false; } Var var[2]; bool inverted; }; class FailedVarSearcher { public: FailedVarSearcher(Solver& _solver); const bool search(uint64_t numProps); template const bool removeUslessBinFull(); private: //For 2-long xor const TwoLongXor getTwoLongXor(const XorClause& c); void addFromSolver(const vec& cs); uint32_t newBinXor; //For detach&re-attach (when lots of vars found) template void cleanAndAttachClauses(vec& cs); const bool cleanClause(Clause& ps); const bool cleanClause(XorClause& ps); void completelyDetachAndReattach(); //For re-adding old removed learnt clauses const bool readdRemovedLearnts(); void removeOldLearnts(); //Main const bool tryBoth(const Lit lit1, const Lit lit2); const bool tryAll(const Lit* begin, const Lit* end); void printResults(const double myTime) const; Solver& solver; //Time uint32_t extraTime; //For failure bool failed; //bothprop finding BitArray propagated; BitArray propValue; vec bothSame; //2-long xor-finding vec xorClauseSizes; vector > occur; void removeVarFromXors(const Var var); void addVarFromXors(const Var var); BitArray xorClauseTouched; vec investigateXor; std::set twoLongXors; bool binXorFind; uint32_t lastTrailSize; //2-long xor-finding no.2 through // 1) (a->b, ~a->~b) -> a=b // 2) binary clause (a,c): (a->g, c->~g) -> a = ~c uint32_t bothInvert; //finding HyperBins void addBinClauses(const Lit& lit); BitArray unPropagatedBin; vec propagatedVars; void addBin(const Lit& lit1, const Lit& lit2); void fillImplies(const Lit& lit); BitArray myimplies; vec myImpliesSet; uint64_t hyperbinProps; vector litDegrees; const bool orderLits(); uint64_t maxHyperBinProps; uint64_t binClauseAdded; //Remove useless binaries template const bool fillBinImpliesMinusLast(const Lit& origLit, const Lit& lit, vec& wrong); template const bool removeUselessBinaries(const Lit& lit); void removeBin(const Lit& lit1, const Lit& lit2); vec toDeleteSet; vec oneHopAway; vec wrong; //Temporaries vec tmpPs; //State for this run uint32_t toReplaceBefore; uint32_t origTrailSize; uint64_t origProps; uint32_t numFailed; uint32_t goodBothSame; //State between runs bool finishedLastTimeVar; uint32_t lastTimeWentUntilVar; bool finishedLastTimeBin; uint32_t lastTimeWentUntilBin; double numPropsMultiplier; uint32_t lastTimeFoundTruths; uint32_t numCalls; }; #endif //FAILEDVARSEARCHER_H