Exemplo n.º 1
0
def searchForSolution(BFSolverObj, SolverRef, skipList):
    """description: flush out this algorithm better
    """
    myLog.info("<=== START ===>")
    myLog.info("skipList: ", skipList)
    satisfied, skipList2 = BFSolverObj.run(SolverRef, skipList)
    if satisfied:
        myLog.info("FINAL unsat_core=", skipList)
        return (True, skipList)
    elif satisfied == False and len(skipList2) > 0:
        skipList3 = list(skipList2)
        myLog.error("FAILED: ", skipList3) # new list of identifiers then recurse
        while len(skipList3) > 0:
            pID = str(skipList3.pop())
            satisfied, newList3 = BFSolverObj.run(SolverRef, skipList + [ pID ])
            if satisfied:
                return (True, skipList + [ pID ])
        
        # if all combinations failed above, then continue to the next level
        skipList3 = list(skipList2)
        while len(skipList3) > 0:
             pID = str(skipList3.pop())
             satisfied, newList4 = searchForSolution(BFSolverObj, SolverRef, skipList + [ pID ])
             if satisfied:
                 return (True, newList4) # skipList + [ pID ])
        
        return (satisfied, None)
    else:
        myLog.error("TODO: handle this scenario.")
        return (satisfied, skipList)
Exemplo n.º 2
0
def _readConfig(fileVars, fileKeys):
    info = None
    skVars = None
    mskVars = []
    rndVars = []
    
    if infoKeyword in fileKeys:
        info = getattr(fileVars, infoKeyword)
    if mskVarsKeyword in fileKeys:
        mskVars = getattr(fileVars, mskVarsKeyword)
    if rndVarsKeyword in fileKeys:
        rndVars = getattr(fileVars, rndVarsKeyword)
    if skVarsKeyword in fileKeys:
        skVars = getattr(fileVars, skVarsKeyword)
    
    if len(mskVars) == 0:
        myLog.error(mskVarsKeyword, "was not defined in ", filename); sys.exit(-1)
    elif info == None:
        myLog.error(infoKeyword, "was not defined in ", filename); sys.exit(-1)
    elif skVars == None:
        myLog.error(skVarsKeyword, "was not defined in ", filename); sys.exit(-1)
    
    info[skVars].sort()
    ci = CleanInfo(info, skVars)
    ci.clean()
    info = ci.getUpdatedInfo()
    
    if len(mskVars) > 0:
        cvr = CleanVarRefs(info, skVars, mskVars)
        cvr.setIsMsk()
        mskVars = cvr.clean()
    if len(rndVars) > 0:
        cvr = CleanVarRefs(info, skVars, rndVars)
        rndVars = cvr.clean()
    #myLog.info("New MSK LIST: ", mskVars)
    return (mskVars, rndVars, skVars, info)