Menu
  • HOME
  • TAGS

set displayed scale of axis in plot?

Tag: netlogo

In the model I'm working on, ticks are months, and line plots are updated once every year, i.e. every 12 ticks. As ticks accumulate, the scale within the graph changes, of course, and the number in the lower right corner of the plot increases. This number reflects the number updates that have been made to the plot--i.e. the number of years. The number is the number of years that can be represented on the plot given its current scale.

Is there a way to change this number, without changing the rest of the plot, and without changing the idea that ticks are months? It would be convenient for this maximum x-axis value to show the number of months--i.e. ticks that could be displayed, even though the plot is only updated every 12 ticks.

Best How To :

Use the set-plot-x-range primitive. http://ccl.northwestern.edu/netlogo/docs/dictionary.html#set-plot-x-range

NetLogo Headless Meaning with respect to speed

netlogo

netlogo-headless doesn't need to deal with speed slider ... the speed slider is there only to manage the computer video ressource. Without GUI the speed is maximum.

set variables in netlogo

netlogo

Instead of using variables for this, you should define a reporter: to-report x report 2 * y end though, for the sake of those reading your code and for your future self looking back at your code, use more descriptive variable names than x and y :)...

Checking unique list in a patchset

netlogo

This will do it: length remove-duplicates [state] of patches ...

Netlogo Linking Breeds

netlogo

