simulation.py¶
FixedParamsSimulation
¶
__init__(self, seeds, parameters, hdf5_file, nproc=1, to_store=[], to_store_srvc=[], pre_simulate=None, post_simulate=None, append_data=False)
special
¶
Run multiple seeds with a fixed set of parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seeds |
list |
Seeds to run. |
required |
parameters |
dict |
Parameters dictionary. |
required |
hdf5_file |
str |
File to store data. |
required |
nproc |
int |
Number of simultaneous threads to run. Defaults to 1. |
1 |
to_store |
list |
Data to be stored. If not informed will store default TO_STORE. |
[] |
to_store_srvc |
list |
Service data to be stored. If not informed will store default TO_STORE_SRVC. |
[] |
pre_simulate |
function |
A function to be run between community initialization and simulation, it must accept a community object as parameter. |
None |
post_simulate |
function |
A function to be run after simulation of the community, it must accept a community object as parameter. |
None |
append_data |
bool |
Try to append seeds that are not in the hdf5 file, will not run seeds already stored on the hdf5 file. Defaults to False. |
False |
Source code in comorbuss/lab/simulation.py
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 |
|
check_seeds(self)
¶
Remove seeds already on hdf5 file.
Source code in comorbuss/lab/simulation.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
simulate(self)
¶
Run simulations.
Source code in comorbuss/lab/simulation.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
Simulation
¶
The Simulation class handles multiple simulations with multiple seeds and/or multiple combinations of parameters.
Seealso
Usage examples can be found in the jupyter-examples folder in the repository:
__init__(self, experiment_name, seeds, fixed_parameters={}, iteration_parameters=[], recording_data=[], recording_data_srvc=[], nproc=1, pre_simulate=None, post_simulate=None, out=None, append_data=False, store_git_hash=False)
special
¶
Instances and initialize a Simulation object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiment_name |
str |
Name of the experiment, will me used to name files and folders. |
required |
fixed_parameters |
dict |
Fixed parameters. |
{} |
iteration_parameters |
dict or list |
Parameters to iterate during simulation.
|
[] |
recording_data |
list |
List with all data to be recorded after the simulation. |
[] |
recording_data_srvc |
list |
List with all service data to be recorded after the simulation. |
[] |
pre_simulate |
function |
A function to be run between community initialization and simulation, it must accept a community object as parameter. |
None |
post_simulate |
function |
A function to be run after simulation of the community, it must accept a community object as parameter. |
None |
seeds |
list |
List of seeds. |
required |
nproc |
int |
Number of concurrent threads. Defaults to 1. |
1 |
append_data |
bool |
Append data to existing files, will not simulate existing seeds. Defaults to False. |
False |
out |
str |
Output directory. |
None |
store_git_hash |
bool |
Runs 'git rev-parse HEAD' on current folder and stores it to configurations files. Defaults to False. |
False |
Source code in comorbuss/lab/simulation.py
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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
get_hdf5_files(self)
¶
Generates a dict of the hdf5 files for the set simulations with the sim_id/name as the keys.
Returns:
Type | Description |
---|---|
dict |
Paths to the HDF5 files. |
Source code in comorbuss/lab/simulation.py
374 375 376 377 378 379 380 381 382 383 |
|
get_iteration_parameters(self)
¶
Outputs the iteration parameters as a list of dicts.
Returns:
Type | Description |
---|---|
dict |
Iteration parameters as list of dicts. |
Source code in comorbuss/lab/simulation.py
385 386 387 388 389 390 391 392 393 394 395 |
|
print_iteration_parameters(self)
¶
Prints the iteration parameters as a list of dicts.
Source code in comorbuss/lab/simulation.py
397 398 399 |
|
simulate(self, node=0, number_of_nodes=1, node_type='seeds')
¶
Runs the simulations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
int |
[description]. Defaults to 0. |
0 |
number_of_nodes |
int |
Divides the simulation in multiples nodes. Defaults to 1. |
1 |
node_type |
str |
Specify where to divide nodes, |
'seeds' |
Source code in comorbuss/lab/simulation.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
|
realization(args)
¶
Executes a single seed with a given set of parameters and stores the hdf5 file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters |
dict |
Parameters dictionary. |
required |
hdf5_file |
str |
File to store data. |
required |
to_store |
list |
Data to be stored. |
required |
to_store_srvc |
list |
Service data to be stored. |
required |
Source code in comorbuss/lab/simulation.py
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 |
|