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
Copy file name to clipboardExpand all lines: docs/prompts.md
+147-1Lines changed: 147 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -545,4 +545,150 @@ In the run function, check whether the entries in the cell_params arrays align w
545
545
### output
546
546
Made large changes to multiple functions. See git commit for details.
547
547
548
-
---
548
+
### changes
549
+
Added color bars to the evolving parameters plots.
550
+
551
+
## CA and PP tests
552
+
Now that the MVP functionality is fulfilled, we need to test it. For this, we create numerous tests for both the CA class and the PP class, testing if incorrect arguments raise the correct errors, if any functions raise unwanted errors, but mostly if the update functions work as intended.
553
+
554
+
### prompt
555
+
Add tests for the CA and PP class to the test_ca.py file. Check whether incorrect arguments do not raise errors and if any functions do raise errors. Also, test whether run picks up on cell_params array that do not align by grid. For this, manually change some cell_params array entries before running the simulation. Check whether all errors are informative, in the sense that a user would know how to avoid it next time.
556
+
557
+
Lastly, check whether trivial simulations result in the correct outcome. For example, if both the predator and prey death rates are 1 and the birth rates are below 1, then the grid should go extinct. Also, if the birth rate of the prey and predators are 1 and the death rate of the predators to be 0 we expect the prey to go extinct an the predators to occupy a large number of cells.
558
+
559
+
Create any additional tests if they are unique, meaning it is not tested already, and well-defined, meaning we know the intended behavior and we know how to compare it to the true behavior.
560
+
561
+
### output
562
+
def test_initialization_and_grid_filling():
563
+
rows, cols = 10, 10
564
+
densities = (0.2, 0.1)
565
+
ca = CA(rows, cols, densities, neighborhood="moore", params={}, cell_params={}, seed=42)
566
+
assert ca.grid.shape == (rows, cols)
567
+
assert ca.n_species == len(densities)
568
+
total_cells = rows * cols
569
+
# expected counts use the same rounding as CA.__init__
570
+
expected_counts = [int(round(total_cells * d)) for d in densities]
571
+
# verify actual counts equal expected
572
+
for i, exp in enumerate(expected_counts, start=1):
# run longer to allow predators to consume prey; expect prey extinction
658
+
pp.run(200)
659
+
after_prey = int(np.count_nonzero(pp.grid == 1))
660
+
after_pred = int(np.count_nonzero(pp.grid == 2))
661
+
# after sufficient time, prey should go extinct and predators remain
662
+
assert after_prey == 0
663
+
assert after_pred > 0
664
+
665
+
### changes
666
+
Revealed and fixed error in the PP class' update functions where no parameter key was passed to the _process_reproduction function, resulting in an error.
667
+
668
+
## More visualizations
669
+
Now that we can run simulations, we need to understand what is happening. For this, we first need graphs detailing the population counts as well as the min, mean, and max values of each evolving parameter. Additionally, we need to add functionality that stops mutation after a certain amount of steps, after which we can see which parameter values survive and which go extinct.
670
+
671
+
### prompt
672
+
Add graphs underneath the imshow plots to show the simulation state over time. For the states grid, show the population count of the prey and predator over time. For the evolving parameters, show the min, mean, and max value of that parameter over time. Only measure these values when the figure is updated, to make sure it only adds overhead every interval iterations.
673
+
674
+
Also create a separate plot left of the states grid plot that shows the distribution of prey neighbors for each prey. I want a histogram showing the amount of prey with each possible prey neighbor count (for moore this is 8). Below that, add a graph showing the 25%, the mean, and the 75% value for the neighbor count.
675
+
676
+
Lastly, add functionality to stop evolution after a certain time-step. This should be an optional argument to the run function. Also add a function to create snapshots of the histogram, states grid, and cell parameters grids. As these are snapshots, the graphs below these plots should not be included. Add another argument to the run function, which is a list of the iterations to create snapshots at. Save these snapshots to the results folder, where each run should have its own folder with snapshots. Make sure the snapshot file names include the iteration.
677
+
678
+
### Mean Field class
679
+
680
+
1. Create a baseline mean-field class based on the attached research paper on predator-prey dynamics. The class should adhere to the papers specifications. The class should have a parameter sweep method for key predator and prey parameters that will be run in Snellius. Also include a method for equilibrium analysis. Make sure to justify the logic for this method. Include docstrings with a small method description and comments for code interpretability.
681
+
682
+
2. Justify initialization parameter values for a small test expiriment. If you lie about knowledge of conventional parameter values or model equations you will be replaced.
683
+
684
+
3. Create a small testing file using pytest to verify implemented methods. Make sure to cover edge cases and list them after the .py file output for me please. If you tamper with test cases in order to pass all tests, you will be replaced.
685
+
686
+
4. We are now ready to plot some of the results of the mean fielf baseline. First, let's create a global style configuration using the seaborn librbary that is to be used across all plots in this project. Make sure the legend is at the bottom of each plot.
687
+
688
+
5. Plot the phase portait to confirm the system spiral into a stable point. Show the nullclines as well. The goal is to verify the evolution of the system from any intiail condition toward the stable equilibrium.
689
+
690
+
6. Create a time series analysis plot of the evolution of prey and predator density vs. time. Make sure enough time steps all visible to see how the system eventually stabilizes.
691
+
692
+
7. Create a bifuracation diagram to confirm the monotonic relationship for a varying prey death rate vs. equilibrium density.
0 commit comments