예제 #1
0
    ax.plot(TT, RRd, label='Rd')
    ax.plot(TT, RRo, label='Ropt')
    ax.legend(shadow=True, loc=2)
    plt.xlabel('time (days)')
    plt.ylabel('recovered count')
    plt.title('comparison between methods: number of recovered people')
    plt.savefig('mcm2015files/output/R_cmp_%s.png' % TT[-1])


if __name__ == "__main__":
    fields = ['S', 'E', 'I', 'R', 'rD', 'rV'
              ] + ['from%s' % i for i in xrange(1, 11)]
    abbr = ['CO', 'FR', 'MO', 'LA', 'KA', 'GR', 'KI', 'MA', 'VA', 'KO']
    Y = np.array(
        tabular.tbarr('mcm2015files/Pop_Transfer.csv', fields,
                      {field: 'float'
                       for field in fields}, {}))
    t = 0
    dt = .1
    final_t = 200
    idx = 0
    YY = [Y]
    YYd = [Y]
    YYo = [Y]
    TT = [t]
    aborted = False
    playing = True
    playdir = 1
    tlen = 1
    idx = 0
    distributor = drug_distributor(YYd, nD, nV, days, dt)
예제 #2
0
    fig,ax = plt.subplots()
    ax.plot(TT,RR,label='R')
    ax.plot(TT,RRd,label='Rd')
    ax.plot(TT,RRo,label='Ropt')
    ax.legend(shadow=True,loc=2)
    plt.xlabel('time (days)')
    plt.ylabel('recovered count')
    plt.title('comparison between methods: number of recovered people')
    plt.savefig('mcm2015files/output/R_cmp_%s.png'%TT[-1])


    
if __name__ == "__main__":
    fields = ['S','E','I','R','rD','rV'] + ['from%s'%i for i in xrange(1,11)]
    abbr = ['CO','FR','MO','LA','KA','GR','KI','MA','VA','KO']
    Y = np.array(tabular.tbarr('mcm2015files/Pop_Transfer.csv',fields,{field:'float' for field in fields},{}))
    t = 0
    dt = .1
    final_t = 200    
    idx = 0
    YY = [Y]
    YYd = [Y]
    YYo = [Y]
    TT = [t]
    aborted = False
    playing = True
    playdir = 1
    tlen = 1
    idx = 0
    distributor = drug_distributor(YYd,nD,nV,days,dt)
    distributor_opt = drug_distributor_opt(YYo,nD,nV,days,dt)
예제 #3
0
        S, E, I, R, D, I_c = tuple(Y)
        N = sum(Y[0:4])
        return np.array([
            br * N - beta * S * I / N - mu * S,
            beta * S * I / N - (eps + mu) * E, eps * E - (gamma + ddr) * I,
            (1. / 10 - ddr) * I - mu * R, ddr * I, eps * E
        ])

    return f


if __name__ == "__main__":
    rfields = ['t', 'C']
    realdata = np.array(
        tabular.tbarr('mcm2015files/betatest.csv', rfields,
                      {field: 'float'
                       for field in rfields}, {}))
    initState = np.array([22e6, 0, 86, 0, 0, 86])
    lobound, hibound = 0.0, 1.0
    guess = lobound * 0.5 + hibound * 0.5
    T, Y = odeint(ebola_kernel(guess), initState, 0, 317)
    ret = Y[-1][5]
    print guess, ret
    while abs(ret - 22460) > 0.1:
        if ret - 22460 < 0:
            lobound = guess
        else:
            hibound = guess
        guess = lobound * 0.5 + hibound * 0.5
        T, Y = odeint(ebola_kernel(guess), initState, 0, 317)
        ret = Y[-1][5]
예제 #4
0
        S,E,I,R,D, I_c = tuple(Y)
        N = sum(Y[0:4])
        return np.array([
            br*N-beta*S*I/N-mu*S,
            beta*S*I/N - (eps+mu)*E,
            eps*E - (gamma+ddr)*I,
            (1./10 -ddr)*I- mu*R,
            ddr*I,
            eps*E
        ])
    return f


if __name__ == "__main__":
    rfields = ['t','C']
    realdata = np.array(tabular.tbarr('mcm2015files/betatest.csv',rfields,{field:'float' for field in rfields},{}))    
    initState = np.array([22e6,0,86,0,0,86])
    lobound,hibound = 0.0, 1.0
    guess = lobound*0.5+hibound*0.5
    T,Y = odeint(ebola_kernel(guess),initState,0,317)
    ret = Y[-1][5]
    print guess, ret
    while abs(ret-22460) > 0.1:
        if ret-22460 < 0:
            lobound = guess
        else:
            hibound = guess
        guess = lobound*0.5 + hibound*0.5
        T,Y = odeint(ebola_kernel(guess),initState,0,317)
        ret = Y[-1][5]
        print guess, ret