⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread_decide.cpp

📁 多核环境下运行了可满足性分析的工具软件
💻 CPP
字号:
/********************************************************************************************MiraXT -- Copyright (c) 2007, Tobias Schubert, Matthew Lewis, Natalia Kalinnik, Bernd Becker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies orsubstantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.********************************************************************************************/// Selects and assigns the next variable. Not only "free" variables, but also all current // implications for which "Boolean Constraint Propagation" hasn't been done so far, will // be covered and selected first.inline int Thread::decide(void){  // Any unprocessed implications left?  if (sEI != ucEI) { return decideImplication(); }    // Increment the number of calls of "decide".  decisionCount++;  // What about deleting some clauses?  if (currentDL == 0 && (DSprogress+256) < ucEI) { cleanClauseDB(); DSprogress = ucEI; }    // Let's check if it is time for cleaning the database, dividing the current subproblem,  // reducing the literal's activities, performing a restart, or terminating the search process.  if ((decisionCount & 127) == 0)    {        // Is it time to delete some clauses with a low activity?      if(numClausesAdded > cleanOften && currentDL != 0)        {	  cleanOften = cleanOften + (cleanOften >> 2);	  if (cleanOften > 16384) { cleanOften = 16384; }	  numClausesAdded = 0;	  cleanClauseDB();        }            // Is there some other thread waiting for a new and unchecked subproblem?      if (currentDL != 0 && theDecisionQueue->needMoreDecisionStacks() == true)        { theDecisionQueue->addDecisionStack(currentDL, DLLookupArray, DecisionStack); }            // Is it time to reduce the literal's activities?      if (literalActivityIncCount > reduceOften)         {	  literalActivityIncCount = 0; 	  reduceLiteralActivity();	  myVSIDS->sort(false);        }            // What about a restart?      if (restartCount > restartInc)        {	  restartCount = 0;   	  restartInc = restartInc + (restartInc >> 1);	  if (restartInc > restartMax) { restartInc = 500; restartMax += restartMax; }	  myVSIDS->sort(false);	  restartSearch();        }      // Check if we reached the given CPU limit?      if ((decisionCount & 1023) == 0)        { if ((getTime() - masterControl->startTime) >= maxTime) { return 0; } }      // Terminate the search?      if (masterControl->masterDone != 0) { return 0; }    }  //  Now it's time to select and assign the next variable.  int myDecision = myVSIDS->decide(Assignment);  if (myDecision != 0) { pushDecision(myDecision); }  return myDecision;}// Reset "unitClauseSearchArray" (Implication Queue Sorting).inline void Thread::resetUnitClauseSearchArray(){ for(int L=0; L<=IQSize; L++) { unitClauseSearchArray[L].clearFast(); } }// Swap the implications on positions "P1" and "P2" within the decision stack.inline void Thread::swapImplicationsDS(int P1, int P2){      int H             = DecisionStack[P1];  DecisionStack[P1] = DecisionStack[P2];  DecisionStack[P2] = H;    DSLookupArray[H >> 1]                 = P2;  DSLookupArray[DecisionStack[P1] >> 1] = P1;    H                   = forcingClauseDS[P1];  forcingClauseDS[P1] = forcingClauseDS[P2];  forcingClauseDS[P2] = H;}// Determine the correct implication queue of the implication "Literal" within "unitClauseSearchArray".inline void Thread::addUnitDecisionSort(int Literal) {  // Take a look at the "normalized" activity of "-Literal".  unsigned int T = (literalActivity[Literal ^ 1] >> 16);  // What about the activity?  if (T != 0)    {      // Ok, so let's decide in which implication queue of "unitClauseSearchArray"      // the current literal should be stored (implications for which "T" is equal       // zero will be processed in a chronological manner after processing all       // implications within the different implication queues first).       T = IQSize + ((T - IQSize) & -(T < IQSize));      unitClauseSearchArray[T].push(Literal);    }}// Determine the next implication to be processed.inline bool Thread::decideImplication(void){  // Get the first non-empty implication queue of "unitClauseSearchArray",   // starting with the queue storing the "most active implications" (i.e.,   // storing the implications for which the literal with the opposite truth   // is currently very "active").  int myPos = IQSize; while(myPos > 0 && unitClauseSearchArray[myPos].size() == 0) { myPos--; }     // Is there any non-empty implication within the queue of "unitClauseSearchArray"?  // If not, all remaining implications will be treated in chronological order.  if(myPos > 0)    {      // What's the ID of the non-empty queue?      if (myPos < IQSize)        {	  swapImplicationsDS(sEI,DSLookupArray[unitClauseSearchArray[myPos].last() >> 1]);	  unitClauseSearchArray[myPos].pop();        }      else        {	  // Currently, the implication queue with ID "IQSize" is not empty,	  // meaning that we have some implications with really a high activity. 	  // So, let's check in detail which implication should be processed first.	  unsigned int  MaxVal   = 0;	  int           MaxPos   = 0;	  int*          UCSA     = unitClauseSearchArray[IQSize];	  int           sizeUCSA = unitClauseSearchArray[IQSize].size();	                myPos    = 0;	  int           myLit;	  	  while(myPos < sizeUCSA)            {	      myLit = UCSA[myPos];	      if (literalActivity[myLit ^ 1] > MaxVal)                 { MaxVal = literalActivity[myLit ^ 1]; MaxPos = myPos; }	      myPos++;            }	  	  MaxVal = UCSA[MaxPos];	  unitClauseSearchArray[IQSize].rem(MaxPos);	  swapImplicationsDS(sEI,DSLookupArray[MaxVal >> 1]);        }    }  // Let's increment the "Stack End Index", since the next implication gets processed soon.  sEI++;  // Everything went fine.  return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -