Solving ode with external time-varing parameters

Hello everyone,

I’m relatively new to Python and am currently working on building a SEIR model using the DifferentialEquation module from pymc3.ode. However, I’m facing some challenges, particularly with parameters in my model that vary over time, such as vaccine coverage and birth rate. Typically, in an ODE defined as ode(t, y, p), I could access values using t, like data[t, "vac_coverage"]. But with pymc3.ode, it appears that t is a Theano tensor variable and can’t be used as an index directly. Could anyone advise on how to incorporate external parameters and index them effectively in this context?

Thank you very much for your assistance!

Here is my failed attempt…

S, E, I, R, V, S2, E2, I2, R2, inci, inci1, inci2 = [state_matrix[i, :]for i in range(12)]
    t = tt.cast(t//52, 'int32')
    row = theano.function([t], data_shared[t])
    
    vac_coverage = theano.function([t], row[4])/100
    birth_rate = theano.function([t], row[3])/1000
    age_migration_rates = theano.function([t], row[5:10])/52
    vac_eff = theano.function([t], row[10])

    N = np.sum(state_matrix[:, :9], axis=0)

    Birth = np.sum(N) * birth_rate / 52

    lambda_ = (waifw[0].dot(I) + waifw[0].dot(I2))/N

    dS = (-lambda_ * S + S).dot(aging_matrix(age_migration_rates)) - S