![]() The model then uses a while loop with the conditional not file-at-end? to iterate through the entire file. The data comes in a sequence of numbers that can be divided into lots of three, with each representing the x and y coordinates of a patch, and then the color value to be added to that patch. NetLogo then opens up an empty list called patch-data, and then reads in the data. But in this case, the file should be in the same directory, so there shouldn’t be any trouble. NetLogo will only find a file if it is located in the same directory as the model itself, or if you specify another file location. What this does is first check whether the data file (“File IO Patch Data.txt”) exists, and if it didn’t it would send you a message saying the file isn’t in the current directory. User-message "There is no File IO Patch Data.txt file in current directory!" Set patch-data sentence patch-data (list (list file-read file read file-read)) Ifelse ( file-exists? "File IO Patch Data.txt" ) [ If you push “load-patch-data”, a window opens that looks like this:ĭoesn’t seem like anything else happened, but when you push that button, some code runs in the background: to load-patch-data If you open this model, there are three buttons: “load-patch-data”, “show-patch-data”, and “load-own-patch-data”. An example of this can be found in the Code Examples section of the NetLogo model library (“File Input ogo”). One way to bring data into NetLogo would be to use the file input-output commands, which allow Netlogo to read in text files according to user-defined rules. Importing GIS data using file input/output commands You’ll want to consider these when you add in your data, as these will influence how your data is translated to the NetLogo world. Here you can set your origin point, maximum and minimum coordinates, patch size, and whether or not the world “wraps” as a toroid or cylinder. NetLogo has an in-built, gridded topology which can be manipulated by right clicking on the world window in the NetLogo interface and selecting “edit”. ![]() these patches are “grass”, other patches are “not grass”). However, for most applications, the spatial data generated by NetLogo models are gross abstractions (e.g. The NetLogo platform possesses several of the basic characteristics of a GIS, in the sense that it keeps track of spatial data in a systematic way, and can be used to create visualizations of spatial data. In this tutorial, I’ll talk about how to do this using NetLogo. If we want to build models that operate in realistic geographic settings (and many archaeological applications of agent-based models are aimed at this goal see here or here for examples), we need to find a way of integrating geographic data with models. For archaeology and other disciplines where the systems under study are cannot be confined to a laboratory, this often means being able to consider our data in spatial terms. This is certainly useful when dealing with a general problem like segregation, but what if we have a specific case study to which we want to apply our model? The integration of models with case-specific datasets becomes particularly important when our models are to be used for policy and decision-making. In these instances, it is often necessary to have models that are capable of producing results that can be interpreted in real-world terms. ![]() Classic agent-based models like Schelling’s model of segregation use very simple ideas about how the world works to explore how complex structures might emerge from simple behavioral rules.
0 Comments
Leave a Reply. |