430 likes | 444 Views
CS 214 Modeling and Simulation. Modeling. TERMINOLOGY. System A group of objects that are joined together in some regular interaction or interdependence toward the accomplishment of some purpose. Entity An object of interest in the system. E.g., customers at a bank. TERMINOLOGY (continued).
E N D
CS 214Modeling and Simulation Modeling
TERMINOLOGY • System • A group of objects that are joined together in some regular interaction or interdependence toward the accomplishment of some purpose. • Entity • An object of interest in the system. • E.g., customers at a bank
TERMINOLOGY (continued) • Attribute • a property of an entity • E.g., checking account balance • Activity • Represents a time period of specified length. • Collection of operations that transform the state of an entity • E.g., making bank deposits
TERMINOLOGY (continued) • Event: • change in the system state. • E.g., arrival; beginning of a new execution; departure • State Variables • Define the state of the system • Can restart simulation from state variables • E.g., length of the job queue.
TERMINOLOGY (continued) • Process • Sequence of events ordered on time • Note: • the three concepts(event, process,and activity) give rise to three alternative ways of building discrete simulation models
What is modelling? • A Model is a simplification of a real system • Modelling is the process of representing a system with a specific tool to study its behaviour • A model can be • Analytic when a mathematical approach is feasible (e.g. Queuing Model) • A simulation model used for complex systems
Model • A Model is a pattern, plan, representation (especially in miniature), or description designed to show the main object or workings of an object, system, or concept. • Model may also refer to: • Abstractions, concepts, and theories • representations of objects • human and animal behavior • occupations • history and culture • lighting • In geography …
Examples • In general, modelling is used for systems with some sort of uncertainty • Waiting time in a restaurant/Aiport • Time to go from home to the University • Response time and Throughput of a web server • The productivity of manufacturing systems • Design of multi-processor machine
Examples: Movement • Consider a system when a given object move • This system can be modelled by the equation S= V * t Where S is the distance run through V is the speed of the object t is the time that has been observed. • This is simplification of the real world • Another model can take into account the direction of movement, or the three dimension coordinate … • It is therefore to study the behaviour of the system based on a specific model
Examples: Model of a particle in a potential-field (Physics) • In this model we consider a particle as being a point of mass m which describes a trajectory • The trajectory is modeled by a function x : R → R3 given its coordinates in space as a function of time. • The potential field is given by a function V:R3 → R and the trajectory is a solution of the differential equation • Note this model assumes the particle is a point mass, which is certainly known to be false in many cases we use this model, for example, as a model of planetary motion.
Examples: Radio Propagation Model Empirical Model of Radio Channel Source: Kannan Srinivasan and Philip Levis, RSSI is Under Appreciated, ACM Workshop on Embedded Networked Sensors (EmNets 2006), • A radio propagation model is an empirical mathematical formulation for the characterization of radio wave propagation as a function of frequency, distance and other conditions. • Different types of models • Models for outdoor environments: Ground wave, Sky wave, Environmental Attenuation, Point-to-Point propagation models, Terrain models, City Models • Models for indoor environments • Free Path Loss Model (Mathematical Model)
Performance Evaluation of a System A SYSTEM is a collection of entities (e.g., people or machines) that act and interact together toward the accomplishment of some logical end. SYSTEM Experiment with the Actual System Experiment with a Model of the System There is always the question of whether it actually reflects the system. Too costly or disruptive Not appropriate for the design Make assumptions that take the form of mathematical or logical relationships Mathematical Model Analytical Solution Simulation If the model is simple enough. E.g., calculus, algebra, probability theory Highly complex systems
Simulation versus Analytical Modeling • Simulation is not used when a suitable mathematical model exists • Simulations are often complex error-prone pieces of software • Simulation can take a LONG time to execute • Mathematical models are less flexible, but they are exact and efficient The problem is what model represents better the real world?
Classification of Models 1. Static vs. Dynamic Models: 2. Deterministic vs. Stochastic Models: Represents a system as it evolves over time (e.g., a conveyor system in a factory) Time plays no role; represents a system at a particular point in time (e.g., Monte-Carlo methods) Involves random variables, probabilities (e.g., most queueing and inventory systems) No probabilistic components (e.g., worst-case analysis of a system)
CLASSIFICATION OF SIMULATION MODELS Static (Monte Carlo) Dynamic Systems Represents the system behaviour over time Continuous Simulation: • (Stochastic) Differential Equations Discrete Event Simulation: • System quantities (state variables) change with events Represents the system at a particular point in time • Estimation of p • Risk Analysis in Business • Water Level in a Dam • Queueing Systems • Inventory Systems
Classification of Models 3. Continuous vs. Discrete Models: The state of the system changes only at discrete points in time. The state of the system changes continuously (e.g., chemical processes) Bit Arrival in a Queue # of cars in a parking lot bit bit time time Discrete Model Continuous Model
SIMULATION “WORLD-VIEWS” • Pure Continuous Simulation • CPU scheduling model • Pure Discrete Simulation • Event-oriented / Activity-oriented / Process-oriented • number of students attending the class • Combined Discrete / Continuous Simulation
Goals and Objectives • Building a model is an iterative (repetitive) process, • Some steps need to be repeated • First, define goals and objectives • What is the objective of building a model for the system? • What are the properties of the system that need to be considered to reach the goal? • Second, collect available information about the system • gather data by doing some measurement, or assuming empirical data
The Conceptual Model • After studying the available information and with the goals in mind, we start identifying our system in its three main dimensions: • Spatial, • Temporal and • Structural • By answering the basic questions about space, time and structures, we describe the conceptual model of the system.
Goals and Objectives The Space Dimension • What is the specific size of the object that we need to analyze? • How far spatially does that system extend (scalability)? • How does the system evolve in space? • Is it static, or dynamic?
Goals and Objectives The Structural Dimension • What are the elements and processes in our system? • How much detail about them we need and can afford? • Do we have enough information about all of them or some of them are entirely unknown? • Which are the limiting ones, where are the gaps in our knowledge? • What are the interactions between the elements?
Goals and Objectives The Time Dimension • What is the time duration we should observe the system? • Are we looking at it over years, days, hours, or seconds? • Which processes are so slow that they may be considered constant during the observed time? • Do we need to see how does the system evolve in time, like in a movie, or we just need a snapshot of the reality, like on a photo? • Static or Dynamic ? • If the system is evolving, how does it change from one state to another? • Is it a continuous process or a discrete process? • Is the transition from one state of the system to another stochastic or deterministic?
The Conceptual Model • A conceptual model may be a mental model, a flow diagram. • Building the right conceptual model is half the way to success. • In the conceptual model, you should clearly identify the following components of the system: • Boundaries • Variables • Parameters • Forcing functions • Control functions
The Conceptual Model • Boundaries: specify what elements are included in the system and those not. • They distinguish the system from the outside world. • What material and information flows into and out of the system? • What processes are internal and which ones are external. • State Variables: They characterize the elements in the system. These quantities represent the evolution of the system, that you analyze and report as a result of the modeling exercise. • Parameters: They also characterize the elements of the system, but they are constant throughout the modeling process. Parameters can either be measured by direct experiments or may be borrowed from analyses of similar systems performed previously.
The Conceptual Model • Forcing functions: They describe the effect of the outside world upon system. • The forcing functions may change in time, but they do not respond to changes within the system. • Control functions: They are actually parameters, except that you allow them to change to see how their change affects your system dynamics. • It is like the tuning button on your radio set. At every time it is dialed to a certain position, but you know that it may vary and result in different performance of the system.
Mathematical Model • The conceptual model can be analyzed using some mathematical tools (Probability, Algebra, Differential equations, Queuing theory, etc …) • The model must be formalized (the formalization step). • Formalization is finding the adequate mathematical equations/formulation to represent the real system. • Instead of concepts, words, images, you need to come up with equations and formulas. • Formalization is not always possible and there is no one-to-one correspondence between a conceptual model and its mathematical formalization. There are only certain rules and recommendations, but no ultimate procedure known.
Sensitive Analysis • Sensitivity Analysis: the study of how the variation in the output of a model can be distributed (qualitatively or quantitatively) to different sources of input variation. • Sensitivity Analysis offer valid tools for characterizing the uncertainty associated with a model. • Methodology: there are several technique, but the most common is sampling-based sensitivity analysis. • With sampling-based sensitivity analysis, the model is executed repeatedly for combinations of values sampled from the distribution (assumed known) of the input factors.
Calibration • Calibration is often regarded as including the process of adjusting the output or indication on a measurement instrument to agree with value of the applied standard, within a specified accuracy. • After formulization of the model, adjust the behavior of mathematical model to fit the behavior of the real system by tuning some parameters of the model. • Solving the equations and generate trajectories for the variables. • The Calibration process consists in adjusting the results of the analysis of the mathematical model with the data available.
Verification and Validation • Verification is a quality process used to evaluate whether or not a model complies with the specification of the real system. • Validation is the process of establishing documented evidence that provides a high degree of assurance that a model complies with the real system. • It is sometimes said that validation ensures that ‘you built the right model’ and verification ensures that ‘you built it right’.
Case StudyProblem Description • A certain airport contains a single runway on which arriving aircraft must land. • Once an aircraft is cleared to land, it will use the runway, during which time no other aircraft can be cleared to land. • Once the aircraft has landed, the runway is available for use by other aircraft. The landed aircraft remains on the ground for a certain period of time before departing. The objective is to determine: • The average time an aircraft must wait when arriving at an airport before they are cleared to land • The maximum number of aircraft that will be on the ground at one time
Observations • The output metrics suggest focusing on • Waiting process • Number of aircraft on the ground • We could develop a detailed model keeping track of the position of each aircraft every second, but this is not necessary to derive the desired output metrics • Queueing models are a natural abstraction for modeling systems like these that include • Customers competing to use limited resources • Waiting (queueing) to use the resource • Primary metrics of interest have to do with resource utilization, time customer is being served or waiting • Details of what customer is doing while waiting are not important
Conceptual Model: Single Server Queue queue customer server • Customer (aircraft) • Entities utilizing the system/resources • Server (runway) • Resource that is serially reused; serves one customer at a time • Queue • Buffer holding aircraft waiting to land
Queueing Network Applications Queueing networks useful for many applications • Customers utilizing business services (e.g., bank, hospital, restaurant …) • Manufacturing: assembly lines • Supply chains • Transportation (aircraft, vehicles) • Computer communication networks • Computer systems (jobs being processes by a set of compute servers; I/O systems)
Specification Model (Queueing Networks) • Customers • What is the arrival process? • Schedule of aircraft arrivals, e.g., log from specific dates (trace driven) • Often, probability distribution defines time between successive customer arrivals (interarrival time) • Assumes interarrival times independent, and identically distributed (iid) • Not always true (e.g., customers may leave if lines are too long!) • Customer attributes? • Sometime different flavors, e.g., priorities or other properties • Servers • How much service time is needed for each customer? • May use probability distribution to specify customer service time (iid) • How many servers? • Queue • Service discipline - who gets service next? • First-in-first-out (FIFO), Last-in-first-out (LIFO), random … • May depend on a property of the customer (e.g., priority, “smallest” first) • Preemption? • Queue capacity? What if the queue overflows?
Specification Model (cont.) Our assumptions: • Customers • Assume arrivals are iid, following an exponential distribution for interarrival times with mean A • Assume all customers are identical (no specific attributes) • Servers • Assume customer service time is iid, exponentially distributed, mean L • Assume one server (one runway) • Queue • Assume first-in-first-out queue (first-come-first-serve) discipline • Assume queue has unlimited capacity • How do we model aircraft after they have landed? • Could use a second (trivial) server, with service time indicating time one ground, and an unlimited number of servers • Implicitly assume “conservative” server; server never idle if there is a customer waiting in queue
Computational Model A computer simulation is a computer program that models the behavior of a physical system over time. To do this, we must • Define a computer representation of the state of the system, i.e., define state variables that encode the current state of the physical system • Determine the state of the system over all points in time in which we are interested (compute a sample path) • Define a simulation program that modifies state variables to model the evolution of the physical system over time. Key questions • What are the state variables? • How does the state change (what rules are used)?
State Variables queue customer server State: • InTheAir: number of aircraft either landing or waiting to land • OnTheGround: number of landed aircraft • RunwayFree: Boolean, true if runway available
Evolving System State • Given the current state of the system, how do we determine the new system state? • At which points in time (in the simulated system) do we need to compute the system state? • Fixed time increments (time stepped simulation) • Irregular time increments (typically, when the state changes)
Time Step Implementation /* ignore aircraft departures */ Float InTheAir: # aircraft landing or waiting to land Float OnTheGround: # landed aircraft Boolean RunwayFree: True if runway available Float NextArrivalTime: Time the next aircraft arrives Float NextLanding: Time next aircraft lands (if one is landing) For (Now = 1 to EndTime) { /* time step size is 1.0 */ if (Now >= NextArrivalTime) { /* if aircraft just arrived */ InTheAir := InTheAir + 1; NextArrivalTime := NextArrivalTime + RandExp(A); if (RunwayFree) { RunwayFree := False; NextLanding := Now + RandExp(L); } } if (Now >= NextLanding) { /* if aircraft just landed */ InTheAir := InTheAir - 1; OnTheGround := OnTheGround + 1; if (InTheAir > 0) NextLanding := Now + RandExp(L) else {RunWayFree := True; NextLanding := EndTime+1;} } }