Netlogo Probabilistic movement by a turtle to surrounding patches

I want a turtle to Probabilistically move to one of the patches in it's neighbors. The value of probability for patch variable. This is quite similar to genetic algorithm selection. I wish to implement any selection technique possible. UPDATE: Value of probability of a patch: means the chance of getting that patch selected. So a patch with zero probability have get no chance of getting selected. And a patch with 100 percent probability will always get selected.: UPDATE2: The following I found

Netlogo How to create a list containing who numbers of neighbors

I have a set of turtles. each turtle have some neighbors, I would like to create a list of who numbers of neighbors, i.e., at the end I would like each turtles should own a list containing who numbers of neighbors. I tried it but some how one agent is always getting empty list of neighbors.

NetLogo custom extension command parameters error

I'm getting a problem with a reporter from a custom extension "myextension". I'm using NetLogo v.5.0.5. Here's the code of the Java class reporter: public class DoActionPrimitive extends DefaultReporter { @Override public Syntax getSyntax() { return Syntax.commandSyntax( new int[]{ Syntax.WildcardType(), // Platform Syntax.StringType(), // Action Syntax.ListType()}, // Parameters

Netlogo: Ask directed link "my-in-turtle" and "my-out-turtle"

I've been working in netlogo for some time, but there is one thing I can't really figure out. You can ask a turtle what its out- and in-links are, but is there a way to ask a link the equivalent using a simple construction of both-ends and/or other-end? right now my code is if one-of both-ends [firing = true] and one-of both-ends [time-not-fired = 1] [do-stuff] but what I'd like to do is if my-in-turtle [firing = true] and my-out-turtle [time-not-fired = 1] [do-stuff] is there an easier/

In-Cone only works for patch centers Netlogo

I'm having some issues with the in-cone command in Netlogo. I am trying to identify the sum / mean of all the patch variables directly in front of my turtles current location (ie the sum of all the variables it crosses). However, this only appears to be working when my turtle is at the center of a patch (co-ordinates are integers not decimals), which also means I can only move my turtles at right angles. I'm yet to find any other questions pertaining to the same issue on Stackoverflow or elsewhe

Dynamic turtle creation in netlogo

