Fix logic issues in predator prey model and tune parameters#27
Conversation
🆗 Pre-flight checks passed 😃This pull request has been checked and contains no modified workflow files or spoofing. It should be safe to Approve and Run the workflows that need maintainer approval. |
|
Thanks @tkoskela for looking into this. Yep—it’s very tricky to tune the parameters to give nice results, but this is certainly a big improvement over the previous version. A couple of notes:
|
|
More than happy to defer to @JostMigenda's judgement on approving this, looks reasonable at a glance. Please, remember to briefly review the instructor notes/solution incase anything subtle has changed there. I think the original code was heavily inspired by our FLAMEGPU Python tutorial, which is probably inspired by a common simple agent-based model. Though that subtle bug looks like something FLAMEGPU would handle natively so it's almost certainly my mistake. https://github.com/FLAMEGPU/FLAMEGPU2-tutorial-python Thanks for supporting this project! |
This comment was marked as outdated.
This comment was marked as outdated.
Yeah, I was using Copilot for tuning the parameters. I get your point about the comments, they're not very useful and I've removed them and fixed the formatting. |
|
The function-level profiling results remained qualitatively fairly similar, so I made just a few small tweaks to the text but kept screenshots of profiling results unchanged. Line-level profiling results changed a bit more, so I had to update the outputs as well as the exercise text. These commits should now cover all follow-on changes resulting from the logic fix and is ready for review. |
There was a problem hiding this comment.
Yeah this looks so much better.
| if c: | ||
| children.append(c) | ||
| self.predators.extend(children) | ||
| self.prey.extend(children) |
There was a problem hiding this comment.
Still such a dumb mistake.
Robadob
left a comment
There was a problem hiding this comment.
Changes look thorough, I added one suggested tweak (more-so to the original text). However after writing the comment (profiling-lines.md:502) I'm in two minds about it. See what you think.
Ensure prey (1) have children, which (2) aren’t predators
135452c to
fa0f039
Compare
|
I've rebased to resolve the two conflicts (junk conflicts around Please squash, or atleast clean up the history before merge. Feel free to delete my contribution tags from any commit comments, all I've done is housekeeping. |
Co-authored-by: Robadob <robert.chisholm@sheffield.ac.uk>
61f0526 to
5c835be
Compare
|
I like the suggestion. Added that and cleaned up the history a bit; merging now. |
Auto-generated via `{sandpaper}`
Source : 67c684a
Branch : md-outputs
Author : GitHub Actions <actions@github.com>
Time : 2026-02-21 20:57:59 +0000
Message : markdown source builds
Auto-generated via `{sandpaper}`
Source : aedc2e6
Branch : main
Author : Jost Migenda <jost.migenda@kcl.ac.uk>
Time : 2026-02-21 20:56:17 +0000
Message : Merge pull request #27 from tkoskela/tk/predprey-params
Fix logic issues in predator prey model and tune parameters
I sat down with @JostMigenda in a workshop and had a go at tuning the parameters of the predator prey model to get it to oscillate between predator and prey populations. It is not quite there yet, the prey still all die, but works a bit better.