Ejemplo n.º 1
0
 def objective(self):
     """ Try to get to the end ! """
     simulate(params=self.params,
              callback=self.callback,
              hourly=False,
              plt=self.plt,
              stopping_i=1)
     return len(self.metric_history) + 10 * (self.threshold_discrepancy -
                                             self.running_discrepancy)
Ejemplo n.º 2
0
 def run(self):
     """ To illustrate the OU process  """
     self.axs[0][0].clear()
     simulate(params=self.params,
              plt=plt,
              callback=self.callback,
              home=self.home,
              work=self.work,
              positions=self.initial_positions,
              stopping_t=150)
Ejemplo n.º 3
0
 def run(self):
     """ To illustrate the OU process  """
     self.axs[0][0].clear()
     home, work = initialization(self.params)
     simulate(params=self.params,
              plt=plt,
              callback=self.callback,
              home=home,
              work=work,
              stopping_t=50)
Ejemplo n.º 4
0
def modify_and_run(baseline, triples):
    # python3 shell.py large_town geometry n 20000 health vi 0.5
    params = BASELINES[baseline]
    descriptions = list()
    n = len(triples)
    assert n % 3 ==0, 'Expecting triples of command line parameters '
    num = int(n/3)
    print(num)
    for k in range(num):
        category = triples[3 * k].lower()
        param    = triples[3 * k+1].lower()
        assert category in CATEGORIES
        assert param in list(DESCRIPTIONS[category].keys())
        factor   = float(triples[3*k+2])
        params, desc = modifier( category=category, param=param, factor=factor, baseline=params )
        descriptions.append(desc)
    simulate(params=params, plt=plt, xlabel=','.join(descriptions))
Ejemplo n.º 5
0
 def run(self):
     """ To illustrate the OU process  """
     home, work, positions = initialization(self.params)
     simulate(params=self.params,plt=plt,callback=self.callback,home=home,work=work,positions=positions)
Ejemplo n.º 6
0
from pandemic.example_parameters import TOY_TOWN
from pandemic.simulation import simulate
import matplotlib.pyplot as plt
import time

if __name__ == "__main__":
    simulate(params=TOY_TOWN, plt=plt)
Ejemplo n.º 7
0
def small_town(with_plot=True):
    params = LARGE_TOWN
    params['geometry']['n']= int( params['geometry']['n'] / 2 )
    simulate(params=params, plt=plt if with_plot else None)
Ejemplo n.º 8
0
def large_town(with_plot=True):
    simulate(params=LARGE_TOWN, plt=plt if with_plot else None)
Ejemplo n.º 9
0
def town_with_close_neighbours(with_plot=True):
    params = LARGE_TOWN
    params['geometry']['r']= 0.5*params['geometry']['r']   # Sprawl distance
    simulate(params=params, plt=plt if with_plot else None)
Ejemplo n.º 10
0
def town_that_tests_randomly(with_plot=True):
    params = LARGE_TOWN
    params['health']['sp']= 3*params['health']['sp']
    params['health']['ip'] =6*params['health']['ip']
    simulate(params=params, plt=plt if with_plot else None)
Ejemplo n.º 11
0
def town_that_tests_symptomatic_more(with_plot=True):
    params = LARGE_TOWN
    params['health']['sp']= 3*params['health']['sp']
    simulate(params=params, plt=plt if with_plot else None)
Ejemplo n.º 12
0
from pandemic.example_parameters import SMALL_CITY
from pandemic.simulation import simulate
import matplotlib.pyplot as plt

if __name__ == "__main__":
    simulate(params=SMALL_CITY, plt=plt)
Ejemplo n.º 13
0
 def run(self):
     simulate(params=self.params,
              callback=self.callback,
              plot_hourly=False,
              plt=self.plt,
              xlabel="Sending results to www.swarmprediction.com. Thanks!")
Ejemplo n.º 14
0
from pandemic.example_parameters import SMALL_CITY, TOWN
from pandemic.simulation import simulate
import matplotlib.pyplot as plt
from copy import deepcopy
import numpy as np
import math


def equal_spaced_homes(b, num):
    num1 = int(math.sqrt(num))
    return [(x, y) for x in np.linspace(-b, b, num1)
            for y in np.linspace(-b, b, num1)]


if __name__ == "__main__":
    params = deepcopy(TOWN)
    num = 10000
    params['geometry']['b'] = 5.0
    b = params['geometry']['b']
    params['motion']['t'] = 48
    params['geometry']['c'] = 0.0  # Nobody commutes
    params['health']['vi'] = 50.0  # Collision -> infection
    home = equal_spaced_homes(b, num)
    work = deepcopy(home)
    params['geometry']['n'] = len(home)
    pos = deepcopy(home)
    simulate(params=params, home=home, work=work, positions=pos, plt=plt)