E-217-PROG-2010-1: Simulation 2 Thorisson Lecture Notes

Thórisson Lecture 1




More Concepts

Modularity A modular system is one with well-defined interfaces between components. A house made of LEGO bricks is modular because the elements it is made of have a well defined studs-tubes that can be interfaced.
Input/Output A system that requires initialization or data to produce its effects requires Input.
A system's change of the input state or its production of new data is its Output.
Nonlinearity A nonlinear system is a system whose output is not proportional to its input.
Emergence A phenomenon is called emergent if the interaction of many components at one level of description gives rise to a new phenomenon at a higher level of description. Emergence cartoon
Second-order emergence When an emergent phenomenon, like a society, gives rise to other emergent phenomena within it, e.g. a police force and government.
Micro-level In psychology: the cognitive function. (In sociology: the individual.)
Macro-level In psychology: the individual. (In sociology: the society.)









Stages of Creating a Simulation

Creating a model The model is the “story” – equivalent to a scientific theory (from small to large).
Implementing the model Choosing platform, programming language, etc., and writing the program.
Debugging Getting rid of bugs.
Grounding Making sure the simulation relates to reality.









Creating a Model

Determine the scope What set of questions would we want to be able to answer with our simulation? What are the most extreme conditions that the system should be able to take? What is a typical set of questions we will study?
Simplification All simulations select certain parts to be included and some parts to be excluded (no complete simulation exists of any natural phenomenon – it couldn't, because everything in the world can (potentially) affect anything else).
“…simplifications, or abstractions, are a necessary part of the modeling of nature. Without them, the models would mimic reality instead of explaining it.”
— Przemyslaw Prusinkiewicz
Define parameters Decide which variables should be independent and dependent; deciding on how to represent these in variables in the selected programming language.
Define processes What are the operations we want to manipulate the parameters? What are their inputs and outputs?
Define interactions between processes How can the processes defined interact with each other?
Decide analysis methods How do we want to analyze the results? What are the main variables to watch?









Implementing the Model as a Simulation

Selecting a programming language Main choice is between a compiled language vs. interpreted.
Complied (ísl. þýdd) language A compiler is used to compile into machine code first, once. The machine code then runs on the CPU.
Pros: Runs fast. Cons: Less flexible than interpreted code, harder to develop incrementally.
Interpreted (ísl. túlkað) language An interpreter converts each program instruction as the program is being run.
Pros: More flexible runtime execution. Easier to develop incrementally. Cons: Runs 10x slower than compiled code.
Programming Now you know what this is!
Incremental development By incremental development a simulation is built piece by piece, module by module. There are many ways to do this – an interpreted programming language allows developers to do this flexibly; some systems exist to help with the process.










Simulation Creation Process

Simluation Process
(source: Nigel Gilbert (2005). Simluation for the Social Scientist, p. 13. New York: Open University Press.)









Types of Simulation

Types of Simluation
(source: Nigel Gilbert (2005). Simluation for the Social Scientist, p. 13. New York: Open University Press.)




Cellular Automata A.k.a. CA
Grid-based computing system where each cell can have two or more states and looks at its neighbors to determine its next state. CA
Agent-oriented A.k.a. Multi-agent simluations.
Use the concept of semi-autonomous programs that interact with each other. Compared to e.g. the cells in CAs each agent is typically very complex (think of it as a full computer program executable).










Features of Agent-Based Simulation

Main component The “agent” - a semi-autonomous piece of code.
Autonomy Agents are considered stand-alone entities.
Interaction A.k.a. “social ability” - agents can interact.
Reactivity Agents react to incoming data.
Proactivity Agents “plot” on their own.
Abstraction An agent in an agent-based simulation can stand for any acting entity - it is assumed to map to some real (or imagined) phenomenon with one or more of the above features.
Example: An agent can stand for a whole consumer market or it can stand for a single human consumer.









Examples of NetLogo Simulation Code

NetLogo-ToAct
(source: Nigel Gilbert (2005). Simluation for the Social Scientist, p. 189. New York: Open University Press.)





NetLogo-ToShop
(source: Nigel Gilbert (2005). Simluation for the Social Scientist, p. 186. New York: Open University Press.)








EOF