You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This enumeration will call the function `rule` we give it O(q^2) times, where q is the number of reachable states. This preprocessing step also builds an internal representation of the transition function, so it will not need to continue calling `rule`. Thus we don't need to worry too much about our code for `rule` being efficient.
368
369
@@ -375,9 +376,9 @@ sim.config_dict
375
376
376
377
377
378
378
-
379
-
{0: 500000, 50: 500000}
380
-
379
+
```
380
+
{0: 500000, 50: 500000}
381
+
```
381
382
382
383
383
384
@@ -387,15 +388,15 @@ sim.config_array
387
388
388
389
389
390
390
-
391
-
array([500000, 0, 0, 0, 0, 0, 0, 0,
392
-
0, 0, 0, 0, 0, 0, 0, 0,
393
-
0, 0, 0, 0, 0, 0, 0, 0,
394
-
0, 0, 0, 0, 0, 0, 0, 0,
395
-
0, 0, 0, 0, 0, 0, 0, 0,
396
-
0, 0, 0, 0, 0, 0, 0, 0,
397
-
0, 0, 500000], dtype=int64)
398
-
391
+
```
392
+
array([500000, 0, 0, 0, 0, 0, 0, 0,
393
+
0, 0, 0, 0, 0, 0, 0, 0,
394
+
0, 0, 0, 0, 0, 0, 0, 0,
395
+
0, 0, 0, 0, 0, 0, 0, 0,
396
+
0, 0, 0, 0, 0, 0, 0, 0,
397
+
0, 0, 0, 0, 0, 0, 0, 0,
398
+
0, 0, 500000], dtype=int64)
399
+
```
399
400
400
401
401
402
A key result about these discrete averaging dynamics is that they converge in O(log n) time to at most 3 consecutive values. It could take longer to reach the ultimate silent configuration with only 2 consecutive values, so if we wanted to check for the faster convergence condition, we could use a function that checks for the condition. This function takes a configuration dictionary (mapping states to counts) as input and returns `True` if the convergence criterion has been met.
It is recommended to use an interactive matplotlib backend, such as `ipympl`, which can be installed with `pip install ipympl` and then activated with the cell magic `%matplotlib widget`. The recommended environment to use for these notebooks is [Jupyter Lab](https://jupyterlab.readthedocs.io/en/stable/). Unfortunately, these interactive backends are not supported with [Google Colab](https://colab.research.google.com/), so there does not seem to be an easy way to have access to interactive backends with something that can be run only in a browser without local installation.
794
795
@@ -851,15 +852,15 @@ bar = widgets.interact(plot_row,
For more complicated protocol, it is helpful to have the states be more complicated Python objects. A recommended method is to define an Agent [dataclass](https://docs.python.org/3/library/dataclasses.html) that includes various fields.
859
860
860
861
As a concrete example, we will use the protocol from [Simple and Efficient Leader Election](https://drops.dagstuhl.de/opus/volltexte/2018/8302/pdf/OASIcs-SOSA-2018-9.pdf). We start by translating the explicit description of an agents state into our Agent class.
We can use the pandas [groupby](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html) function to conveniently look at the values of just one field. For a field whose name is the string `field`, then calling `sim.history.groupby(field, axis=1).sum()` gives the counts of values of just a single state. If we have a set of fields `field1, field2, ...` then calling `sim.history.groupby([field1, field2, ...], axis=1).sum()` will give the counts of values of just those fields.
`ppsim` is able to simulate any Chemical Reaction Network that has only bimolecular (2-input, 2-output) and unimolecular (1-input, 1-output) reactions. There is a special syntax used to specify CRNs, such as
@@ -1898,4 +1899,4 @@ By default, `ppsim` sets the volume `v` to be the population size `n`, which mak
1898
1899
For more details about the CRN model and how it is faithfully represented as a continuous time population protocol, see [this paper](https://arxiv.org/abs/2105.04702).
1899
1900
1900
1901
## More examples
1901
-
See https://github.com/UC-Davis-molecular-computing/population-protocols-python-package/tree/main/examples/
0 commit comments