Economic Simulations in Swarm: Agent-Based Modelling and Object Oriented Programming

Economic Simulations in Swarm: Agent-Based Modelling and Object Oriented Programming
of 12
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Share
Tags
Transcript
    Article number:  1013 Please cite this article as following: Pietro Terna, 2002, Economic Simulations in Swarm: Agent-Based Modelling and Object Oriented Programming - By Benedikt Stefansson and Francesco Luna: A Review and Some Comments about “Agent Based Modeling”, The Electronic Journal of Evolutionary Modeling and Economic Dynamics, n° 1013, http://www.e-jemed.org/1013/index.php  Economic Simulations in Swarm: Agent-Based Modelling and Object Oriented Programming - By Benedikt Stefansson and  Francesco Luna: A Review and Some Comments about “Agent  Based Modeling” Pietro Terna  Dipartimento di Scienze economiche e finanziarie G.Prato, Università di Torino, Italia Abstract There are three different “symbol systems” available to social scientists: the familiar verbal argumentation and mathematics, but also a third way, computer simulation. Computer simulation, or computational modeling, involves representing a model as a computer program. The key question is: What tools can we use in building our models, if we follow the “third way”? Simulation will have to be written in some Esperanto: it is obvious that the current Babel is against the emergence of a renewed enthusiastic effort in economic theory. Swarm is a library of functions offering tools in the middle between basic programming (Fortran, C, C++, Java, ….) and closed packages for dynamic simulation; it helps us to develop our own software, using a well-defined protocol and powerful tools to deal with agents’ behavior, interaction and time sequences. So it can be considered an excellent candidate to play the role of this necessary Esperanto. Keywords: Economic simulation, Swarm, Agent Based Modeling  JEL:  B41, B59, C15 Copyright:  Pietro Terna, 2002   The Electronic Journal of Evolutionary Modeling and Economic Dynamics http://www.e-jemed.org/ 2 Economic Simulations in Swarm: Agent-Based Modelling and Object Oriented Programming - By Benedikt Stefansson and Francesco Luna: A Review and Some Comments about “Agent Based Modeling”   Pietro Terna Dipartimento di Scienze economiche e finanziarie G.Prato, Università di Torino, Italia pietro.terna@unito.it  Introduction Reviewing a book like that edited by Luna and Stefansson (2000) - mainly being one of the co-authors, as in my case - means getting involved in the general subject of model building and modeling techniques. According to Gilbert and Terna (2000): Ostrom (1988) proposed that there are three different “symbol systems” available to social scientists: the familiar verbal argumentation and mathematics, but also a third way, computer simulation. Computer simulation, or computational modelling, involves representing a model as a computer program. Computer programs can be used to model either quantitative theories or qualitative ones. They are particularly good at modelling processes and although non-linear relationships can generate some methodological problems, there is no difficulty in representing them within a computer program. The logic of developing models using computer simulation is not very different from the logic used for the more familiar statistical models. In either case, there is some phenomenon that we as researchers want to understand better. This is the “target”. We build a model of the target through a theoretically motivated process of abstraction (this model may be a set of mathematical equations, a statistical equation, such as a regression equation, or a computer program). We then examine the behaviour of the model and compare it with observations of the social world. If the output from the model and the data collected from the social world are sufficiently similar, we use this as evidence in favour of the validity of the model (or use a lack of similarity as evidence for disconfirmation). The key question now is: What tools can we use in building our models, if we follow the “third way”? With Luna and Stefansson (2000), Introduction, p.xxiii: The volume Economic Simulations In Swarm has several goals: 1. it wants to propose a common language to those economists who already employ simulations as one of their tools of analysis; 2. it will present for the first time a language (Swarm) with a condensed, but rather exhaustive, tutorial; 3. it collects a rich variety of srcinal contributions to economics, where simulations offer a natural mode of analysis of the dynamics of complex systems with heterogeneous agents. Following Hahn (1991), Luna and Stefansson argue (p.xxiv, xxv): Perhaps, economics is destined to be once more  an inductive discipline; whether it will be “softer” because of that (as Hahn implies) it is difficult to say. Undoubtedly, however, in   The Electronic Journal of Evolutionary Modeling and Economic Dynamics http://www.e-jemed.org/ 3 their inductive efforts, theoreticians will find simulations of artificial “worlds” more and more useful to extract regularities and/or to push their “simple” thought experiments to “unforeseeable” outcomes. These results are very useful to help the intuition to the researcher and often suggest srcinal interpretations of real world phenomena. Unfortunately, too often the acceptability of the frame of analysis and the transmissibility of its result are spoiled by the difficulty to read   the model and hence by the “unreplicability” of the results reported. It is hence becoming pivotal to construct a common language, not dissimilar from French for diplomacy or more recently English. Simulation will have to be written in  some Esperanto: it is obvious that the current Babel is against the emergence of a renewed enthusiastic effort in economic theory. Swarm 1  is a library of functions offering tools in the middle between basic programming (Fortran, C, C++, Java, ….) and closed packages for dynamic simulation; it helps us to develop our own software, using a well-defined protocol and powerful tools to deal with agents’ behavior, interaction and time sequences. So it can be considered an excellent candidate to play the role of this necessary Esperanto. About simulation and social sciences, some key recent references are Epstein (1999), Axtell (2000), Tesfatsion (2001). 1. What is Swarm and how to use it Following the Swarm documentation 2 , but also Minar et al.  (1996), we introduce a general sketch about how one might implement an experiment in the agent based modelling field. An idealized experiment requires: (i) the definition of computer based experimental procedure and (ii) the software implementation of the problem. The first step is that of translating the real base (the physical system) of our problem into a set of agents and events. From a computational point of view, agents become objects and events become steps activated by loops in our program. In addition, in a full object oriented environment, time steps are also organized as objects. We can now consider three different levels of completeness in the structure of our software tools: 1. at the lowest level (i.e., using plain C) we have to manage both the agent memory structures (commonly with a lot of arrays) and the time steps, with loops (such as “for” structures) driving the events; this is obviously feasible, but it is costly (a lot of software has to be written; many “bugs” have to be discovered); 2. at a more sophisticated level, employing object oriented techniques (C++, Objective C, Java, etc.), we avoid the memory management problem, but we have nevertheless to run time steps via the activation of loops; 3. finally, using a high level tool such as Swarm, we can dismiss both the memory management problems and the time simulation ones; in high level tools, also the events are also treated as objects, scheduling them in time-sensitive widgets (such as action-groups). In the Swarm context, we use the Object-Oriented Programming languages Objective-C or Java. According to the Swarm documentation, computation in a Swarm application takes 1  http://www.swarm.org. 2  Refer always to the Swam home page http://www.swarm.org.   The Electronic Journal of Evolutionary Modeling and Economic Dynamics http://www.e-jemed.org/ 4place by instructing objects to send messages to each other. The basic message syntax is (Objective C): [targetObject message Arg1: var1 Arg2: var2];  or (Java 3 ): targetObject.messageArg1$Arg2(var1, var2);  where targetObject  is the recipient of the message, messageArg1:Arg2:  is the message to send to that object, and var1  and var2  are arguments to pass along with the message. The idea of Swarm is to provide an execution context within which a large number of objects can “live their lives” and interact with one another in a distributed, concurrent manner. What those objects contain? This is the crucial question to understand what Swarm is: They can contain anything we put into their object oriented code, from simple rule execution to highly complicated logic and mathematics (artificial neural networks, classifier systems, genetic algorithms, …). We are completely free in using simple agents, like passive performers of fixed rules to full BDI (Beliefs, Intentions, Desires) cognitive agents (obviously, writing the specific code). We are nevertheless always completely able to manage all the details (as interactions, schedules of events, …) of our experiments, what is non completely feasible with other tools, directly devoted to BDI development, like SDML 4 . Technically speaking, in the context of the Swarm simulation system, the generic outline of an experimental procedure takes the following form. i. Create an artificial universe replete with space, time, and objects that can be located, within reason, to certain “points” in the overall structure of space and time within the universe., and allow these objects to determine their own behavior according to their own rules and internal state in concert with sampling the state of the world, usually only sparsely. ii. Create a number of objects which will serve to observe, record, and analyze data produced by the behavior of the objects in the artificial universe implemented in step i. iii. Run the universe, moving both the simulation and observation objects forward in time under some explicit model of concurrency. iv. Interact with the experiment via the data produced by the instrumentation objects to perform a series of controlled experimental runs of the system. A remark about the consequences of publishing the result of a simulation: Only if we are using a high level structured programming tool, it is possible to publish simulation results in a useful way. Quoting again from Swarm documentation: The important part (. . .) is that the published paper includes enough detail about the experimental setup and how it was run so that other labs with access to the same equipment can recreate the experiment and test the repeatability of the results. This is hardly ever done (or even possible) in the context of experiments run in computers, and the crucial process of independent verification via replication of results is almost unheard 3  Where the $  signs represent an added notation in Swarm (it is not a Java convention) to keep memory also in the Java version of Swarm, of the srcinal position, and meanings, of the parameters in the more explicit Objective C notation. 4  http://www.cpm.mmu.ac.uk/sdml/     The Electronic Journal of Evolutionary Modeling and Economic Dynamics http://www.e-jemed.org/ 5 of in computer simulation. One goal of Swarm is to bring simulation writing up to a higher level of expression, writing applications with reference to a standard set of simulation tools. For this, the fact that the Swarm structure has two different levels is very useful. There is the model level (and we can have nested models of models, or swarms of swarms) and the observer level which considers the model (or the nested models) as a unique object to interact with, in order to obtain the results and to send them to various display tools and widgets. Figures 1 and 2 are related to the different levels of Swarm (figures come from Minar et al., 1996). Figure 1: a Swarm intented as ModelSwarm (composed of agents). We finally underline here the key role of Swarm, because the characteristics of the software we use are crucially important in assuring the success of this way of formalizing models. Only if we use high quality software we are able to communicate the details of our model, allow other scholars to replicate the results, and avoid difficulties in modifying poorly written code. The best way to improve the quality of the programming is to choose an object-oriented language. This choice simplifies the translation of the problem into a set of agents and events. From a computational point of view, agents become objects and events become steps activated by loops in the program. In addition, in a fully object oriented environment, events (or time steps) can be organized as objects. The key term here is object: a piece of code containing data and rules operating on them. A these characteristics are contained in Swarm.
Advertisement
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks