Presentation is loading. Please wait.

Presentation is loading. Please wait.

M10 WS11:Krankenhausbedarfsplanung The World as We See It given by Gabriel Wurzer and Wolfgang E. Lorenz www.iemar.tuwien.ac.at.

Similar presentations


Presentation on theme: "M10 WS11:Krankenhausbedarfsplanung The World as We See It given by Gabriel Wurzer and Wolfgang E. Lorenz www.iemar.tuwien.ac.at."— Presentation transcript:

1 M10 WS11:Krankenhausbedarfsplanung The World as We See It given by Gabriel Wurzer and Wolfgang E. Lorenz www.iemar.tuwien.ac.at

2 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 2, © 2011, Technical University Vienna.Today Patches, neighborships, turtle  world interaction Colors and custom shapes …and a giant leap towards simulation

3 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 3, © 2011, Technical University Vienna. A closer look at colors Colors in NetLogo are really numbers. Names like YELLOW are only shorthands.

4 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 4, © 2011, Technical University Vienna. See it yourself… 1.Change the pcolor of some patches by right-clicking and choosing „inspect“, then set pcolor e.g. to YELLOW 2.YELLOW is changed to 45 3.Also try it for WHITE and for BLACK

5 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 5, © 2011, Technical University Vienna. Greys are interesting… The color 0 stands for BLACK. This is the default color for patches. The color 9.9 stands for WHITE, and all other colors in between 0 and 9.9 are grays. Observation: Percentages go from 0-100, NetLogo colors from 0-9.9 Hmmmmm…..

6 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 6, © 2011, Technical University Vienna. Mapping grays to a patch property (absolute) patches-own [ popul ] … ask patches [ set popul pcolor ] Hint: could also use a scale factor, e.g. set popul color *

7 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 7, © 2011, Technical University Vienna. Mapping color to percentage patches-own [ popul ] … ask patches [ set popul (pcolor / 9.9) * 100 * ]

8 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 8, © 2011, Technical University Vienna. How to get the patch colors? a)Generate using code b)Import using one bitmap („map“) per property. c)Import from text file (not covered, see NetLogo Examples and NetLogo Dictionary) ask patches [ set pcolor ((pxcor 2) + (pycor 2)) ] mod ask patches [ set pcolor ((random 101) * 9.9) ; get a grey ] (nonsensical for generating patch properties)

9 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 9, © 2011, Technical University Vienna. Import from bitmap e.g. for supplying data generated by a GIS: 1.Export to bitmap - Right-click the view area and choose „Export View“ 2.Use graphics program to overlay GIS data 3.Re-import using Note: Bitmap file must be in same directory as netlogo model import-pcolors „name.png“ import-pcolors

10 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 10, © 2011, Technical University Vienna.Pitfalls Scaling will occur if image size is not same as view area size (there- fore use „Export View“) Fine details will be lost if colour changes „in the middle of a patch“ Colors will be mapped to the nearest NetLogo colour (use greys or known NetLogo colours*) * create some patches with the right colour before exporting the view

11 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 11, © 2011, Technical University Vienna. Pixel-exact mapping (not always possible - memory!) Can do pixel-exact import when clicking on Settings in Interface, then specifying: max-pxcor half image width max-pycor half image height Patch-size 1 pixels

12 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 12, © 2011, Technical University Vienna. Population Data Radial city available on www.iemar.tuwien.ac.at/assets/docs/population.png patches-own [ popul ] to setup import-pcolors „population.png“ ask patches [ set popul pcolor ] end

13 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 13, © 2011, Technical University Vienna. Towards a simulation… Patches holding population The World consisting of initial population Turtle of breed hospital hosting other Turtles of breed hospital with constant capacity (in units of population) with constant radius (in patches) with constant radius and capacity demographic development compute radius compute capacitycheck adequacy

14 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 14, © 2011, Technical University Vienna. Further plan… 1.Create turtle (hospital) with new shape „hospital“ 2.Move turtle with mouse 3.New concept: Intermediate Storage 4.Interaction world  turtle 5.Set hospital size according to population

15 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 15, © 2011, Technical University Vienna. Custom shapes for turtles From Tools, choose Turtle Shapes Editor Click on „New“ to add a shape

16 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 16, © 2011, Technical University Vienna. The shape editor in brief Draw your shape In the name field, assign a name Should the shape rotate with the heading of the turtle, click on Rotatable Under „Color that changes“, give the color that is set to the turtle‘s color hospital

