Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Simulations: Real or Fantasy Worlds Represented with Objects and UML - Prof., Exams of Computer Science

An introduction to simulations, their purpose, and the role of object-oriented programming in creating them. It covers the differences between continuous and discrete simulations, the concept of resources, and the importance of aggregation, generalization, and specialization in modeling. The document also includes an example of a wolfdeersimulation using uml class diagrams.

Typology: Exams

Pre 2010

Uploaded on 08/04/2009

koofers-user-j04-1
koofers-user-j04-1 🇺🇸

10 documents

1 / 6

Toggle sidebar

Related documents


Partial preview of the text

Download Understanding Simulations: Real or Fantasy Worlds Represented with Objects and UML - Prof. and more Exams Computer Science in PDF only on Docsity! 1 Introduction to Simulations CS1316: Representing Structure and Behavior Story  What’s a simulation? Why do we simulate? • Discrete vs. Continuous • Resources  Building software to be modifiable: Software Engineering • Building models out of objects: aggregation, generalizing and specializing  Continuous Simulations • Predatory-prey: Wolves and Deer • Changing our simulation • Creating hungry wolves • Other options: Hungry deer? Deer sex? Wolf sex?  How do we compare simulations? • Creating text files Wildebeests as Simulations Simulations  “A simulation is a representation of a system of objects in a real or fantasy world. The purpose of creating a computer simulation is to provide a framework in which to understand the simulated situation, for example, to understand the behavior of a waiting line, the workload of clerks, or the timeliness of service to customers. A computer simulation makes it possible to collect statistics about these situations, and to test out new ideas about their organization.” • Adele Goldberg & David Robson, Smalltalk-80: The Language and Its Implementation (Addison-Wesley, 1989) 2 Simulations and Objects  Object-oriented programming was invented, in part, to make simulations easier to build!  The characteristics of objects make them more like real world objects, e.g., • Each thing knows some stuff and knows how to do some stuff. • Objects get things done by asking each other to do things. • Your internals are private, unless you want to make them otherwise. Continuous vs. Discrete Simulations  Two main kinds of simulations in the world.  Continuous: Each moment of time is simulated. • When every moment counts.  Discrete: Skip to the important moments. • Want to simulate 100 years? Resources  Resources are points of coordination in a simulation. • Examples: A cashier, a library book, a parking space on a ferry, a jelly bean.  Some resources are fixed and others are produced and consumed.  Some resources are renewable and shared.  Others are coordinated. • Example: For a surgeon to do a surgery, the patient must meet the surgeon at the operating table (the resource) When an object has to wait…  What happens if you (or your proxy object) need a resource and it’s not available? • You wait in a queue • A list that is first-in-first-out (FIFO) 5 A UML Class Diagram +run() -wolves -deer WolfDeerSimulation +setAgent() +getAgent() -myTurtle AgentNode +getNext() +remove() +count() +add() -next LLNode +act() +getClosest() Wolf Turtle +act() +die() Deer * -myTurtle1 * -wolves1 * -deer 1 -mySim 1 * -mySim1 * Unified Modeling Language (UML)  This is a UML class diagram. • A graphical notation for describing the relationships between classes in a model.  UML is a standard that describes several different kinds of diagrams. • Collaboration diagrams: How objects work together and how they call on one another. • Sequence diagrams: What the order of events are in an object system. A class in a UML class diagram Name of the class Instance variables or fields: What the class instances know Operations or methods: What the instances know how +run() -wolves -deer WolfDeerSimulation Generalization-specialization relationships Turtle +act() +die() Deer A Deer is a subclass of Turtle: It’s a specialization of Turtle 6 Associations WolfDeerSimulation has two AgentNodes in it: One to represent wolves and one to represent deer. AgentNodes don’t know their simulation +run() -wolves -deer WolfDeerSimulation +setAgent() +getAgent() -myTurtle AgentNode * -wolves1 * -deer 1 A Class Diagram describes the Model, without the Code +run() -wolves -deer WolfDeerSimulation +setAgent() +getAgent() -myTurtle AgentNode +getNext() +remove() +count() +add() -next LLNode +act() +getClosest() Wolf Turtle +act() +die() Deer * -myTurtle1 * -wolves1 * -deer 1 -mySim 1 * -mySim1 *
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved