示例#1
0
def processFiles(files):
    for f in files:
        print "Processing file", f
        with open(f, "r") as fhandle:
            equations = fhandle.read().split("\n")
            print equations
            for equation in equations:
                if equation[0] == "#":
                    continue
                varequ = equation.split("|")
                if len(varequ) == 2:
                    var, equ = varequ
                else:
                    var = "x"
                    equ = varequ[0]

                var = var.strip()
                equ = eqparser.parse(equ.strip())

                print "var: %s, equ: %s" % (var, equ)
                print "Simplifying with AStar search:"
                start = time.time()
                res = eqsimplifier.simplify(equ, var, restart=restart, alpha_val=alpha_val)
                end = time.time()
                print "Simplified in ", end - start, " seconds"
                print res
示例#2
0
def processFiles(files):
    for f in files:
        print 'Processing file', f
        with open(f, 'r') as fhandle:
            equations = fhandle.read().split('\n')
            print equations
            for equation in equations:
                if equation[0] == '#':
                    continue
                varequ = equation.split('|')
                if len(varequ) == 2:
                    var, equ = varequ
                else:
                    var = 'x'
                    equ = varequ[0]

                var = var.strip()
                equ = eqparser.parse(equ.strip())

                print 'var: %s, equ: %s' % (var, equ)
                print 'Simplifying with AStar search:'
                start = time.time()
                res = eqsimplifier.simplify(equ,
                                            var,
                                            restart=restart,
                                            alpha_val=alpha_val)
                end = time.time()
                print 'Simplified in ', end - start, ' seconds'
                print res
示例#3
0
def interactive():
    while 1:
        try:
            s = raw_input("Eq >. ")
            x = raw_input("Var >. ")
        except EOFError:
            print
            break
        p = eqparser.parse(s)
        print "This is parsed at: " + repr(p)
        print "This is parsed at: " + str(p)
        print "Variable to evaluate: " + x

        print "Simplifying with AStar search:"
        start = time.time()
        res = eqsimplifier.simplify(p, x, restart=restart, alpha_val=alpha_val)
        end = time.time()
        print "Simplified in ", end - start, " seconds"
        print res
示例#4
0
def interactive():
    while 1:
        try:
            s = raw_input('Eq >. ')
            x = raw_input('Var >. ')
        except EOFError:
            print
            break
        p = eqparser.parse(s)
        print 'This is parsed at: ' + repr(p)
        print 'This is parsed at: ' + str(p)
        print 'Variable to evaluate: ' + x

        print 'Simplifying with AStar search:'
        start = time.time()
        res = eqsimplifier.simplify(p, x, restart=restart, alpha_val=alpha_val)
        end = time.time()
        print 'Simplified in ', end - start, ' seconds'
        print res