当前位置: 首页>>代码示例>>C++>>正文


C++ Formula::remove方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:belolourenco,项目名称:sniper,代码行数:101,代码来源:FaultLocalization.cpp


注:本文中的Formula::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。