示例#1
0
def buildBDDmain(example):
    try:
        bdd = BDD.bdd_init(
            example)  # "python/programoutput/" + uniqid + ".txt"

    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 len(bdd["var_order"]) > BDD_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 BDD package and run it on your own machine."
        exit_err()

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

    BDD.ite_build(bdd)

    stats = BDD.stat_string(bdd)
    sat_count = BDD.sat_count(bdd)
    variable_order = bdd["var_order"]
    sat_assigns = BDD.all_sat(bdd)
    sat_assigns_string = ""
    for x in sat_assigns:
        sat_assigns_string += str(list(map(lambda y: 0
                                           if '~' in y else 1, x))) + '\n'

    dot_file = uniqid + ".dot"
    #    print("dot_file = ", dot_file)
    #    print("BDD = ", bdd)

    BDD.dot_bdd(bdd, dot_file)
    #print reduce(lambda x, y : x + " " + y, [dot_PATH, dot_ARGS, dot_file, dot_OUT])
    #err = os.system(reduce(lambda x, y : x + " " + y, [dot_PATH, dot_ARGS, dot_file, dot_OUT]))
    #print( rm + " " + dot_file )
    #   print("Dot file left behind as", dot_file)
    #os.system(rm + " " + dot_file)

    #   if err != 0:
    #       ERR_str = "There was an error running dot on the server"
    #       exit_err()

    STAT_str = "Number of satisfying assignments: " + str(sat_count) + "\n"\
                + stats + "\n\nAll satisfying assignments:\n" + "------------------------------\n"\
                + sat_assigns_string
    print("Satisfying string is", STAT_str)
示例#2
0
        exit_err()
        
    if len(bdd["var_order"]) > 14:
        ERR_str = "Your formula contains too many variables for the web interface. Please try again with less than 14 variables or download the BDD package and run it on your own machine."
        exit_err()
                        
    if len(pb.print_expr(bdd["expr"])) > 500:
        ERR_str = "Your formula is too long for the web interface. Please try again with a smaller formula or download the BDD package and run it on your own machine."
        exit_err()

    BDD.reorder_ite_build(bdd)

    stats = BDD.stat_string(bdd)
    sat_count = BDD.sat_count(bdd)
    variable_order = bdd["var_order"]
    sat_assigns = BDD.all_sat(bdd)
    sat_assigns_string = ""
    for x in sat_assigns:        
        sat_assigns_string += str(map(lambda y : 0 if '~' in y else 1, x)) + '\n'
    
    dot_file = "python/programoutput/" + uniqid + ".dot"
    BDD.dot_bdd(bdd, dot_file)
    #print reduce(lambda x, y : x + " " + y, [dot_PATH, dot_ARGS, dot_file, dot_OUT])
    err = os.system(reduce(lambda x, y : x + " " + y, [dot_PATH, dot_ARGS, dot_file, dot_OUT]))
    #print rm + " " + dot_file
    os.system(rm + " " + dot_file)

    if err != 0:
        ERR_str = "There was an error running dot on the server"
        exit_err()
    
示例#3
0
文件: runMe.py 项目: KingsleyZ/PyBool
# Oct 10, 2011

# Simple BDD script to prove that Babies cannot manage crocodiles
# See Solution.txt for a complete walkthrough.

import sys

sys.path.append("../../include/")
sys.path.append("../../../../PyBool/include/")
import BDD
import os

if __name__ == "__main__":

    # creating and initializing the BDD
    x = BDD.bdd_init("build8.txt")
    y = BDD.bdd_init("build8.txt")

    # building the tree
    BDD.build(x)
    BDD.ite_build(y)

    BDD.dot_bdd(x, "dotfile1.dot")
    BDD.dot_bdd(y, "dotfile2.dot")

    if BDD.sat_count(x) != BDD.sat_count(y):
        print "error!"

    if BDD.all_sat(x) != BDD.all_sat(y):
        print "error!"
示例#4
0
sys.path.append("../../include/")
sys.path.append("../../../../PyBool/include/")
import BDD
import pdb

if __name__ == "__main__":

    #creating and initializing the BDD
    x = BDD.bdd_init("formula.txt")

    #building the tree
    BDD.ite_build(x)

    #find and display all sat assignments
    print("All Sat assignments: ")
    print("----------------------------")

    b = BDD.all_sat(x)

    for q in b:
        print(q)

    print ""

    print BDD.stat_string(x)

    print ""
    print "One satisfying assignment is: "
    print BDD.any_sat(x)
    BDD.dot_bdd(x, "myDot.dot")
示例#5
0
文件: runMe.py 项目: KingsleyZ/PyBool
sys.path.append("../../../../PyBool/include/")
import BDD
import pdb

if __name__ == "__main__":
    
    #creating and initializing the BDD
    x = BDD.bdd_init("formula.txt")

    #building the tree
    BDD.ite_build(x)

    #find and display all sat assignments
    print("All Sat assignments: ")
    print("----------------------------")

    b = BDD.all_sat(x)

    for q in b:
        print(q)

    print ""

    print BDD.stat_string(x)

    print ""
    print "One satisfying assignment is: "
    print BDD.any_sat(x)
    BDD.dot_bdd(x, "myDot.dot")

示例#6
0
文件: runMe.py 项目: ganeshutah/Jove
#Tyler Sorensen
#Oct 10, 2011

#Simple BDD script to prove that Babies cannot manage crocodiles
#See Solution.txt for a complete walkthrough.

import sys
sys.path.append("../../include/")
sys.path.append("../../../../PyBool/include/")
import BDD
import os

if __name__ == "__main__":

    #creating and initializing the BDD
    x = BDD.bdd_init("build8.txt")
    y = BDD.bdd_init("build8.txt")

    #building the tree
    BDD.build(x)
    BDD.ite_build(y)

    BDD.dot_bdd(x, "dotfile1.dot")
    BDD.dot_bdd(y, "dotfile2.dot")

    if BDD.sat_count(x) != BDD.sat_count(y):
        print "error!"

    if BDD.all_sat(x) != BDD.all_sat(y):
        print "error!"
示例#7
0
        exit_err()

    if len(bdd["var_order"]) > BDD_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 BDD package and run it on your own machine."
        exit_err()

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

    BDD.reorder_ite_build(bdd)

    stats = BDD.stat_string(bdd)
    sat_count = BDD.sat_count(bdd)
    variable_order = bdd["var_order"]
    sat_assigns = BDD.all_sat(bdd)
    sat_assigns_string = ""
    for x in sat_assigns:
        sat_assigns_string += str(map(lambda y: 0
                                      if '~' in y else 1, x)) + '\n'

    dot_file = "python/programoutput/" + uniqid + ".dot"
    BDD.dot_bdd(bdd, dot_file)
    #print reduce(lambda x, y : x + " " + y, [dot_PATH, dot_ARGS, dot_file, dot_OUT])
    err = os.system(
        reduce(lambda x, y: x + " " + y,
               [dot_PATH, dot_ARGS, dot_file, dot_OUT]))
    #print rm + " " + dot_file
    os.system(rm + " " + dot_file)

    if err != 0: