solvers.particles
Not for the user: many runs of a compartmental program stepped forward together: the particles of a particle filter
It exists so that a particle filter can advance many runs at once.
Used with: compartments; declared modules
Classes
| Name | Description |
|---|---|
| Particles | Many runs of an engine’s program, from its start, each with its own compartments and random numbers, stepped forward together; for ss.fitting.ParticleFilter |
Particles
solvers.particles.Particles(engine, n, rng, by_group=False)Many runs of an engine’s program, from its start, each with its own compartments and random numbers, stepped forward together; for ss.fitting.ParticleFilter
The runs start from the engine as it is (restarted), and the engine is not changed until restore(). advance() takes every run through more steps, and select() keeps some of the runs (each as often as it is picked), as a filter does when it draws them again.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| engine | ss.solvers.Compartmental |
the engine of a declared disease, restarted; or an ss.solvers.JointStates, for diseases tracked jointly, whose program’s compartments are then the states |
required |
| n | int |
the number of runs | required |
| rng | np.random.Generator |
from which the random numbers of each run are spawned | required |
| by_group | bool |
whether to keep the stocks and flows by group (else their total, as one group) | False |
Attributes
| Name | Type | Description |
|---|---|---|
| stocks | array |
the number in each state at each time point of each run, at the start of its step (runs × time points × states × groups) |
| flows | array |
the flow along each transition and mover over the step from each time point, likewise |
| done | int |
the steps the runs have taken, which is the time point they have reached (the results are filled in before it) |
| npts | int |
the time points of a whole run |
Methods
| Name | Description |
|---|---|
| advance | Take every run to time point end (through the steps before it), if it is not there already |
| restore | Give the engine back its program as it was (a run with a time fraction of its own writes it there), without what the runs left in its cache |
| select | Keep the runs picked, each as often as it is picked, with their stocks and flows from time point keep on (those before it are left as they were) |
advance
solvers.particles.Particles.advance(end, tables=None, fracs=None, row0=0)Take every run to time point end (through the steps before it), if it is not there already
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| end | int |
the time point, after the last step to take | required |
| tables | list |
the parts of the program that vary in time, as ss.kernels.advance() takes them, if not the engine’s own: one entry for every run, or one for each (as each particle of IF2 has its own values) |
None |
| fracs | array |
the time fraction between places of every run (runs by entries), if not the engine’s own | None |
| row0 | int |
the row of a whole run’s tables that the first row of tables is |
0 |
restore
solvers.particles.Particles.restore()Give the engine back its program as it was (a run with a time fraction of its own writes it there), without what the runs left in its cache
select
solvers.particles.Particles.select(picks, keep=0)Keep the runs picked, each as often as it is picked, with their stocks and flows from time point keep on (those before it are left as they were)