Exemplo n.º 1
0
    def compute_trajectory(self, dev_max, dev_var, dev_thr):
        n_chunks, chunk_size_ms, last_chunk_ms = self._get_integration_chunks()
        init_cond = self.init_cond
        idx = None

        for i in range(n_chunks):
            if i == n_chunks - 1:
                integrator = Integrator(self.m, last_chunk_ms, self.dt)
            else:
                integrator = Integrator(self.m, chunk_size_ms, self.dt)

            integrator.set_initial_conditions(init_cond)
            idx = integrator.find_limit_cycle(dev_max, dev_var, dev_thr, methods.EULER)

            if idx[1] > idx[0] or i == n_chunks - 1:
                return integrator.data[:, idx[0]:idx[1]].copy()
            else:
                init_cond = integrator.data[:, -1].copy()
Exemplo n.º 2
0
        closure()
        t2 = time.time()
        total_t += t2 - t1
    return total_t / n

#def floq(gamma, dt, traj):
    #msfi.compute_Floquet(gamma, dt, traj) 
    #evals,_ = np.linalg.eig(msfi.X[-1])
    
    #return np.sort(np.abs(evals))[::-1]

def lyap(gamma, dt, traj):
    return msfi.compute_Lyapunov(gamma, dt, traj, n=100, max_iter=1e5)#, epsilon=1)

print('Computing trajectory...\n')
idx1, idx2 = i.find_limit_cycle(1e-5, 0, -1.4, methods.EULER)
length = idx2 - idx1
traj = i.data[:, idx1-4*length:idx2].copy()
del i

print('\nTesting MSF with lambda = row_sum...\n')

#print(floq(0, dt, traj))
les = lyap(-m.par.eps, dt, traj)
print les.mean(1)
#les = np.sort(les, 0)[::-1]
#x, q, n = msfi.test_qr()

#print('\nMeasuring computation time...\n')
#f = lambda: msfi.compute_Floquet(m.par.eps, dt, traj)
#print("{0} seconds per call, dt = {1}, ndim = {2}, niter = {3}".format(timeit(f, n), dt, m.ndim, traj.shape[1]))
Exemplo n.º 3
0
#traj = np.load('sgy_period_ref.npy')

m = SGY_neuron()
m.set_parameters(**reference_set)

# unstable parameters
m.par.g_ampa = 0
m.par.g_nmda = 0.09
m.par.w = 1.0

msfi = MSF_Integrator(m)
i = Integrator(m, tmax, dt)
i.set_initial_conditions(init)

# compute periodic trajectory
idx1, idx2 = i.find_limit_cycle(1e-5, test_var_thr=-55)
traj = i.data[:, idx1:idx2].copy()
del i

def floq(gamma):
    msfi.compute_Floquet(gamma, dt, traj) 
    evals,_ = np.linalg.eig(msfi.X[-1])
    return np.sort(np.abs(evals))[::-1]#import time

#t1 = time.time()
#msfer.compute_Floquet(1, 0.0005, traj)
#t2 = time.time()

#print t2-t1