M10 WS11:Krankenhausbedarfsplanung More, More and Even-More More given by Gabriel Wurzer and Wolfgang E. Lorenz www.iemar.tuwien.ac.at.

Slides:



Advertisements
Similar presentations
NETLOGO LISTS Or… James says, fput THIS!. What are LISTS? Shopping list Address list DNA sequences Any collection of similar or dissimilar things Often.
Advertisements

Netlogo! NetLogo is a programmable modeling environment for simulating complex systems. Modelers can give instructions to hundreds or thousands of independent.
Wurzer, Lorenz, Popov: „NetLogo Workshop (Part 1)“, in eCAADe 2012 Prague, Slide 1 „Netlogo First Steps (Artif. Societies) “, in Social Simulation Conference.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
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.
An Introduction to NetLogo given by Gabriel Wurzer. ,
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Database Applications – Microsoft Access Lesson 9 Designing Special Queries Updated 4/11.
Database Applications – Microsoft Access Lesson 9 Designing Special Queries.
2-Day Introduction to Agent-Based Modelling Day 1: Session 4 Networks.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
CISC 1600 – Lecture 3.2 Simulations Complex Input & Output NetLogo.
2-Day Introduction to Agent-Based Modelling Day 2: Session 8 Exploring Model Collections, NetLogo Lists, Further Resources.
Week 11 DO NOW QUESTIONS. An ask turtles block is a set of instructions that is issued to every turtle. Even though computers can do things very quickly,
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
A Look Inside Some NetLogo Simulations Bruce Edmonds Centre for Policy Modelling Manchester Metropolitan University.
Martin Dodge Practical 2, 24th March 2004, pm Social Science Research Methodologies.
An Introduction to NetLogo Gabriel Wurzer, Vienna University of Technology AnthropologischeGesellschaftWien.
Microsoft ® Access ® 2010 Training Create Queries for a New Database If a yellow security bar appears at the top of the screen in PowerPoint, click Enable.
Agent-Based Modeling and Simulation (ABMS) Bertan Badur Department of Management Information Systems Boğaziçi University.
Step 2: Inviting to Challenge Group. DON’T! Before getting into the training, it’s important that you DON’T just randomly send someone a message asking.
New Mexico Computer Science For All Command Procedures in NetLogo Maureen Psaila-Dombrowski.
New Mexico Computer Science For All Variables and Scope Maureen Psaila-Dombrowski.
New Mexico Computer Science For All Creating Turtles Maureen Psaila-Dombrowski.
Creating a Historical Tour in Alice By Jenna Hayes May 2010.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
MIS 585 Special Topics in MIS: Agent-Based Modeling 2015/2016 Fall.
MIS 585 Special Topics in MIS Agent-Based Modeling NetLogo: Summary of Manual and Dictionary.
Introduction to Arrays. Learning Objectives By the end of this lecture, you should be able to: – Understand what an array is – Know how to create an array.
21/03/ Working with Controls Text and List Boxes.
M10 WS11:Krankenhausbedarfsplanung The World as We See It given by Gabriel Wurzer and Wolfgang E. Lorenz
MOODLE TRAINING — ADVANCED TOPICS — Fall 2016 Convocation week Michael Scanlan Office of Information Technology.
Memory Management.
An Introduction to NetLogo given by Gabriel Wurzer and Wolfgang E
AnthropologischeGesellschaftWien
User-Written Functions
Gadgets and Dashboards
Debugging Intermittent Issues
MIS 643 Agent-Based Modeling NetLogo: Summary of Manual and Dictionary.
FOP: JavaScript Arrays(Lists)
Practical Office 2007 Chapter 10
Loops BIS1523 – Lecture 10.
ECS10 10/10
Debugging Intermittent Issues
UNIT 3 – LESSON 5 Creating Functions.
Lecture 25 More Synchronized Data and Producer/Consumer Relationship
Worked Examples - Incremental Software Development Worked Example
Hands-On given by Gabriel Wurzer and Wolfgang E. Lorenz
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Database Applications – Microsoft Access
Number and String Operations
AN INTRODUCTION TO: POWERPOINT.
Lesson 16: Functions with Return Values
Creating Functions with Parameters
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Introduction to TouchDevelop
Arrays
Remembering lists of values lists
Moodle Training — Advanced Topics —
Data Structures & Algorithms
Motivational Behavior with Canines
creating a ecosystems model in net logo
CISC101 Reminders Assignment 3 due today.
Week 7 - Monday CS 121.
Complete exercise 8-11 in the workbook.
Presentation transcript:

