如何有效地将属性设置为地图的一部分

huangapple go评论47阅读模式
英文:

How to set a property to a proportion of a map effectively

问题

我在Netlogo上有一张非常大的地图,我想告诉它有一定比例(可以通过滑块更改)的区域有咖啡种植园。然而,地图太大,处理时间太长。我目前的方法可以工作,但我希望有更快的方法。

我有以下代码:

ask patches [set total-cultivation count patches with [Type-Cover= "Agricultural Areas"]]

ask n-of (total-cultivation * %area) patches [set plant-type coffee ]

Total Cultivation是一个全局变量
%area的取值范围是0到1。

这是地图。灰色部分是我需要计算的部分。提前感谢您的帮助。

cobertura >= 18 and cobertura <= 18.99 or cobertura >= 19 and cobertura <= 19.99[set pcolor grey set Type-Cover "Agricultural Areas"]

如何有效地将属性设置为地图的一部分

编辑:我遇到另一个问题。即使这个方法有效,patches也会随机放置,但种植园不只占用一个像素,它们通常是相互靠近的。我该如何解决这个问题?

英文:

I have a really big map on Netlogo and I want to tell it a a certain (changable by a slider) percentage of it has a coffee plantation. Howevere, the map is so big that its taking too long to process. The way i have it works but I´m hoping theres a faster way to do this.

I have

ask patches [set total-cultivation count patches with [Type-Cover= "Agricultural Areas"]]

ask n-of (total-cultivation * %area) patches [set plant-type coffee ]

Total Cultivation is a Global Variable
The %area goes from 0 to 1.

This is the map. The grey part is the one a need to count. Thanks in advance

 cobertura >= 18 and cobertura <= 18.99 or cobertura >= 19 and cobertura <= 19.99[set pcolor grey set Type-Cover "Agricultural Areas"]

如何有效地将属性设置为地图的一部分

Edit: I encountered another problem. Even if this worked patches would be placed at random, but plantations dont take just one pixel, they are mostly close together. How would i solve this?

答案1

得分: 3

你要求每个单独的补丁都进行计数。这意味着每个补丁都要评估N个补丁的类型覆盖,总共需要N^2次操作。

从你后来的使用方式来看,我假设total-cultivation是一个全局参数。所以只需剪切补丁就足以将其减少到N次操作。

set total-cultivation count patches with [Type-Cover= "Agricultural Areas"]

至于你的第二个问题,你首先需要弄清楚你的系统规则是什么。它们应该有多聚集?你可以在Stackoverflow上找到关于聚类的几个早期问题,所以我建议去看看那些问题。

英文:

You are asking every single patch to do the count. That means that N patches each evaluate the type cover of N patches, for a total of N^2 operations.

From how you are using it later on, I assume total-cultivation is a global parameter. So just cutting out the patches will already do the trick for reducing it to N operation.

set total-cultivation count patches with [Type-Cover= "Agricultural Areas"]

As for your second question, you will first need to figure out what the rules of your system are. How clustered are they supposed to be? You can find several earlier questions about clustering here on Stackoverflow, so I would suggest taking a look at those.

huangapple
  • 本文由 发表于 2023年6月22日 01:26:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76525795.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定