Implementing Complex Systems Simulation Using Param Time Module

Is it possible to have a parameter that depends on parameters at the previous time step using the dynamic time functionality of param?

For example, I want to model a bathtub.

import param as pm
class BathTub(pm.Parameterized):
    x = pm.Magnitude(0.5, doc="The level of water in the bathtub")
    k = pm.Number(0.1, bounds=(0, None), doc="The width of the drain")

    def step(self):
        self.x -= self.k * self.x


b = BathTub(x=lambda pm.Dynamic.time())

Obviously the way i’m instantiated BathTub with dynamic time is not correct, but I can’t conceptually think about how to do it correctly. Is it possible to model complex systems with the param time module?

I would really appreciate hearing from @philippjfr on the matter consider the implementation of: topographica/topo/base/simulation.py at master · ioam/topographica · GitHub

Thanks!

Heya!

The param Time stuff takes me all the way back to my PhD when I implemented it :slight_smile:

The original motivation was to have ‘time controlled randomness’, essentially I needed the random number generator to output a fixed value for a given simulation time (instead of being dependent on the number of calls).

I can’t quite remember how it interacts with dynamic parameters (I think it was via numbergen which still ships with param afaik) but I do remember that the idea is that you had a global Time object (i.e. a singleton) where you could increment the time (typically by a simulation time step at a time).

I’m not entirely clear what you are trying to achieve here but hope that is some useful context/background!