1/29/2024 0 Comments Reporter netlogoAlthough we kept the code of this model example deliberately simple, defining this reporter would make a big difference if we had a more complex model where we needed to calculate the speed of a particle in many different parts of our code. Instead of writing this complicated code to calculate a particle's speed within the go procedure, we define a speed reporter. However, each of them has a different speed because a particle's kinetic energy is equal to its mass times the square of its speed divided by two ($E = \frac m v^2$). These circles represent particles within a gas container. In the model example below, we have many circles large and small. Now, whenever we would like to calculate the area of a circle, we could simply write circle-area radius. For example, if we wanted to calculate the area of circles many times in our code, we could define the following reporter: to-report circle-area To-report is often used for complex calculations. Once we define this variable, we can replace each turtles with statement in our code with big-green-people, such as ask big-green-people. Reporters can be useful to tidy up your code and keep you from repeating lines of code if you use the same equation or long line of code multiple times, a to-report procedure can be used to replace it.įor example, instead of writing ask turtles with many times, we could define a reporter procedure as follows: to-report big-green-people In our example, we use the Simulated Annealing simdesign (simdesignGenSA()). Notice in the following example that the brackets come before of: if xcor 0 [įinally, you can create custom reporters using the to-report keyword to begin a reporter procedure and the report command at the end of your procedure, right before the end keyword. Here we present two simple examples for running an optimization algorithm on a NetLogo model with nlrx. Usually, the observer uses ask to ask all turtles or all patches to run commands. Many turtle, patch, and link properties such as color or label can be thought of as both variables that we can change with the set command, as well as reporters that provide us with the values of these variables. NetLogo uses the ask command to specify commands that are to be run by turtles or patches. Other primitives that we use for filtering agentsets or manipulating lists such as of, with, sort-on, and word are reporters, too. We need to use ticks in some other algorithm such as: if ticks > 9 [ A reporter is a predefined procedure that returns a value and, unlike a command, cannot be a stand-alone code element. For example, we cannot just write ticks in the code. NetLogo has some useful built-in reporters that cannot be changed directly such as ticks, pi, e, world-width, and world-height. A reporter is a predefined procedure that returns a value and, unlike a command, cannot be a stand-alone code element.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |