Evolutionary Economics and Social Complexity Science 19
Stanislaw Raczynski
Interacting
Complexities of
Herds and Social
Organizations
Agent Based Modeling
Evolutionary Economics and Social Complexity
Science
Volume 19
Editors-in-Chief
Takahiro Fujimoto, Tokyo, Japan
Yuji Aruka, Tokyo, Japan
Editorial Board
Satoshi Sechiyama, Kyoto, Japan
Yoshinori Shiozawa, Osaka, Japan
Kiichiro Yagi, Neyagawa, Osaka, Japan
Kazuo Yoshida, Kyoto, Japan
Hideaki Aoyama, Kyoto, Japan
Hiroshi Deguchi, Yokohama, Japan
Makoto Nishibe, Sapporo, Japan
Takashi Hashimoto, Nomi, Japan
Masaaki Yoshida, Kawasaki, Japan
Tamotsu Onozaki, Tokyo, Japan
Shu-Heng Chen, Taipei, Taiwan
Dirk Helbing, Zurich, Switzerland
The Japanese Association for Evolutionary Economics (JAFEE) always has adhered
to its original aim of taking an explicit "integrated" approach. This path has been
followed steadfastly since the Association’s establishment in 1997 and, as well, since
the inauguration of our international journal in 2004. We have deployed an agenda
encompassing a contemporary array of subjects including but not limited to:
foundations of institutional and evolutionary economics, criticism of mainstream
views in the social sciences, knowledge and learning in socio-economic life,
development and innovation of technologies, transformation of industrial
organizations and economic systems, experimental studies in economics, agent-
based modeling of socio-economic systems, evolution of the governance structure of
firms and other organizations, comparison of dynamically changing institutions of
the world, and policy proposals in the transformational process of economic life. In
short, our starting point is an "integrative science" of evolutionary and institutional
views. Furthermore, we always endeavor to stay abreast of newly established methods
such as agent-based modeling, socio/econo-physics, and network analysis as part of
our integrative links.
More fundamentally, “evolution” in social science is interpreted as an essential
key word, i.e., an integrative and /or communicative link to understand and re-domain
various preceding dichotomies in the sciences: ontological or epistemological,
subjective or objective, homogeneous or heterogeneous, natural or artificial, selfish or
altruistic, individualistic or collective, rational or irrational, axiomatic or psychologicalbased, causal nexus or cyclic networked, optimal or adaptive, micro- or macroscopic,
deterministic or stochastic, historical or theoretical, mathematical or computational,
experimental or empirical, agent-based or socio/econo-physical, institutional or
evolutionary, regional or global, and so on. The conventional meanings adhering to
various traditional dichotomies may be more or less obsolete, to be replaced with
more current ones vis-à-vis contemporary academic trends. Thus we are strongly
encouraged to integrate some of the conventional dichotomies.
These attempts are not limited to the field of economic sciences, including
management sciences, but also include social science in general. In that way,
understanding the social profiles of complex science may then be within our reach.
In the meantime, contemporary society appears to be evolving into a newly emerging
phase, chiefly characterized by an information and communication technology
(ICT) mode of production and a service network system replacing the earlier
established factory system with a new one that is suited to actual observations. In
the face of these changes we are urgently compelled to explore a set of new properties
for a new socio/economic system by implementing new ideas. We thus are keen to
look for “integrated principles” common to the above-mentioned dichotomies
throughout our serial compilation of publications. We are also encouraged to create
a new, broader spectrum for establishing a specific method positively integrated in
our own original way.
More information about this series at />
Stanislaw Raczynski
Interacting Complexities
of Herds and Social
Organizations
Agent Based Modeling
Stanislaw Raczynski
Facultad de Ingeniería
Universidad Panamericana
Ciudad de México, México
ISSN 2198-4204 ISSN 2198-4212 (electronic)
Evolutionary Economics and Social Complexity Science
ISBN 978-981-13-9336-5 ISBN 978-981-13-9337-2 (eBook)
/>© Springer Nature Singapore Pte Ltd. 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of
the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology
now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book
are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, express or implied, with respect to the material contained herein or for any errors
or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims
in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Singapore Pte Ltd.
The registered company address is: 152 Beach Road, #21-01/04 Gateway East, Singapore 189721,
Singapore
Preface
According to John von Neumann, “by a model is meant a mathematical construct
which, with the addition of certain verbal interpretations, describes observed phenomena. The justification of such a mathematical construct is solely and precisely
that it is expected to work — that is, correctly to describe phenomena from a reasonably wide area.” Humans always (sometimes unconsciously) have used models created in their brains. When our technical skills have grown, the models acquired the
form of physical, scale models, drawings, and finally sophisticated logical and
mathematical constructions. The common concept of modeling is defined as a scientific activity, the aim of which is to make a particular part or feature of the world
easier to understand.
The complexity of the real world can be modeled to some extent. There are many
definitions of complexity, recently related to “system of systems” structures. Note
that a system that contains a great number of sub-systems or items or a huge number
of differential equations is not necessarily complex. The complexity lies in the way
the components interact with each other and the diversity of system components. In
such systems, the simulation results may provide information about the behavior of
the whole system, which is not the sum of individual behavior patterns. This is also
interpreted as nonlinearity. This book is focused on this kind of modeling and simulation experiments.
Analog and digital computers gave us a powerful tool for model building and
analysis. At the very beginning of the computer era, the differential equations have
been solved on analog machines, helping scientists and engineers to design mechanisms, circuits, and complex devices. The field of model applications has grown
over the decades, including not only the works of engineering and exact sciences but
also the models of animal and human societies.
At the very beginning, model builders have been looking for some kinds of algebraic, ordinary, or partial differential equations to describe real system behavior.
The most known and explored field is the System Dynamics (SD) approach that
mainly uses models in the form of ordinary differential equations. However, it
should be noted that this is not the only way to build models. A strange conviction
aroused among the modelers that everything in the real world can be described by
v
vi
Preface
differential equations. In general, this is not true. Although the SD methodology is
still widely used and useful, there are other ways for model building, like fuzzy
logic, differential inclusions, discrete event simulation, and agent based models,
among others.
The topic of this book is agent based modeling. The rapid growth of the computational capacity of new computers permits us to create thousands of objects in
computer memory and make them interact with each other. In agent based models,
the objects are equipped with certain artificial intelligence, can optimize their
behavior, and take decisions. Some systems can be modeled both using differential
equations and agent based approach. The results of these two methods are frequently
quite different, for example, results of the Lotka-Volterra prey-predator model and
the prey-predator agent based model. Here, we will not suggest which of these models is valid or not. These are just different modeling methods that produce results of
different kind. Undoubtedly, agent based modeling is more flexible and can reflect
more behavioral patterns of the individuals, providing the insight on the macro-
behavior of the system. In Chap. 1, there are comments on some agent based modeling tools. The other chapters contain examples of applications to artificial societies
and competing populations of individuals and the growth, interactions, and decay of
organizations and other applications. For reader’s convenience, a short recall about
object- and agent-based modeling is repeated in each chapter. Thus, each chapter
can be read as independent unit. In Chap. 9, you can find a description of an experimental software package that uses the classic continuous system dynamics graphical user interface (GUI) that is used to construct the model. However, the transparent
simulation engine that runs behind this GUI is discrete event simulation. This way,
we can compare the results of the conventional system dynamics packages with
these provided by discrete event simulation. The relevant differences between these
two simulation paradigms are pointed out.
Mexico City, Mexico
Stanislaw Raczynski
Acknowledgements
I would like to express my gratitude to the Editors of the journals listed below for
the permission to use the updated versions of my articles, as follows:
Simulating self-organization and interference between certain hierarchical structures. Nonlinear Dynamics, Psychology, and Life Sciences, 2014, Vol 18, no 4,
used in Chap. 2 of this book,
A Self-destruction game, Nonlinear Dynamics, Psychology, and Life Sciences,
2006, Vol 10, no 4, used in Chap. 7 of this book,
The spontaneous rise of the herd instinct: agent-based simulation, Nonlinear
Dynamics, Psychology, and Life Sciences, to appear, used in Chap. 5 of this
book.
Simulation of the dynamic interactions between terror and anti-terror organizational structures, Journal of Artificial Societies and Social Simulation, Vol. 7, no.
2, used in Chap. 3 of this book.
Influence of the gregarious instinct and individuals’ behavior patterns on macro
migrations: simulation experiments, Journal of Human Behavior in the Social
Environment, Vol. 28, no 2, used in Chap. 6 of this book. Visit the journal home
page at www.tandfonline.com.
Stanislaw Raczynski
vii
Contents
1Agent-Based Models: Tools ���������������������������������������������������������������������� 1
1.1General Remarks������������������������������������������������������������������������������ 1
1.2Discrete Event Simulation���������������������������������������������������������������� 2
1.2.1GPSS ������������������������������������������������������������������������������������ 4
1.2.2Arena������������������������������������������������������������������������������������ 4
1.2.3SIMIO ���������������������������������������������������������������������������������� 5
1.2.4Simula ���������������������������������������������������������������������������������� 5
1.2.5PASION, PSM++, and BLUESSS���������������������������������������� 6
1.3Example�������������������������������������������������������������������������������������������� 12
1.4Conclusion���������������������������������������������������������������������������������������� 16
References�������������������������������������������������������������������������������������������������� 16
2Simulating Self-Organization and Interference Between Certain
Hierarchical Structures ���������������������������������������������������������������������������� 19
2.1Introduction�������������������������������������������������������������������������������������� 19
2.2The Model���������������������������������������������������������������������������������������� 21
2.2.1General Concepts������������������������������������������������������������������ 21
2.2.2Interaction Rules ������������������������������������������������������������������ 23
2.3Simulation ���������������������������������������������������������������������������������������� 25
2.4Conclusion���������������������������������������������������������������������������������������� 27
References�������������������������������������������������������������������������������������������������� 28
3Interactions Between Terror and Anti-terror Organizations���������������� 31
3.1Introduction�������������������������������������������������������������������������������������� 31
3.2The Model���������������������������������������������������������������������������������������� 33
3.2.1Interactions Between Structures ������������������������������������������ 36
3.2.2Simulation Tool and Model Implementation������������������������ 37
3.2.3Simulation Experiments�������������������������������������������������������� 40
3.3Conclusion���������������������������������������������������������������������������������������� 45
References�������������������������������������������������������������������������������������������������� 45
ix
x
Contents
4Organization Growth and Decay: Simulating Interactions
of Hierarchical Structures, Corruption and Gregarious Effect������������ 47
4.1Introduction�������������������������������������������������������������������������������������� 47
4.2Agent-Based Modeling �������������������������������������������������������������������� 49
4.3Simulation Tool�������������������������������������������������������������������������������� 51
4.4The Model���������������������������������������������������������������������������������������� 52
4.4.1The Individuals �������������������������������������������������������������������� 52
4.4.2Organizations������������������������������������������������������������������������ 54
4.4.3Auxiliary Control Process���������������������������������������������������� 55
4.5Simulation Experiments�������������������������������������������������������������������� 55
4.5.1Experiment 1: Criterion Function Zero�������������������������������� 57
4.5.2Experiment 2: Change Criterion – Size�������������������������������� 58
4.5.3Experiment 3: Corruption Level ������������������������������������������ 59
4.5.4Experiment 4: Accumulated Corruption ������������������������������ 59
4.5.5Experiment 5: Criterion – Grow Rate (Herd Instinct)���������� 61
4.6Conclusion���������������������������������������������������������������������������������������� 63
References�������������������������������������������������������������������������������������������������� 63
5The Spontaneous Rise of the Herd Instinct: Agent-Based
Simulation�������������������������������������������������������������������������������������������������� 67
5.1Introduction�������������������������������������������������������������������������������������� 67
5.2Agent-Based Modeling �������������������������������������������������������������������� 69
5.2.1General Remarks������������������������������������������������������������������ 69
5.2.2BLUESSS Simulation Package�������������������������������������������� 70
5.3The Model���������������������������������������������������������������������������������������� 71
5.3.1Environment�������������������������������������������������������������������������� 71
5.3.2Event: Search for Food �������������������������������������������������������� 73
5.4Simulations �������������������������������������������������������������������������������������� 75
5.4.1Gregarious Factor, Search for Food�������������������������������������� 75
5.4.2The Influence of the Threat�������������������������������������������������� 76
5.5Conclusion���������������������������������������������������������������������������������������� 79
Appendix���������������������������������������������������������������������������������������������������� 80
References�������������������������������������������������������������������������������������������������� 81
6Influence of the Gregarious Instinct and Individuals’ Behavior
Patterns on Macro Migrations: Simulation Experiments���������������������� 83
6.1Introduction�������������������������������������������������������������������������������������� 83
6.2Object- and Agent-Based Models ���������������������������������������������������� 84
6.3The Simulation Tool�������������������������������������������������������������������������� 85
6.4The Model���������������������������������������������������������������������������������������� 86
6.5Simulations �������������������������������������������������������������������������������������� 89
6.6Similarity to the Real Data���������������������������������������������������������������� 94
6.7Conclusion���������������������������������������������������������������������������������������� 95
References�������������������������������������������������������������������������������������������������� 96
Contents
xi
7Simulating Our Self-Destruction�������������������������������������������������������������� 97
7.1Introduction�������������������������������������������������������������������������������������� 97
7.2The Model���������������������������������������������������������������������������������������� 99
7.3Findings�������������������������������������������������������������������������������������������� 101
7.4Conclusion���������������������������������������������������������������������������������������� 104
References�������������������������������������������������������������������������������������������������� 105
8Prey-Predator Models Revisited: Uncertainty, Herd Instinct,
Fear, Limited Food, Epidemics, Evolution, and Competition���������������� 107
8.1Introduction�������������������������������������������������������������������������������������� 107
8.2Continuous Model���������������������������������������������������������������������������� 109
8.2.1Simple Simulation���������������������������������������������������������������� 109
8.2.2Uncertainty and Differential Inclusions�������������������������������� 110
8.3Agent-Based Simulation ������������������������������������������������������������������ 112
8.3.1General Remarks������������������������������������������������������������������ 112
8.3.2Simulation Tool�������������������������������������������������������������������� 113
8.3.3The Model���������������������������������������������������������������������������� 113
8.4Simulation Experiments�������������������������������������������������������������������� 115
8.4.1Entity Attributes, More Detail���������������������������������������������� 115
8.4.2Results: Random Walk���������������������������������������������������������� 116
8.4.3Chase and Escape Direction Enabled ���������������������������������� 118
8.4.4Food, Chase/Escape Enabled������������������������������������������������ 119
8.4.5Gregarious Instinct �������������������������������������������������������������� 120
8.4.6Fear, Food, and Energy �������������������������������������������������������� 121
8.4.7Epidemics, Disaster�������������������������������������������������������������� 122
8.4.8Evolution������������������������������������������������������������������������������ 124
8.4.9Variance Analysis������������������������������������������������������������������ 125
8.5Competition�������������������������������������������������������������������������������������� 127
8.6Conclusion���������������������������������������������������������������������������������������� 131
References�������������������������������������������������������������������������������������������������� 131
9Discrete Event Simulation vs Continuous System Dynamics���������������� 133
9.1Introduction�������������������������������������������������������������������������������������� 133
9.2The DESD Tool�������������������������������������������������������������������������������� 135
9.3Examples������������������������������������������������������������������������������������������ 136
9.3.1A Simple Birth-Death Process���������������������������������������������� 136
9.3.2Prey-Predator Model������������������������������������������������������������ 138
9.4Conclusion���������������������������������������������������������������������������������������� 141
References�������������������������������������������������������������������������������������������������� 141
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
������������������������������������������������������������������������������������������������������������������ 149
Chapter 1
Agent-Based Models: Tools
1.1 General Remarks
The methodological focus of this book is the object- and agent-based simulation.
No state equations or system dynamics schemes are used. Recall that in the discrete
object-based modeling, we create objects that behave according to the user-defined
rules and execute their events in discrete moments of the model time. The agent-
based models manage objects called agents, which are equipped with certain “intelligence.” They can take decisions, optimize their actions, and interact with each
other and with the environment. Agent-based models (ABMs) are a type of
microscale models that simulate the simultaneous operations and interactions of
multiple agents in an attempt to recreate and predict the appearance of global complex phenomena.
The individuals in ABM models may be of different types. Although the rules of
behavior are the same for individuals of the same type, the behavior is not identical
for all of them. This modeling method has many applications, mainly in ecology,
biology, and social sciences. A key notion is that simple behavioral rules (micro
model) generate complex (macro) behavior. An important central tenet is that the
whole is greater than the sum of the parts. Individual agents are typically characterized as rational. They are presumed to be acting in what they perceive as their own
interests, such as reproduction, economic benefit, or social status, using heuristics
or simple decision-making rules (Railsback et al. 2006; Bandini et al. 2009). Note
the main difference between object-oriented and simulation package. The latter, in
addition to object creation, provides (or should provide) a “clock” mechanism that
automatically manages the model time and event execution. The ABM modeling is
supported by many programming and simulation tools. Let us list only some of
the most popular tools: SWARM developed in 1994 by the Santa Fe Institute
(Swarm Development Group, 2001), Ascape developed in 2001 (Parker 2001),
Breve-2.7.2 (Klein 2002), Recursive Porous Agent Simulation Toolkit released in
© Springer Nature Singapore Pte Ltd. 2020
S. Raczynski, Interacting Complexities of Herds and Social Organizations,
Evolutionary Economics and Social Complexity Science 19,
/>
1
2
1 Agent-Based Models: Tools
2003 (Michael et al. 2006), Cormas developed in 2004 by VisualWorks (Bommel
et al. 2015), MASON (Luke et al. 2005), MASS package (Tatai et al. 2005),
FLAME (Coakley et al. 2006; Holcombe et al. 2013), MATSim of EHT Zürich
(Bazzan and Klugl 2009), and SOARS developed in 2010 (Tanuma et al. 2005,
2006), among others.
ABMs are widely used in modeling of the organization dynamics. An example of
an agent-oriented model, called the BC model, can be found in the article by Krause
(2000). In that model, the agent’s attributes include “opinions,” and the interaction
between agents depends on the distance between their opinions in a nonlinear way.
These interactions can result in an action being taken by the agent. Other examples
of models of social structures based on the concept of opinion interactions can be
found in Latane and Nowak (1997) and Galam and Wonczak (2000). A similar
approach is presented by Chatterjee and Seneta (1977) and Cohen et al. (1986).
These works refer to the dynamics of forming of social groups in accordance with
the existing agents’ attributes (opinions). Some quite interesting results, more
closely related to the terrorism problem, are described by Deffuant et al. (2002).
Some more general concepts of “computational sociology” and agent-based
modeling (ABM) can be found in the article of Macy and Willer (2002). Other general recommended readings in the field are Bak (1997), Cioffi-Revilla (1998), Gotts
et al. (2003), Axelrod (1997), Epstein and Axtell (1996), and Holland (1998). An
interesting contribution to a model of the structure of the Osama bin Laden organization is included in a Vitech Corporation page (link: see Long 2002). Other (ABM)oriented approach can be found in Crowder et al. (2012) and Hughes et al. (2012).
In these publications we can find discussions about the potential advantages of the
ABM approach through a range of examples and through the identification of
opportunities in the field of organizational psychology.
Another approach is used by Lustick (2000), where the agents interact on a landscape. It is shown that macro-patterns emerge from micro-interactions between
agents. An important conclusion is that such effects are more likely when a small
number of exclusivist individuals are present in the population. The simulations of
other mechanisms of clustering in agent-oriented models are described by Younger
(2003), who deals with the creation of social structures in the process of food and
material storage.
1.2 Discrete Event Simulation
Recall that by the model time, we understand the time variable that is controlled by
the simulation program during the simulation run. The real time represents the time
of our (or computer) physical clock. For example, simulating the movement of a
galaxy, we can simulate several millions of model time years. On a fast computer,
his simulation may take several minutes in the real time.
3
1.2 Discrete Event Simulation
There are many real systems, where we can define the processes named events
that consist in changing the state of the system. For example, the events may describe
the start or the end of a service process and a birth or death of a model entity or
taking place in a waiting line. In many situations such events can be considered to
be executed in a very small interval of time, compared to the total length of model
simulation time. The discrete event simulation means that we suppose that the
model events are discrete, i.e., they are accomplished within model time interval of
length zero. This model simplification makes the simulations very fast.
The Discrete Event Specification (DEVS) formalism is used to describe models
in discrete event simulation. In the DEVS formalism, an “atomic” model M is
defined as follows:
M = X ,S ,Y ,s int ,s ext ,l ,t
s int : S ® S,s ext : Q ´ S ® S , l : Q ® Y ,
(1.1)
where X is the input space, S is the system state space, Y is the output space, σint is
the internal state transition function, σext is the external transition function, and Q is
the “total state.”
Atomic models can be coupled to form a coupled model. The coupled models
can also be coupled in hierarchical way to form more complex models. The coupled
DEVS model is as follows:
coupled DEVS º X self ,Yself ,D,{Mi } ,{I i } ,{Z i ,j} ,select
The subindex self-denotes the coupled model itself. D is a set of unique component references. The set of components is:
{M
i
i Î D}
The select component defines the order of execution for simultaneous events that
may occur in the coupled model. This component must be added to the model to
avoid ambiguities in the simulation algorithm and to make the model implementation-
independent. There is a huge research done on the select algorithms because the
treating of the simultaneous events is rather difficult task.
To treat complex models with variable structure, the Dynamic Structure Discrete
Event System Specification (DSDEVS) is used. We will not discuss the DSDEVS
formalism here. The use of the DEVS formalism is relevant in big models, where
the time of execution, hierarchical model building, and portability are important
factors.
By time and event management (TEM), we understand the time clock and event
queue management (inside the “simulation engine”), including the basic queuing
model operations provided by the simulation package. The object behavior modeling (OBM) is a set of additional items like user-defined distributions and logical
functions, nontypical operations, object attributes, and the general object behavior.
4
1 Agent-Based Models: Tools
Let us start with GPSS (General Purpose Simulation System), omitting earlier
tools like the forgotten but very nice language of the 1950s CLS (control and simulation language).
1.2.1 GPSS
This language, developed primarily by Geoffrey Gordon at IBM around 1960
(Gordon 1975), has contributed important concepts to every discrete event simulation language developed ever since. This is an old tool, but it is still used and works
perfectly. In fact, GPSS is an object-oriented tool, although it does not fit into the
modern object-oriented paradigms. The objects in GPSS are called transactions.
These are moving items that appear, go through the fixed model facilities, and disappear. GPSS World has been extended by PLUS, the Programming Language
Under Simulation. The TEM level instruction set of GPSS is simple and easy to use.
It can be dominated by anyone in few hours of learning and running example queuing models. The OBM level mechanisms are not so easy. Recall that the new versions of GPSS have an embedded language PLUS. If the user wants to equip objects
(transactions) with any additional properties and individual, nonstandard behavior,
he must learn PLUS and dominate the information about the SNAs (standard
numeric attributes). The PLUS manual is a whole chapter of the GPSS manual or a
separate document of about 60 pages. The SNA documentation occupies also several dozen pages, including great number of attributes and additional items. Using
all this stuff, the user can simulate more advanced models, but the created objects
can hardly be considered as “intelligent.”
1.2.2 Arena
Arena modeling system from Systems Modeling Corporation is a nice and widely
used simulation tool. It is equipped with a graphical user interface (GUI) and animation mechanisms (see Kelton et al., 2004). The TEM level of Arena permits to
quickly create a queuing or manufacturing discrete event models, needs no coding,
and results in clear flowcharts of the model. The OBM level is somewhat more
complicated. Arena is built on the SIMAN (Pedgen et al. 1995) simulation language. So, first of all, the user must learn SIMAN to be able to manage user-defined
logics, statistics, and/or a nonstandard object behavior. The Arena entities (moving
objects) can be equipped with time attributes, cost attributes, entity-type variable,
group member variables, and other. The specification of the attributes and other
Arena pre-defined variables takes about 30 pages in the Arena documentation.
Again, if the user wants to create and manage a little bit more complicated object
behavior, he/she must learn SIMAN and dominate dozens of pages of the Arena
manual.
1.2 Discrete Event Simulation
5
1.2.3 SIMIO
This is a multi-paradigm software delivered by SIMIO LLC. SIMIO® is created by
a team of simulation software developers led by Dennis Pedgen and Sturrok (2010).
Compared to Arena, SIMIO is a step forward in creating models with intelligent
objects. The object definition in SIMIO is more general. Objects may be fixed facilities or moving dynamic objects named entities. The user can define his/her own
objects, store and reuse them, or use the objects from the standard library. These
may be fixed (server, machine), link (a pathway for entities), node (link intersections), entity (dynamic object, like client in a shop), or transporter (it can pick up
and drop entities at nodes).
The user defines the object properties. They may be of different types such as
strings, numbers, selections from a list, and expressions. The properties are edited
in multiple edition windows. There are many ways to define a SIMIO model. A
programmer familiar with an object-oriented language like C++ or Delphi can
understand and dominate the SIMIO modeling in reasonable time and effort. SIMIO
creators claim that the process-based objects in SIMIO are both simpler and more
powerful than the code-based objects in other modeling tools. SIMIO offers both
TEM and OBM facilities, although they are not clearly separated from each other.
1.2.4 Simula
We must mention here Simula, its mostly known version 67 (Dahl and Nygaard
1967). Although it is a tool developed more than 50 years ago, it is still perhaps one
of the most advanced and elegant object-oriented languages. In fact, Simula itself is
just object-oriented and not a simulation language. The modeling facilities have
been added to the language as a part of its standard class library and are encapsulated in the Process class. Any object that inherits the Process class properties can
use the clock mechanism and event scheduling. The object behavior management is
coded directly in the language. As for an old software, it originally had no GUI and
other graphical facilities. The language is rather difficult to learn and needs previous
training in Algol.
If we define the “intelligence” as the ability to make decisions due to a more
sophisticated algorithms or equip the objects with some kind of artificial intelligence, only an advanced object-oriented algorithmic languages provide such features. Simula has this capacity. Perhaps this is the reason why Simula is still quite
popular among the computer science researchers.
Anyway, if someone wants to create an object-oriented simulation package with
intelligent objects, he/she finally must create a new high-level object-oriented algorithmic language. The question is: Isn’t it better to take a known, complete, widely
known, used, and advanced language and add to it the time and queuing management layer (TEM)?
6
1 Agent-Based Models: Tools
1.2.5 PASION, PSM++, and BLUESSS
BLUESSS (Blues Simulation System) is the tool used in the simulations discussed
in this book. The package evolved from the Delphi-based languages PASION and
PSM++. The use of this particular package is not necessary. The models described
in the following chapters may be simulated using other agent-based tools. This
package was used because of its relation to the C++ language.
Important questions both in teaching and implementing computer simulation are:
• Must a simulationist be a programmer?
• Must he/she be a mathematician?
Depending on what is the role of the simulationist in the whole process of creating and using a simulation program, the response can be yes or not. It seems that the
commercial simulation tools are being developed in order to prevent the user from
any coding and to make all the mathematics (statistical considerations) as transparent and simple as possible. To say that this is a correct tendency, first of all we must
know who the simulationist is. If he/she is a plant engineer, a sociologist, a warehouse manager, or just an amateur, the tool should be “fast and easy” (user of kind
1). However, if he/she is a professional simulationist and develops simulations in
serious and professionally advanced way, he/she should be able to create and to
code necessary algorithms and be aware of the model mathematics (user of kind 2).
While teaching computer simulation, it is not always clear to which kind of users we
should address. This is an important question, because the contents of the simulation course and the tools we use strongly depend on the student/user kind.
It seems that the new discrete event and general-purpose packages are being
designed mostly for the users of kind 1. The new software has always a well-
designed graphical user interface (GUI) and offers a ready-to-use, encapsulated
probability distributions and statistics. However, despite of good manuals and additional materials, the users of kind 1 frequently commit fundamental errors, like
using the Poisson inter-arrival time distribution for the Poisson arrival process. One
could say that users of kind 2 can do their simulations in any algorithmic language
and need no simulation packages. Obviously, this is not true. A simulation tool
should provide ready-to-use mechanisms to avoid unnecessary work (but nothing
more). In general, the question is if, in our simulations, we need intelligent objects
(agents) at all. The answer is yes. Such objects are not needed in academic examples
and simple simulations (users of kind 1). However, if we face the reality, for example, a real manufacturing system, it is quite sure that there will be objects that do not
fit in standard blocks or facilities offered by most of the simulation packages. In
such case the use of intelligent objects will be inevitable.
BLUESSS evolved from the PASION and PSM++ packages, related to Delphi.
Some applications and remarks on discrete event simulation in these packages can
be found in Raczynski (2000, 2004, 2006a, b).
The package runs over the Embarcadero™ C++Builder. The user can be of kind
1 or of kind 2 (programmer skills). Taking about a professional simulationist, we
1.2 Discrete Event Simulation
7
should rather think about users of kind 2. My point is that few really professional
simulationists do not dominate C++. BLUESSS is a simple simulation language and
has the BLUESSS-to-C++ translator. So, the user can code model events in C++, if
necessary, or use one of the BLUESSS code generators to create models without
coding.
The following modules (source code generators) are included in the BLUESSS
package:
•
•
•
•
Queuing Model Generator
Flow diagrams. Continuous simulation using signal flow diagrams
Continuous simulation using bond graphs
Continuous simulation, ordinary differential equations
After defining the model, the BLUESSS system generates the source BLUESSS
code, translates into C++, and invokes the C++Builder which produces the executable program. The event queue in BLUESSS works due to the three-phase discrete
simulation strategy (see O’Keefe (1986)).
Using the QMG module, the user defines the model in the Arena-like style, with
no coding at all. As the process of creating exe file (stand-alone, independent executable) passes through the C++ compilation, BLUESSS QMG module can use all
the features of C++ (see Fig. 1.1).
In other words, the comparison of QMG with, for example, Arena can be summarized in the following table (Table 1.1).
Note that the QMG graphical model editor is very simple and can be dominated
in 15 min of “training,” even without consulting any documentation. The objects
Fig. 1.1 BLUESSS
features
Table 1.1 Creating intelligent objects (Arena vs. BLUESSS)
Use Arena
Create model flowchart with Arena
Learn SIMAN, learn Arena manual including 30 pages of entity
attribute and expression specifications, code the necessary expressions
Why not replace it with
Use QMG graphical
model editor
Use C++
8
1 Agent-Based Models: Tools
created in QMG can be equipped with simple abilities (logical expressions, additional attributes) or with any complicated decision-making algorithms, like fuzzy
logic, iterative optimization algorithms, neural nets, and database consulting. They
can execute external programs or use external files. The object can do everything
what can be coded in C++. There are no restrictions on the type and size of its attributes (those can be numbers, strings, arrays, pointers, and/or C++ structures of any
kind). If required, the object can communicate through the Internet, sing a song,
display an OpenGL image, execute an external program, etc. Obviously, objects
cannot intervene in the TEM (time and event management) of QMG. There are also
some restrictions on the use of pointers. When the object disappears, it must execute
a user-provided code to free the memory allocated to the pointed structures.
Otherwise memory leaks can occur.
To create a QMG flowchart, the user picks up blocks (like GPSS facilities or
Arena modules) and defines the basic block parameters like inter-arrival times, service times, etc. Then the simulation can be invoked. The entities (dynamic objects)
appear, go through the blocks, and disappear. As stated before, the additional entity
attributes can be declared, being of any available C++ type.
The relation between the entities and the C++ entity-related code is very simple.
Any entity which enters to any of the model blocks simply calls a global C++ function named SVOP. Both calling entity and block identifiers, as well as all entity
attributes, are passed to SVOP as actual parameters. For the assembly operation,
SVOP is called by each entering entity and for the new (assembled) one. So, in the
SVOP body, the user can identify the block/entity pair and code any required action.
For example, entities can enable or disable model blocks (using the semaphore logic
variables) or execute more complicated actions (Fig. 1.2.).
Fig. 1.2 Fragment of a QMG model. Automatic calls to the SVOP function
1.2 Discrete Event Simulation
9
Suppose, for example, that we need the following actions to be taken:
• If an entity enters the queue number 59, its string attribute myname includes the
string dog, and the entity age is greater than 100 model time units (the time spent
in the system), and then it invokes external program other.exe.
• If any entity enters the assembly block 42 and the sum S of the length of queue
39 and queue 41 exceeds 24, then close (disable) generators 29 and 40. If S is less
or equal to 24, then enable these generators.
• If any entity waits in any queue for more than 20 time units, display a warning
message.
In the below code, n is the calling block number, SOURCE is the number of
block where the entity has been created, TIMIN is the model time instant when the
entity has been created, TIMQ is the time the entity has been waiting in a queue (if
it is actually waiting), and myname is an additional, user-defined entity attribute.
TIME is a global variable representing the model time. The function nr returns the
queue length. QUEx is the reference to the queue block number x, and SEMx is a
Boolean variable (a semaphore) that enables (if true) or disables (false) the block
number x. DisplayWorning is a user-define C++ function (may show something on
the screen, emit a sound, etc.).
The SVOP procedure in this case may be as follows:
void SVOP(int n, int SOURCE,
float TIMIN, float TIMQ, String∗ myname)
{
bool b;
if(n==59 && AnsiPos("dog",∗myname)>0
&& TIME-TIMIN>100)
WinExec("other.exe",1);
if(n==42){
b=nr(QUE39)+nr(QUE41)>24;
SEM29=b; SEM40=b;}
if(TIMQ>20)DisplayWarning();
}
This is a very simple example. Inside the SVOP function, the user can insert any
C++ code to define the entity behavior and/or block operations.
Queuing and manufacturing models of BLUESSS may use animation. See
Fig. 1.3 for an example of manufacturing animation.
As stated before, BLUESSS is a general-purpose package. It contains several
modules (source code generators) for queuing/manufacturing models, continuous
simulation using ordinary differential equations, signal flow graphs, bond graphs, or
combined models. The user can create the source code or use any of the BLUESSS
modules to avoid coding. The final product is an independent exe file, ready to run.
The package structure is shown on Fig. 1.4. In BLUESSS everything (except the
code taken from C++ libraries) passes through the BLUESSS source code and
10
1 Agent-Based Models: Tools
Fig. 1.3 BLUESSS animation example. Manufacturing
through the C++ code (generated automatically). The user can create his/her code or
use the code generators. The options are as follows (see Fig. 1.4):
Queuing models: The queuing module generates the source code which is translated to C++ and compiled.
ODE (ordinary differential equations) module receives the right-hand sides of the
equations. The rest is done automatically (source codes generation,
compilation).
Block diagrams and signal flow module: The user defines graphically the model
structure and the necessary parameters. The module generates the model equations; the rest is done as above.
Bond graphs: The user draws the bond graph model and gives its parameters. The
rest is done automatically.
Animator: 2D off-line animation of queuing models is available.
Variance analysis: Postmortem additional statistical analysis can be invoked. This
includes the max-min and confidence intervals for the model trajectories, shown
as functions of time. This feature, provided by few simulation packages, is very
useful while simulating queuing and stochastic models. In Fig. 1.5 an example of
such analysis is shown. This is the length of a simulated queue. The gray region
is where the length of the queue is supposed to belong with probability 0.92. The
curve inside the region is the average queue length in function of model time.
The average is taken over a series of repeated simulations. If the gray region is
big (big variance), then it can be seen how little informative the average value is.
1.2 Discrete Event Simulation
11
Fig. 1.4 BLUESSS package structure
Fig. 1.5 Variance analysis of BLUESSS package. Confidence intervals for the length of a waiting
line
12
1 Agent-Based Models: Tools
Fig. 1.6 BLUESSS
simulation of a multiple
pendulum
The user can see and modify both the BLUESSS and C++ codes. For queuing
models, he/she can also use the SVOP functions as described earlier. Although the
queuing models of BLUESSS are rather simple, the possibility of working on the
generated code makes it possible to simulate any required object behavior.
These are only some examples of BLUESSS features. BLUESSS can use any
tools available in C++. Interesting animations, both for continuous and discrete
event models, can be created using the OpenGL graphics.
Observe (Fig. 1.4) that both discrete event and continuous models result in the
BLUESSS source code. The only difference is that the continuous models are simulated as a sequence of events with a small time step, each event being a call to one
of the possible numerical methods for ODE. This means that at the source code
level, the user can mix discrete and continuous models in the same simulation program. In Fig. 1.6 you can see a screen of a continuous model simulation (multiple
pendulum), animated with OpenGL graphics.
1.3 Example
BLUESSS can be used not only to simulate queuing models, ODE models, or bond
graphs. Let us mention a somewhat nontypical application. The mode we recall here
was coded in PASION. As stated before, PASION was a precursor of PSM++ and
BLUESSS packages. The program structure and the concepts of processes and
events are identical in these packages. The only difference is that the event body in
BLUESSS is coded in C++ instead of Delphi Pascal. All other features are the same.
This example model belongs to biological and medical applications. It is a (simplified) model of our immune system. We do not discuss this model in a separate
chapter because it is an old research, published nearly 30 years ago Raczynski
1.3 Example
13
(1989), when our knowledge about the immune system was not so complete as in
recent time. This research will be continued in the near future.
Most of the published HIS models are based on ordinary differential equations
derived from balance equations for the number of macrophages, T-cells, antibodies,
etc. Using such continuous models, we should remember, however, that the expressions used to calculate the growth rates are valid only for systems that fulfill the
necessary assumptions needed for the birth-and-death equations (e.g., the ergodicity
assumption). Not all growing populations satisfy these assumptions. An important
consequence of the birth-and-death equation is that the process is memoryless. In
other words, all the future states are independent on the system history, previous to
the moment determined by the time delay. This property makes the confiability of
differential equation models rather doubtful. In fact, it is not certain that the HIS
obeys any differential equation at all.
Note that the birth-and-death equation describes the changes of the expected
value for the size of the population, while the result of discrete simulation is a realization of the modeled stochastic process, i.e., a system trajectory and not an
expected trajectory. Observe that the trajectories of the expected values of the modeled variables do not provide sufficient information. What it means, for example, to
get a satisfactory average response of the immune system, if the “modeled patient”
dies in 50% of the simulation runs? This information might be easily lost when
using continuous, birth-and-death models. The cost of the discrete simulation is, of
course, rather high compared to the continuous modeling and rises considerably
when more objects are generated. The model described here should be treated as an
“immunological game” rather than a valid model of the HIS (recall that it is just an
example of a 30-year-old research). The results are merely of qualitative type. The
model includes the following components:
• Macrophages. These are primary defenders. They consume wide amount of
debris from our bloodstream as well as invading bacteria and viruses. They also
activate other defense mechanisms by activating the helper T-cells.
• Helper T-cells. These cells are activated by macrophages and stimulate the reproduction of other cells of the HIS. Helper T-cells also produce interleukin-2 (IL-2)
and a lymphokine. BCGF make other HIS cells more active.
• Killer T-cells. The cells of this type kill the body cells which have been infected
by a virus, disrupting its replication cycle.
• B-cells. Activated by helper T-cells, these cells begin to replicate and to produce
antibodies which neutralize the viruses.
• Antibody. The elements produced by the B-cells in order to disable certain type
of viruses, recognized earlier by the macrophages.
• Suppressor T-cells. These cells slow the defensive activities of the HIS after the
infection has been conquered.
• The thymus. This organ generates the T-cells which enter into the bloodstream.
• Virus. This is a strange invader that enters the bloodstream. To multiply it must
slip into a body cell where it replicates quickly.
14
1 Agent-Based Models: Tools
The rules of interaction between the model components are as follows. The
infecting virus enters the bloodstream and looks for a body cell in order to infect it
and replicate. Some of the viruses are devoured by the macrophages and those
which have entered body cells replicate rapidly. The infected cells die releasing new
viruses ready to infect other healthy cells. A macrophage that has eaten a virus displays its “antigen” on its surface and couples with a helper T-cell. Some of the
T-cells are able to recognize the strange antigen and become active. The activation
of other killer and helper T-cells and the B-cells is done by changing the level of
some bodies named lymphokines in the bloodstream. Thus, while detecting a
strange invader, a macrophage produces a lymphokine IL-1 which activates the
helper T-cells. These cells begin to produce the lymphokine IL-2, which activates
other helper and killer T-cells. The helper T-cells also secrete a lymphokine BCGF
which activates the B-cells and produce the gamma interferon (IF) which increases
the activity of the B-cells and T-cells. Each active B-cell becomes a factory of protein molecules called antibodies which neutralize the viruses recognized earlier by
the helper T-cells. The joint effort of macrophages, killer T-cells and antibodies
permit to stop the replication of the viruses, deactivate, and wipe out them from the
infected organism (Perelson 1988).
The model for the infection with the AIDS virus is similar. The only difference
is that this virus attacks the helper T-cells, deactivating the main part of the immune
system. Other infecting viruses or bacteria cannot be detected and disabled effectively, and the consequences of any infection can be fatal. The above (simplified)
mechanism of the immunological response can be treated as a sequence of events
and can be coded and simulated directly using any object-oriented simulation language. PASION has been used because it offers all needed features (see the
BLUESSS features mentioned earlier). The objects can be generated according to
the process (object-type) declarations. Thus, the virus, the macrophage, and each of
the cells of the HIS are described as processes. A process declaration specifies the
object attributes, such as its lifetime and other parameters, and describes all possible
events in the “life” of the object. PASION has the necessary “clock mechanism”
which controls the execution of the events; it is equipped with such features as
inheritance, repetitive simulation, and history file and permits all Delphi structures.
The environment of the language supports interactive simulation, graphics, statistical analyses of the resulting trajectories, etc.
Consult Raczynski (1989) for more detailed description of the simulation program. Here, we only show some results provided by PASION simulation run.
Figure 1.7 shows the plot of the model variables in response to a viral infection. The
vertical axis is the relative cell number in logarithmic scale. The cell population
varied up to 200–500 cells each time interval equal to 10 days.
The figures shown here are of rather low quality; these are screenshots from
simulations carried out nearly 30 years ago. Figure 1.7 shows the average simulated
response to a viral infection. Vertical scale shows the number of simulated cells in
logarithmic scale, as functions of time. In Fig. 1.8 we can see the average trajectory