Sei sulla pagina 1di 9

i

A Course in Individual-based and Agent-based


Modeling

Steven F. Railsback

Volker Grimm

Preface
In 2005, we published Individual-based Modeling and Ecology, which laid out our ideas
on why and how individual-based models can be used in ecology and, by analogy, in
many other fields. As we wrote that book we realized that a separate introductory book
on how to build and use agent-based and individual-based models was still needed—
with all the general and conceptual material to cover, we could not provide the practical
detail and examples needed for people to teach themselves and others how to get started.

Our goal in writing this book is to eliminate a barrier that currently limits use of agent-
based and individual-based modeling: in most research fields, few professors and
professionals are trained in the essential skills of simulation modeling and software
development. This situation is in stark contrast to statistical modeling: almost every
university department in every science has faculty skilled in statistics and expects its
students to develop some facility in statistical modeling. As individual-based and agent-
based simulation becomes an ever-more-important tool, we expect more and more
departments will want to offer classes while lacking instructors with the necessary
experience. We designed this book to help “bootstrap” the adoption of this new

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
ii

technology by allowing researchers of all experience levels to get themselves and their
students started doing science with agent-based models.

We designed this book so it can be used by itself, but many of its users will benefit from
reading Individual-based Modeling and Ecology first or at the same time. Our first book
focused on conceptual aspects of how to design individual-based models and analyze
them to do science, and this book focuses on implementing and analyzing models on the
computer. Unlike Individual-based Modeling and Ecology, this book is not specific to
ecology: we intend it to be useful for the many fields in which a textbook on individual-
based or agent-based simulation is needed. Because the term “agent-based model”
(ABM) is widely used outside ecology, we chose to use the term “agent-based” in this
book. There have been historical differences between individual- and agent-based
models, but these differences are fading away and we consider the terms interchangeable.
Likewise, we also implicitly include and address “multi-agent systems”, a branch of
agent-based modeling that originated from computer science and research on artificial
intelligence and artificial life.

Course overview
This book and its supporting materials are designed both for people who want to learn
agent-based modeling by themselves and for introductory classes in agent-based
modeling for scientists. These classes could be offered in the many academic fields
(especially the biological and human sciences) in which ABMs are becoming an
important research tool, and could easily be interdisciplinary. The book is designed to
support instructors with little previous experience in simulation modeling or computer
programming, although such experience (perhaps in the form of a computer scientist co-
instructor) would be helpful.

The course is targeted to graduate students and advanced undergraduates who are starting
their research careers, but it is also appropriate for experienced scientists who want to
begin using agent-based modeling. No previous formal training in mathematical

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
iii

modeling or computer programming is presumed, and students are unlikely to require


mathematics beyond basic algebra.

The course combines conceptual material corresponding to lectures and extensive


exercises to provide hands-on experience. Students can expect to learn about the
conceptual and theoretical aspects of using ABMs in science along with the practical
skills of implementing models on the computer using NetLogo software. Among the
topics covered are:
• How to design an ABMs for a particular system and problem,
• A conceptual foundation for designing and describing ABMs,
• Programming models and conducting simulation experiments in NetLogo, and
• Analyzing ABMs to solve scientific problems including development of theory
for complex systems.

Major themes
This course is not primarily about programming with NetLogo. Instead, this is a course
on how to do science using ABMs as a tool. We want to remove barriers to using ABMs
for addressing appropriate questions and problems, and to improve how they are used in
science. Therefore, throughout the course we emphasize several themes about doing
science:

(1) Using models for solving research problems. The primary characteristic of scientific
models is that they are designed to solve a specific problem about a specific system or
class of systems. These problems might include predicting how the system responds to
novel conditions, or just understanding the mechanisms that drive the system.
(2) Basing models on theory, and using models to develop theory. We focus on theory for
the agent-level adaptive behaviors that produce complex system behaviors.
(3) Learning and following the conventions and theory of scientific modeling. Modeling
is often treated as a completely intuitive process that lacks the standard procedures and

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
iv

theory of (for example) statistical or chemical analysis. But there is, in fact, much that
modelers need to learn from our precedessors.
(4) Documenting models and testing software. These tasks are often treated by novices as
tedious distractions but they are in fact essential―and productive, and even sometimes
fun―parts of scientific modeling. And they are especially essential and productive for
agent-based models.
(5) Standardization. One of the biggest historic difficulties with ABMs is that the
standard “languages” we have for thinking about and describing other kinds of models
(especially, differential equations and statistics) are not sufficient for formulating ABMs.
Luckily, a great deal of recent work has gone into developing standards for ABMs, and
we emphasize their use. Throughout this book we will use a standard protocol (called
“ODD”) for describing models and a set of standard concepts for thinking about and
designing ABMs; and NetLogo itself is a standard language for programming ABMs.

Why NetLogo?
Choosing which software platform to use in this book was a critical decision for us. There
are now many platforms for agent-based modeling, and they vary in many ways. We
learned to use the most popular platforms and tried teaching several of them. This
experience led us to three clear conclusions. First, there is no one ideal platform:
platforms are inevitably compromises that cannot be best for all applications. Second, the
ABM platform situation is unstable; new platforms appear regularly while long-term
funding for maintenance and support of established platforms remains uncertain. But
third, we concluded that NetLogo stands clearly ahead of the others as a platform for
beginners and even for many advanced scientific models.

NetLogo provides a simplified programming language and graphical interface that lets us
build, observe, and use ABMs without needing to learn the complex details of a standard
programming language. NetLogo can be used for quite complex models, including many
used in real science published in real journals. Just as importantly, Uri Wilensky and the
NetLogo team at Northwestern University provide an extremely complete, helpful, and

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
v

professional set of documentation and tutorial materials. NetLogo was originally


designed as an educational tool, but its use in science has grown very rapidly and
NetLogo itself has changed to meet the needs of scientists.

Despite NetLogo’s capabilities, we expect that some students will eventually want more
programming flexibility and power, and faster execution speed. Therefore, we also try to
prepare interested students for additional training in programming and software
development. Upon finishing the material in this book, some students may wish to follow
with, for example, a class in Java programming and training in one of the IBM platforms
(e.g., Repast, MASON) that use Java.

What we expect of instructors


We wrote this book with the expectation that many instructors using it will have little or
no prior experience with ABMs. This approach is unusual for a text book, but we had
little choice, given how few faculty have such experience.

What do we expect of instructors? First, we expect it will be helpful to digest Individual-


based Modeling and Ecology fairly thoroughly, especially because it presents many of
the ideas behind this book in more detail and provides more explanation for why we do
things the way we do. Second, instructors will need to develop (or find someone with)
enough experience with NetLogo to stay ahead of their students. This platform can be
very easy to learn, but it has a very distinct style that takes getting used to. Prior
experience with programming may or may not be helpful: NetLogo uses some standard
programming techniques (e.g., declaring variables, writing subroutine-like procedures),
but if you try to write NetLogo code the way you write C or Java (e.g.), you will be
frustrated and miss most of its advantages.

Luckily, there are reasons not to fear NetLogo. First, NetLogo’s excellent documentation
and example models will be a great help to you and your students. And NetLogo is fun: if
you try to learn it completely by yourself, expect to have an initial hour or two of

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
vi

confusion and frustration―followed by great difficulty making yourself stop. Also,


NetLogo is becoming quite popular and it is likely that you can find experienced users on
campus, or perhaps even a computer science professor or student willing to learn and
help. Finally, there is an on-line NetLogo users community and even a special forum for
educators; you can find these from the NetLogo web site. If you you start working your
way through NetLogo’s tutorial materials with some focus a few weeks before starting to
teach, you should be fine.

The third thing we hope for from instructors is help keeping students from picking up bad
modeling habits that are unfortunately common in science. Our experience, after building
many ABMs, is that software that has not been tested seriously is very likely to contain
important mistakes, even with a platform as simple as NetLogo. And a written
description of the model is necessary for both scientific communication and software
testing. NetLogo encourages experimentation: it is very easy and fun to make little
changes and see their effect on the model. This experimentation is fine, but students need
to learn that they are not really modeling until they write down what they want their
model to do and why, and then provide solid evidence that their software is actually
doing what they wrote down. We hope instructors will do what computer programming
instructors do: treat assignments as incomplete unless software is accompanied with
documentation of (a) its purpose and design and (b) a serious attempt to find mistakes in
it. You will find your students making much more rapid progress with modeling after
these steps become habit.