17 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 17, © 2011, Technical University Vienna. Assigning your newly drawn shape Hint: if you do not want your shape to change color, set „Color that changes“ to some color that does not appear in the shape. breed [hospitals hospital] patches-own [popul] to setup clear-all import-pcolors "population.png" ask patches [ set popul pcolor ] create-hospitals 1 [ set shape "hospital" ] end

18 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 18, © 2011, Technical University Vienna. Move turtle with mouse to go if mouse-down? [ ask turtle 0 [ set xcor mouse-xcor set ycor mouse-ycor ] end mouse-down? mouse-xcor mouse-ycor

19 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 19, © 2011, Technical University Vienna. Storing values - recapitulation So far, two type of storages have been introduced: –properties of an entity –values entered via the user interface (called global variables) property

20 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 20, © 2011, Technical University Vienna. Intermediate storage (called local variables) makes code easier to read by letting the programmer refer to them under a new name needed for computing e.g. sums of population to example turtles with[…] ask [ … ] end candidates (create) (as)

21 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 21, © 2011, Technical University Vienna. Local variables are created using let let introduces the variable and assigns a value variables can subsequently be used by giving their name the value of an already existing local variable can be changed using the already known to example let turtles with[…] ask [ … ] end candidates let set

22 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 22, © 2011, Technical University Vienna. Simple examples Calculation using variables: let a 12 let b 20 let c (a + b) let d 0 set d (d + 1) Creating and using variables Using set to change values of variables:

23 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 23, © 2011, Technical University Vienna. to example let turtles with[…] ask [ … ] end candidates let Lifespan of local variables Local variables are temporary: they exist only in the code block that introduced them. Lifespan Lifespan to.. end or [... ]

24 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 24, © 2011, Technical University Vienna. Details on assignments Can assign… a number, boolean or string (e.g. 10, false, „person“) the special value NOBODY which stands for „no value set“ a result of a reporter or query (e.g. sin 30) agents (e.g. turtles with [color = RED]) …and: values contained in other variables let a 10 let b false let c „person“ let d NOBODY let e sin 30 let f turtles with[color=RED] let g f let h f with[xcor > 0] let i sin a

25 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 25, © 2011, Technical University Vienna. Assigning agentsets Hint: keywords turtles, patches, persons, etc. return agentsets, i.e. collections of netlogo entities you can use with […] acts as a filter test whether the set is empty by using the keyword any? let redones turtles with [color = RED] if any? redones [ ask redones […] ] any?

26 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 26, © 2011, Technical University Vienna. Local variables – who needs that? (revisited) e.g. when building sums to total-population let total 0 ask patches [ set total (total + popul) ] ; total now contains the ; sum of all popul end just an illustration, we will come back to this in a moment

27 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 27, © 2011, Technical University Vienna.Interactions ask patch 0 0 [ ask neighbors [ … ] always take the form of nested asks e.g. neighborship interaction: patch asks its neighbors neighbors

28 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 28, © 2011, Technical University Vienna. Details on neighborship interactions ask patch 0 0 [ ask neighbors with[…] [ ] ask neighbors4 with[…] [ ] ask patches in-radius 4 with[…][ ] neighbors: eight patches that surround the calling patch neighbors4: four patches (north, south, west and east) in-radius: entities being within the given radius of the caller neighbors neighbors4 in-radius Hint: in-radius can also be used for turtles, i.e. turtles in-radius 4

29 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 29, © 2011, Technical University Vienna. The same for turtles breed [hospitals hospital] patches-own [popul] to setup clear-all import-pcolors "population.png" ask patches [ set popul pcolor ] create-hospitals 1 [ set shape "hospital" ] end to go if mouse-down? [ ask turtle 0 [ set xcor mouse-xcor set ycor mouse-ycor let total 0 ask patches in-radius radius [ set total (total + popul) ] set size (total / somefactor ) ] end

30 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 30, © 2011, Technical University Vienna. Hospital capacity according to population

31 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 31, © 2011, Technical University Vienna. Import an overlying image Can import an image (just for eye candy, does influence NetLogo) using Can clear the imported image using import-drawing „name.png“ clear-drawing

32 Wurzer/Lorenz: „4D Simulation im Planungsprozess“, Lecture Notes, Slide 32, © 2011, Technical University Vienna. Eye candy and finish. Overlay from www.iemar.tuwien.ac.at/assets/ docs/overlay.png More elaborate shape for hospital (non-rotatable) All packed together  www.iemar.tuwien.ac.at/assets/ docs/ hospital_1.zip

33 THANK YOU !


Download ppt "M10 WS11:Krankenhausbedarfsplanung The World as We See It given by Gabriel Wurzer and Wolfgang E. Lorenz www.iemar.tuwien.ac.at."

Similar presentations


Ads by Google