示例#1
0
 def threaded_simulate (self, thread):
     
     half = int (POP_SIZE / 2)
     start = 0 if thread == 1 else half
     end = start + half
     population = self.population [start:end]
     for c in population:
         c.fitness = simulate_model (c.genotype)
     self.population[start:end] = population
示例#2
0
    def threaded_simulate(self, thread):

        half = int(POP_SIZE / 2)
        start = 0 if thread == 1 else half
        end = start + half
        population = self.population[start:end]
        for c in population:
            c.fitness = simulate_model(c.genotype)
        self.population[start:end] = population
示例#3
0
    def unthreaded_simulate (self):
        #print "inside unthreaded_simulate"
        # Run population through simulation.
        for c in self.population:
            c.set_fitness (simulate_model (c.genotype,self.t_1,self.t_2))
            print "simulate %s, %s" % (str(self.t_1),str(self.t_2))

        for c in sorted(self.population, key= lambda c: c.fitness):
            print "{: <12} {}".format (c.genotype, c.fitness)
            
        print ""
示例#4
0
    def unthreaded_simulate(self):
        #print "inside unthreaded_simulate"
        # Run population through simulation.
        for c in self.population:
            c.set_fitness(simulate_model(c.genotype, self.t_1, self.t_2))
            print "simulate %s, %s" % (str(self.t_1), str(self.t_2))

        for c in sorted(self.population, key=lambda c: c.fitness):
            print "{: <12} {}".format(c.genotype, c.fitness)

        print ""
示例#5
0
 def run (self):
     starti = self.starti
     endi = self.endi
     num_iter = len (self.population) / 2
     for i in range (starti, endi):
         c = self.population [i]
         fitness = 0
         try:
             fitness = simulate_model (c.genotype,self.t_1,self.t_2)
         except:
             pass
         if fitness >= 1:
             self.population [i].fitness = fitness
         else:
             self.population [i].fitness = 1
示例#6
0
 def run(self):
     starti = self.starti
     endi = self.endi
     num_iter = len(self.population) / 2
     for i in range(starti, endi):
         c = self.population[i]
         fitness = 0
         try:
             fitness = simulate_model(c.genotype, self.t_1, self.t_2)
         except:
             pass
         if fitness >= 1:
             self.population[i].fitness = fitness
         else:
             self.population[i].fitness = 1
示例#7
0
 def run (self):
     #print "inside MP run"
     while True:
         c = self.task_queue.get()
         fitness = 0
         if c is None:
             break
         try:
             fitness = simulate_model (c[0].genotype,c[1],c[2])
         except:
             pass
         if fitness >= 1:
             c[0].fitness = fitness
         else:
             c[0].fitness = 1
         self.result_queue.put (c[0])
示例#8
0
 def run(self):
     #print "inside MP run"
     while True:
         c = self.task_queue.get()
         fitness = 0
         if c is None:
             break
         try:
             fitness = simulate_model(c[0].genotype, c[1], c[2])
         except:
             pass
         if fitness >= 1:
             c[0].fitness = fitness
         else:
             c[0].fitness = 1
         self.result_queue.put(c[0])
示例#9
0
#!/usr/bin/env python

import simulate
import fit_data
import model_data
import pandas as pd
import tools

model = simulate.load_model('volume_reference.txt')

#df =  model_data.get_model_parameters_as_dataframe(model)
#df.to_csv('used_model_parameters.csv')

#set paras
#param_list = ['V_b', 'V_os', '[c_e]', '[c_i]', 	'k_deg', 'k_nutrient', 'modulus_adjustment', 'phi',	'pi_t0', 'pi_tc_0']

#df = pd.read_csv('used_model_parameters.csv')
#model = model_data.set_model_parameters_from_dataframe(model, df, param_list, row=1)

#run simu

simulation_result = simulate.simulate_model(model, end_time=7200)
simulate.plot((simulation_result, ), legend=True)