Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write portions of a discrete event simulation in JavaScript. Discrete event simulations are often used to analyze customer service operations, such as an airline ticket

Write portions of a discrete event simulation in JavaScript. Discrete event simulations are often used to analyze customer service operations, such as an airline ticket counter. An event in such a simulation represents something of note that happens, such as a customer arriving at the counter or a customer transaction being completed. The heart of the simulation is an event queue, which is a time-ordered list of upcoming events. In addition to the time at which the event will occur, each element of the event queue has a field indicating the type of event (such as "transaction complete"). The program iterates through the event queue, each time removing and processing the event at the front of the

queue. This may cause other events to be added to the queue (they will not necessarily be added to the end, but instead are added so that the event times remain ordered; so this is actually a priority queue). This iteration continues until the queue is exhausted, at which time information gathered during program execution (such as the average time customers spent waiting in line for an agent) is output. (a) Write a constructor for a class Event; the instances of this class will be used to represent simulation events. Each instance should have properties time (assume that this is a Number) and type (of arbitrary type). Your constructor should have two arguments corresponding to these properties, so that the properties can be initialized easily when an instance is constructed. (b) Write a constructor and methods for a class EventQueue representing an event queue. There should be a method empty() that returns true if and only if the queue is empty; a method add() that takes an Event object as its argument and adds it to the queue; and a method removeNextEvent() that removes the Event with the smallest time value (breaking ties arbitrarily) from the event queue and returns this object. (c) Use the classes of (a) and (b) to write a simple airline ticket counter simulation. Input the number of ticket agents working at the counter. The event queue should be initialized by adding a number of customer-arrival events at various times, each time being an integer representing the number of minutes since the ticket counter opened. The program should then begin processing the event queue by removing the first event. If no agent is free when a customer-arrival event occurs, an element containing the current time should be pushed onto a data structure representing the waiting line at the ticket counter (so each element of the line structure represents a customer by the time at which the customer entered the line). If an agent is free when a customer-arrival event occurs, then the number of busy agents is incremented and a transaction-complete event is scheduled to occur three minutes later. When a transaction-complete event occurs, if any customers are in the waiting-line structure, then the first customer is removed from the line and the length of time that customer waited in line is added to an accumulator variable; the number of busy agents is unchanged. Otherwise, if no customers are waiting, an agent becomes free. The simulation ends when no events remain in the event queue. At this time, average customer wait time (accumulated wait time divided by number of customers) is output.

imageimage

Discussion: Ingiring it on the case that you have an empirical relationship between and independent variable, such as time, and dependent variable, velocity, but no explict analytic functional relationship between the two. When trying to compe the derivatives of such as saksown function for which you only have a set of data, it is often used to fitcompate interpolating polyacials to fit to the date, the d the polynomials. This is what you are asked to do in this nest problem data with second, third, and fourth-order polyai Flet the 2 10 12 17 16 12 14 1 Use the bl-is MATLAB tios pelyfis, polyder, and polyvaltocomplete interpolating polynomials and their derivat

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Analytics Data Science And Artificial Intelligence Systems For Decision Support

Authors: Ramesh Sharda, Dursun Delen, Efraim Turban

11th Global Edition

1292341556, 9781292341552

More Books

Students also viewed these Computer Network questions

Question

When do you adjust the amount of prepaid expenses?

Answered: 1 week ago