计算和报告智能体移动半径周围一定半径内的地租
Calculating & reporting land-rent of patches in a certain radius around the agent's movement-radius
总结
我正在开发一个土地利用模型,其中包含一个森林世界和能够将森林转化为农田的海龟。海龟(在这种特定情况下是公司)有能力移动到其移动范围内的目的地补丁并清除它们周围半径范围内的森林(将其变成农田)。
目标是让公司根据转换周围补丁的预测利润来选择他们的目的地补丁,即就景观中的移动位置做出经济决策。利润(或我的模型中的土地租金)是转换成本、维护成本和潜在惩罚的函数,从补丁收益中减去。因此,理想的目的地补丁是一个补丁,其周围的补丁集群具有最高的预测利润总和。我做了一个小图来帮助形象化这个概念:concept of cluster profit in radius
到目前为止我做了什么
到目前为止,我有以下与寻求最大地租补丁相关的程序:1)将公司移动到具有最大预测地租的补丁
2)报告最大预测土地租金,使用报告功能。我也尝试过 ask-patches 函数,但无济于事。
补丁有相关的惩罚,这取决于它们是否是保护区的一部分,并且可以由某个参与者拥有(取决于它们所在的位置和转换它们的人)。
Problem/Goal
我需要的是一个结构,它要求乌龟(公司)给定半径内的每个补丁计算另一个给定半径内每个补丁的土地租金。换句话说,我希望乌龟能够说:如果我去到我移动半径内的这个补丁 xy,我将通过转换该补丁 xy 周围的所有补丁获得最大的地租。
下面的代码不会产生任何错误消息,但从海龟的行为来看,它似乎也不正确 运行ning 。海龟在世界范围内随机移动,直接运行进入受保护的区域(侵占会被处以高额罚款),导致它们破产。
patches-own
owned-by ;; "R" indicated it's unoccupied forest
protected-area ;; whether the patch is part of a protected area
encroachment-fine ;; the $-amount a turtle is fined for converting this patch of forest
GUI inputs
company-conversion-radius ;in what radius around themselves companies can convert land
to move-to-max-rent-C
ifelse any? patches in-radius (company-conversion-radius * 2 - 1) with [owned-by = "R"] [ ;here, companies 'scan' their environment for any patches that have forest (expressed through owned-by = "R"), if there are forested patches, companies move to the destination-patch that promises the highest profit (land-rent)
let destination-C max-rent-C
move-to destination-C
]
;; if no forest patch within their scanning-radius, they face the nearest forest patch anywhere and move towards it
[
face min-one-of patches with [owned-by = "R"] [distance myself]
move-to patch-ahead company-conversion-radius
]
end
to-report max-rent-C
ask patches in-radius (company-conversion-radius * 2 - 1) [
let available-conversion-patches count patches in-radius company-conversion-radius with [owned-by = "R"]
report max-one-of patches in-radius company-conversion-radius with [owned-by = "R"] [;;formula for calculating land rent]
]
end
我找到了这个帖子 ask turtle to perform calculations from patch set,但它似乎没有完全回答我的问题,因为它只要求围绕海龟进行计算,而不是围绕海龟可以到达的补丁。
你快到了(我想)。我无法 运行 你的代码,但通过阅读它,max-rent-C 程序将正确识别给定半径内 returns 最佳利润的补丁。您的问题是您没有以正确的方式调用该过程。想象一只乌龟在补丁 A,有机会移动到补丁 B,但想要 select 提供最大利润的 B。那只乌龟必须做的是想象自己在所有可能的补丁 B 处,并计算在该位置时它周围所有补丁的利润。这就是您在问题中所说的内容,但为清楚起见重述。
因此,与其向 A 询问最大值,还不如找到给出最大值的最大值。
而不是:
let destination-C max-rent-C
尝试:
let potential-destinations patches in-radius (company-conversion-radius * 2 - 1) with [owned-by = "R"]
let destination-C max-one-of potential-destinations [max-rent-C]
假设所有公司的半径都相同,我可能会让每个补丁都拥有自己的值作为变量。那么你可以只选择一个单独函数中最高的那个。
此外,公司的变动范围现在似乎等于转换范围。我希望它们是不同的东西,所以即使它们具有相同的值,我也会使用不同的名称。我在我的代码中将其拆分以使其更清晰。
您还应该意识到您所要求的计算量可能很大。如果 N 个公司正在询问 M 个补丁,P 个周围补丁的组合值是多少,那么您正在进行 N * M * P 计算。如果您的程序 运行 很慢,这可能是造成它的原因。
总的来说,我认为您的代码应该类似于:
patches-own
rent-value ;the value of this specific tile
HQ-value ;the value of making this a destination patch
to update-value
ask patches [ ; ask every patch to update its HQ value
set HQ-value 0
ask patches in-radius company-conversion-radius [ ; by summing over the rent-value of its radius
set HQ-value of [myself] HQ-value of [myself] + rent-value
;you could incorporate your protections and penalties here too.
]
]
这应该会导致所有补丁更新它们的 HQ 值。
如果你的公司少,补丁多,请海龟做以下操作会更快:
to update-value
ask turtles [
ask patches in-radius company-movement-range [
set HQ-value 0
ask patches in-radius company-conversion-radius [
;...
总结
我正在开发一个土地利用模型,其中包含一个森林世界和能够将森林转化为农田的海龟。海龟(在这种特定情况下是公司)有能力移动到其移动范围内的目的地补丁并清除它们周围半径范围内的森林(将其变成农田)。 目标是让公司根据转换周围补丁的预测利润来选择他们的目的地补丁,即就景观中的移动位置做出经济决策。利润(或我的模型中的土地租金)是转换成本、维护成本和潜在惩罚的函数,从补丁收益中减去。因此,理想的目的地补丁是一个补丁,其周围的补丁集群具有最高的预测利润总和。我做了一个小图来帮助形象化这个概念:concept of cluster profit in radius
到目前为止我做了什么 到目前为止,我有以下与寻求最大地租补丁相关的程序:1)将公司移动到具有最大预测地租的补丁 2)报告最大预测土地租金,使用报告功能。我也尝试过 ask-patches 函数,但无济于事。 补丁有相关的惩罚,这取决于它们是否是保护区的一部分,并且可以由某个参与者拥有(取决于它们所在的位置和转换它们的人)。
Problem/Goal 我需要的是一个结构,它要求乌龟(公司)给定半径内的每个补丁计算另一个给定半径内每个补丁的土地租金。换句话说,我希望乌龟能够说:如果我去到我移动半径内的这个补丁 xy,我将通过转换该补丁 xy 周围的所有补丁获得最大的地租。 下面的代码不会产生任何错误消息,但从海龟的行为来看,它似乎也不正确 运行ning 。海龟在世界范围内随机移动,直接运行进入受保护的区域(侵占会被处以高额罚款),导致它们破产。
patches-own
owned-by ;; "R" indicated it's unoccupied forest
protected-area ;; whether the patch is part of a protected area
encroachment-fine ;; the $-amount a turtle is fined for converting this patch of forest
GUI inputs
company-conversion-radius ;in what radius around themselves companies can convert land
to move-to-max-rent-C
ifelse any? patches in-radius (company-conversion-radius * 2 - 1) with [owned-by = "R"] [ ;here, companies 'scan' their environment for any patches that have forest (expressed through owned-by = "R"), if there are forested patches, companies move to the destination-patch that promises the highest profit (land-rent)
let destination-C max-rent-C
move-to destination-C
]
;; if no forest patch within their scanning-radius, they face the nearest forest patch anywhere and move towards it
[
face min-one-of patches with [owned-by = "R"] [distance myself]
move-to patch-ahead company-conversion-radius
]
end
to-report max-rent-C
ask patches in-radius (company-conversion-radius * 2 - 1) [
let available-conversion-patches count patches in-radius company-conversion-radius with [owned-by = "R"]
report max-one-of patches in-radius company-conversion-radius with [owned-by = "R"] [;;formula for calculating land rent]
]
end
我找到了这个帖子 ask turtle to perform calculations from patch set,但它似乎没有完全回答我的问题,因为它只要求围绕海龟进行计算,而不是围绕海龟可以到达的补丁。
你快到了(我想)。我无法 运行 你的代码,但通过阅读它,max-rent-C 程序将正确识别给定半径内 returns 最佳利润的补丁。您的问题是您没有以正确的方式调用该过程。想象一只乌龟在补丁 A,有机会移动到补丁 B,但想要 select 提供最大利润的 B。那只乌龟必须做的是想象自己在所有可能的补丁 B 处,并计算在该位置时它周围所有补丁的利润。这就是您在问题中所说的内容,但为清楚起见重述。
因此,与其向 A 询问最大值,还不如找到给出最大值的最大值。
而不是:
let destination-C max-rent-C
尝试:
let potential-destinations patches in-radius (company-conversion-radius * 2 - 1) with [owned-by = "R"]
let destination-C max-one-of potential-destinations [max-rent-C]
假设所有公司的半径都相同,我可能会让每个补丁都拥有自己的值作为变量。那么你可以只选择一个单独函数中最高的那个。 此外,公司的变动范围现在似乎等于转换范围。我希望它们是不同的东西,所以即使它们具有相同的值,我也会使用不同的名称。我在我的代码中将其拆分以使其更清晰。 您还应该意识到您所要求的计算量可能很大。如果 N 个公司正在询问 M 个补丁,P 个周围补丁的组合值是多少,那么您正在进行 N * M * P 计算。如果您的程序 运行 很慢,这可能是造成它的原因。
总的来说,我认为您的代码应该类似于:
patches-own
rent-value ;the value of this specific tile
HQ-value ;the value of making this a destination patch
to update-value
ask patches [ ; ask every patch to update its HQ value
set HQ-value 0
ask patches in-radius company-conversion-radius [ ; by summing over the rent-value of its radius
set HQ-value of [myself] HQ-value of [myself] + rent-value
;you could incorporate your protections and penalties here too.
]
]
这应该会导致所有补丁更新它们的 HQ 值。 如果你的公司少,补丁多,请海龟做以下操作会更快:
to update-value
ask turtles [
ask patches in-radius company-movement-range [
set HQ-value 0
ask patches in-radius company-conversion-radius [
;...