Ejemplo n.º 1
0
def simulate(years, iterations):
    forecast_id = dbutil.get_forecast_id()

    original_physicians = dbutil.load_workforce()

    forecast = {}
    for iteration in range(iterations):
        # list() creates a copy of the original list
        physicians = list(original_physicians)

        for year in range(2011, years+2012):
            if year > 2011:
                r = retire.RetireEvent()
                r.process(physicians)

            c = census.CensusEvent(forecast_buckets)
            c.process(physicians)

            rows = []
            for key, value in c.counts.iteritems():
                # HeadcountSigma, HeadcountSigma^2, FTESigma, FTESigma^2
                stats = [value, value*value, value, value*value, iteration];
                rows.append([forecast_id, year] + list(key) + stats)
            dbutil.write_forecast(rows)

    dbutil.merge_forecast(forecast_id, iterations)
    return dbutil.get_forecast(forecast_id)
Ejemplo n.º 2
0
 def get(self):
     fid = int(self.get_argument('fid', 1))
     rows = dbutil.get_forecast(fid)
     self.render('templates/simulation.html', rows=rows, forecast_id=fid,
             years='?', iterations='?')