Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROGRAM: Need code for program ! Variables for the bank model: EList = OList of Event objects (time, type) (ordered time (primary) and type

JAVA PROGRAM: Need code for program !

Variables for the bank model:

EList = OList of Event objects (time, type) (ordered time (primary) and type (secondary))

Qcust = Queue2 of Customer objects (a, s)

(a = arrival time, s = service time)

Tasks = stack of Task objects (arr, ser) (arr = arrival time, ser = service time)

Ci = customer at teller i (i = 1, 2, 3)

Bi = 1 if teller i is busy with a customer, 0 otherwise (i= 1, 2, 3)

Cust = next customer to arrive in bank (customer just read from CustArr file)

T = next task to be placed on the Tasks stack (task just read from TaskArr file)

CustArr = file of Customer

TaskArr = file of Task

TaskCurr = current task being worked on by teller 3

tt = throughtime for a customer

TT = total throughtime for all customers

Count (also called n in the example) = number of customers leaving the bank

CURR = current time

Events

  1. Exit from teller 1
  2. Exit from teller 2
  3. Exit from teller 3
  4. Ignore (Customer quits Qcust and exits bank- this is not implemented yet as an event)
  5. Task completion by teller 3
  6. Task arrival
  7. Customer arrival

The program begins by initializing the variables based on the given initial data.

The program then repeatedly executes the first event on the event list, until the event list is empty. To execute the next event, call the method Execute():

Execute() //method to execute the next event, at time = CURR

Event e = EList.del(EList.getData(1)) //delete and save the first event on event list

CURR = e.getTime()

Type = e.getType()

Now execute this type of event at time CURR, as follows:

To execute a type 1 exit event (customer C1 exits from teller 1 at time CURR):

  1. Print C1(a, s)
  2. Compute and print through-time tt = CURR a
  3. T = T + tt; Count = Count + 1;
  4. If Qcust is nonempty (Qcust.getSize() > 0), let C1 = Qcust.dequeue(), C1 =(a1, s1).
  1. Let Event next = Event(CURR + s1, 1) //prepare next exit 1 event
  2. EList.insert(next) //insert future type 1 exit event into the event list
  3. B1 = 1 (teller 1 is busy)

Type 2 exit events are done in the same way.

Type 3 exit events are a little different (customer C3 exits from teller 3 at time CURR):

Steps 1-3 are the same as for a type 1 exit event.

(*) If the Tasks stack is empty but Qcust is not empty, then continue as in step 4) above, but applied to C3 = (a3, s3), to prepare the next type 3 exit event. Set B3 = 1.

If the Tasks stack is nonempty, let TaskCurr = Tasks.pop(), TaskCurr = (arr, ser)

  1. Let Event next = Event(CURR + ser, 5) //prepare next task completion type 5 event
  2. EList.insert(next) //insert future type 5 event into the event list
  3. B3 = 1 (teller 3 is busy)

Type 5: Task completion event

  1. At time CURR, teller 3 completes TaskCurr = (arr, ser). Print the time, type of event, and TaskCurr.
  2. If the stack is nonempty, let TaskCurr = Tasks.pop(), and suppose TaskCurr = (arrNew, serNew). Prepare a future type 5 task completion event for time CURR + serNew, and insert this future event into the event list; set B3 = 1 (teller 3 is now bust with a new task).
  3. If the stack is empty and the customer queue is nonempty, then continue as in step (*) of the type 3 event.

Type 6: Task arrival

  1. At time CURR, task T = (arr, ser) arrives. Push this onto the stack with Tasks.push(T).
  2. If the stack was previously empty, then T is now the only task on the stack, so if teller 3 is free (B3 = 0), then teller 3 can begin service on this task. In this case, set TaskCurr = Tasks.pop(). Teller 3 will complete service for this task at CURR + ser, so prepare a future type 5 task completion event next = Event(Curr + ser, 5) and insert into the event list. Set B3 = 1 (teller 3 is busy with this new task.)
  3. If TaskArr (the task arrivals file) is not EOF, read the next task object into T,

T = (arrNew, serNew). Prepare a type 6 task arrival event for time arrNew,

Event next = Event(arrNew, 6), and insert into the event list.

Type 7 Customer arrival

The customer who is arriving is CUST(a, s), the customer last read from the file CustArr.

  1. Qcust.enqueue(CUST)
  2. If Qcust.getSize() == 1:
  1. If some teller is not busy, let i be the smallest number of a free teller.
  2. Let Ci = Qcust.dequeue(), Ci = (a, s)
  3. As in the type i exit event, prepare the next type i exit event for time CURR + s, and insert this event into the event list. Set Bi = 1 (busy).
  1. Read a new value for CUST(a, s) from CustArr (if the file is nonempty)
  1. Prepare the next Type 7 arrival event for time a and insert the event into the event list.

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

Step: 3

blur-text-image

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

Navigating The Supply Chain Maze A Comprehensive Guide To Optimize Operations And Drive Success

Authors: Michael E Kirshteyn Ph D

1st Edition

B0CPQ2RBYC, 979-8870727585

Students also viewed these Databases questions

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago