本文整理汇总了C++中Formula::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ Formula::remove方法的具体用法?C++ Formula::remove怎么用?C++ Formula::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formula
的用法示例。
在下文中一共展示了Formula::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Formula
std::vector<SetOfFormulasPtr>
FaultLocalization::allDiagnosis(Formula *TF,
std::vector<ProgramTrace*> traces,
YicesSolver *yices) {
std::vector<SetOfFormulasPtr> MCSes;
int progress = 0;
int total = traces.size();
// Working formula
Formula *WF = new Formula(TF);
// For each E in WF, E tagged as soft do
unsigned z = 0;
std::vector<BoolVarExprPtr> AV;
std::map<BoolVarExprPtr, ExprPtr> AVMap;
std::vector<ExprPtr> clauses = WF->getExprs();
for(ExprPtr e : clauses) {
if (e->isSoft()) {
// AI is a new auxiliary var. created
std::ostringstream oss;
oss << z++;
BoolVarExprPtr ai = Expression::mkBoolVar("a_"+oss.str());
ai->setInstruction(e->getInstruction());
ai->setLine(e->getLine());
AV.push_back(ai);
AVMap[ai] = e;
ExprPtr notai = Expression::mkNot(ai);
//notai->setWeight(e->getWeight());
notai->setLine(e->getLine());
notai->setSoft();
WF->add(notai);
// Remove E and add EA as hard
ExprPtr ea = Expression::mkOr(e, ai);
WF->remove(e);
ea->setHard();
WF->add(ea);
}
}
if (AV.empty()) {
delete WF;
std::cout << "No MaxSMT solution!\n";
if (options->verbose()) {
std::cout << "==============================================\n";
}
return MCSes;
}
yices->init();
yices->addToContext(WF);
for(ProgramTrace *E : traces) {
if (options->verbose()) {
displayProgressBar(progress, total);
}
// At this point there is only WF in the context
yices->push();
// Assert as hard the error-inducing input formula
ExprPtr eiExpr = E->getProgramInputsFormula(TF);
eiExpr->setHard();
yices->addToContext(eiExpr);
if (options->dbgMsg()) {
std::cout << "-- Error-inducing Input: ";
eiExpr->dump();
std::cout << std::endl;
}
// Assert as hard the golden output (if any)
// (= return_var golden_output)
Value *goldenOutput = E->getExpectedOutput();
if (goldenOutput) {
BasicBlock *lastBB = &targetFun->back();
Instruction *lastInst = &lastBB->back();
if (ReturnInst *ret= dyn_cast<ReturnInst>(lastInst)) {
Value *retVal = ret->getReturnValue();
if (retVal) {
ExprPtr retExpr = Expression::getExprFromValue(retVal);
ExprPtr goExpr = Expression::getExprFromValue(goldenOutput);
ExprPtr eqExpr = Expression::mkEq(retExpr, goExpr);
eqExpr->setHard();
yices->addToContext(eqExpr);
if (options->dbgMsg()) {
std::cout << "-- Golden ouput: ";
eqExpr->dump();
std::cout << std::endl;
}
}
}
}
// Compute a MCS
SetOfFormulasPtr M = allMinMCS(yices, AV, AVMap);
if (!M->empty()) {
SetOfFormulasPtr M2 = avToClauses(M, AVMap);
MCSes.push_back(M2);
if (options->printMCS()) {
std::cout << "\n" << M2 << "\n" << std::endl;
}
} else {
//if (options->verbose() || options->dbgMsg()) {
std::cout << "Empty MCS!\n";
//}
}
// Backtrack to the point where there
// was no Pre/Post-conditions in the formula
yices->pop();
// Progress bar
//.........这里部分代码省略.........