netlogo

How to form subset form a set of numbers in Netlogo

放肆的年华 提交于 2019-12-11 09:40:06
问题 Dear Netlogo community, I am looking to generate subset of a set of numbers. for example if a set is [1 2 3 4 5] then subset would be [1 2] [1 3] [1 4] [1 5] [ 1 2 3] [1 2 4]....... I know we can generate very easily by using bit manipulation in java. But I have no idea how to implement in Netlogo. I am doomed. Any help would be really appreciated. Thanks 回答1: This is easiest to solve using recursion: to-report subsets [xs] if empty? xs [ report [[]] ] let recurse subsets butfirst xs report

Move agents in nodes

試著忘記壹切 提交于 2019-12-11 09:24:37
问题 I am trying to move my agents from one vertex of my road network to another one which the following code. However, I got an error, saying that MOVE-TO expected input to be an agent but got NOBODY instead. If new location is already defined which this code as part of the agentset of slocation , where is the problem? to go ask citizens [start-movement] move end to start-movement let nearest-node min-one-of nodes [distance myself] set slocation nearest-node move-to slocation end to move ask

Read data from file in every ticks

心已入冬 提交于 2019-12-11 09:08:10
问题 I am using NetLogo and I want to read two types of data (for example "x" and "y") from a file for each agent in each time step (tick). Does anyone know how I can do this? Here is the code: breed [agents agent] agents-own [ need tax] to setup clear-all define-xy reset-ticks end to define-xy file-open "D:\\data\\xy.txt" while [not file-at-end?] [ let items read-from-string (word "[" file-read-line "]") crt 1 [ set xcor item 0 items set ycor item 1 items set label ycor ] ] file-close end to go

Netlogo: Making a turtle interact with anotherone after evaluating similarity in a given variable

旧城冷巷雨未停 提交于 2019-12-11 09:01:48
问题 I have several turtles each with three variables opinion1, opinion2 and opinion3. I need them to: identify which of these three variables has the highest value find another turtle in their network with a value at least as high as the one found in 1. update its own value found in 1. with respect to that of the turtle found in 2. What I have done doesn't really work because it only updates looking at o1 without really having a look at which of the tree (opinion1, opinion2 or opinion3) is the

How to share a NetLogo model through GitHub

我的梦境 提交于 2019-12-11 08:49:22
问题 This really helpful question (and answer) works great for sharing a NetLogo model through a public folder in Dropbox. However, my understanding is that Dropbox will no longer (though for the moment still does) support sharing HTML (and so NetLogo files) this way. The question and answer above mentioned GitHub, and in particular the URL to the "raw" HTML file, as a potential solution. I tried this but had some problems. Here's the file hosted via Dropbox (it works) : https://dl

Making States in a GIS file become and act as Turtles in Netlogo

心不动则不痛 提交于 2019-12-11 07:58:28
问题 I have a general model that uses turtles on patches as cities/states in the NetLogo world. I would like to extend the general model to a specific country. I have imported the GIS map into NL. How do I map states in the GIS map to the turtles in NetLogo, so I can run the general model using the exact space/world and data of a specific country? So for example, in my general model, I create one turtle per patch, assign it variables, perform some analysis and get an output. What I now want to do

How to group agents in NetLogo and ask them to stay in group while foraging?

时间秒杀一切 提交于 2019-12-11 07:18:47
问题 I have slightly problem in keeping a group of agents moving together in NetLogo world Here is what I want to do. I want them to stay in group while moving, the rules to keep them in groups are BOIDS, which I'm gonna apply "separate,cohere and align" codes within groups. Here is my code. This is global code globals[ ;;;;;;;;;;;;;;;;global variables;;;;;;;;;;;;;;;;;;;;;; t-bp ;;time taken in ticks t-time ;;time taken in seconds groups ] Here is what the turtles has turtles-own[ food-found on

Turtles moving in a pattern (Netlogo)

亡梦爱人 提交于 2019-12-11 07:12:48
问题 Good afternoon, I'm trying to make my turtles to move between a set of 4 blue patches. I can make them get to those patches but after that they just stay there, and what I need is to them continuously move (in order) to the next blue patch to their right. I don't know how to do it. This is the section of the code I'm talking about: to move-turtles ask turtles [while [[pcolor] of patch-here != blue] [ face min-one-of patches with [pcolor = blue ] [ distance myself ] forward 1 ] ] tick end By

How to use agents as keys in table of table extension?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 07:07:50
问题 I am using the table extension as variable owned by a breed of agents. The content of this table contains values referred to agents of another agent-set ( events ). As table keys, I use e-ids a list with the who numbers of each agent in events breed. The following procedure initializes the tables: to setup-tables ask walkers [ set we-tfound table:make set we-interest table:make foreach e-ids [ [?] -> table:put we-tfound ? 0 table:put we-interest ? 1 ] ] ask links [ set popularity table:make

How can I improve following function in NetLogo?

房东的猫 提交于 2019-12-11 06:57:55
问题 I have changed many parts of my code to improve performance, now following is one of the most time consuming procedures in my code: to deduct [Picking_Agent C] If label_ = "Common Food Source" [ Let witnesses_From_Other_Village other (agents in-radius vision with [Belongs_to != [Belongs_to] of Picking_Agent and member? Picking_Agent agents in-cone vision 100 ]) if any? witnesses_From_Other_Village [Let Penalty (0 - (C / count witnesses_From_Other_Village * 10)) ask witnesses_From_Other