Exam #1 for Computer Simulation Spring 2005

Similar documents
>>> Assignment #4 for Simulation (CAP 4800) <<<

>>> Assignment #3 for Simulation (CAP 4800) <<<

>>> SOLUTIONS <<< a) What is a system? Give a short formal definition. (Hint: what you draw a box around is not a formal definition)

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

Midterm 2 Sample solution

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Unit 5 Vocabulary. A function is a special relationship where each input has a single output.

Functor (1A) Young Won Lim 8/2/17

UNIT 11. Query Optimization

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork

Physics 208: Electricity and Magnetism Exam 1, Secs Feb IMPORTANT. Read these directions carefully:

Functor (1A) Young Won Lim 10/5/17

Engineer To Engineer Note

What do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers

CSE 401 Midterm Exam 11/5/10 Sample Solution

P(r)dr = probability of generating a random number in the interval dr near r. For this probability idea to make sense we must have

Fall 2018 Midterm 2 November 15, 2018

What do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers

Math 464 Fall 2012 Notes on Marginal and Conditional Densities October 18, 2012

ECE 468/573 Midterm 1 September 28, 2012

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.

Spring 2018 Midterm Exam 1 March 1, You may not use any books, notes, or electronic devices during this exam.

A REINFORCEMENT LEARNING APPROACH TO SCHEDULING DUAL-ARMED CLUSTER TOOLS WITH TIME VARIATIONS

MIPS I/O and Interrupt

Pointers and Arrays. More Pointer Examples. Pointers CS 217

Questions About Numbers. Number Systems and Arithmetic. Introduction to Binary Numbers. Negative Numbers?

CS143 Handout 07 Summer 2011 June 24 th, 2011 Written Set 1: Lexical Analysis

Introduction to Integration

Class-XI Mathematics Conic Sections Chapter-11 Chapter Notes Key Concepts

Complete Coverage Path Planning of Mobile Robot Based on Dynamic Programming Algorithm Peng Zhou, Zhong-min Wang, Zhen-nan Li, Yang Li

HW Stereotactic Targeting

4452 Mathematical Modeling Lecture 4: Lagrange Multipliers

CMSC 331 First Midterm Exam

CSCE 531, Spring 2017, Midterm Exam Answer Key

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

Thirty-fourth Annual Columbus State Invitational Mathematics Tournament. Instructions

How to Design REST API? Written Date : March 23, 2015

Study Guide for Exam 3

CS 430 Spring Mike Lam, Professor. Parsing

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an

CIS 1068 Program Design and Abstraction Spring2015 Midterm Exam 1. Name SOLUTION

Control-Flow Analysis and Loop Detection

COMMON HALF YEARLY EXAMINATION DECEMBER 2018

Fall 2017 Midterm Exam 1 October 19, You may not use any books, notes, or electronic devices during this exam.

Reference types and their characteristics Class Definition Constructors and Object Creation Special objects: Strings and Arrays

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example:

Definition of Regular Expression

Overview. Network characteristics. Network architecture. Data dissemination. Network characteristics (cont d) Mobile computing and databases

Math 35 Review Sheet, Spring 2014

Slides for Data Mining by I. H. Witten and E. Frank

1.1 Lines AP Calculus

11/28/18 FIBONACCI NUMBERS GOLDEN RATIO, RECURRENCES. Announcements. Announcements. Announcements

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

Data sharing in OpenMP

LECT-10, S-1 FP2P08, Javed I.

Improper Integrals. October 4, 2017

CS453 INTRODUCTION TO DATAFLOW ANALYSIS

Engineer To Engineer Note

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries

A Transportation Problem Analysed by a New Ranking Method

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. General Tree Search. Uniform Cost. Lecture 3: A* Search 9/4/2007

SIMPLIFYING ALGEBRA PASSPORT.

Quiz2 45mins. Personal Number: Problem 1. (20pts) Here is an Table of Perl Regular Ex

Performance analysis of QoS mechanisms in IP networks

c360 Add-On Solutions

MATH 2530: WORKSHEET 7. x 2 y dz dy dx =

12-B FRACTIONS AND DECIMALS

pdfapilot Server 2 Manual