Maybe you can make use of one-of and some filters on agensets using with. Probably they will facilitate your work and makes clear your intentions. Buyers-own [dPrice MadeNewTrade?] Sellers-own [dPrice MadeNewTrade?] to Test ask Buyers [ let dBuyPrice dPrice let SellersTrade Sellers with [MadeNewTrade? = false and dBuyPrice >= dPrice]...

Is there something similar to contains in netlogo

string,if-statement,netlogo

NetLogo's member? primitive will do exactly that: if member? "word" phrase [ do-something ] ...

How to make constrained combinations of scenarios in NetLogo Behavior Space?

netlogo,behaviorspace

You can use the stop condition in Behavior Space like A + B + C + D != 1 ...

Is there any jar file is defined in 3D environment can be used in writting Netlogo extension, for example the path has pzcor?

java,jar,netlogo

You don't need a different jar. NetLogo.jar has all of NetLogo 3D in it. You just need to use Patch3D instead of Patch....

How can I take real time data from a web site using NetLogo?

real-time,netlogo,agent-based-modeling

You can use the NetLogo web extension to get real time information from any stock price API. Looks like Yahoo has a pretty simple API. To use their API to, for example, get Google's latest stock price, you'd do something like: web:make-request "http://download.finance.yahoo.com/d/quotes.csv" "GET" [["s" "GOOG"] ["f" "l1"] ["e" ".csv"]]...

how to create turtles from extension in NetLogo

netlogo

I managed to answer my question with this code: world = (World) cntxt.getAgent().world(); // in my case, I start with a network empirical = readNetwork(new File(filename)); AgentSet agentset = new org.nlogo.agent.ArrayAgentSet(Turtle.class, Manager.empirical.getVertexCount(), false, Manager.world); AgentSet breed = Manager.world.turtles(); // add a turtle for every node that I have in the...

Setting Age on Turtles

netlogo

Alan's solution is good if you want age to be equal to the number of ticks since a turtle was created. You can divide that number by another number if you want a different measure of age. For example, if ticks represent months, you can divide by 12 to get...

how to turn a column full of factored lists into a data frame

r,netlogo

Mydf = read.table( text= gsub( "\\[|\\]", "", d$conflict) ) ...

Netlogo - Sampling from a Beta-Pert Distribtuion

distribution,netlogo,gamma-distribution,beta-distribution

to-report random-pert [#minval #likeval #maxval] ;use pert params to draw from a beta distribution if not (#minval <= #likeval and #likeval <= #maxval) [error "wrong argument ranking"] if (#minval = #likeval and #likeval = #maxval) [report #minval] ;;handle trivial inputs let pert-var 1. / 36 let pert-mean (#maxval + 4...

netlogo turtles move directly to another turtle when in range

netlogo

Suppose you want a range of 5, and suppose you want the raptors to move one step towards the nearest human per tick. Then: ask raptors [ let candidates humans in-radius 5 if any? candidates [ let target min-one-of candidates [distance myself] face target fd 1 ] ] ...

random seed fails to reproduce run in NetLogo when selecting breed-neighbors

netlogo

There is no such known problem. If you think you've found a bug, please open a ticket at https://github.com/NetLogo/NetLogo/issues/new and include a SSCCE. (The above code is not self-contained — you don't include the necessary declarations, and you don't include the code you used to test and reproduce the bug...

How to get connected two or more turtles within radius NetLogo

netlogo

If I have understood what you want, this will work globals [radius] to setup clear-all create-turtles 50 [setxy random-xcor random-ycor] set radius 5 connect end to connect ask turtles [ ask other turtles in-radius radius [ create-link-from myself ] ] end The problem is that you have ask turtles in-radius...

Error while loading raster data in netlogo

gis,netlogo

That NetLogo code looks fine and is exactly the same syntax that I have successfully used in my project. One possibility is that the problem is with the format of the .asc data, it may have been corrupted. Try opening the .asc dataset with a text editor and check that...

Is it possible to assign a number to a lists with the same name to be differentiated?

netlogo

You can, but it is almost surely the wrong approach. (For one thing, the names will not be global unless you declare them all ahead of time.) Instead, use the table extension, create a global to hold your table, and use the table to map your id numbers to your...

Average results from multiple simulations

netlogo

This should be simple enough if you use BehaviorSpace. In your experiment definition, put score in the Measure runs using these reporters textbox and uncheck Measure run at every step. When you run your experiment, save your results using Table output. It will produce a csv that you can open...

How to avoid adding a link between two nodes twice

network-programming,netlogo

link-neighbor? will tell you that. It's a turtle reporter and it takes one argument; the turtle that you are want to know if it is connected to. So: ask n-of number-of-links turtles [create-link-with one-of other turtles with [not link-neighbor? myself]] will do the trick. Keep in mind that this will...

How to make a size slider in netlogo?

netlogo

So you've made a slider with a global variable size-of-turtle. Do you have a procedure that will actually tell the turtles to do what you ask? And yes, please show your error message. If you have a slider that nothing refers to, nothing will happen when you change the values...

Running netlogo with 64 bit Java from a batch file

netlogo

What directory are you running that command from? For NetLogo to find extensions, sample models, etc., the current working directory at startup time must be the NetLogo directory. So your script should chdir there first.

netlogo multiple catchment area using neighbors

netlogo

I tried your code. First I used the catchment-area as a global variable and the world behave as you specified, then I tried to set the catchment area as an own of every single patch so that every single patch has one associated: patches-own[ catchment-area ] So now using the...

is there a built in way to create a list of consecutive integers?

netlogo

Found the answer: show n-values 9 [?] will display [0 1 2 3 4 5 6 7 8] show n-values 9 [? + 1] will display [1 2 3 4 5 6 7 8 9]...

Trouble using with-min

netlogo

There are two problems here. One is that create-links-with is wrong because one-of returns a single agent, not an agentset. You need create-link-with. But the main problem is with this part: other turtles with-min [...] NetLogo understands this as other (turtles with-min [...]). This reports an empty agentset, because the...

NetLogo nothing named SCREEN-SIZE-X has been defined

netlogo,screen-size

I think screen-size-x and screen-size-y are NetLogo history. You can use max-pxcor, max-pycor and min-pxcor, min-pycor to get the world borders or world-width and world-height to get just the size. To get a random position there are random-xcor and random-ycor. to setup-turtles setxy random-xcor random-ycor end ...

define neighbor turtles using in-radius or distance

netlogo

It has to do with the timing of side effects in your program. Suppose that the very first turtle to move moves near the center. None of the other turtles have moved yet, so they're all still on patch 0 0 and set my-neighbors (other turtles) in-radius 3 will capture...

Netlogo- Creating agents with traits from .csv files

csv,netlogo

I believe you can modify my example to match your problem, in summary I first read the file into a global list, extracted the number of agents, assigned properties of agents at each tick and ran the simulation: extensions [csv] Breed [Drivers Driver] turtles-own[ Name List-Of-Actions ] globals [li] to...

Extension not found error with control flow extension

netlogo

There is no release for the extension yet. The zip file that you downloaded is just the source code and doesn't contain the compiled JAR files that you need to use the extension with NetLogo. If you want to try it out, you will have to build it yourself. For...

Selectively grab Instances for creating a movie

netlogo

I would suggest moving the unwanted interface items to the edge of the Interface tab, recording the movie, then cropping the movie in movie-editing software to remove the unwanted portion. Alternatively, you could cover the unwanted interface items with one or more opaque white notes, or cover them with other...

Draw an arrow for a vector on the top of each of the turtles

netlogo

Here's how I'd do it: Make sure your turtles are all of one breed, say, particles, or whatever they represent. Create another turtles breed called vectors or something. These turtles are going to be the tip of your vectors but you'll use links to actually visualize the vectors. Now, you...

if elseif else implementation in Netlogo environment

netlogo

The only way I can wholeheartedly recommend is: ifelse condition1 [ ... ] [ ifelse condition2 [ ... ] [ ifelse condition3 [ ... ] [ ifelse ... But yeah, the indentation and readability aren't great. For thoughts on possible eventual improvements, see https://github.com/NetLogo/NetLogo/issues/344 and https://github.com/qiemem/ControlFlowExtension....

Find a single duplicate in a list of lists Netlogo

list,duplicates,netlogo

This is quick and dirty, but find-dup should return the first duplicated item (in this case a sublist) in the list. to go let listA [[-9 2] [-9 1] [-9 0][-9 -1][-9 -2][-9 -3][-9 -4][-8 0][-9 0]] show find-dup listA end to-report find-dup [ c ] ;returns the first duplicated...

Shortest path query returning empty list

netlogo

It works as designed. The documentation of path primitives says: If no path exist between the source and the target turtles, all primitives will report an empty list. On the other hand, distance primitives will report false if no path exists. As per the documentation: Finds the shortest path to...

Histogram over non-integral buckets

netlogo

You can control the bar width directly using set-plot-pen-interval.

Behaviour space simultaneous simulations error

netlogo

It seems possible that you are running into https://github.com/NetLogo/NetLogo/issues/105. Are you calling clear-all at the start of your setup procedure?...

Perspective based ranking?

netlogo

If you want to model relations between agents, NetLogo has the perfect thing for that: links! Having each turtle assign a score to all other turtles can be quite naturally expressed as: directed-link-breed [ rankings ranking ] rankings-own [ score ] to setup clear-all create-turtles 10 ask turtles [ create-rankings-to...

Creating overlapping agents in a line

netlogo

This is a lot of code to ask anybody to debug for you. I would suggest solving a simpler version of the problem first. Do you have code that can create wall-agents turtles in a single patch, evenly spaced along a line? Once you had a working code that did...

Why am i getting the expected a true/false here rather than an a list or block here?

netlogo

The problem in your code is this expression (and you must have changed it, because it doesn't compile): [pcolor] n-of 2 neighbors4 = grey n-of 2 neighbors4 returns an agentset consisting of two randomly chosen patches of the four neighbors. In order to get a list of its colors, you...

Netlogo: How to randomly select out of all neighbor patches that have a higher elevation?

netlogo

You can use uphill primitive i.e. dictionary with something like ask turtles [ uphill elevation ] EDIT You can use something like ask tutles [ let myelevPatch elevation patch-here let higherpatches patches in neighbors with [elevation > myelevPatch] move-to one-of higherpatches ] ...

NetLogo: histogram with list of strings

histogram,netlogo

You didn´t use quotes in your histogram list, but I am assuming that you wanted to plot a list of strings like ["a" "b" "c" ...], right? As far as I know, it is not possible to use categorical values (like strings) for a histogram in netlogo plots. This is...

NetLogo: Measure maximum distance between 2 patches

distance,netlogo

Try with max: max [distancexy 0 0] of patches with [pcolor = green] ...

nw:weighted-path-to, nw:turtles-on-weighted-path-to and multiple equally weighted paths

netlogo

Good question! You can generate either list from the other, but I think turtle-path to link-path is easier: ;; Construct the turtle path, putting the current turtle on the front: let turtle-path fput self nw:turtles-on-weight-path-to turtle 3 "weight" ;; Iterate through pairs of turtles, getting the link connecting them let...

NetLogo - Distributing grains of sand in sandpile model to random neighbours

netlogo

Instead of asking 4 neighbors, ask min list 4 count neighbors: ask n-of (min list 4 count neighbors) neighbors [ ... ] But from the model point of view, there will be different redistribution on the edge of the table, so this is not a good idea. Maybe it is...

How to create random binary/boolean variable in Netlogo

netlogo,agent-based-modeling

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 [...

turtles think that they are always on a patch that is black

netlogo

Putting the turtles pen down colors over the patches. It does not change the color of the patches. (You just cannot see that anymore.) To changes the patch color, always use pcolor.

Development of turtles from one breed to another

netlogo

To turn a turtle into a hatchling, just do set breed hatchlings! So, your code will probably look something like: if age > 10 [ set breed hatchlings ] ...

Should I use in-radius or in-cone to define vision in NetLogo 3D?

netlogo

In NetLogo 3D, in-radius is spherical. Why not just try it? It should only take you a minute to verify this by experiment using NetLogo 3D's Command Center....

How to call a list for update multiple times until a condition is fulfilled in Netlogo

list,procedure,netlogo

This is easiest to solve using recursion: to-report remove-fenced-sublists [xs] if empty? xs [ report [] ] let pos position first xs butfirst xs if not is-number? pos [ report fput first xs remove-fenced-sublists butfirst xs ] report remove-fenced-sublists sublist xs (pos + 2) length xs end Sample run: observer>...

How to get NetLogo to run a function every 30 minutes

netlogo

Check out every. It makes sure the given command block runs at most once per time period. Anyway, if your go is being run by a forever button, then this should work: to go every 30 * 60 [ get-data execute-and-return-decision-based-on-the-data-just-retrieved ] end ...

Why do i get this error every time i try to run the code within my U.I.?

netlogo

I think it come from a mise understanding of with condition ... something like ask patches [ if pcolor = blue [ ask turtles-here [ set heading towards one-of patches with [pcolor = grey] ] ] ] work for me ! ...