예제 #1
0
if len(sys.argv) != 3:
    print "Invalid number of arguments."
    print "./pop_lyapunov.py <ID> <size>"
    sys.exit(0)
ID = sys.argv[1]
size = sys.argv[2]

#The hero!
o = shelve.open("../dat/"+ID+"/"+ID+".2999.pop")['pop'][0]
if size == 'local':
    step = 0.000000001
    # Increase back up to 1000
    start = o['amplitude'] - step*1000
    stop = o['amplitude'] + step*1000
elif size == 'global':
    start = 0
    step = 0.000001
    stop = 0.03
else:
    raise ValueError, "wtf!"
input = o['org']

for amplitude in misc.arange(start, stop+step, step):
    lyaps = [metrics._lyapunov( input,
                                maps.network,
                                [random(), random()],
                                amplitude)
                                    for i in range(10)]
    print amplitude, sum(lyaps)/float(len(lyaps))

    vals = d['vals']
    print "Awesome!  Skipping calc."
else:
    vals = [ [0 for j in range(len(res))] for i in range(len(res)) ]
    for i in range(len(res)):
        done = 100 * i / float(len(res))
        print "\rDone:  %%%f.  i=%i of %i." % (done, i, len(res)),
        sys.stdout.flush()

        for j in range(len(res) / 2.0 ):
            x, y = res[i], res[j]

            input = [[x,y],[0,0]]
            amplitude = 1
            lyaps = [metrics._lyapunov( input,
                                maps.logistic,
                                [random()],
                                amplitude)
                                    for k in range(1)]

            if sum(lyaps)/float(len(lyaps)) > 0:
                vals[i][j] = 0
            else:
                vals[i][j] = -1 * sum(lyaps)/float(len(lyaps))
    d['vals'] = vals
    d.close()
    print "Done calcing.. building image now."

top = max(max(vals))
for i in range(len(res)):
    for j in range(len(res) / 2.0):
        val = vals[i][j]
    vals = d['vals']
    print "Awesome!  Skipping calc."
else:
    vals = [ [0 for j in range(len(res))] for i in range(len(res)) ]
    for i in range(len(res)):
        done = 100 * i / float(len(res))
        print "\rDone:  %%%f.  i=%i of %i." % (done, i, len(res)),
        sys.stdout.flush()

        for j in range(len(res)):
            x, y = res[i], res[j]

            input = [[x,y]]
            amplitude = 1
            lyaps = [metrics._lyapunov( input,
                lambda x : maps.logistic(x, 4),
                                [random()],
                                amplitude)
                                    for k in range(3)]

            if sum(lyaps)/float(len(lyaps)) > 0:
                vals[i][j] = 0
            else:
                vals[i][j] = -1 * sum(lyaps)/float(len(lyaps))
    d['vals'] = vals
    d.close()
    print "Done calcing.. building image now."

top = max(max(vals))
for i in range(len(res)):
    for j in range(len(res)):
        val = vals[i][j]