I need to represent in netlogo a matrix, which is patches with number on them, in both the matrix form and the tree form (quad tree).
is it possible to have mor that one world in netlogo? i need to visualize a world of patches and a tree at the same time.
I don't think it's possible but you can try modeling a big space and use half of it for your patches and the other half for the tree.
Related
I'm using GIS extension in Netlogo to import shapefiles, then creating turtles from attributes of the shapefile. I'm using the distance primitive to calculate the distance between turtles. I know Netlogo does converts the shapefile to netlogo space, so the distances wouldn't be reported the same b/w GIS and Netlogo. For example, in GIS distance between turtle A and B is 49550 meters. In Netlogo, it's 0.2038. Is there a way to determine what the units of measure are in Netlogo? Is the conversion always the same or does it depend on the projection? Thanks for any assistance.
The distance in a NetLogo model is entirely arbitrary. You are deciding the unit of distance implicitly when you import a GIS real-world structure into whatever number of patches there are in the NetLogo world. In your case, the easiest way to work out the conversion factor is likely to be to find a few points on your GIS and get their xcor and ycor. From your question, haven't you already done this? You have said that 0.2038 is 49550m.
There will also be problems coming out of the projection - if your model covers a large real world area, then the mismatch between the surface of a sphere and a flat model will mean the distance conversion is different at different locations.
Maybe this helps. I found a model here, which is also trying to work with space.
I quote: "Grid cell size does not represent an absolute spatial unit (e.g. meters); instead, the size of grid cells is only meaningful with respect to the step size of individuals which can vary with user input."
After my NetLogo simulation, I would like to measure the total area covered by only the turtles. Is there a simple way to implement this in NetLogo, or will I have to do this in another program?
My simulation has clusters that form and I would eventually like to calculate the cluster agent density. 1
NetLogo is not aware of where the edge of the turtles’ shapes are. So, if you are trying to work out what proportion of the screen has shapes on it, you need to do some complicated programming to calculate where the edges of the shapes are, how they overlap and so on. However, if all you care about is where the turtles are, then it's much easier. For example, to work out the proportion of patches where there are at least one turtle, you could do:
count patches with [any? turtles-here] / count patches
so I am trying to model the spread of cancer throughout human tissue and I am wondering how to make the turtles grow and divide like actual cancer cells do?
More specific:
I am starting with one turtle in the center of the interface and i want that turtle to divide into two turtles then those turtles do the same as the first one, one splits into two two split into four and four split into 8. How do i code this?
I am trying to plot a graph that shows the variables of all agents of one breed. Although the number of agents is rather small, I think there must be a more elegant way than creating a pen for every agent. Is there?
Elegance, here, depends on what exactly you want to do. It can be perfectly legitimate to create one plot pen per turtle, using create-temporary-plot-pen. Among advantages, it means that you can give each plot pen a name and show a legend on your plot.
That being said, it's also very easy to use a single pen for all your agents. Suppose you have multiple turtles, of different colors, and you want to plot their sizes. You can put something like this in a pen's "update commands":
ask turtles [ set-plot-pen-color color plotxy ticks size ]
This will change the pen to the color of each turtle and plot a single point for that turtle. Just be sure to set your pen to "point" mode in the advanced pen options.
Also notice the use of plotxy instead of just plot, allowing you to specify an x coordinate instead of relying on the "auto advance" behavior of plot.
I have a landscape that includes a road network as in the below figure.
I would like to calculate an average number of roads (or white line in the figure) that link each color polygon (for example a black polygon) between them.
In a network, a link corresponds to a road, a node corresponds to a color polygon and I think that to calculate an average number of roads between color polygons means to calculate the average node degree of the network. For example, in the figure, the two black polygons are linked by two roads. So, the degree of a black polygon is 2. Is it possible to calculate a node degree with the extension Network of Netlogo ?
Thanks in advance for your help.
Normal NetLogo contains link agents that link turtles even without an extension. Calculating degree is usually just a matter of doing [ count my-links ] of node where node is the turtle you want to know the degree of. However, in NetLogo, turtles can't be connected by more than one link. The typical workaround for this is create a links-own variable (just like turtles-own or patches-own variable) . This variable is often called weight, but you can call it whatever you want. In that case, you would do [ sum [ weight ] of my-links ] of node to calculate the degree.
This is all assuming you have a network representation of your roadways, which it doesn't sound like you do. Furthermore, I'm not sure what you're trying to represent is a network, since (as shown in your picture) roads branch at intersections. Thus more than two polygons could be connected by a single (for some definition of "single") road. This is often called a hypernetwork or hypergraph. However, this is probably a heavier weight concept than what you want.
Now, I'm not entirely sure what you're really trying to calculate. Is it:
...the number of roads connected to a polygon? The lower polygon has 4 roads connected to it, the upper has 3 (visible).
...the number of polygons directly connected to the polygon? Both polygons are connected to 1 other (visible) polygon, though I assume in the larger picture there are more.
The number of roads connected to a polygon would be pretty easy to calculate, assuming each road is 1 pixel wide. You could just do:
count (patch-set [ neighbors4 with [ is-road? ] ] of polygon)
where polygon is a patch set containing the patches of the polygon and is-road? is a reporter that returns true for road patches and false for non-road patches (this could be something pcolor = white). Note that this will break if roads are wider than 1 patch or if the same road can touch a polygon in other places. Let me know if that's the case and I'll expand this into something that can that into account.
The number of polygons directly connected to the polygon is more difficult. The basic idea would be to follow the roads out until you hit other polygons and count the number that you hit. Code for this is somewhat tricky. I think the best way to go about it would be to have two patch-sets, frontier and explored and list of found polygons. frontier should initialize to every road patch touch the polygon. Each iteration, get the polygons touching the frontier and add them to the list of found polygons if they're not already in there. Add the frontier to explored. Get all the road patches touching the frontier that are not in explored. Set the frontier to this new set of patches. Keep going until frontier is empty. This is a version of breadth-first search. There could be a better way to do this.