M10 WS11:Krankenhausbedarfsplanung More, More and Even-More More given by Gabriel Wurzer and Wolfgang E. Lorenz

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 2, © 2011, Technical University Vienna.Today Filling the academical quarter: What to do if things go wrong (debugging) Followed by: You might get more than one value More neighbors and interactions Making code more readable and re-usable

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 3, © 2011, Technical University Vienna.Debugging Today meaning „to fix software errors“ Previous meaning: Grace Hopper, 1947, Logbook Mark II: „Relay #70, Panel F (moth) in relay.“, National Museum of American History, Washington Rear Admiral Grace Hopper, US Navy

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 4, © 2011, Technical University Vienna. NetLogo debugging capabilities...are astonishingly limited: print value… prints a value to the command center area, e.g. Concatenation may happen for adding a pre- or suffix to the printed value, using the (word … ) command: ask turtle 0 [print shape] print (word „The shape is “ shape)

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 5, © 2011, Technical University Vienna. Further debugging… ask turtles with […] [ print ] watch turtle 0 watch one-of turtles self reports the breed followed by the who number of the turtle, (e.g. „turtle 0“) watch puts a shiny spot around a turtle if you want to watch one randomly chosen agent out of a population, you can use the reporter one-of in fact, one-of is a general command for choosing one member of a population self one-of watch

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 6, © 2011, Technical University Vienna. Querying somebody else‘s properties Often, you „are“ observer or a specific turtle or patch. Querying somebody else‘s values can be done using of: of is used to access a property of an entity given by you. Examples: print [shape] of turtle 0 print [pcolor] of patch 0 0 ask patch 0 0 [ set pcolor [pcolor] of patch 1 1 ]

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 7, © 2011, Technical University Vienna. Comparing ask and of ask patch 0 0 [ print pcolor ;you are patch 0 0 ] ; you are observer print [pcolor] of patch 0 0 ask enters an entity. Therefore, can access a property by giving its name (e.g. print pcolor) of accesses a property of an entity you give – you need not be „inside“ the entity Hint: yes, of is a reporter, you might have guessed it!

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 8, © 2011, Technical University Vienna. Using of for debugging Add a monitor to the Interface In the appearing dialog, you can type any query. Type the following query and hit OK: The result of this query will be shown in the textfield of the monitor.

TOWARDS DEMOGRAPHIC DATA

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 10, © 2011, Technical University Vienna. You might get more (than one value) In a new newtlogo model, create five turtles Then, monitor the following: What you got is a list, used by netlogo to give you „more than one value“ Hint: The funky animation happens because the monitor runs over and over again, and [color] of turtles gives you the colors in randomized order. [color] of turtles

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 11, © 2011, Technical University Vienna. List are for… e.g. storing change of mortality as time-series or, as netlogo code: item 0item 6 … let mortality (list ) print mortality (list )

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 12, © 2011, Technical University Vienna. How to add a value a list … by the way, there is also that adds a value to the start of a list let mortality (list ) set mortality lput 13 mortality print mortality lput item fput

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 13, © 2011, Technical University Vienna. Further list commands (see Netlogo Dictionary) get the first item: get the last item: omit the first item: omit the last item: is the list empty? get item 3 of the list: get number of items: set mortality but-first mortality but-first set mortality but-first mortality but-last print first mortality first print first mortality last print empty? mortality empty? print 3 mortality item print mortality length

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 14, © 2011, Technical University Vienna. remove item 3: remove item with value 15: remove duplicates: replace item 3 by value 15 sort the list (ascending): set mortality remove 15 mortality remove Even further… set mortality but-first mortality remove-duplicates set mortality remove-item 3 mortality remove-item set mortality replace-item 3 mortality 15 replace-item set mortality mortality sort

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 15, © 2011, Technical University Vienna. And further… Add a plot to your model…

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 16, © 2011, Technical University Vienna. Histograms act on lists In hospital-1.nlogo, type the following into observer>: …to get the list of population sizes per patch. then type the following: print [popul] of patches set-histogram-num-bars 3 histogram [popul] of patches set-histogram-num-bars histogram

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 17, © 2011, Technical University Vienna. Calculations on lists remember from last lecture: to total-population let total 0 ask patches [ set total (total + popul) ] ; total now contains the ; sum of all popul end let mylist [popul] of patches let total mylist see how easy the same is done using lists sum maxminmedian variance…

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 18, © 2011, Technical University Vienna. Storing lists globally, step 1 …so they are available everywhere in a program („global variables“ or simply globals) Look at the newly introduced global with: globals [ mortality ] (standard value for globals)

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 19, © 2011, Technical University Vienna. Storing lists globally, step 2 in setup, fill the global in go, use it globals [ mortality ] to setup set mortality (list 15, 11, …) end to go ; get mortality at time ; = how many % of turtles die end ticks tick

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 20, © 2011, Technical University Vienna. From where do I get list values e.g. data.wien.gv.at (list 15.5 …) © data.wien.gv.at

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 21, © 2011, Technical University Vienna. Big Picture  Lists Patches holding population The World consisting of initial population Turtle of breed hospital hosting other Turtles of breed hospital demographic development Lists Color Maps

