示例#1
0
文件: BDD.py 项目: cmplx/PBDD
def bdd_init(fName):
    """
    Initializes a BDD data structure (dictionary) with the 
    Boolean Formula stored in file name FNAME
    """
    #parse file using PyBool
    expr      = pb.parse_std(fName)
    var_order = expr["var_order"]
    expr      = expr["main_expr"]

    #make sure all variables are accounted for
    assert(len(var_order) >= pb.number_vars(expr))

    #values are tuples in the form (i, low, high)
    t_table = {0 : ((len(var_order)+1), None, None),
               1 : ((len(var_order)+1), None, None)}

    return {"u"              : 1             ,
            "n"              : len(var_order),
            "h_table"        : {}            ,
            "t_table"        : t_table       ,

            #boolean formula info
            "var_order"      : var_order     ,
            "expr"           : expr          }
示例#2
0
文件: BDD.py 项目: ganeshutah/Jove
def bdd_init(example):
    """
    Initializes a BDD data structure (dictionary) with the 
    Boolean Formula stored in file name FNAME
    """
    #parse file using PyBool
    expr = pb.parse_std(example)
    var_order = expr["var_order"]
    expr = expr["main_expr"]

    #make sure all variables are accounted for
    assert (len(var_order) >= pb.number_vars(expr))

    #values are tuples in the form (i, low, high)
    t_table = {
        0: ((len(var_order) + 1), None, None),
        1: ((len(var_order) + 1), None, None)
    }

    return {
        "u": 1,
        "n": len(var_order),
        "h_table": {},
        "t_table": t_table,

        #boolean formula info
        "var_order": var_order,
        "expr": expr
    }
示例#3
0
    f = open("python/programoutput/error" + uniqid + ".txt", "w")
    f.write(ERR_str)
    f.close()
    exit(0)
    
if __name__ == "__main__":

    try:
        expr = pb.parse_std("python/programoutput/" + uniqid + ".txt")["main_expr"]    
        
    except pb.Parse_Error as e:
        ERR_str = "There was an error parsing your file, please check your syntax\n" \
                  + e.value + "\n"
        exit_err()
        
    if pb.number_vars(expr) > 14:
        ERR_str = "Your formula contains too many variables for the web interface. Please try again with less than 14 variables or download the PBL package and run it on your own machine."
        exit_err()
                        
    if len(pb.print_expr(expr)) > 500:
        ERR_str = "Your formula is too long for the web interface. Please try again with a smaller formula or download the PBL package and run it on your own machine."
        exit_err()

    
    expr = pb.exp_cnf(expr)
    STAT_str = pb.print_expr(expr) + "\n"
    
    f = open("python/programoutput/programoutput" + uniqid + ".txt", "w")
    f.write(STAT_str)
    f.close()
示例#4
0
    f.write(ERR_str)
    f.close()
    exit(0)


if __name__ == "__main__":

    try:
        expr = pb.parse_std("python/programoutput/" + uniqid +
                            ".txt")["main_expr"]

    except pb.Parse_Error as e:
        ERR_str = "There was an error parsing your file, please check your syntax\n" \
                  + e.value + "\n"
        exit_err()

    if pb.number_vars(expr) > PBL_VAR_LENGTH:
        ERR_str = "Your formula contains too many variables for the web interface. Please try again with less than 14 variables or download the PBL package and run it on your own machine."
        exit_err()

    if len(pb.print_expr(expr)) > 500:
        ERR_str = "Your formula is too long for the web interface. Please try again with a smaller formula or download the PBL package and run it on your own machine."
        exit_err()

    expr = pb.exp_cnf(expr)
    STAT_str = pb.print_expr(expr) + "\n"

    f = open("python/programoutput/info" + uniqid + ".txt", "w")
    f.write(STAT_str)
    f.close()