ME-ESE-13 LECTURE I & II: Introduction to modeling, simulation, and optimization Dr. Tayab Din Memon Department of Electronic Engineering, MUET Outline • System and System Types • Natural Vs. Artificial • Open loop and Closed loop • Static Vs. Dynamic • Models and Model Types • Physical Model • Mathematical Model • Deterministic vs. stochastic models • Simulation • • • • What is Simulation Reasons for Simulation Phases and Steps of Simulation Develop Simulation Model 2 Reference Books • Any suitable book may be referred • Recommended Books for this course are: 1. Richard S. Muller and Theodore I. Kamins “Device Electronics for Integrated Circuits” 2. Christopher M. Snowden “ Introduction to Semiconductor Device Modeling”. 3 Systems • What is System • A system is a set of components which are related by some form of interaction and which act together to achieve some objective or purpose • Components are the individual parts or elements that collectively make up the system • Relationships are the cause-effect dependencies between components • Objective is the desired state or outcome which the system is attempting to achieve 4 A Daily life System Example • Collectors • Capture sun’s thermal energy • Storage tank • Pump • Move the water through the tank • Booster element • Heat water • Relief valve • Cold water inlet • Hot water outlet Solar-Heated Water System 5 Systems • Natural vs. Artificial Systems • A natural system exists as a result of processes occurring in the natural world (e.g. river, universe) • An artificial system owes its origin to human activity (e.g. space shuttle, automobile) • Find-out few more differences between Natural and Artificial System • Static vs. Dynamic Systems • A static system has structure but no associated activity (e.g. bridge, building, furniture, dishes and etc ) • A dynamic system involves time-varying behavior (e.g. machine, U.S. economy, entertainment equipment (radios, televisions, tape recorders, etc.) • Find-out few more differences between Static and Dynamic Systems 6 Systems • Open-Loop vs. Closed-Loop systems • Inputs • Variables that influence the behavior of the system • e.g. wheel, accelerator, and brake of a car • Outputs • Variables that are determined by the system and may influence the surrounding environment • e.g. direction and speed of a car • An open-loop system cannot control or adjust its own performance • e.g. watch, car • A closed-loop system controls and adjusts its own performance in response to outputs generated by the system through feedback • e.g. watch with owner, car with driver • Feedback is the system function that obtains data on system performance (outputs), compares the actual performance to the desired performance (a standard or criterion), and determines the corrective action necessary 7 System Controller Input Output Open-Loop System Desired Reference or Input Error + Signal - System Controller Output Feedback Closed-Loop System 8 Models • What is Model • A model of a system is a representation of the construction and working of the system • Similar to but simpler than the system it represents • Close approximation to the real system and incorporate most of its salient features • Should not be so complex that it is hard to understand or experiment with it • Physical Model • A physical object that mimics some properties of a real system • e.g. During design of buildings, it is common to construct small physical models with the same shape and appearance as the real buildings to be studied • Through prototyping process • Prototyping is the process of quickly putting together a working model (a prototype) in order to test various aspects of a design, illustrate ideas or features and gather early user feedback 9 Models • Mathematical Model • A description of a system where the relationship between variables of the system are expressed in a mathematical form • e.g. Ohm's law describes the relationship between current and voltage for a resistor; Hooke's Law gives the relationship between the force applied to an unstretched spring and the amount the spring is stretched when the force is applied, etc. • Through virtual prototyping • Virtual prototyping is a technique in the process of product development. It involves using computer-aided design (CAD) and computer-aided engineering (CAE) software to validate a design before committing to making a physical prototype [source Wikipedia]. 10 Mathematical Models (Cont…) • Deterministic vs. stochastic models • In deterministic models, the input and output variables are not subject to random fluctuations, so that the system is at any time entirely defined by the initial conditions chosen • e.g. the return on a 5-year investment with an annual interest rate of 7%, compounded monthly • In stochastic models, at least one of the input or output variables is probabilistic or involves randomness • e.g. the number of machines that are needed to make certain parts based on the probability of machine failure 11 Fspring Fspring spring constant The amount spring is stretched FSpring = -k∙x x= -FSpring/k Hooke’s Law 12 Simulation • What is Simulation • A simulation of a system is the operation of a model of the system, as an imitation of the real system • A tool to evaluate the performance of a system, existing or proposed, under different configurations of interest and over a long period of time • e.g. a simulation of an industrial process to learn about its behavior under different operating conditions in order to improve the process • Reasons for Simulation • Experiments on real systems are too expensive, too dangerous, or the system to be investigated does not yet exist • e.g. Investigating ship durability by building ships and letting them collide is a very expensive method of gaining information; training nuclear plant operators in handling dangerous situations by letting the nuclear reactor enter hazardous states is not advisable 13 Simulation • Reasons for Simulation (Cont.) • The time scale of the dynamics of the system is not compatible with that of the experimenter • e.g. It takes millions of years to observe small changes in the development of the universe, whereas similar changes can be quickly observed in a computer simulation of the universe • Easy manipulation of parameters of models (even outside the feasible range of a particular physical system) • e.g. The mass of a body in a computer-based simulation model can be increased from 40 to 500 kg at a keystroke, whereas this change might be hard to realize in the physical system • Suppression of disturbances • Allow isolating particular effects and gaining a better understanding of effects of particular interest as a result • e.g. simulation of free-fall objects ignores the effect of air resistance 14 Simulation • Dangers of Simulation • Fall in love with a model • Become too enthusiastic about a model and forget about the experimental frame • e.g. Hooke’s law applies only if the spring is not stretched beyond its elastic limit • Force reality into the constraints of a model • e.g. Shaping of our societies after fashionable economic theories that have a simplified view of reality and ignoring many other important aspects of human behavior, society, and nature • Forget the model’s level of accuracy • All models have simplifying assumptions • e.g. Free-fall motion is a simplified model (assuming air resistance is negligible) 15 Phases and Steps of Simulation • Phase 1. Develop Simulation Model • • • • • • Step 1. Identify the problem Step 2. Formulate the problem Step 3. Collect and process real system data Step 4. Formulate and develop a model Step 5. Validate the model Step 6. Document model for future use • Phase 2. Design and Conduct Simulation Experiment • A test or series of tests in which meaningful changes are made to the input variables of a simulation model so that we may observe and identify the reasons for changes in the performance measures • Step 7. Select appropriate experimental design • Step 8. Establish experimental conditions for runs • Step 9. Perform simulation runs 16 Simulation • Phase 3. Perform Simulation Analysis • Step 10. Analyze data and present results • Step 11. Recommend further courses of actions 17 Develop Simulation Model • Step 1. Identify Problem • Enumerate problems with an existing system • Produce requirements for a proposed system • Step 2. Formulate Problem • Define overall objectives of the study and specific issues to be addressed • Define performance measures • Quantitative criteria on the basis of which different system configurations will be evaluated and compared • Develop a set of working assumptions that will form the basis for model development • Model boundary and scope (width of model) • Determines what is in the model and what is out • Level of detail (depth of model) • Specifies how in-depth one component or entity is modeled • Determined by the questions being asked and data availability • Decide the time frame of the study • Used for one-time or over a period of time on a regular basis 18 Develop Simulation Model • Step 3. Collect and Process Real System Data • Collect data on system specifications, input variables, performance of the existing system, etc. • Identify sources of randomness (stochastic input variables) in the system • Select an appropriate input probability distribution for each stochastic input variable and estimate corresponding parameters • Standard distributions (e.g. normal, exponential, etc.) • Empirical distributions • Software packages for distribution fitting (e.g. @Risk, Arena, Matlab, etc.) 19 Develop Simulation Model • Step 4. Formulate and Develop a Model • Develop schematics and network diagrams of the system • How do entities flow through the system • Translate conceptual models to simulation software acceptable form • Verify that the simulation model executes as intended • Build the model right (low-level checking) • Traces • Vary input parameters over their acceptable ranges and check the output 20 Develop Simulation Model • Step 5. Validate Model • Check whether the model satisfies or fits the intended usage of system (high-level checking) • Build the right model • Compare the model's performance under known conditions with the performance of the real system • Perform statistical inference tests and get the model examined by system experts • Assess the confidence that the end user places on the model and address problems if any • Step 6. Document Model for Future Use • Objectives, assumptions, inputs, outputs, etc. 21 Design and Conduct Simulation Experiment • Step 7. Select Appropriate Experimental Design • Performance measures • Input parameters to be varied • Ranges and legitimate combinations • Document experiment design • Step 8. Establish Experimental Conditions for Runs • Whether the system is stationary (performance measure does not change over time) or non-stationary (performance measure changes over time) • Whether a terminating or a non-terminating simulation run is appropriate • Starting condition • Length of warm-up period • Model run length • Number of statistical replications • Step 9. Perform Simulation Runs 22 Simulation Analysis • Step 10. Analyze Data and Present Results • Statistics of the performance measure for each configuration of the model • Mean, standard deviation, range, confidence intervals, etc. • Graphical displays of output data • Histograms, scatterplot, etc. • Document results and conclusions • Step 11. Recommend Further Courses of Actions • Other performance measures • Further experiments to increase the precision and reduce the bias of estimators • Sensitivity analysis • How sensitive the behavior of the model is to changes of model parameters • etc. 23 Model Development: A case study LECTURE – II An Example of Model Building (continued) • You are the owner of a new take-out restaurant, McBurgers, currently under construction • You want to determine the proper number of checkout stations needed • You decide to build a model of McBurgers to determine the optimal number of servers 25 • Problem Figure 12.3 System to Be Modeled 26 An Example of Model Building (continued) • A new customer arriving • An existing customer departing after receiving food and paying • Next: Develop an algorithm for each event • Should describe exactly what happens to the system when this event occurs 27 • First: Identify the events that can change the system Figure 12.4 Algorithm for New Customer Arrival 28 An Example of Model Building (continued) • The algorithm for the new customer arrival event uses a statistical distribution (Figure 12.5) to determine the time required to service the customer • Can model the statistical distribution of customer service time using the algorithm in Figure 12.6 29 Figure 12.5 Statistical Distribution of Customer Service Time 30 Figure 12.6 Algorithm for Generating Random Numbers That Follow the Distribution Given in Figure 12.5 31 Figure 12.7 Algorithm for Customer Departure Event 32 An Example of Model Building (continued) • Must initialize parameters to the model • Model must collect data that accurately measures performance of the McBurgers restaurant 33 An Example of Model Building (continued) • When simulation is ready, the computer will • Run the simulation • Process all M customers • Print out the results 34 Figure 12.8 The Main Algorithm of Our Simulation Model 35 Running the Model and Visualizing Results • Scientific visualization • Visualizing data in a way that highlights its important characteristics and simplifies its interpretation • An important part of computational modeling • Different from computer graphics 36 Running the Model and Visualizing Results (continued) • Scientific visualization is concerned with • Data extraction: Determine which data values are important to display and which are not • Data manipulation: Convert the data to other forms or to different units to enhance display 37 Running the Model and Visualizing Results (continued) • Output of a computer model can be represented visually using • A two-dimensional graph • A three-dimensional image • Visual representation of data helps identify important features of the model’s output 38 Figure 12.9 Using a Two-Dimensional Graph to Display Output 39 Figure 12.10: Using a Two-Dimensional Graph to Display and Compare Two Data Values 40 Figure 12.11 Three-Dimensional Image of a Region of the Earth’s Surface 41 42 Figure 12.12 Three-Dimensional Model of a Methyl Nitrite Molecule Figure 12.13 Visualization of Gas Dispersion 43 Running the Model and Visualizing Results (continued) • Image animation 44 • One of the most powerful and useful forms of visualization • Shows how model’s output changes over time • Created using many images, each showing system state at a slightly later point in time Figure 12.14 Use of Animation to Model Ozone Layers in the Atmosphere 45 CASE STUDY – II STEP WISE A machine shop contains two drills, one straightener, and one finishing operator. Type 1 parts require drilling, straightening, and finishing in sequence. Type 2 parts require only drilling and finishing. The frequency of arrival and the time to be routed to the drilling area are deterministic for both types of parts. Straightener Drill #1 Drill #2 Finishing Operator Legend: Type 1 parts Type 2 parts 47 Step 1. Identify the problem • Assess utilization of drills, straightener, and finishing operator • The following modification to the original system is of interest: the frequency of arrival of both parts is exponential with the same respective means as in the original system Step 2. Formulate the problem Objectives • Obtain the utilization of drills, straightener, and finishing operator for the system • Assess the modification Performance measure • Utilization of operations (the fraction of time the server is busy, i.e. busy time divided by the total time) Assumptions • Two drills are identical • There is no material handling time between the three operations • Parts are processed on a first-come-first-serve basis • Parts wait in a queue till one of the two drilling machines becomes available 48 Step 3. Collect and process real system data • A type 1 part arrives every 30 min. • A type 2 part arrives every 20 min. • It takes 2 min. and 10 min. to route a type 1 part and a type 2 part to the drilling area, respectively • Drilling time is normally distributed with mean 10 min. and standard deviation 1 min. • Straightening time is exponentially distributed with a mean of 15 min. • Finishing requires 5 min. per part Step 4. Formulate and develop a model • A model of the system and the modification are developed using a simulation package • A trace verifies that the parts flowed through the job shop as expected Step 5. Validate the model • The model of the original system is run for a sufficiently long period, and its utilization performance measures are judged to be reasonable by the machine shop operators Step 6. Document model for future use • The models of the original system and the modification are documented as thoroughly as possible 49 Step 7. Select appropriate experimental design • Performance measures are the utilization of operations • Vary input parameters: operating times for drilling, straightening, and arrival time of parts (in modification) • Document experiment design for the models of the original and modified systems Step 8. Establish experimental conditions for runs • The system is non-stationary • There is no part in the machine shop initially • 1000 min. warm-up period • Each model is run three times for 4000 min. Step 9. Perform simulation runs • Runs are performed as specified in Steps 7 and 8 50 Step 10. Interpret and present results Utilization Statistics of Models of Original and Modified Systems (in parenthesis) Drilling Straightening Finishing Mean Run #1 0.83 (0.78) 0.51 (0.58) 0.42 (0.39) Mean Run #2 Mean Run #3 Std. Run #1 Std. Run #2 Std. Run #3 0.82 (0.90) 0.84 (0.81) 0.69 (0.75) 0.68 (0.78) 0.69 (0.76) 0.52 (0.49) 0.42 (0.56) 0.50 (0.49) 0.50 (0.50) 0.49 (0.50) 0.41 (0.45) 0.42 (0.40) 0.49 (0.49) 0.49 (0.50) 0.49 (0.49) • Utilization of each drill is about 80% • Utilization of straightener is about 50% • Utilization of finishing operator is about 40% • Average utilization of the original and modified systems does not differ significantly • The standard deviation of the drilling operation seems to have increased because of the increased randomness in the modification 51 Step 11. Recommend further course of action • Other performance measures of interest may be: throughput of parts for the system, mean time in system for both types of parts, average and maximum queue lengths for each operation • Other modification of interest may be: the flow of parts to the machine shop doubles 52 Simulation Tools • General Purpose Programming Languages • FORTRAN, PASCAL,C/C++ JAVA, etc. • Advantages: • Little or no additional software cost • Universally available (portable) • No additional training • Disadvantages: • Every model starts from scratch • Very little reusable code • Long development cycle for each model 53 Simulation Tools • General Simulation Languages • Arena, Extend, GPSS, SIMSCRIPT, SIMULINK (In Matlab), etc. • Advantages • Standardized features in modeling • Shorter development cycle for each model • Very readable code • Disadvantages • Higher software cost (up-front) • Additional training required • Limited portability 54 Simulation Tools • Special Purpose Simulation Packages • Manufacturing (e.g. AutoMod, FACTOR/AIM, etc.), Communications network (e.g.COMNET III, NETWORK II.5, etc.), Business (BP$IM, ProcessModel, etc.), Health care (e.g. MedModel) • Advantages • Very quick development of complex models • Short learning cycle • little programming • Disadvantages • High cost of software • Limited scope of applicability • Limited flexibility 55 Optimization • What is Optimization • Its objective is to select the best possible decision for a given set of circumstances without having to enumerate all of the possibilities • Involves maximization or minimization as desired • How can a large manufacturing company determine the monthly product mix at its Indianapolis plant that maximizes corporate profitability? • Design of civil engineering structures such as frames, foundations, bridges, towers, chimneys and dams for the minimum cost • Components • Decision variables • Variables in the model which you have control over • Objective function • A function (mathematical model) that quantifies the quality of a solution in an optimization problem • Constraints • Conditions that a solution to an optimization problem must satisfy • Restrict decision variables by defining relationships among them • Find the values of the decision variables that maximize (minimize) the objective function value, while staying within the constraints 56 Optimization • Linear Programming • The objective function and all constraints are linear functions (e.g. no squared terms, trigonometric functions, ratios of variables) of the decision variables Example: Maximize z = 15x1+10x2 subject to 0≤ x1 ≤2, 0 ≤ x2 ≤ 3, x1+x2 ≤4 The objective function is z = 15x1+10x2 The constraints are: 0≤ x1≤2, 0 ≤ x2 ≤ 3, x1+x2 ≤4 57 x 5 2 x1=2 4 x2=3 3 Optimal point (x1=x2=2) 2 x1+ x2 = 4 Feasible Region 1 z = 40 0 0 1 z = 10 z = 20 z = 30 2 x1 3 4 5 58 zmax = 15*2 + 10*2 = 50 Excel Solver • A Microsoft Excel Add-In • Go to Tools >>Add-Ins , select Solver Add-in, click OK • Originally designed for optimization problems but also useful for root finding and similar mathematical problems Target cell • The objective or goal • Maximize, minimize or set a specific value to the target cell Changing cells • Can be adjusted until the constraints in the problem are satisfied and the cell in the Set Target Cell box reaches its target Constraints 59 • The restrictions placed on the changing cells