예제 #1
0
 def population_init(self):
     '''(re-)initializes population'''
     self.population = initialize_population(self.Config,
                                             self.Config.mean_age,
                                             self.Config.max_age,
                                             self.Config.xbounds,
                                             self.Config.ybounds)
예제 #2
0
    def __init__(self):

        self.Config = Configuration()
        self.frame = 0

        self.population = initialize_population(self.Config,
                                                self.Config.xbounds,
                                                self.Config.ybounds)

        self.pop_tracker = Population_trackers()

        self.peak_infections = 0
예제 #3
0
									mean_age=mean_age,
									max_age=max_age,
									age_dependent_risk=age_dependent_risk,
									risk_age=risk_age,
									critical_age=critical_age,
									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])
예제 #4
0
    # risk parameters
    age_dependent_risk = True  # whether risk increases with age
    risk_age = 55  # age where mortality risk starts increasing
    critical_age = 75  # age at and beyond which mortality risk reaches maximum
    critical_mortality_chance = 0.1  # maximum mortality risk for older age
    treatment_dependent_risk = True  # whether risk is affected by treatment
    # whether risk between risk and critical age increases 'linear' or 'quadratic'
    risk_increase = "quadratic"
    no_treatment_factor = 3  # risk increase factor to use if healthcare system is full

    ######################################
    ##### END OF SETTABLE PARAMETERS #####
    ######################################

    # initalize population
    population = initialize_population(pop_size, mean_age, max_age, xbounds,
                                       ybounds)
    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])
        # Load dataset
        df = pd.read_csv(args.d + "/" + args.d + ".data", header=None)

        # One-hot-encode attributes if tic-tac-toe dataset
        if args.d == "tic-tac-toe":
            df = pd.get_dummies(df,
                                columns=list(df.columns.values)[:-1],
                                drop_first=True)
            # Removing & appending label column at the end and renaming the columns
            col_9 = df.pop(9)
            df[9] = col_9
            df.columns = list(range(len(df.columns.values)))

        # Initialize population: returns list of individuals
        program_list = population.initialize_population(
            df, operators_mapping, args.p)

        # Run GP
        generation.run_each_generation(program_list, args.g, df, args.gap,
                                       args.tdp, MAX_PROGRAM_SIZE, args.d,
                                       NUMBER_OF_REGISTERS, vr_obj)

        print('Overall time: ' +
              str(round(timeit.default_timer() - overall_start, 3)) +
              ' seconds.\n')

    except Exception as err:
        print("Unexpected problem encountered: \n", str(err))
        traceback.print_exc()
예제 #6
0
    age_dependent_risk = True  #whether risk increases with age
    risk_age = 55  #age where mortality risk starts increasing
    critical_age = 75  #age at and beyond which mortality risk reaches maximum
    critical_mortality_chance = 0.1  #maximum mortality risk for older age
    treatment_dependent_risk = True  #whether risk is affected by treatment
    #whether risk between risk and critical age increases 'linear' or 'quadratic'
    risk_increase = 'quadratic'
    no_treatment_factor = 3  #risk increase factor to use if healthcare system is full

    ######################################
    ##### END OF SETTABLE PARAMETERS #####
    ######################################

    #initalize population
    population = initialize_population(pop_size,
                                       xbounds=xbounds,
                                       ybounds=ybounds)
    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)

    #place hospital on map x(-2, -1.5) y(-0.5, 0.5)
    #put hospital workers (first 50?) in their own bounds

    #population[0:healthcare_workers], \
    #destinations[0:healthcare_workers] = set_destination_bounds(population[0:healthcare_workers],
    #                                                            destinations[0:healthcare_workers],