netlogo

How to create random binary/boolean variable in Netlogo

跟風遠走 提交于 2019-12-04 19:26:45
I'd like to assign a random boolean variable to each turtle, but I'm not seeing a function that would simulate a draw from a Bernoulli distribution. This gets close, but it's awkward: ifelse random-in-range 0 1 < .5 [set expensive? false] [ set expensive? true ] Anyone know a better way? Bryan Head A few options: one-of [ true false ] random 2 = 1 random-float 1 < 0.5 - If you need to modify the probability, to get any Bernoulli distribution you want If I deal with a lot of probabilistic stuff in a model, I like to add to-report probability [ p ] report random-float 1 < p end as an easy

Getting R to use newer versions of java

自作多情 提交于 2019-12-04 07:32:37
This question is related to this other question . I am trying to use RNetLogo with R and get the following error. nl.path <- "/Applications/NetLogo 5.1.0" NLStart(nl.path) Error in .jnew("nlcon/Preprocess") : java.lang.UnsupportedClassVersionError: nlcon/Preprocess : Unsupported major.minor version 51.0 From what I understood in this other question , the problem is that R is using an old version of Java which is incompatible with RNetLogo. I installed Java 8.0 hoping to solve the problem but my understanding is that, despite Java 8.0 being installed on my computer (Mac OS Maverick), R does not

Using Lists vs Agentsets

妖精的绣舞 提交于 2019-12-04 06:39:17
Lists of agents and agentsets are two different data types in NetLogo (and can be converted with turtle-set and sort ). The documentation states that you use lists for an ordered collection of agents and sets for an unordered collection. It appears that anonymous procedures available to lists makes lists more flexible than agentsets. On the other hand, using 'ask' in combination with agentsets is more common in the example models and has been stated to be more readable. Can one translate any combination of list and anonymous procedure to a statement using an agentset and 'ask'? In particular,

How do I create a timer on netlogo?

。_饼干妹妹 提交于 2019-12-04 06:20:44
问题 For my maze project, I want to create a monitor button that keeps track of how long it takes for the turtle to get from start to finish. How would I code for the timer? 回答1: Check out reset-timer and timer and in the docs. During maze setup, do a reset-timer . During the running of maze you can check on elapsed time with timer 回答2: If you mean how many patches passed in moving to the target, you can use following: turtles-own [target move-counter] to Your-Move-Function let t target face min

Determining max, min and mean turtle cluster size, as well as number of turtle clusters in netlogo

匆匆过客 提交于 2019-12-04 05:51:37
问题 See the code below intended for determining the number of settled turtle clusters (Red and grey turtles) out of a number of randomly distributed non-settled turtles (black), as well as the maximum, minimum and mean cluster size (radial extent) in a netlogo world/ interface. globals[ cluster-size cluster-count cluster-size-growth cluster-count-growth ] to setup clear-all ask patches [ set pcolor white ] create-turtles 1000 [ set color black set label-color blue setxy random-xcor random-ycor

Netlogo Sprouting turtles spaced at less than one patch

寵の児 提交于 2019-12-04 05:12:16
问题 I want to place turtles on each of the black patches(below Figure) such that there is no gap between turtles at all: Code I use right now: ask patches with [pcolor = black][sprout-dead-turtles wall-agents [set color red]] This gives the following result: But I want to place turtles in between each of the two patches as well. So that I can cover the showing black part. Note: Changing the shape of turtles is no use to my purpose though it would cover the black area. My aim to create a replusion

NetLogo turtles leaving a trail that fades with time

寵の児 提交于 2019-12-04 02:54:45
I have turtles moving across the view, and I'd like to be able to follow where they go by making them leave a trail behind them, as though they were emitting smoke as they went. Of course, I could use the turtle pen ( pen-down ), but since there are many turtles, the view rapidly gets filled with old trails. The solution could be trails that last only for a few ticks before they dissipate. But I don't know how to achieve that. To be more specific: 1) Is there a technique for making the line drawn following a pen-down command gradually fade away over the period of some ticks? 2) If not, is

Merge traffic lanes in NetLogo simulation

旧巷老猫 提交于 2019-12-03 21:45:02
I want to write a NetLogo program to merge automobile lanes. Vehicles are in 4 lanes, separated by 3.5 meters (with each patch representing 1m). The center coordinates of each lane are at ycor values of -3.75, -7.25, -10.75 and -14.25. Vehicles have random xcor values with ycor values at the center of one of the lanes, and are heading to the right. I want the traffic to merge so that cars driving toward the center of the map ( distancexy 0 0 <50 ) all move to the same lane at ycor = -14.25 as pictured. So the car already in that lane continues forward, but the cars in other lanes turn right 45

Is NetLogo too slow for big simulations? How can I speed up a NetLogo model?

青春壹個敷衍的年華 提交于 2019-12-03 14:02:29
Is NetLogo a good platform for big models (>10,000s of patches, turtles)? How can I speed up a model that runs very slowly? We just published an article on execution speed of NetLogo; it is available at: http://jasss.soc.surrey.ac.uk/20/1/3.html The article's main points are (a) NetLogo is not necessarily slow for executing large scientific models, and in fact has speed advantages over some alternatives; and (b) NetLogo models do often execute very slowly at first but can almost always be sped up dramatically by using a few basic techniques. We provide a step-by-step strategy for measuring and

agent-based simulation: performance issue: Python vs NetLogo & Repast

五迷三道 提交于 2019-12-03 09:21:26
问题 I'm replicating a small piece of Sugarscape agent simulation model in Python 3. I found the performance of my code is ~3 times slower than that of NetLogo. Is it likely the problem with my code, or can it be the inherent limitation of Python? Obviously, this is just a fragment of the code, but that's where Python spends two-thirds of the run-time. I hope if I wrote something really inefficient it might show up in this fragment: UP = (0, -1) RIGHT = (1, 0) DOWN = (0, 1) LEFT = (-1, 0) all