2-Day Introduction to Agent-Based Modelling Day 2: Session 5 Variables and Debugging.

Slides:



Advertisements
Similar presentations
1 SESSION 5 Graphs for data analysis. 2 Objectives To be able to use STATA to produce exploratory and presentation graphs In particular Bar Charts Histograms.
Advertisements

2-Day Introduction to Agent-Based Modelling Day 1: Session 2 NetLogo Style, Documentation, kinds of agents, reacting to other agents.
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Agents and Pervasive Computing Group Università di Modena e Reggio Emilia System Requirements NetLogo is designed: to run almost any type of computer.
Bison Management Suppose you take over the management of a certain Bison population. The population dynamics are similar to those of the population we.
Running MSOPIT for Assignment #6 These Slides are Base on MS3D version 4.6 which was current in Sept. of 2009 Note – These slides contain concepts also.
Getting to know Greenfoot
Program: Little Crab Mr Gano.
Introduction to Excel 2007 Part 2: Bar Graphs and Histograms February 5, 2008.
Outline/Coverage Terms for reference Introduction
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Thank you for participating in our experiment. Through the decisions you make today, you will have the opportunity to earn monetary rewards. You will be.
Using Surfcam to Produce a Numeric Control (NC) Program An Introduction to the CAD/CAM Process Instructions for 3 Axis Programming Using the D&M CNC Milling.
EPIDEMIOLOGY: Introduction to the Agent-based epidemic modeling Dr. Qi Mi Department of Sports Medicine and Nutrition, SHRS, Univ. of Pitt.
Chapter 1 Supply, Demand and Equilibrium
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
1 Linear Programming Using the software that comes with the book.
Introduction to Excel 2007 Bar Graphs & Histograms Psych 209 February 1st, 2011.
Introduction to Excel 2007 Part 3: Bar Graphs and Histograms Psych 209.
What to do when you are done. PRINTING WITH PHOTOSHOP.
AP STATISTICS LESSON 3 – 1 EXAMINING RELATIONSHIPS SCATTER PLOTS.
Department of Computer Science What is NetLogo UH-DMML  Multi-agent programmable modeling environment  Well suited for modeling complex systems evolving.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Fell View Computer Club StarLogo TNG – Session Two.
Animated Charting Using the Alice Bar Chart Template World By Elizabeth Liang under the direction of Professor Susan Rodger Duke University December 2010.
2-Day Introduction to Agent-Based Modelling Day 1: Session 1 Introduction, commands, loops, conditionals.
JQuery Page Slider. Our goal is to get to the functionality of the Panic Coda web site.Panic Coda web site.
Windows Forms Programming in C# Windows Forms CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
Spreadsheets in Finance and Forecasting Presentation 8: Problem Solving.
2-Day Introduction to Agent-Based Modelling Day 1: Session 4 Networks.
Introduction to TouchDevelop
Spreadsheet-Based Decision Support Systems Chapter 22:
European Computer Driving Licence Syllabus version 5.0 Module 4 – Spreadsheets Chapter 22 – Functions Pass ECDL5 for Office 2007 Module 4 Spreadsheets.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
2-Day Introduction to Agent-Based Modelling Day 2: Session 8 Exploring Model Collections, NetLogo Lists, Further Resources.
Sample size vs. Error A tutorial By Bill Thomas, Colby-Sawyer College.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
An Introduction to Designing and Executing Workflows with Taverna Katy Wolstencroft University of Manchester.
GEM A Finance Survival Kit GEM2508 Frederick H. Willeboordse
A Look Inside Some NetLogo Simulations Bruce Edmonds Centre for Policy Modelling Manchester Metropolitan University.
Using the Experimental Method to Produce Reliable Self-Organised Systems, B. Edmonds, ESOA 2004, New York, July 2004, slide-1 Using.
Sampling Distributions. What is a sampling distribution? Grab a sample of size N Compute a statistic (mean, variance, etc.) Record it Do it again (until.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Models in NetLogo Day 3 COLQ 201 Multiagent modeling Harry Howard Tulane University.
1 The Price is Right - Or is it? How can we find the right sale price to actually increase profits? You see them on TV, you hear them on the radio, and.
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.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
C++ Programming Lecture 10 Functions – Part II
1 Setting Up for RePast, and Running a Repast Stand Alone Example 06/21/2004 by Deddy Koesrindartoto Department of Economics Iowa State University.
Advanced Graphing Using Excel V.1 Part II: Giving your graph style Written and Created by: James Golen University of Michigan – Dearborn Science Learning.
Structured Programming I – Relational & Logical Operators Objectives: By the end of this class you should be able to: Change graph interactively in EXCEL.
B UY / SELL A BOX OF CHOCOLATES SES 2015 Term 1. Who are we?  Your class represents the market of buyers and sellers for chocolates.
Introduction to Graphics in R 3/12/2014. First, let’s get some data Load the Duncan dataset It’s in the car package. Remember how to get it? – library(car)
 Columns  Rows  Cells  Ranges  Cell addresses  Column headers  Row headers  Formulas  Spreadsheet.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose.
2-Day Introduction to Agent-Based Modelling Day 2: Session 7 Social Science, Different Purposes and Changing Networks.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
ACCESS PROJECT TWO. PROJECT ONE In project one you: -Created Tables -Created Forms -Created Reports In this project you will learn about queries. Databases.
Pivot Table Working with Excel (2010). What can we do with a pivot table ?  Creating a pivot table  Connection between variables  Calculate data (sum,
1 Agent-Based Tools: focus on NetLogo Ing. Cristina Ponsiglione University of Naples Federico II Laboratorio di Simulazione ad Agenti.
M10 WS11:Krankenhausbedarfsplanung More, More and Even-More More given by Gabriel Wurzer and Wolfgang E. Lorenz
An introduction to Netlogo agent-based software
Variables & getting info from the user
creating a ecosystems model in net logo
An Introduction to Designing and Executing Workflows with Taverna
Presentation transcript:

2-Day Introduction to Agent-Based Modelling Day 2: Session 5 Variables and Debugging

2 dimensions of code context Being aware of what the context of any command is important to understanding it. Which agent is doing the instruction: the observer, a kind of agent, a patch? In which procedure/ask is it? Example: –ask sellers [set size 50] 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 2 This bit might be in the “setup” procedure in the observer context. This bit is is in the seller context within the ask within the “setup” procedure.

Variables with different scopes Variables are simply named “slots” that remember the values you set them to. You then use them by their name but they act like the value they are currently set to. E.g. –set price 4.30 –set money money + 1 –show [price] of sellers Different kinds of variable have different scopes – that is kinds of code context where they can be used by that name Variables listed in “global” or set in the interface (using a slider etc.) are global, and can be set or used anywhere Other variables are “local” to an agent such as color, xcor ycor, size and those listed in “…-own” in the code Another kind are local to a procedure, defined by “let” statements within the procedure When you use a variable that is local, which value you get is determined by the context of the statement 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 3

The “Market Simulation” Load the example simulation called “5-market-begin.nlogo” Look at the top of the code 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 4 This is a global variable, look for how it is used in the code to sum up all the sales of each seller. It is what is displayed by the “Tot.Sales” monitor in the Interface. Here the extra variables local to each seller and buyer is listed.

Within a procedure 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 5 Here variables that are local to the “go” procedure are defined. They only have meaning within “go” or any procedure or agent called from “go”. Variables local to each seller are being set and used here. Note “production- rate” can be used here because it is a global variable. Here the global variable is being set to zero at the start of a simulation time tick.

About the Market Simulation There are buyers and sellers Buyers eat a certain amount of food each time tick, and have a given income Sellers have regular costs and production of food each time tick Buyers see if there are any sellers with a unit of food to sell, and if so look for the cheapest seller and buys what it can afford from this seller Sellers adjust their price depending on the level of their sales (dropping them if sales 6) 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 6

Play with the simulation Try different values for the global parameters set by the sliders Then step through the simulation Inspect different agents at different stages and see what state they are in (right-click on them select seller or buyer name and then inspect) Type in commands to query the state of the simulation, e.g.: –show [price] of sellers –show [food] of buyers –show mean [price] of sellers –show max [price] of sellers –Etc. Try playing with the simulation again looking at the values as they change in the simulation 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 7

Adding Monitors Right-click on some space and choose “Monitor” Fill in dialogue As shown here Then “OK” Maybe right-click on the Monitor that has now appeared and choose “select” then adjust its size and position Make other helpful monitors for money etc. 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 8

Adding graphs and histograms 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 9 Expand the whole Interface window. Then right-click on some empty space and chose “plot”. Then click on the small pencil icon in the plot dialogue and fill it in like this. Then “OK” Then in the plot dialogue change the Name and the min and max values for the X axis. Then “OK” Go back to the simulation and play with it again, noticing the histogram of buyer food levels. Add some more histograms for: seller prices etc. you may have to go back and adjust ranges of X/Y axes.

Some things to aim for… What additional aspects could you add to the simulation to make it more realistic? Can you change the simulation so that buyers/sellers act more rationally? What happens if you “kill off” buyers with food < 0? (ask buyers with [food < 0] [die]) What happens if you “kill off” sellers that go bankrupt (money < 0)? What behaviours lead to better/more stable market outcomes (i.e. without huge stocks of food, money, negative food etc.)? 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 10

Discussion – what were the main difficulties? 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 11

Stage of Debugging Most coding time is not spent making the original simulation but in “fixing” it or adding more code in (e.g. plots, new aspects) More careful design can help reduce time spent debugging but it still dominates There are different stages of debugging (in order of both occurrence and difficulty): 1.Fixing syntax errors so the code runs 2.Making the micro-level behaviours work as you intended them to (verification) 3.Making the resultant outcomes be as you want them to be (tuning and validation) 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 12

Strategies for debugging Keep adding more graphs, monitors, visualisations etc. so you better understand what is happening Turn parts of the behaviours “off” by temporarily changing the code (e.g. make all prices fixed) to see what happens Temporarily adding “show” statements into the code to show what is happening, e.g. –show (word "Food of " self " is " food) 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 13

Agent Case Studies Global outputs such as graphs, monitors, visualisations can only go so far… There is often nothing else for it but to follow a particular agent step by step checking what it does and its state each time compared to the code This is time-consuming and everybody tries to avoid doing it… …you often will simply not really understand your simulation unless you do! 2-Day Introduction to Agent-Based Modelling, Manchester, Feb/Mar 2013, slide 14

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