Commit e5284691 authored by Carlos GO's avatar Carlos GO
Browse files

adaptive mutation rate with option mutation_rate=-1

parent 6edb4035
......@@ -159,6 +159,13 @@ def populate(size, length, gc, fit="energy", target=None):
def mutate(rna, mutation_rate):
mutations = 0
new_seq = ""
#if adaptive mutation rate, mutation rate is a function of stability.
if mutation_rate == -1:
sig = lambda e: 1 / (1 + np.exp(-e))
mutation_rate = sig(rna.energy)
pass
for s in rna.sequence:
r = random.random()
if r < mutation_rate:
......@@ -314,3 +321,6 @@ def start(generations=20, size=10, length=50, fit='energy', gc=0.5,\
pool.map(evolve, todo)
else:
evolve(next(todo))
if __name__ == "__main__":
start(mutation_rate=-1, dest="maternal_adaptive.csv")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment