Simulation

The simulations module contains all the tools to simulate the models and generate the data needed to perform the analysis.

class er.simulation.Simulation(network: er.model.network.NetworkModel, walker: er.model.walker.Walker, num_sims=1000)

Bases: object

The base abstract class for simulations.

Parameters
abstract run()

Run the simulation.

class er.simulation.ConcurrentSimulation(network: er.model.network.NetworkModel, walker: er.model.walker.Walker, num_sims=1000)

Bases: er.simulation.simulation.Simulation

The base class for concurrent simulations.

run(progress=True)

Runs the simulations concurrently.

class er.simulation.MFPTSimulation(network: er.model.network.NetworkModel, walker: er.model.walker.Walker, num_sims=1000)

Bases: er.simulation.simulation.ConcurrentSimulation

Mean First Passage Time Simulation.

Simulates independent walkers on a graph and finds the Mean First Passage Time for all the nodes. Since all the walkers move on independent networks this simulation works well with memoryless implementations of the network.

Parameters
class er.simulation.MEFPTSimulation(network: er.model.network.NetworkModel, walker: er.model.walker.Walker, num_walkers: int, num_sims=1000)

Bases: er.simulation.simulation.ConcurrentSimulation

Mean Extreme First Passage Time simulation.

Simulates many particles and calculates the mean time required for the first one to hit the target. It is a generalization of the MFPT simulation for multiple particles which are diffusing at the same time. This models an activation process where one particle is sufficient to activate a target/receptor.

If you only need to simulate a single particle, use MFPTSimulation instead, since it is optimized for single particle analysis.

class er.simulation.TrajectoryGenerator(network: er.model.network.NetworkModel, walker: er.model.walker.Walker)

Bases: object

Trajectory generator.

TrajectoryGenerator simulates an arbitrary number of walkers on a network and returns the trajectories of each walker.

trajectories(num_walkers, max_time, start_nodes=None, progress=True)

Simulates the walkers motion for a limited time.

Parameters
  • num_walkers (int) – The number of walkers to simulate.

  • max_time (float) – The time at which the simulation will be interrupted.

  • progress (bool) – Whether to show the progress bar during the simulation.

Returns

trajectories – A pandas.DataFrame containing the trajectories.

Return type

pd.DataFrame

trajectories_to_target(num_walkers, target, keep=None, progress=True)

Simulates the walkers motion until they hit a given target.

Parameters
  • num_walkers (int) – The number of walkers to simulate.

  • target – The target node label.

  • keep (int) – The number of trajectories to keep (sorted by arrival time). For example, if keep is 10 only the trajectories of the first 10 walkers to arrive at the target will be returned. If set to None, all the trajectories will be returned.

Returns

data – A pandas.DataFrame containing the trajectories.

Return type

pandas.Dataframe