Lexical Analysis. Amitabha Sanyal. ( as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Dr. D.M. Akbar Hussain

Dynamic Programming. Andreas Klappenecker. [partially based on slides by Prof. Welch] Monday, September 24, 2012

On the Detection of Step Edges in Algorithms Based on Gradient Vector Analysis

Matrices and Systems of Equations

>>> SOLUTIONS <<< Answer the following question regarding the basics of systems and performance modeling.

Tool Vendor Perspectives SysML Thus Far

Topics in Analytic Geometry

such that the S i cover S, or equivalently S

Chapter 7. Routing with Frame Relay, X.25, and SNA. 7.1 Routing. This chapter discusses Frame Relay, X.25, and SNA Routing. Also see the following:

Lecture Overview. Knowledge-based systems in Bioinformatics, 1MB602. Procedural abstraction. The sum procedure. Integration as a procedure

Fault injection attacks on cryptographic devices and countermeasures Part 2

Lecture 7: Integration Techniques

CS 221: Artificial Intelligence Fall 2011

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009

Constrained Optimization. February 29

Chapter 2 Sensitivity Analysis: Differential Calculus of Models

Discussion 1 Recap. COP4600 Discussion 2 OS concepts, System call, and Assignment 1. Questions. Questions. Outline. Outline 10/24/2010

9.1 apply the distance and midpoint formulas

High Priority Traffic in HCF on Wireless Networks

Transparent neutral-element elimination in MPI reduction operations

CS412/413. Introduction to Compilers Tim Teitelbaum. Lecture 4: Lexical Analyzers 28 Jan 08

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing

Answer Key Lesson 6: Workshop: Angles and Lines

Representation of Numbers. Number Representation. Representation of Numbers. 32-bit Unsigned Integers 3/24/2014. Fixed point Integer Representation

The Greedy Method. The Greedy Method

Engineer-to-Engineer Note

EECS 281: Homework #4 Due: Thursday, October 7, 2004

1 Quad-Edge Construction Operators

PROBABILISTIC SEISMIC DEMAND ANALYSIS CONSIDERING RANDOM SYSTEM PROPERTIES BY AN IMPROVED CLOUD METHOD

Accelerating 3D convolution using streaming architectures on FPGAs

Transcription:

Exm # for Computer Simultion Spring 005 >>> SOLUTION <<< Welcome to exm # in Computer Simultion. Red ech problem crefully. There re eight required problems (ech worth.5 points) nd one extr credit problem worth 0 points. Plese write your nswers in the spce provided. You my hve clcultor nd one 8.5 x inch sheet of pper with you. On this sheet you my hve nything you wnt (definitions, formuls, flow chrts, etc.) in your hndwriting on both sides of the pge. You my not hve photocopies or printed text on your formul sheet. Plese nswer ech problem on seprte sheet of pper. Good luck!!! Problem # ) Precisely define model nd give three resons why we build nd experiment with models. A model is representtion (physicl, logicl, or functionl) tht mimics nother object under study. The gol in building model is to be ble to predict the behvior of the originl object. Building nd studying models is usully cheper nd sfer thn studying the rel object. Sometimes it is not possible to study the ctul object (when it does not exist) nd model is thus required. b) Describe cpcity plnning. Wht re the inputs to the process nd wht re the outputs? Cpcity plnning is process where the inputs re worklod evolution, system prmeters, nd desired service nd the outputs re sturtion point nd costeffective lterntives. c) Define computer simultion. Computer simultion is the discipline of designing model of n ctul or theoreticl physicl system, executing the model on computer, nd nlyzing the execution results. d) Wht re some of the key performnce mesures of interest in IT systems? Response time or dely is the key mesure of interest for most IT systems. Throughput, loss, utiliztion, relibility, nd vilbility re other mesures of interest. Problem # You re responsible for the opertion of three server computers. Every morning you check ech server if it is up or down. The probbility of ny given server being down is p = 0.0 (nd this is independent of the stte of the other servers). Solve for Pr[i servers re down] for i = 0,,, nd 3. Wht is the men number of servers tht re down in the morning? Wht is the vrince? Wht is the stndrd devition? This is binomil distribution. We solve for Pr[ i = 0] = 0 Pr[ i = ] = Pr[ i = ] = Pr[ i = 3] = 3 0 ( 0.0) ( 0.90) ( 0.0) ( 0.90) 3 ( 0.0) ( 0.90) 3 0 3 = 0.79 = 0.43 = 0.07 3 3 3 ( 0.0) ( 0.90) = 0. 00 men = n p = 3 0.0 = 0.30 vr ince = n p q = 3 0.0 0.90 = 0.7 s tn drd _ devition = n p q = 0.596

Problem #3 You re given the following trnsction trce dt (e.g., from dtbse server) where :59:58 is time zero. Time Trnsction size :59:58 00 bytes :00:00 00 :00:0 00 :00:04 00 :00:0 300 :00:3 300 ) Wht is the men interrrivl time? Wht is the men trnsction size? The interrrivl times re,, 3, 6, nd seconds. The men is thus ( + + 3 + 6 + 3) = 3 seconds. The trnsctions sizes re 00, 00, 00, 00, 300, nd 5 6 300 bytes. The men is thus ( 00 00 + 00 + 00 + 300 + 300) = 00 b) Wht is the stndrd devition of trnsction size? + bytes. S tn drd _ devition = 6 ( 00 00) + ( 00 00) + ( 00 00) + ( 00 00) + ( 300 00) + ( 300 00) ) = 8. 65 c) Plot histogrm of the trnsction size. Rtio 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0. 0. 0 0 00 00 300 400 Trnsction size (bytes) d) Write C function tht returns vlue tht is empiriclly distributed bsed on the trce dt for trnsction size. You my ssume tht you cn cll function rnd_vl() tht will return uniformly distributed rndom vrible between 0 nd. The function is: double emp_trnsction_size(void) double z; z = rnd_vl(); if (z < (.0 / 3.0)) return(00.0); if (z < (.0 / 3.0)) return (00.0); return (300.0);

Problem #4 Write C function tht will return Preto distributed rndom vrible with prmeters nd b. The CDF of Preto distribution b is F( x) =. You my ssume tht you cn cll function rnd_vl() tht will return uniformly distributed rndom x vrible between 0 nd. First we need to invert the function to solve for x s follows: b z = x b x x = = z b = z b z Then we cn write the C function s: double preto(double, double b) double z; do z = rnd_vl(); while (z == 0.0); return(b / pow(z, (.0 / ))); Problem #5 Answer the following questions bout queueing theory: ) Describe Kendll nottion A queue is described s A/S/c/k/m where A is the rrivl distribution, S is the service distribution, c is the number of servers, k is the cpcity of the system in number of customers, nd m is the number of customers in the universe. A nd S cn be M for Mrkov, D for deterministic, G for generl, nd others. b) Stte Little s Lw L = λ W for L is the men number in the system, λ is the rrivl rte, nd W is the men wit in the system c) Given λ (rrivl rte), µ (service rte), L (men number in the system), nd W (men wit in the system) show how to solve for Lq (men number in the queue), nd Wq (men wit in the queue) for single server queue. Lq = L ρ where ρ is the system utiliztion, which is rrivl rte divided by service rte ( ρ = λ µ ). ( µ ) Wq = W where µ is the service rte.

Problem #6 For n M/M/ queue, plot the men number of customers in the system (L) for utiliztion of 0.50, 0.60, 0.70, 0.80, 0.90, nd 0.95. ρ For n M/M/ we know tht L = so for the given vlues of utiliztion we compute L ρ s.0,.5,.33, 4, 9, nd 9. We cn then plot: L (men num in system) 0 8 6 4 0 8 6 4 0 0.5 0.6 0.7 0.8 0.9 Utiliztion Problem #7 Attched is mm_mini.c. This is the M/M/ simultion progrm from McDougll nd lso s discussed in clss. Modify the progrm such tht deprting customer hs probbility PR_REDO of immeditely returning to the queue. The vlue of PR_REDO could be set s constnt (e.g., with #define). Your modified mm_mini.c models single server queue with error checking where deprting customer with detected error is immeditely sent bck for re-service. The probbility of deprting customer hving detected error is PR_REDO. See yellow highlighted code on the ttched mm_mini.c progrm. Problem #8 List the bsic components nd give the flowchrt of discrete event simultion. Describe how n event list works. The bsic components re system stte, simultion clock (time), event list, event routine, sttisticl counters, librry routines, report genertor, initiliztion routine, nd min progrm. The flowchrt is Figure 4.4 from Molloy (hnded-out nd/or discussed in clss on Wednesdy 0/09/05).

Extr Credit: (0 points) Write simultion progrm in C for problem #. As with the previous problems, you my ssume tht rnd_vl() exists nd cn be clled. One possible solution is (rnd_vl() is not shown): #include <stdio.h> double rnd_vl(void); void min(void) int totl, i, s, s, s3, sum, count[4]; totl = 000000; count[0] = count[] = count[] = count[3] = 0; for (i=0; i<totl; i++) sum = s = s = s3 = 0; if (rnd_vl() < 0.0) s = ; if (rnd_vl() < 0.0) s = ; if (rnd_vl() < 0.0) s3 = ; sum = s + s + s3; count[sum]++; printf("pr[0 down] = %f \n", (double) count[0] / totl); printf("pr[ down] = %f \n", (double) count[] / totl); printf("pr[ down] = %f \n", (double) count[] / totl); printf("pr[3 down] = %f \n", (double) count[3] / totl); The output from this progrm is: Pr[0 down] = 0.79539 Pr[ down] = 0.476 Pr[ down] = 0.06753 Pr[3 down] = 0.00098 Which mtches (s expected) the theoreticl (nlysis) results from problem #. ---

//===================================================== file = mm_mini.c ===== //= A simple M/M/ queue simultion = //= Notes: = //= = //= This progrm is dpted from "Figure.4" in Simulting Computer = //= Systems, Techniques nd Tools by M. H. McDougll (987) = //=---------------------------------------------------------------------------= //= Build: gcc mm_mini -lm, bcc3 mm_mini.c, cl mm_mini.c = //=---------------------------------------------------------------------------= //= Execute: mm_mini = //=---------------------------------------------------------------------------= //= History: KJC (0/7/99) - Genesis = //----- Include files --------------------------------------------------------- #include <stdio.h> // Needed for printf() #include <mth.h> // Needed for log() //----- Constnts ------------------------------------------------------------- #define SIM_TIME.0e6 // Simultion time #define PR_REDO 0.0 // Probbility to redo deprting customer //----- Function prototypes --------------------------------------------------- double expntl(double x); // Generte exponentil RV with men x double rnd_vl(void); // Generte unif(0,) RV //===== Min progrm ========================================================== void min(void) double end_time = SIM_TIME; // Totl time to simulte double T = 3.0; // Men time between rrivls double Ts =.0; // Men service time double time = 0.0; double t = 0.0; double t = SIM_TIME; long int n = 0; // Simultion time // Time for next event # (rrivl) // Time for next event # (deprture) // Number of customers in the system // Min simultion loop while (time < end_time) if (t < t) time = t; //** Event # (rrivl) // Set time to tht of current event // Increment number of customers in system n++; if (rnd_vl() < PR_REDO) // Test if should redo or not t = time; t = time + expntl(t); if (n == ) // If first customer in system then t = time + expntl(ts); // ssign its deprture time // *** Event # (deprture) time = t; // Set time to tht of current event n--; // Decrement number of customers in system if (n > 0) // If customers in system then t = time + expntl(ts); // ssign next deprture time // If no customers in system then t = end_time; // ssign next deprture to "infinity"

//= Function to generte exponentilly distributed RVs = //= - Input: x (men vlue of distribution) = //= - Output: Returns with exponentil RV = double expntl(double x) double z; // Uniform rndom number from 0 to // Pull uniform RV (0 < z < ) do z = rnd_vl(); while ((z == 0) (z == )); // Inversion formul for exonentil RV return(-x * log(z)); //= Multiplictive LCG for generting uniform(0.0,.0) rndom numbers = //= - x_n = 7^5*x_(n-)mod(^3 - ) = //= - With x seeded to the 0000th x vlue should be 04368065 = //= - From R. Jin, "The Art of Computer Systems Performnce Anlysis," = //= John Wiley & Sons, 99. (Pge 443, Figure 6.) = double rnd_vl(void) const long = 6807; // Multiplier const long m = 47483647; // Modulus const long q = 7773; // m div const long r = 836; // m mod sttic long x = ; // Rndom int vlue (seed is set to ) long x_div_q; // x divided by q long x_mod_q; // x modulo q long x_new; // New x vlue // RNG using integer rithmetic x_div_q = x / q; x_mod_q = x % q; x_new = ( * x_mod_q) - (r * x_div_q); if (x_new > 0) x = x_new; x = x_new + m; // Return rndom vlue between 0.0 nd.0 return((double) x / m);