**3. Repast Simphony**

in the literature seems to be inspired by living systems. Living systems offer an organization and operation at different levels ranging from the genetic to the social experience. The most common applications that can be shown in living systems are biological systems including human physiology which examine major systems such as cardiovascular system, immune system, nervous system, endocrine system, etc., and predator-prey relationship in the ecosystem, birds and fish flocks, organisms that live in colonies such as foraging ants, bees, wasps,

ABMS allows the researchers an experimental experience to create, analyze, and explicate the relationship between the artificial and the real world. In comparison with other modeling approach based on mathematical and numerical analysis, control theory, biomechanical techniques, etc., ABMS is referred to as "individual-based model" [2]. Individual is called agent which has a set of attributes and autonomous behavior. Agents are situated in some set of spaces and time. Agents interact with other agents in the simulation environment. The simulation environment includes agents that perform their actions and achieve their goals.

In this chapter, we will focus on the use of computer simulation for building the agent-based models in biological systems. This chapter intends to provide brief descriptions of the agentbased models that illustrate how to build and implement case studies, which reflect the rela-

This chapter is organized as follows: Section 2 gives a brief overview of ABMS; Section 3 presents the description of Repast Simphony toolkit which has ability to display and schedule in real time; Section 4 provides implementation of case studies involving different scenarios to better understand ABMS phenomena; and Section 5 concludes with a brief summary of this

Agent-based modeling and simulation (ABMS) can be defined in very diverse disciplines like artificial intelligence, complexity science, game theory, etc. [3, 4]. ABMS provides a suitable simulation modeling technique for the analysis of complex systems and emergent phenomena in biological systems, social sciences, economy, management systems, etc. [5, 6]. ABMS is a computational model implemented as computer simulation in which there are individual entities and their behaviors and interactions. It focuses on rules and interaction among the individuals or components of the real system. In the ABMS, the systems are characterized by the autonomous and independent entities known as agents performing some kind of behaviors (action and interactions) in the simulation environment [7]. In the literature, it is possible to see many examples of agent-based modeling in the different fields including traffic control,

ABMS has advantage of creating a model compared to traditional approaches. No any set of formulas or mathematical equations are needed to build an agent-based model. ABMS focuses on the rules that will determine the behaviors of agents [8]. In order to develop an

and termites, and etc. [1].

30 Modeling and Computer Simulation

tionship in the real world.

**2. Agent-based modeling and simulation**

biomedical research, ecology, energy analysis, etc. [4].

chapter.

Repast (Recursive Porous Agent Simulation Toolkit) Simphony is an agent-based modeling and simulation framework based on the object-oriented programming using Java language. It is free and open source so that it offers the users the widespread use of the agent development environments. Repast Simphony uses Eclipse-integrated development environment (IDE) for developing computer code [13]. Repast Simphony tool offers researchers a flexible way to write models including graphical user interface, toolbar to control the simulation processes (start, step, pause, stop, exit, etc.), displaying agents and their environment, monitoring the output data (time chart, histogram bar), scheduling of simulations, parameter management, data sets, data loaders, etc. Repast Simphony is the most suitable simulation framework for agent-based model development. Classes of agents and their interactions are displayed in Repast Simphony. The output data are graphically presented in time charts and/or histogram bar. Repast Simphony allows the users to record inbuilt data to txt files and displays as movies or images. Also, the users obtain the snapshots of graphics and/or display. Repast Simphony has advantage to display, schedule, analyze, update, or manipulate a running simulation in real time.

After downloading the latest version on Repast Simphony from its web page, creating a new Repast Simphony project is very easy. The first step is to run Eclipse IDE. After the new Repast Simphony Project, which includes a source directory, and default package is created, the scenario directory structure is prepared by creating agent classes.

To build an agent-based model, it is necessary to create classes. More agent classes can be created according to the scenario of the model. The classes include any number of methods to describe the attributes and roles of agents. Setup or step methods are called for each iteration of the simulation. In the each iteration of the simulation, the simulation runtime is described with time steps or tick counts. During the simulation runtime, the agents perform their actions. The get and set methods, which describe agents' attributes, may update the value returned or stored in each tick count. The agents may continue or update their actions according to the results of the previous action they performed.

Agents are situated in continuous space and/or grid in the simulation environment which provides a context for interaction and communication of agents. Agents may be distributed to the environment randomly or with some rules. They may have the energy to make them survive. If the agent's energy is exhausted, the agent may die. If the agent's energy reaches the reproduction threshold, it may reproduce. In the simulation environment, there are heterogeneous agents which have different types. For example, an agent may represent the animal, while the other may represent the human. A style class in two-dimensional (2D) or threedimensional (3D) simulation environment can be created in a way that defines the physical properties of agents such as size, color, and shape. Global parameters associated with agent classes, including initial values of project given by users, may be defined in an xml file.

Repast Simphony provides the users a graphical user interface (GUI). GUI allows the users to manage the simulation processes and to control the parameters. GUI has a user panel that includes run options, parameters, and scenario tree. To form the scenario tree of a project, context builder Java file is defined in data loaders to display agents and the environment on which agents are located. It is possible to observe agents' behavior outputs on the plots and charts. Data sets are created to graphically illustrate time charts defining variables over time. The data set source is determined by pointing out the relevant methods. Histogram bar chart illustrates the distribution of variables.
