Python Implementation#
Main module.
- kleinberg_grid_simulator.python_implementation.python_edt.python_edt(n=1000, r=2, p=1, q=1, n_runs=10000, numba=True, parallel=False)[source]#
Python-based computation of the expected delivery time (edt).
- Parameters:
n (
int
, default=1000) – Grid siDer (
float
, default=2.0) – Shortcut exponentp (
int
, default=1) – Local rangeq (
int
, default=1) – Number of shortcutsn_runs (
int
, default=10000) – Number of routes to computenumba (
bool
, default=True) – Use JiT compilationparallel (
bool
, default=False) – Parallelize runs. Use for single, lengthy computation. Coarse-grained (high-level) parallelisation is preferred.
- Returns:
The expected number of steps to go from one point of the grid to another point of the grid.
- Return type:
- kleinberg_grid_simulator.python_implementation.greedy_walk.edt_gen(gen, n, p, q, n_runs)[source]#
Core computation of Expected Delivery Time (edt).
- kleinberg_grid_simulator.python_implementation.shortcuts.draw_1_lt_r_lt_2(n, r)[source]#
- Parameters:
- Returns:
A shortcut generator
- Return type:
callable
Examples
>>> set_seeds() >>> gen = draw_1_lt_r_lt_2(100, 1.5) >>> gen() (-78, -103) >>> gen = draw_1_lt_r_lt_2(1000000000, 1.8) >>> gen() (123799, 141186)
- kleinberg_grid_simulator.python_implementation.shortcuts.draw_2_lt_r(n, r)[source]#
- Parameters:
- Returns:
A shortcut generator
- Return type:
callable
Examples
>>> set_seeds() >>> gen = draw_2_lt_r(100, 2.5) >>> gen() (29, -45) >>> gen = draw_2_lt_r(10000000, 2.8) >>> gen() (2, 0) >>> gen = draw_2_lt_r(100000, 2.2) >>> gen() (0, -1) >>> gen() (-39, -15)
- kleinberg_grid_simulator.python_implementation.shortcuts.draw_r_eq_1(n)[source]#
- Parameters:
n (
int
) – grid size- Returns:
A shortcut generator
- Return type:
callable
Examples
>>> set_seeds() >>> gen = draw_r_eq_1(100) >>> gen() (0, -103) >>> gen = draw_r_eq_1(1000000000) >>> gen() (677037233, 596605187)
- kleinberg_grid_simulator.python_implementation.shortcuts.draw_r_eq_2(n)[source]#
- Parameters:
n (
int
) – grid size- Returns:
A shortcut generator
- Return type:
callable
Examples
>>> set_seeds() >>> gen = draw_r_eq_2(100) >>> gen() (-50, -103) >>> gen = draw_r_eq_2(1000000000) >>> gen() (23, -6)
- kleinberg_grid_simulator.python_implementation.shortcuts.draw_r_lt_1(n, r)[source]#
- Parameters:
- Returns:
A shortcut generator
- Return type:
callable
Examples
>>> set_seeds() >>> gen = draw_r_lt_1(100, .5) >>> gen() (0, -103) >>> gen = draw_r_lt_1(1000000000, .8) >>> gen() (1482484865, 59640099)