I am new to netlogo and was hoping if someone can help me with how to create turtles based on the user input. In the interface tab i have a slider whose value ranges between 2 & 10. Depending on the value defined by the user using this slider, that many number of turtles should be created. I tried using multiple if statements but there is a problem in the succeeding steps. if (slider-value = 2) [create2] if (slider-value = 3) [create3] if (slider-value = 4) [create4] if (slider-value =

Netlogo behaviorspace setup, go and something in between

I have a model that creates a network and selects seed nodes in the setup then runs a contagion process in the go. For multiple runs, I would like to avoid regenerating the network. If I create two procedures full-setup and part-setup, is there a way to make BehaviorSpace do full-setup the first time and part-setup for all other runs? I was thinking of something with an ifelse on behaviorspace-run-number but I don't think I can guarantee that run number 1 is the first one to hit the processors.

Netlogo Getting a Turtle to move to a random position (within a time interval, e.g. 15 ticks), then search for turtles/objects at that position (45 ticks)

I want to create two types of turtles (1. could be an object): Turtles who doesn't move (could be an object instead of turtle?), but is randomly placed at the bottom of the screen or at the top of the screen. Turtles which goes through two phases then repeats; firstly it searches the area within a time interval, e.g. 45 ticks, then it moves to a random position within a time interval, e.g. 15 ticks. Within the searching phase If the moving turtle is near (in-radius 5) a turtle/object th

Netlogo Subtract. SET variableX-variableY only once

I'm trying to set a resource variable. It will be time and will function like sugar in sugarscape. Its setup is: ask agentes [set time random-in-range 1 6]. The thing is... I want the agentesto participate in activities linking like we said here. But, with each participation, it should subtract a unity of agentes's time. I imagine it must be with foreachbut I seem to be unable to grasp how this works. ask n-of n-to-link agentes with [n-t-activity = [n-t-activity] of myself] in-radius sight-

Netlogo How to get the id number of a new turtle just created?

I have the following code where I hatch a new agent, to t-of-slowdown [ es-poi ] if we-look > 0 [ set we-look (we-look - 1) if (we-look <= 0) [ if es-poi and (not any? events-here) [ hatch-events 1 [ set color green set size 5 set is-poi? true set new-poi true let m [[ end2 ] of cur-link] of myself move-to m ] set events-x ([who] of events-here) show events-x set we-poi-var va-geom

Netlogo Removing an agentset from another agentset (the agents from the first set which are also present in the second set)

in my netlogo code I have a network with companies (that is my breed). I want to ask the companies to share information with their neighbors and their neighbors and so on, this works (see code below, the agentsets are b, c and d). However when I ask for information on the third level neighbors my agentset also includes the first level neighbors (obviously since it takes all neighbors into acount), so I want to remove these first level neighbors from the third level neighbors agentset. In the c

Netlogo - How to get energy value for each fish

enter image description here hello, can anyone help me on how to get the energy values for each fish. I want to graph it later but i'm having a hard time getting the energy value per fish. (Planning to do this on a large scale)

what are all the required steps to convert a NetLogo GUI model to run headless mode on a cluster?

Other than avoiding clear-all in headless mode, do we need to convert "all" the switches and sliders to global variables? what else should be done to run a large NetLogo model on a cluster without GUI? I have followed this guide to convert my model but I don't know how we set the values if we remove the init-globals in the headless setup? I get the div/0 error due to not initializing the explicit global variable by following the exact steps, after

How to manually adjust wrapping topology of netlogo interface?

Netlogo only provides four topology options that dictates what turtles and patches do when they reach the any given edge of the netlogo world or interface, namely, box, torus, horizontal wrapping and vertical wrapping ... Is there a way to adjust these options so that just one edge is wrapped? Or three edges are wrapped for instance?

Netlogo Applying a list of functions on a list of argument lists

I have a list of anonymous functions that I need to map over a list of argument lists. My desire is to obtain a list containing lists whose elements are the functions in the functions list, evaluated at each argument list. My first thought was to map the functions list over the argument lists and then apply the functions in the functions list on each element in the arguments list. ;; definitions for k functions let fj [ [x1 x2 ... xn ] -> <body j> ] ... let args [ [ ... ] [ ... ] ..

Netlogo How is code with an unset global variable not returning 'nobody'?

I have a student who created a global variable called random-patch and a patch variable called elevation. They then used elevation to randomly choose a patch to set random-patch to. Problem is the code is running and choosing a patch without setting the patch variable elevation. I understand it is automatically set to zero but shouldn't this code usually come up with nobody? Any help understanding the issue here would be appreciated. Code: globals [ random-patch ] patches-own [ elevation ] t

How to print an output inside a box in NetLogo

I am doing a task in NetLogo and I have to create a simple calculator. I have completed the given task but I need to print the output inside a box in addition to the command center. Since I'm very new to NetLogo it is difficult find the code lines. let output 0 let a Number_1 let b Number_2 if operator = "+" [ set output a + b print (word "result = " output)] The above code is for add operator and I'm looking for the next line to print the result inside a box.

Is there a more efficient way to generate random binomial numbers in Netlogo?

Currently my model is using the following snippet for random binomial number generation, it's effectively the lynchpin that makes the whole thing work and is called the most frequently: to-report random-binomial [n p] report sum n-values n [ifelse-value (p > random-float 1) [1] [0]] end However, this function doesn't run very quickly if n becomes very large (e.g. 10,000,000). Based on an old thread I'm trying a possibly more efficient solution: to-report random-binomial [n p] report len

Netlogo Assigning colors to patches with no neighboring patches having the same color

I'm a beginner, and I'm trying to generate a geographical space with three different colored patches. I'd also like for them to not be neighbors if they have the same color (for yellow and black) as that would make no sense in the model I'm working on. This is the code I've used so far to setup-patches ask patches [set pcolor green] ask n-of number-of-cities patches [ set pcolor yellow] ask n-of number-of-coal patches [ set pcolor black] end Again, I'd like black patches to not ha

NetLogo : what is a good way for Storing link values and deducting the dead link values without calling links more than 1 time?

I am sorry to keep asking about links, but one of the features that I am going to add to my model is considering collective mutual relationship of people of different villages in village's future relationships, I have a few thousand links and it's not efficient to call links and get their value whenever the village wants to make a decision (the decision is made every 48 ticks at clock 0) Agents own belongs_to which is one one "Village1" Village2" Village3" or "Village4" Links have a Value of

When can I compare NetLogo values as integers?

Is there official documentation to resolve the apparent conflict between these two statements from the NetLogo 5.0.5 Programming Guide: "A patch's coordinates are always integers" (from the Agents section) "All numbers in NetLogo are stored internally as double precision floating point numbers" (from the Math section on the same page.) Here's why I ask: if the integer patch coordinates are stored as floating point numbers that are very close to integer values then I should avoid comparisons

Unknown delay in Netlogo

There are 5000 milliseconds in 5 seconds. So if I run this code in Netlogo during that time: every 0.001 [ some-calls-in-the-middle tick ] I expect to get 5000 ticks, but I'm getting no more than 150. Is there any way to map ticks to seconds more efficiently?

NetLogo Custom Patch Mesh

For my model, I need the patch grid in Netlogo to correspond (in shape, size, location) to the mesh in a finite element model. Is there a way to introduce a patch grid that has each patch defined by its coordinate nodes? From the finite element model I can get a matrix defining all the nodes of the elements ( defining mesh geometry ). Any help in translating this to a custom patch grid in Netlogo is greatly appreciated. Thanks

Netlogo How to create links between all turtles except itself?

I want to create links between all turtles who are green. But I dont know how to include that know link shall be created with the turtle itself. What I got: ask turtles with [ green? = true ] [ create-links-with turtles with [ green? = true ] ] Error I get: A turtle cannot link to itself. error while household 178 running CREATE-LINKS-WITH called by procedure GREEN called by procedure GO called by Button 'go'

Netlogo Error when loading RandomGraphs script

When I try and load some NetLogo scripts (not all), among which the included RandomGraphs.nlogo, I get an error: Nothing named NW:SET-SNAPSHOT has been defined. Any clue? I am running the latest version of NetLogo (5.1.0) on Ubuntu 14.04 and OpenJDK.

How can I count dead turtles in Netlogo

I would like to know the numbers of all turtles died in my pseudo model. How can I do that? I would appreciate very much a simply and fast running solution for that problem, like count dead turtles. I was thinking of a routine like this (but do not know how to implement it): if turtle is dead % checking all turtles if dead or alive set death_count death_count + 1 % set counter tick % go one step ahead in model This is my code sample (without any check so far): breed [ humans human ] humans-o

NetLogo substitute for breed

I was wondering whether there is a substitute for the breed function in Net Logo? I looked for a substitute in the dictionary but all I found was globals and I don't think that fully covers what the breed function can do. If there is a substitute, what is it?

Setting the value of a variable in netlogo

I'd like to set the value of a patch's variable to be the same as that of one of its neighbours. What'd I'd like is something along the lines of: ask patches[ let trader max-one-of neighbors [payoff] set strategy [strategy of trader] ] in order to set the strategy of each patch to be the same as the strategy of its neighbour that has the highest payoff. The above doesn't work. Can anyone please tell me how to do this? Thank you.

Netlogo Randomizing the order an agent calls a procedure?

I have an 5 procedures I'd like an agent to perform but I need them to randomize the order in which they perform them. For example: 1) possible ordering ask turtles [ move eat breed search spawn] 2) another possible ordering ask turtles [spawn eat move search breed] 3) another possible ordering: ask turtles [search breed eat move spawn] and so on. Is there there an efficient way to execute the procedures in random order?

Netlogo reduce polynomial example

In the Netlogo dictionary for "reduce" they show an example with one "+" operator reduce [?1 + ?2] [1 2 3 4] which they expand as equivalent to (((1 + 2) + 3) + 4). Later they give this example: ;; evaluate the polynomial, with given coefficients, at x to-report evaluate-polynomial [coefficients x] report reduce [(x * ?1) + ?2] coefficients end ;; evaluate 3x^2 + 2x + 1 at x = 4 show evaluate-polynomial [3 2 1] 4 => 57 What is the equivalent expansion (using parentheses) for tha

NetLogo create-movie: where to find and how to add VID extension?

I would like to create a movie from my NetLogo model. I followed the Movies example here: I have added the parts of code into my model, and created the button "make-movie" in my interface. extensions [vid] ; .... to make-movie setup vid:start-recorder vid:record-interface ;; show the initial state repeat 2 [ go vid:record-view ] vid:save-recording "out.mp4" end When I try to run it, I have an error: Can't find ex

Distance from origin (start-patch) to center of in-radius cluster of turtles in Netlogo

I have determined the maximum number of turtles within clusters of turtles dispersed across a world in Netlogo such that the largest number of turtles (within said radius) derived for all turtles is the result (assigned to a variable). let corr-peak-density max [count neighbors in-radius 50] of turtles However, I am now trying to get the distance from the origin (start-patch) of the world to this largest cluster of turtles or neighbors and failing at it. Ideally, if I can write code find t

Netlogo Reading two separate CSV files

Currently I am struggling to get my netlogo to read two different ckv files to set my global variables. I got two files that needs to read every tick. See my code so far: to setup clear-all file-close-all ;; Close any files open from last run file-open "oil price.csv" file-open "co2 price.csv" setup-patches create-industries 25 ask industries [set shape "house"] ask industries [set color red] ask industries [move-to one-of patches with [pcolor = green] ] ask industries [set

Netlogo How can attribute of one node of a link be copied from the other node of the same link?

I would like to create a link between a turtle of one breed and another turtle of another breed, and then to copy the value of an attribute of the turtle at one node of the link into an attribute of the other turtle at the other node of the same link. I tried: to go ask one-of apples [ create-link-to one-of oranges ask-mood] end to ask-mood set others-mood [my-mood] of other-end end And (obviously) got the error message "Only a link can get the OTHER-END from a turtle." Please

How to create a graph object in NetLogo

I'd like to use the NetLogo's R extension to send a graph object into R, then use the iGraph package to calculate and return some metrics. iGraph can create a graph from an adjacency matrix or an edgelist (there are other options too). The graph I'd like to send to R is just the links among an agentset. Does anyone know how to do this? The NW:save-matrix will export an adjacency matrix to a file. Do I need to do this and then read the file back into R or is there a more direct way? As always, t

Make different couples in Netlogo in each iteration

I have 100 agents of two types, I call them x and y, which I name randomly by a flyer in each tick. I want to make each agent 'x' interact with an agent 'y' on each tick. My question is, How can I make them interact a number 'n' of times in each tick? I do not know how to define 'n' interactions in each tick ask x [ let target y face target fd 5 interaction ]

How to create a Dataframe/ Table in netlogo?

I am wondering whether is it possible to make a table in netlogo where the left most/first column represents the agent-x who number (i.e agent-x 1, agent-x 2 ...) and the top/first row represents agent-y 's who number (i.e agent-y 23,agent-y 37). The distances between the agents will be added to the corresponding cells. The result will be something similar to Excel, where if column B, contains agent-x 1 and row B contains agent-y 23 the corresponding cell for column B and row B will contain th

Netlogo How do i code how to know if a turtle is moving?

Im making a project for school and i need to know if a turtle has moved to do something for example if turtle moved make the oxygen level drop down by 1. i have just dont know what to use, this is my code: to breathe if pcolor = blue [ set oxygenlevel oxygenlevel +5 ] if turtle = moving???? set oxygenlevel oxygenlevel - 1 if oxygenlevel = 0 [ die ]

get-infected method for netlogo simulation not functioning

The following code is a simple simulation for a virus spreading. It isn't working and I can't find out why. ziek becomes true when an agent mutates (which is in a different method, but is known to be working). The agent also becomes lime. However my agents only mutate and won't get infected. What am I doing wrong? to get-infected ask other turtles [ if color = gray and turtles-here = ziek [set color lime set ziek true]] end

Netlogo: Setting pcolor patches with specific distance from each other

I'm trying to set pcolor orange for different patches. I want them to be created randomly, but always at a distance of R from each other. In this current code, it creates the patches randomly just fine, but simply removes the orange patch if they are within the radius, resulting in fewer than N orange patches. How can I solve this so that all N patches are created at a distance R instead of just the ones which randomly fall out of radius R of each other? ask n-of N patches [

Netlogo Learn the direction of a moving agent

I created a turtle in NetLogo which is moving randomly and there are some obstacles. Is it possible to get its current direction? I want to get the turtle to walk back to the center when it sees an obstacle. I can calculate distance to the center, but since I don't know its direction I can't say forward or backwards, for example.

Netlogo Storing results from several rounds

I am working on a model of tax evasion. I have stationary traders and moving customers that choose to make a transaction at the cheapest trader. The result is stored as a trader variable called turnover. After 1000 ticks or one tax-period, the trader files his taxes. This calculation is based on several factors: to pay-taxes set rep-turnover (turnover) * (1 - evasion-level) ;Evasion level is set by a slider set cost-of-goods ((rep-turnover / 100) * 25) ;assumes cost-of-goods to be 30 per cent

NetLogo: How can the heading of a turtle be passed onto another turtle within a radius?

A turtle reaches a point and for a set amount of time, can relate it's heading to other turtles within it's range. Pseudo code if any? turtles within 5 [pass on heading to other turtle] The other turtle I'm assuming would need a call to use this heading, so something like Pseudo code if has received heading? set heading new heading Also I need to reverse this heading, so that the turtle receiving the heading does not travel at this heading, but rather travels in the opposite direction i.

Netlogo Unable to calculate distance between patches when inside ask turtles

Please help with the following code: ask turtles[ ...... let new-patches no-patches ask patch-here [ set new-patches neighbors] let new-patch min-one-of new-patches [distance goal-patch] face new-patch ..... ] Aim: I want the above code to make the turtle to face towards the patch which is nearest to a given patch ("goal-patch"). Obvious approach not followed: The reason I don't directly use facexy is that there are obstacles in between so th

Netlogo Strange random-seed behaviour after create-<breeds>-with

I am experiencing some strange random-seed behaviour in my model. The following procedure: to testRNG clear-all random-seed 10 type random 100 type "," create-nodes 10 type random 100 type "," ask nodes[ create-node2node-links-with other nodes in-radius (1000)] print random 100 end Produces output that looks like this: observer> testRNG 78,78,42 observer> testRNG 78,78,42 observer> testRNG 78,78,40 observer> testRNG 78,78,42 observer> testRNG 78,78,7

Netlogo Setting an exact percentage of patches red and green color

In setup, I am trying to set an exact percentage of the overall patches red pcolor or green pcolor. I am using the standard patch environment, with 1089 total patches. I have two sliders: slider1 (for setting up to 250 green turtles) slider 2 (for setting up to 250 red turtles) Is there a way to set an exact percentage of the 1089 total patches red and the remaining percentage green? Adapting code from a helpful Q&A previously posted on this site, I have this draft coding: to color-pa

Netlogo memory effect in PDG

I am trying simulate with netlogo a PDG and study the effect of memory in the cooperation. I want memory to be a coefficient m<1 that multiplicate the sum payoff at that time plus the cumulative historical payoff. I want to study the effect of the memory in the cooperation model and see the freqyency of cooperators in the world with and without the memory thank you in advance globals [payoffs] patches-own [payments] to setup clear-all ; green: cooperate, red: defect ask patches [ set payment

  1    2   3   4   5   6  ... 下一页 最后一页 共 12 页