IE 101 Introduction to Industrial and Systems Engineering Lecture Notes by F. Yıldırım PROBABILISTIC MODELS AND SIMULATION 1. PROBABILISTIC MODELS 1.1. Introduction 1.2. What is Probability and Probabilistic Model? 1.3. Some examples 1.4. Markov Models 1.5. Queueing Models 1.6. Inventory Models 2. SIMULATION 2.1. The needs for the imitation of the real world systems 2.2. Sample and Sampling Distributions 2.3. Simulation and the Relevant Basic Concepts 2.4. Statistical Issues in Simulation 2.5. Random Numbers 1 2.6. Random Number Generation 2.7. Simulation with Process Models 2.8. Time- flow Mechanism 2.9. Simulation Languages 3. Discussion 1. In this lecture we will concentrate ourselves on the meaning of probability and the probabilistic models then after introducing the concept of simulation, some applications of simulation techniques will be given. 1.2. There are several interpretations or definitions of probability. The classical- or equally likely- Interpretation of probability: If an event can occur N equally likely and different ways, and if n of these ways have an attribute A, then the probability of the occurrence of A, denoted by P(A), is defined as n/N. Thus the probability of rolling a two with a perfect die is equal to 1/6, for there are 6 equally likely outcomes, the numbers 1 to 6, of which only one has the value 2. This definition is frequently inadequate for representing engineering situations. For example, it is not clear how it may be used to determine the probability of picking a defective unit from a process that in the past has given 73 defective out of 10000 units. In this case, making a defective unit and a good one are not equally likely. The frequency- or empirical interpretation of probability: If an experiment conducted N times, and a particular attribute A occurs n times, then the limit of n/N as N becomes large is defined as the probability of the event A, denoted by P(A). Thus in the preceding example the probability of a defective is 73/10000 or 0.0073 if we consider 10000 to be a large number. 2 The subjective- or man-in-the street interpretation of probability: The probability P(A) is a measure of the degree of belief one holds in a specified proposition A. Under this interpretation, probability may be directly related to the betting odds one would wager (bahse tutuşma) on the stated proposition which represents our degree of belief concerning the effect of design change, based on engineering judgment or experience. 1.3 Probabilities and Probabilistic Model Analysis A model means a system that simulates an object under consideration. A probabilistic model is a model that produces different outcomes with different probabilities. Hence, a probabilistic model can simulate a whole class of objects, assigning each an associated probability. Example 1 The roll of a six-sided die has six parameters p1; p2; : : : ; p6. In particular, pi is the probability of rolling the number i. To be probabilities, the six parameters need to satisfy pi ≥ 0 6 and p =1 i i 1 Example 2 A model of a sequence of three rolls of a die might be that they are all independent, so that the probability of the sequence [2; 4; 6] would be p2*p4*p6. Example 3 An extremely simple model of any DNA or protein sequence is a string over a finite alphabet. Assume that letter a occurs at random with probability qa, independent of all other residues. Then, for a given length n, the probability of the sequence x[1 : : : n] is: n q(x ) i 1 i Probabilistic models have parameters, which are usually estimated from large sets of trusted 3 examples, called a training set-random sample. For example, the probability qa for seeing amino acid a in a protein sequence can be estimated as the observed frequency fa of a in a database of known protein sequences. This way of estimating models is called Maximum likelihood estimation, because it can be shown that using the observed frequencies, one maximizes the total probability of the training set, given the model. In general, given a model with parameter θ and a set of data D, the maximum likelihood estimate (MLE) for θ is the value which maximizes P(D j | θ). When estimating parameters from a small training set, there is a danger of overfitting: the model fits the training set very well, but does not generalize to new data. Conditional, joint, and marginal probabilities Suppose we have two dice D1 and D2. The probability of rolling an i with die D1 is called the conditional probability P(i | D1). If we pick a die at random, with probability P(Dj), j = 1; 2, then the probability for picking Dj and rolling an i is the product P(i;Dj) = P(i | Dj)P(Dj), called the joint probability. In general, P(X; Y ) = P(X | Y )P(Y ) for events X and Y . Given conditional or joint probabilities, a marginal probability is calculated by removing one of the variables, which is accomplished by summing over all possible events. Prior and posterior probabilities An occasionally dishonest casino uses two kinds of dice, of which 99% are fair, but 1% are loaded, so that a 6 appears 50% of the time. We pick up a die and roll [6; 6; 6]. This looks like a loaded die, is it? This is an example of a model comparison problem. That is, our hypothesis Dloaded is that the die is loaded. The alternative is Dfair . Which model fits the observed data better? We want to calculate P(Dloaded j [6; 6; 6]), which is the posterior probability that the die is loaded, given the observed data. Note that the prior probability of this hypothesis is 1 4 100 because only 1% of the dice are loaded. It is called prior because it is our best guess about the die before having seen any information about the sequences of rolls. So in fact, it is still more likely that we picked up a fair die, despite seeing three sixes. 1.4 Markov Models Probabilistic models dealing with probabilities of future occurrences depend on the present occurrences. Example of such model is random walks. 1.5. Queueing Models Probabilistic models dealing with both the arrival patterns and service patterns . 1.6. Inventory Models In inventory models the major objective consists of minimizing the total inventory cost and to balance the economics of large orders or large production runs against the cost of holding inventory and the cost of going short. There are two types of inventory models namely deterministic and stochastic or probabilistic models depending on types of stock variations and on discrete or continuous demand. 2. SIMULATION A simulation is an imitation of some real thing, state of affairs, or process. The act of simulating something generally entails representing certain key characteristics or behaviors of a selected physical or abstract system. Simulation is used in many contexts, including the modeling of natural systems or human systems in order to gain insight into their functioning. Other contexts include simulation of technology for performance optimization, safety engineering, testing, training and education. Simulation can be used to show the eventual real effects of alternative conditions and courses of action. Key issues in simulation include acquisition of valid source information about the referent, selection of key characteristics and behaviours, the use of simplifying approximations and assumptions within the simulation, and fidelity and validity of the simulation outcomes. 5 Types of simulation Historically, simulations used in different fields developed largely independently, but 20th century studies of Systems theory and Cybernetics combined with spreading use of computers across all those fields have led to some unification and a more systematic view of the concept. Physical and interactive simulation Physical simulation refers to simulation in which physical objects are substituted for the real thing. These physical objects are often chosen because they are smaller or cheaper than the actual object or system. Interactive simulation is a special kind of physical simulation, often referred to as a human in the loop simulation, in which physical simulations include human operators, such as in a flight simulat Computer simulation A computer simulation is an attempt to model a real-life situation on a computer so that it can be studied to see how the system works. By changing variables, predictions may be made about the behaviour of the system. Computer simulation has become a useful part of modeling many natural systems in physics, chemistry and biology, and human systems in economics and social science (the computational sociology) as well as in engineering to gain insight into the operation of those systems. A good example of the usefulness of using computers to simulate can be found in the field of network traffic simulation. In such simulations the model behaviour will change each simulation according to the set of initial parameters assumed for the environment. Computer simulations are often considered to be human out of the loop simulations. Traditionally, the formal modeling of systems has been via a mathematical model, which attempts to find analytical solutions to problems which enables the prediction of the behaviour of the system from a set of parameters and initial conditions. Computer simulation is often used as an adjunct to, or substitution for, modeling systems for which simple closed form analytic solutions are not possible. There are many different types of computer simulation, the common feature they all share is the attempt to generate a sample of representative scenarios for a model in which a complete enumeration of all possible states of the model would be prohibitive or impossible. Several software packages exist for running computer-based simulation modeling that makes the modeling almost effortless and simple (e.g., Monte Carlo simulation and stochastic modeling like Risk Simulator). 6 A monte Carlo simulation is a process that generates random number inputs for uncertain values which are then processed by a mathematical model, so that many scenarios can be evaluated. A Random number can be any number “x” from a group of uniformly distributed numbers that falls within an established boundary, usually between 0 and 1. Uniformity is important , in that it m It is increasingly common to hear simulations of many kinds referred to as "synthetic environments". This label has been adopted to broaden the definition of "simulation" to encompass virtually any computer-based representation. Simulation in computer science In computer science, simulation has an even more specialized meaning: Alan Turing uses the term "simulation" to refer to what happens when a digital computer runs a state transition table (runs a program) that describes the state transitions, inputs and outputs of a subject discrete-state machine. The computer simulates the subject machine. In computer programming, a simulator is often used to execute a program that has to run on some inconvenient type of computer, or in a tightly controlled testing environment (see Instruction Set Simulator). For example, simulators are usually used to debug a microprogram or sometimes commercial application programs. Since the operation of the computer is simulated, all of the information about the computer's operation is directly available to the programmer, and the speed and execution of the simulation can be varied at will. Simulators may also be used to interpret fault trees, or test VLSI logic designs before they are constructed. Symbolic simulation is a form of simulation that is also an abstract interpretation of the concrete system under analysis. In theoretical computer science the term simulation represents a relation between state transition systems. This is useful in the study of operational semantics. Simulation in training A soldier tests out a heavy-wheeled-vehicle driver simulator. Simulation is often used in the training of civilian and military personnel. This usually occurs when it is prohibitively expensive or simply too dangerous to allow trainees to use the real equipment in the real world. In such situations they will spend time learning 7 valuable lessons in a "safe" virtual environment. Often the convenience is to permit mistakes during training for a safety-critical system. Training simulations typically come in one of three categories: "live" simulation (where real people use simulated (or "dummy") equipment in the real world); "virtual" simulation (where real people use simulated equipment in a simulated world (or "virtual environment")), or "constructive" simulation (where simulated people use simulated equipment in a simulated environment). Constructive simulation is often referred to as "wargaming" since it bears some resemblance to table-top war games in which players command armies of soldiers and equipment which move around a board. Simulation in education Simulations in education are somewhat like training simulations. They focus on specific tasks. In the past, video has been used for teachers and education students to observe, problem solve and role play; however, a more recent use of simulations in education include animated narrative vignettes (ANV). ANVs are cartoon-like video narratives of hypothetical and reality-based stories involving classroom teaching and learning. ANVs have been used to assess knowledge, problem solving skills and dispositions of children, and pre-service and in-service teachers. Another form of simulation has been finding favour in business education in recent years. Business simulations that incorporate a dynamic model enables experimentation with business strategies in a risk free environment and provide a useful extension to case study discussions. Medical Simulators Medical simulators are increasingly being developed and deployed to teach therapeutic and diagnostic procedures as well as medical concepts and decision making to personnel in the health professions. Simulators have been developed for training procedures ranging from the basics such as blood draw, to laparoscopic surgery and trauma care. Many medical simulators involve a computer connected to a plastic simulation of the relevant anatomy. Sophisticated simulators of this type employ a life size mannequin which responds to injected drugs and can be programmed to create simulations of life8 threatening emergencies. In others simulations, visual components of the procedure are reproduced by computer graphics techniques, while touch-based components are reproduced by haptic feedback devices combined with physical simulation routines computed in response to the user's actions. Medical simulations of this sort will often use 3D CT or MRI scans of patient data to enhance realism. Some medical simulations are developed to be widely distributed (such as via the web) and can be interacted with using standard computer interfaces, such as the keyboard and mouse. Another important medical application of a simulator -- although, perhaps, denoting a slightly different meaning of simulator -- is the use of a placebo drug, a formulation which simulates the active drug in trials of drug efficacy (see Placebo (origins of technical term)). History of Medical Simulation The first medical simulators were simple models of human patients. Since antiquity, these representations in clay and stone were used to demonstrate clinical features of disease states and their effects on humans. Models have been found from many cultures and continents. These models have been used in some cultures (e.g., Chinese culture) as a "diagnostic" instrument, allowing women to consult male physicians while maintaining social laws of modesty. Models are used today to help students learn the anatomy of the musculoskeletal system and organ systems. Active models Active models which attempt to reproduce living anatomy or physiology are recent developments. The famous “Harvey” mannikin was developed at the University of Miami and is able to recreate many of the physical findings of the cardiology examination, including palpation, auscultation, and electrocardiography. Interactive models More recently, interactive models have been developed which respond to actions taken by a student or physician. Until recently, these simulations were two dimensional computer programs which acted more like a textbook than a patient. Computer simulations have the advantage of allowing a student to make judgements, and also to make errors. The process of iterative learning through assessment, evaluation, decision making, and error correction creates a much stronger learning environment than passive instruction. 9 Computer simulators Simulators have been proposed as an ideal tool for assessment of students for clinical skills. Programmed patients and simulated clinical situations, including mock disaster drills, have been used extensively for education and evaluation. These “lifelike” simulations are expensive, and lack reproducibility. A fully functional "3Pi" simulator would be the most specific tool available for teaching and measurement of clinical skills. Such a simulator meets the goals of an objective and standardized examination for clinical competence. This system is superior to examinations which use "standard patients" because it permits the quantitative measurement of competence, as well as reproducing the same objective findings. The "classroom of the future" The "classroom of the future" will probably contain several kinds of simulators, in addition to textual and visual learning tools. This will allow students to enter the clinical years better prepared, and with a higher skill level. The advanced student or postgraduate will have a more concise and comprehensive method of retraining -- or of incorporating new clinical procedures into their skill set -- and regulatory bodies and medical institutions will find it easier to assess the proficiency and competency of individuals. The classroom of the future will also form the basis of a clinical skills unit for continuing education of medical personnel; and in the same way that the use of periodic flight training assists airline pilots, this technology will assist practitioners throughout their career. The simulator will be more than a "living" textbook, it will become an integral a part of the practice of medicine. The simulator environment will also provide a standard platform for curriculum development in institutions of medical education. City Simulators / Urban Simulation A City Simulator can be a game but can also be a tool used by urban planners to understand how cities are likely to evolve in response to various policy decisions. UrbanSim (developed at the University of Washington) and ILUTE (developed at the University of Toronto) are examples of modern, large-scale urban simulators designed for use by urban planners. City simulators are generally agent-based simulations with explicit representations for land use and transportation. 10 Flight simulators Main article: Flight simulator A flight simulator is used to train pilots on the ground. It permits a pilot to crash his simulated "aircraft" without being hurt. Flight simulators are often used to train pilots to operate aircraft in extremely hazardous situations, such as landings with no engines, or complete electrical or hydraulic failures. The most advanced simulators have high-fidelity visual systems and hydraulic motion systems. The simulator is normally cheaper to operate than a real trainer aircraft. Home-built Flight Simulators Main article: Flight simulator Simulation Game Some people who use simulator games, especially flight simulator software, build their own simulator at home. Some people in order to further the realism of their homemade simulator, buy used cards and racks that still run the exact same software they did before they were disassembled from the actual machine itself. Though this brings along the problem of matching hardware and software, and the fact that hundreds of cards plug into many different racks, still, many find that is it well worth it. Some are very serious in building their simulator by buying real aircraft parts like complete nose sectionals of written off aircraft at aircraft boneyards. This permits people who are unable to perform their hobby in real life to simulate it. Marine simulators Bearing resemblance to flight simulators, marine simulators train a ships' personnel. Simulators like these are mostly used to simulate large or complex vessels, such as cruiseships and dredging ships. They often consist of a replication of a ships' bridge, with operating desk(s), and a number of screens on which the virtual surroundings are projected. Engineering (Technology) simulation or Process simulation Simulation is an important feature in engineering systems or any system that involves many processes. For example in electrical engineering, delay lines may be used to simulate propagation delay and phase shift caused by an actual transmission line. Similarly, dummy loads may be used to simulate impedance without simulating propagation, and is used in situations where propagation is 11 unwanted. A simulator may imitate only a few of the operations and functions of the unit it simulates. Contrast with: emulate. (Source: Federal Standard 1037C) Most engineering simulations entail mathematical modeling and computer assisted investigation. There are many cases, however, where mathematical modeling is not reliable. Simulation of fluid dynamics problems often require both mathematical and physical simulations. In these cases the physical models require dynamic similitude. Physical and chemical simulations have also direct realistic uses, rather than research uses; in chemical engineering, for example, process simulations are used to give the process parameters immediately used for operating chemical plants, such as oil refineries. For example, discrete event simulation is often used in industrial engineering, operations management and operational research to model many systems (commerce, health, defence, manufacturing, logistics, etc.) for example, the value-adding transformation processes in businesses, and optimize business performance. Imagine a business, where each person could do 30 tasks, where thousands of products or services involved dozens of tasks in a sequence, where customer demand varied seasonally and forecasting was inaccurate- this is the domain where such simulation helps with business decisions across all functions. Related topics include Theory of Constraints, bottlenecks, and management consulting. Simulation and games Main article: Simulation game Strategy games - both traditional and modern - may be viewed as simulations of abstracted decision-making for the purpose of training military and political leaders (see History of Go for an example of such a tradition). In a narrower sense, many video games are also simulators, implemented inexpensively. These are sometimes called "sim games". Such games can simulate various aspects of reality, from economics to piloting vehicles, such as flight simulators (described above). 12