python - 谁能帮我解决这个 python 问题:狼和猎物动力学
问题描述
嘿伙计们,我今年夏天正在学习 python,我有一个问题要做,如果有人能提供帮助,对我来说一切都是新的:鉴于捕食者(狼)和猎物(鹿)的生态系统,我们将研究它们相互作用的动态. 我们将逐步研究它们数量的演变。在以下的每个时间增量dt=0.01
适用:
编写函数
wolves_and_dear(deer_0, wolves_0, deer_growth, deer_predation, wolves_predation, wolves_decay, dt, n)
这将模拟系统n次并找到系统中狼的最大值。 在此处输入图像描述
解决方案
这是一个应该可以使用的基本模板,问题中似乎缺少公式,因此您必须自己添加它们。学习编写代码是一项非常有用的技能,所以不要复制粘贴这个答案,而是要从中学习。
def wolves_and_dear(deer_0, wolves_0, deer_growth, deer_predation, wolves_predation, wolves_decay, dt, n):
best_wolves = 0
for simulation in range(n):
deer,wolves = deer_0,wolves_0
t = 0
while t < 1:
deer += deer_growth
deer -= deer_predation
wolves -= wolves_predation
wolves -= wolves_decay
t += dt
best_wolves = max(best_wolves,wolves)
return best_wolves
如果您有任何问题,请发表评论,我会尽力提供帮助。
推荐阅读
- visual-studio-2017 - CListCtrl 通过键入搜索:如何显示已键入的内容?
- kubernetes - 在 PhpStorm 上编辑和应用 Kubernetes 资源
- python - Python MagicMock.return_value 返回 MagicMock 而不是 return_value
- python - 如何在 pandas 中使用 if 函数
- amazon-web-services - 如何在调用 API 网关的 Lambda 函数中进行 Node.js 路由(可能使用 express)?
- r - 努力根据模式删除单词(R中的文本分析)
- django - 值比较查询 Django
- sql - 根据 SQL 中另一个表中的值从列中提取子字符串
- html - 如何在保持相应表格结构的同时将表格行项水平居中?
- here-api - 无法到达 HERE api 的路点 1 错误