MORE NEIGHBORS

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 23, © 2011, Technical University Vienna. Neighbors on the same patch ask turtle or patch [ get all other turtles at this spot … ] A turtle or patch wants to know which turtles stand here Should also be able to select other breeds than turtles Reported entities should be „all on this spot, excluding caller“

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 24, © 2011, Technical University Vienna. How it is done… … ask turtle 0 [ ask [ print self ] ask patch 0 0 [ ask [ print self ] turtles-here is a reporter giving all agents on the current spot as agentset if the caller is an agent, he can exclude himself by using „other“ may specifically target other breeds than turtles using breed-name-here (e.g. other persons-here) otherturtles-here

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 25, © 2011, Technical University Vienna. What about social neighbors? Concept: Link two turtles together to signify a relationship between them Should be able to query for „the turtle at the other side of the link“

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 26, © 2011, Technical University Vienna. Introducing links Links are an own breed, which is created by a turtle: Any breed can be linked. Links can be both directed and undirected, although we will only cover the latter ones in this tutorial (refer to NetLogo Dictionary for directed ones). Furthermore, you can create breeds of links, which is also not covered in this course. ask person 0 [ create-link-with turtle 1 ] create-link-with

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 27, © 2011, Technical University Vienna. Get social neighbors… ask person 0 [ create-link-with turtle 1 create-link-with turtle 2 ] ask person 0 [ ask link-neighbors with […] [ print self ] link-neighbors reports all turtles connected to the current turtle by a link as always, this agentset can be further narrowed down using with[…] link-neighbors

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 28, © 2011, Technical University Vienna. Co-create social neighbors breed [persons person] … create-persons 1 [ let holder self create-turtles 1 [ create-link-with holder set xcor random-xcor set ycor random-ycor ] Wish to create persons and turtles at the same time, tied together (Note: it is a house- trained turtle we create). turtle is created by the person using hatch-breed, which is just like create- turtles (but can be used by turtles) laying the turtle on the person‘s lash is done by creating a link to the holder hatch-turtles

MORE INTERACTIONS

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 30, © 2011, Technical University Vienna.Usage ask turtle 0 [ ask patch 0 0 [ … ] An agent wants to interact with other agents or patches, probably exchanging some values In the course of the interactions, multiple nested asks are used, i.e. the first entity is asked, to… ask a second entity, to… do something

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 31, © 2011, Technical University Vienna. How it is done… ask turtle 0 [ let the-turtle self ask patch 0 0 [ set pcolor [color] of the-turtle ] 1.The caller temporarilly stores himself in a local variable 2.Then, the patch is asked 3.Inside the ask, a property of the caller is retrieved using of 4.This value is then assigned to a property of the patch ask color pcolor is set to

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 32, © 2011, Technical University Vienna. Hands on: Dropping a value turtles-own [ carries ] patches-own [ stores ] to setup ask patches [ set stores 0 ] create-turtles 1 [ set carries 10 ] end stores = 0 carries = 10

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 33, © 2011, Technical University Vienna. Hands on: Dropping a value to go ask turtles [ forward 1 if carries > 0 [ set carries (carries - 1) let the-turtle self ask patch-here [ set stores (stores + 1) set pcolor [color] of the-turtle ] end patch-here reports the patch under the turtle

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 34, © 2011, Technical University Vienna. Hands on: Retrieving a value turtles-own [ carries ] patches-own [ stores ] to setup ask patches [ set stores 10 ] create-turtles 1 [ set carries 0 ] end stores = 10 carries = 0

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 35, © 2011, Technical University Vienna. Hands on: Retrieving a value to go ask turtles [ forward 1 if [stores] of patch-here > 0 [ set carries (carries + 1) ask patch-here [ set stores (stores - 1) ] end

MAKING CODE MORE {RE}- USEFUL

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 37, © 2011, Technical University Vienna. A tale of users and programmers User of sin to setup print sin 30 end Programmer of sin to sinus (x) give back result to user end We have seen how to use reporters As mentioned, „something is being done behind the scenes“, i.e.  the parameter or parameters are passed into a reporter  this is used like a variable  the result is given back to the user

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 38, © 2011, Technical University Vienna. Don‘t be a user – write reporters yourself you can write reporters yourself: beneficial for „hiding the details“ of your model: to-report add [x y] let result (x + y) report result end Usage: to-report name [ parameters ] ; calculate something here ; using the parameters report result end to-report water-patches report patches with [pcolor = SKY] end optional to setup print water-patches end no parameters specified

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 39, © 2011, Technical University Vienna.Parameters …can also be used in procedures, by the way: to move-turtles [ in-direction how-far ] ask turtles [ set heading in-direction forward how-far ] end

Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 40, © 2011, Technical University Vienna. Recap – When to use what Write a procedure to group code lines together under a sounding name (e.g. move-turtles) Write a reporter to perform a calculation and return the result to the user (e.g. add) Use parameters whenever your code depends on values that need to be supplied by the user. Hint: Think of parameters as local variables, which are not defined using „let“ but given at the start of your procedure or reporter.

THANK YOU !