Main Run Function
Module to run the AMR Hub ABM simulation.
run_and_analyse_contacts(output_dir, *, distance_threshold=0.1, bins=50, use_gpu=False, heatmap_format='png')
Run one complete simulation without plotting and analyse agent contacts.
Trajectories and contact analysis outputs are written to output_dir.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path
|
Directory for trajectory CSVs and the |
required |
distance_threshold
|
float
|
Maximum distance for two agents to be in contact, by default 0.1 |
0.1
|
bins
|
int
|
Number of spatial bins per axis in the heatmaps, by default 50 |
50
|
use_gpu
|
bool
|
Whether to use GPU acceleration, by default False |
False
|
heatmap_format
|
str
|
Image format of the heatmaps, by default |
'png'
|
Returns:
| Type | Description |
|---|---|
tuple[list[ContactObservation], list[ContactEpisode]]
|
The detected contact observations and the grouped contact episodes. |
Source code in src/amr_hub_abm/run.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
run_steps(simulation, plot_path, *, record, figures=None, trajectory=False)
Run the simulation loop until completion, optionally plotting live.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation
|
Simulation
|
The simulation instance to run. |
required |
plot_path
|
Path | None
|
Directory to save plots if plotting is enabled, otherwise None. |
required |
record
|
bool
|
Whether to record agent states to a CSV file at the end of simulation. |
required |
figures
|
list | None
|
List of Matplotlib figure objects for live plotting, by default None |
None
|
trajectory
|
bool
|
Whether to plot agent trajectories at the end of simulation, by default False |
False
|
Source code in src/amr_hub_abm/run.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
simulate(*, plot=False, record=False, live=False, plot_trajectory=False, use_gpu=False, seed_infections=False)
Simulate the AMR Hub ABM based on a configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plot
|
bool
|
Whether to save plots of the simulation at regular intervals, by default False |
False
|
record
|
bool
|
Whether to record agent states to a CSV file, by default False |
False
|
live
|
bool
|
Whether to display a live plot of the simulation, by default False |
False
|
plot_trajectory
|
bool
|
Whether to plot agent trajectories at the end of simulation, by default False |
False
|
seed_infections
|
bool
|
Whether to seed initial infections for demonstration purposes, by default False |
False
|
Source code in src/amr_hub_abm/run.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |