2-Day Introduction to Agent-Based Modelling Day 1: Session 1 Introduction, commands, loops, conditionals.

Slides:



Advertisements
Similar presentations
First of all – lets look at the windows you are going to use. At the top you have a toolbar, with all your various tools you can use when customising your.
Advertisements

2-Day Introduction to Agent-Based Modelling Day 1: Session 2 NetLogo Style, Documentation, kinds of agents, reacting to other agents.
The essentials managers need to know about Excel
Agents and Pervasive Computing Group Università di Modena e Reggio Emilia System Requirements NetLogo is designed: to run almost any type of computer.
PowerPoint Workshop Presented by Delores Woodhurst.
Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
Unit 3 Day 4 FOCS – Web Design. No Journal Entry.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Word Processing First Steps
Installing SAS 9.3 Raymond R. Balise Health Research and Policy.
Installing SAS 9.3 Raymond R. Balise Health Research and Policy.
Logo Lesson 4 TBE Fall 2004 Farah Fisher. Prerequisites Create basic and complex shapes using Logo procedures Create Logo procedures that use variables.
Introduction to a Programming Environment
Slide 1 FastFacts Feature Presentation December 4, 2014 To dial in, use this phone number and participant code… Phone number: Participant.
Slide 1 FastFacts Feature Presentation 12/16/2014 To dial in, use this phone number and participant code… Phone number: Participant code:
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their.
Postgraduate Essentials University of Edinburgh Postgraduate Essentials Online induction to the course.
2-Day Introduction to Agent-Based Modelling Day 2: Session 5 Variables and Debugging.
Department of Computer Science What is NetLogo UH-DMML  Multi-agent programmable modeling environment  Well suited for modeling complex systems evolving.
The Blue “W” is placed on your Desktop or in your system tray area.
05/09/ Introducing Visual Basic Sequence Programming.
ABM Frameworks Dr Andy Evans With additions from Dr Nick Malleson.
Information guide.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
2-Day Introduction to Agent-Based Modelling Day 1: Session 4 Networks.
Welcome message. The background image would be an image of Electronic Circuit And have a flash action script to animate 0 and 1. This site would be for.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
2-Day Introduction to Agent-Based Modelling Day 2: Session 8 Exploring Model Collections, NetLogo Lists, Further Resources.
Have you tried Track Changes? I think you are going to like it.
CIS—100 Chapter 15—Windows Vista 1. Parts of a Window 2.
How to use the internet The internet is a wide ranging network that thousands of people use everyday. It is a useful tool in modern society that once one.
An Introduction to Designing and Executing Workflows with Taverna Katy Wolstencroft University of Manchester.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
A Look Inside Some NetLogo Simulations Bruce Edmonds Centre for Policy Modelling Manchester Metropolitan University.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Chapter 1 - Getting to know Greenfoot
Introduction to Algorithms using Netlogo. What’s an Algorithm Definitions of Algorithm on the Web: –A procedure or formula for solving a problem.
Models in NetLogo Day 3 COLQ 201 Multiagent modeling Harry Howard Tulane University.
Downloading and Installing Autodesk Revit 2016
CPS120 Introduction to Computer Programming The Programming Process.
An Introduction to Designing and Executing Workflows with Taverna Aleksandra Pawlik materials by: Katy Wolstencroft University of Manchester.
2-Day Introduction to Agent-Based Modelling Day 2: Session 6 Mutual adaption.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Downloading and Installing Autodesk Inventor Professional 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the.
Go to your school’s web locker site Your user name is the first letter of your first name, the first four letters of.
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
Mapping local community assets online Read this if you want to learn how to: 1)Create online maps of local community assets using Google Maps 2)Allow other.
Testing External Survey Automatic Credit Granting Shepherd University Department of Psychology.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
2-Day Introduction to Agent-Based Modelling Day 2: Session 7 Social Science, Different Purposes and Changing Networks.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Introducing Scratch Learning resources for the implementation of the scenario
1 Agent-Based Tools: focus on NetLogo Ing. Cristina Ponsiglione University of Naples Federico II Laboratorio di Simulazione ad Agenti.
An introduction to Netlogo agent-based software
Bomgar Remote support software
Learning to program with Logo
Citation Map Visualizing citation data in the Web of Science
Go to =>
A few tricks to take you beyond the basics of Microsoft Office 2010
Go to =>
Go to =>
Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your.
creating a ecosystems model in net logo
Creating a Simple Game in Scratch
Digital Mapping Welcome to a short presentation on how to create a very basic event route using digital mapping. In this example, we will be using Quo.
Presentation transcript:

2-Day Introduction to Agent-Based Modelling Day 1: Session 1 Introduction, commands, loops, conditionals

Welcome This 2-day course is funded by a grant from the project at the Cathie Marsh Centre for Social Research It is organised and run by –Bruce Edmonds and Ruth Meyer from the Centre for Policy Modelling at the Manchester Metropolitan University –and Nick Shryane and Laurence Lessard- Phillips from the Institute for Social Change at the University of Manchester –With help from Emma Norling, Ali Abbas and Stefano Picascia from the CPM Critically assessing and analysing simulation results, Bruce Edmonds, ISS Course, 2011, slide 2

Course Aims To introduce you to programming and debugging agent-based modelling (ABM) through the NetLogo programming language To give you an idea of some of the things that ABM can represent and how this is done To give you an insight into the ABM way of thinking about social phenomena To help you understand the process of designing, programming and using an ABM To show you some examples of how ABM has been used in the social science literature and research Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 3

What it will not do… Is make you a full agent-based programmer An expert at NetLogo Able to rush off and immediately write a ‘blockbuster’ ABM paper Be able to immediately program what you have in mind to model Sorry! These take time and some patience to achieve, but we hope to have started you on the road in these directions. Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 4

Course Style is… Relaxed! Please feel free to experiment, deviate from the course material, ask questions from the helpers, generally making the course maximally useful for you We will have quite a range of previous computer programming experience among the participants so it is inevitable that some will find some of this a bit slow (if so experiment and extend your knowledge, making use of the helpers around and suggestions for extension), and some will find parts a bit fast (if so ask for lots of help from the helpers and simply don’t worry about it but go at your own pace) Each session will start with an example model, with some explanation/directions from the front, but with suggestions for additional things to do within each model, a model with the additions is also provided It is in the fundamental nature of programming that not everything is obvious – even when you have read the manual – so do ask a helper when you get stuck Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 5

Schedule, Course Material, etc…. Are ALL freely available at: (there will be a minimum of paper distributed) That site has pointers to: The schedule which has pointers to: –The example models –These slides –Further material on the web The Facebook group for the course, which you can join and post discussion points as you go along,: flattery, useful links, etc. (linked to from the course website, you have to go to the page and request an invite!) For those going, meet tonight at 18:00 to go to restaurant Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 6

A Classic Example of an Agent-Based Model: Schelling’s Segregation Model Schelling, Thomas C Dynamic Models of Segregation. Journal of Mathematical Sociology 1: Rule: each iteration, each dot looks at its 8 neighbours and if, say, less than 30% are the same colour as itself, it moves to a random empty square Segregation can result from wanting only a few neighbours of a like colour

Staring the first NetLogo Model If you have not installed NetLogo, please ask for help doing this now Download and run the “1-commands-begin.nlogo” model All example models are linked from the session page on the web, along with all other material for that session Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 8

NetLogo – Interface Panel Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 9 Command Buttons Parameter Slider Typed Direct Commands Speed Control Text Output Panel Selection (looks slightly different on Windows and Macs)

Typing in Commands Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 10 Press “setup” to initialise world World with different colour patches An agent!Type commands in here as follows…

The command centre… “show” means show the result in the command centre Try: show timer (and then try this again) show count agents show agents show sort agents show count patches show count patches with [pcolor = white] Anything typed into the command centre is from the “observer” point of view (yours!) Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 11

Inspecting Patches and Agents Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 12 Right-click (or ctrl click) on a patch, then “inspect” that patch Magnified View Properties of patchType commands to patch here, e.g. set pcolor redClick on little “x” in corner to get rid of inspector Right-click (or ctrl click) on a agent, then “inspect” that agent Try typing commands to agent, e.g.: show who fd 1 fd 2 rt 90 lt 90 fd 1 rt 90 fd 1 set color purple set size 4

Some important ideas The whole world, the turtles, the patches (and later the links) are “agents” That is, they: –have their own properties –can be given commands –can detect things about the world around them, other agents etc. But these are all ultimately controlled from the world (from the view of the observer) It is the world that is given the list of instructions as to the simulation, which then sends commands to patches, agents (and links) using the “ask” command Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 13

Using “ask” Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 14 Try typing commands to agents via the world, e.g.: ask agents [fd 1] ask agents [set color grey] ask agents [set shape “person”] ask agents [fd 1 rt 90 fd 1] ask agents [show patch-here] etc. Can also ask patches: ask patches [show self] ask patches [set pcolor black] ask patch 0 0 [show agents- here]

Running a simulation (the hard way!) Each time “step” is pressed the procedure called “go” is caused to run – this is a list of commands, a program. We will now look at this. Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide Press “setup” to initialise world 1. Move the slider to change parameter 3. Press “step” to make the program run one time step 4. Press “step” lots of times!!

The Program Code Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 16 This text is the programClick on the “Code” tab to see the program It has different parts This chunk of code (from “to” to “end”) is the “setup” procedure – what happens when you press the setup button Text that if after a semi-colon “;” are comments and have no effect Scroll down to look at the “go” procedure – this is what the “step” button does

Parts of the Code Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 17 Everything between “to” and “end” defines what “go” means “ask agents” means to ask (all) agents to do some code, one after the other What it is asking them all to do is between the square brackets “[ …. ]” “if” statements are conditionals they have a condition and an action All the square brackets inside each other can be confusing, if you double-click just outside a bracket, it shows what is in side between it and the matching bracket

To change the program… Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 18 type the following: ;; my bit! if random-float 1 < 0.05 [lt 90] Click within the text and type! You can press “Check” to see if you got the syntax of everything right! If all is well you can then click on “Interface” to go back and try the effect of your change when running the code (pressing the “step” button)

The Information Tab Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 19 Click on the “Info” tab to see a description of the model (or whatever the programmer has written, if anything!) Read it, scrolling down Here are some suggestions of bits of code to add and things to try (in a bit!)

Adding a button and running the code (the fast way!) Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 20 Click on the “Interface” tab to get back to the main view Right-Click some empty space and choose “button” Type the text “go” here and then check (to on) the “forever” switch then “OK” Now when you press the “go” button it will keep doing doing the “go” procedure forever (until you “unpress” it)

Adding a button and running the code for only 10 steps Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 21 Right-Click some different empty space and choose “button” Type the text “repeat 10 [go]” here Type the text “10 steps” here and then “OK” Now when you press the “10 steps” button it will do the “go” procedure only 10 times

The Experimentation Cycle Often programming, especially in the exploratory phase, involves a cycle of: Writing some code Trying it out (as part of a program or as a direct command) Finding errors Reading the NetLogo documentation (more on this next session) Correcting Errors Until it works as you want it to (if ever!) Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 22

Things to try… Try to do the following: add a button to manually turn the agent right (using “rt 90”) add a slider for number of targets and add code to make this number of patches red try to change the “if” commands within the “go” procedure and see what happens add new “if” rules, for example to with a certain probability to turn left (using “if random-float 1 < 0.05 […..]”) add a command within “setup” to place the agent at a random position at the start (using “setxy”, “random max-xcor” and random max-ycor") Some Future Directions in Social Simulation, Bruce Edmonds, ISS Course, 2011, slide 23

The End 2-Day Introduction to Agent-Based Modelling Centre for Policy Modelling Manchester Metropolitan University Business School Institute for Social Change Cathie Marsh Centre for Census and Survey Research University of Manchester