Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from brian import *
- import scipy.optimize
- import matplotlib.pyplot as plt
- import random
- from pyevolve import G1DList
- from pyevolve import GSimpleGA
- from brian.library.ionic_currents import *
- random.randrange(0,3000,1)
- x = arange(0,2500)
- for n in range (0,2500):
- x[n] = random.random()
- def eval_func(chromosome):
- score = 3
- for value in chromosome:
- refract = 3
- tau = 10 * ms
- Vr = -70 * mV
- Vt = -55 * mV
- G = NeuronGroup(1, model='V:volt', threshold=Vt, reset=Vr, refractory=(refract*ms))
- input = SpikeGeneratorGroup(1, [(0, t * ms) for t in x])
- C = Connection(input, G)
- C[0, 0] = 2 * mV
- M = SpikeMonitor(G)
- run(3000 * ms)
- value1 = arange(0,(M.spiketimes[0].size)-1)
- if (M.spiketimes[0].size == 1):
- value1 = M.spiketimes[0][0]
- for n in range (0,(M.spiketimes[0].size)-2):
- value1[n] = M.spiketimes[0][n+1]-M.spiketimes[0][n]
- if value1[n] == 3:
- score += 1
- return score
- genome = G1DList.G1DList(20)
- genome.evaluator.set(eval_func)
- ga = GSimpleGA.GSimpleGA(genome)
- ga.evolve(freq_stats=10)
- print ga.bestIndividual()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement