コード例 #1
0
 def reinitialise(self):
     '''reset the simulation'''
     
     self.frame = 0
     self.population_init()
     self.pop_tracker = Population_trackers()
     self.destinations = initialize_destination_matrix(self.Config.pop_size, 1)
コード例 #2
0
    def __init__(self, *args, **kwargs):
        #load default config data
        self.Config = Configuration(*args, **kwargs)
        self.frame = 0

        #initialize default population
        self.population_init()

        self.pop_tracker = Population_trackers()

        #initalise destinations vector
        self.destinations = initialize_destination_matrix(self.Config.pop_size, 1)        
コード例 #3
0
    def __init__(self, *args, **kwargs):
        #load default config data
        self.Config = Configuration(*args, **kwargs)
        self.frame = 0

        #initialize default population
        self.population_init()

        self.pop_tracker = Population_trackers(self.Config.simulation_steps)

        #initalise destinations vector
        self.destinations = initialize_destination_matrix(
            self.Config.pop_size, 1)
        self.testing = False
        self.positive = []
        self.last_positive = None
        self.last_number_of_tests = 0
コード例 #4
0
 def initialize_simulation(self):
     #initialize times
     self.frame = 0
     self.time = 0
     self.last_step_change = 0
     self.above_act_thresh = False
     self.above_deact_thresh = False
     self.above_test_thresh = False
     #initialize default population
     self.population_init()
     #initalise destinations vector
     self.destinations = initialize_destination_matrix(
         self.Config.pop_size, 1)
     #initalise grid for tracking population positions
     self.grid_coords, self.ground_covered = initialize_ground_covered_matrix(
         self.Config.pop_size, self.Config.n_gridpoints,
         self.Config.xbounds, self.Config.ybounds)
     #initalise population tracker
     self.pop_tracker = Population_trackers(self.Config, self.grid_coords,
                                            self.ground_covered)
コード例 #5
0
									critical_mortality_chance=critical_mortality_chance,
									risk_increase=risk_increase,
									proportion_distancing=proportion_distancing,
									recovery_duration=recovery_duration,
									mortality_chance=mortality_chance,
									treatment_factor=treatment_factor,
									no_treatment_factor=no_treatment_factor,
									treatment_dependent_risk=treatment_dependent_risk)

    #initalize population
    population = initialize_population(configuration)
    population[:,13] = wander_range_x #set wander ranges to default specified value
    population[:,14] = wander_range_y #set wander ranges to default specified value

    #initialize destination matrix
    destinations = initialize_destination_matrix(pop_size, 1)

    #create render folder if doesn't exist
    if not os.path.exists('render/'):
        os.makedirs('render/')

    #define figure
    fig = plt.figure(figsize=(5,7))
    spec = fig.add_gridspec(ncols=1, nrows=2, height_ratios=[5,2])

    ax1 = fig.add_subplot(spec[0,0])
    plt.title('infection simulation')
    plt.xlim(xbounds[0] - 0.1, xbounds[1] + 0.1)
    plt.ylim(ybounds[0] - 0.1, ybounds[1] + 0.1)

    ax2 = fig.add_subplot(spec[1,0])