# %% Configuration # ================ GRAPH = 'er' TAUS = np.concatenate([[0.001], np.arange(0.01, 0.3, step=0.05), np.arange(0.3, 3.01, step=0.1)]) DISTANCE = 25 # %% Run the required simulations # =============================== graph = load_graph(GRAPH) out = data_path(f'MFPT/{GRAPH}_UndirectedNetwork_ExponentialWalker') if not out.exists(): network = UndirectedNetwork(graph) walker = ExponentialWalker(timescale=0.1) sim = MFPTSimulation(network, walker, num_sims=5000) results = sim.run() results.to_csv(str(out)) for tau in TAUS: out = data_path( f'MFPT/{GRAPH}_SwitchingNetwork_ExponentialWalker_tau{tau:e}') if out.exists(): continue print(f'Running simulation: {out}') network = SwitchingNetwork(graph, timescale=tau, memory=False)
# %% Configuration # ================ GRAPH = 'hex' TAU = 3. NUM_TRAJS = 10000 MAX_TIME = 200 # %% Run the required simulations # =============================== graph = load_graph(GRAPH) # Undirected network out = data_path( f'trajs/{GRAPH}_UndirectedNetwork_ExponentialWalker_N{NUM_TRAJS}_max_time{MAX_TIME}', suffix='.parquet') if not out.exists(): print(f'Generating trajectories: {out}') network = UndirectedNetwork(graph) walker = ExponentialWalker(timescale=0.1) generator = TrajectoryGenerator(network, walker) trajs = generator.trajectories(NUM_TRAJS, MAX_TIME) trajs.to_parquet(str(out)) # Active network out = data_path( f'trajs/{GRAPH}_SwitchingNetwork_ExponentialWalker_tau{TAU:e}_N{NUM_TRAJS}_max_time{MAX_TIME}', suffix='.parquet') if not out.exists(): print(f'Generating trajectories: {out}')
# %% Configuration # ================ GRAPH = 'hex' TAUS = np.concatenate([[0.001], np.arange(0.01, 0.075, step=0.005), np.arange(0.75, 0.3, step=0.01), np.arange(0.3, 2.3, step=0.1)]) DISTANCE = 25 # %% Run the required simulations # =============================== graph = load_graph(GRAPH) out = data_path(f'MFPT/{GRAPH}_UndirectedNetwork_ExponentialWalker') if not out.exists(): network = UndirectedNetwork(graph) walker = ExponentialWalker(timescale=0.1) sim = MFPTSimulation(network, walker, num_sims=5000) results = sim.run() results.to_csv(str(out)) for tau in TAUS: out = data_path( f'MFPT/{GRAPH}_SwitchingNetworkConstantRate_ExponentialWalker_tau{tau:e}_sim1000' ) if out.exists(): continue print(f'Running simulation: {out}')
# %% Configuration # ================ TAU = 0.03 VMAX = 3000 GRAPH = "er" # %% Run required simulations # =========================== graph = load_graph(GRAPH) out = data_path(f'MFPT/{GRAPH}_SwitchingNetwork_ExponentialWalker_tau{TAU:e}') if not out.exists(): network = SwitchingNetwork(graph, timescale=TAU, memory=False) walker = ExponentialWalker(timescale=0.1) sim = MFPTSimulation(network, walker, num_sims=5000) print(f'Running simulation: {out}') res = sim.run() res.to_csv(str(out)) # %% MFPT heatmap # =============== data = load_data(f'MFPT/{GRAPH}_SwitchingNetwork_ExponentialWalker_tau{TAU:e}') # data = load_data(f'MFPT/{GRAPH}_UndirectedNetwork_ExponentialWalker')
# %% Configuration GRAPH = 'hex' TAU = 1e9 # “frozen” active network MAX_TIME = 60 NUM_RUNS = 10 # number of independent simulations to run # %% Run the required simulations # =============================== graph = load_graph(GRAPH) for n_run in range(1, NUM_RUNS + 1): out = data_path( f'trajs/{GRAPH}_SwitchingNetwork_ExponentialWalker_tau{TAU:e}_uniform_10_max_time{MAX_TIME}_run{n_run}', suffix='.parquet') if out.exists(): continue print(f'Generating trajectories: {out}') # Start from uniform distribution, 10 particles per node. network = SwitchingNetwork(graph, timescale=TAU) walker = ExponentialWalker(timescale=0.1) num_walkers = 10 * network.graph.number_of_nodes() start_nodes = np.repeat(list(network.graph.nodes), 10) generator = TrajectoryGenerator(network, walker) trajs = generator.trajectories(num_walkers, MAX_TIME, start_nodes=start_nodes) trajs.to_parquet(str(out))
TAUS = [0.03, 0.3, 3] N = 10000 MAX_TIME = 120 GRAPH = 'hex' TARGET = 146 # %% Run the required simulations # =============================== graph = load_graph(GRAPH) for tau in TAUS: out = data_path( f'trajs/{GRAPH}_SwitchingNetwork_ExponentialWalker_tau{tau:e}_N{N}_max_time{MAX_TIME}', suffix='.parquet') if out.exists(): continue print(f'Generating trajectories: {out}') network = SwitchingNetwork(graph, timescale=tau) walker = ExponentialWalker(timescale=0.1) generator = TrajectoryGenerator(network, walker) trajs = generator.trajectories(N, MAX_TIME) trajs.to_parquet(str(out)) # %% Generate the figures # ======================= for tau in TAUS:
GRAPH = 'hex' NUM_TRAJS = 1000 TARGET = 146 TAUS = [0.03, 0.3, 3.] NUM_SIMS = 1000 # %% Run required simulations # =========================== graph = load_graph(GRAPH) distance = nx.shortest_path_length(graph, 0, TARGET) for tau in TAUS: out = data_path( f'trajs/{GRAPH}_SwitchingNetwork_ExponentialWalker_tau{tau:e}_N{NUM_TRAJS}_1st_trajectories_S0_T{TARGET}', suffix='.parquet') if out.exists(): continue print(f'Generating trajectories: {out}') network = SwitchingNetwork(graph, timescale=tau) walker = ExponentialWalker(timescale=0.1) # We generate simulations with NUM_TRAJS particles and keep only the first # to arrive. We repeat this NUM_SIMS times to obtain the statistics of the # first particle to arrive. trajs = [] for sim_id in trange(NUM_SIMS): network.reset()