Overview and suggested course structure


We organized this book in four parts. The first part provides the first tools that students
need to start doing agent-based modeling: a basic understanding of what agent-based
modeling is and the modeling cycle, and basic skills in implementing ABMs in NetLogo.
Part II introduces model design concepts and techniques while reinforcing and building
NetLogo skills. In Part III we focus on a strategy called pattern-oriented modeling that is
very helpful with tough modeling problems such as deciding what details are and aren’t

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
vii

needed in an ABM and how to represent agent behaviors. Then in Part III we move on to
analyzing models: the techniques we use to learn from and do science with ABMs.
Finally, in Part V we provide some direction to students that want to go further,
especially with alternatives to NetLogo.

A course using this book is expected to include both lecture and hands-on computer lab
time. We present many general modeling and software concepts that are best explained in
a lecture format. But most of the learning will take place in a computer laboratory as
students work on exercises, building, testing, and using their own programs and models.
For a college class, we envision each week to include one or two lecture hours plus at
least one computer lab of two to four hours. The course starts with an introductory
chapter intended for lecture. The next four chapters that introduce NetLogo and how to
implement and test models are intended entirely for the computer lab, but with the
instructor leading the class. Then, in parts II and III, each chapter includes concepts to be
introduced in lecture, followed by exercises that reinforce the concepts. In the computer
labs for these chapters, students should be able to work more independently, with the
instructor spending less time in front of the class and more time circulating to help
individual students. Exercises started in lab can be completed as homework.

Programming instructors often provide some kind of “consulting service” to students


needing help with their homework assignments outside of regular class hours. Anyone
who programs regularly knows that the best way to find your mistake is to explain it to
someone else. It is great when students can help each other, and it is good to encourage
them to do so, e.g., by providing a computer room where they can all work. However, it
may be necessary for course instructors or tutors to be available via office hours and
email as needed to get students un-stuck.

Many of our exercises are based on example models that we have developed. We provide
the example models to help new instructors, but they have the disadvantages of not being
specific to any one discipline or familiar to instructors. As instructors develop experience,

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
viii

we expect they will want to develop some of their own example models and exercises.
However, doing so takes a fair amount of time, so we would caution new instructors
against trying to rely on too many of their own models.

Because software platforms change rapidly, we have chosen to support this book by
maintaining a web site (www.railsback-grimm-abm-book.com) that provides complete
versions of the example models, example solutions to exercises, and other supporting
materials. New versions of NetLogo are released regulary and sometimes include changes
in concepts and syntax. Therefore, code examples in the book will no doubt become
obsolete and it would be impossible to keep the book entirely up to date. Hence,
instructors should check our web site as they plan a class and whenever they encounter a
problem with our example models and code. On this book’s web site we will also provide
additional material for instructors, e.g. detailed outlines of semester-long courses or
short-courses.

For the independent learner


If you are one of the people using this book to teach themselves, how should you
proceed? We recommend you read a chapter and then work through its exercises until
you are comfortable moving on. If you are nervous about learning NetLogo by yourself,
keep in mind that there are many learning materials and sources of support provided with
NetLogo and by its users. The on-line user community may be especially helpful for you,
and it is not at all unlikely for you to find other users nearby to consult with. And this
book’s web site provides solutions to most exercises, which you might look up if you are
stuck.

The independent learner may find it especially hard to stay focused on scientific
modeling instead of getting overly drawn into NetLogo programming. NetLogo is great
fun, but remember that writing and playing with a program is not your only goal. To
become a scientific modeler, you must learn to design, document, and analyze models to
solve particular problems. And we trust that, after you try it once or twice, you will find

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press
ix

that testing your NetLogo program is not only quite easy but also important for avoiding
embarassment and saving time. We encourage you to keep thinking about all five of the
major themes we list above.

Copyright 2009 Steven F. Railsback and Volker Grimm


Draft MS in preparation for publication by Princeton University Press

Potrebbero piacerti anche