Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***PLEASE READ THE DESCRIPTION AT THE END OF THE PAGE**** If you do not know how to solve the problem, please do not reply. Otherwise

***PLEASE READ THE DESCRIPTION AT THE END OF THE PAGE****

image text in transcribedimage text in transcribedimage text in transcribed

If you do not know how to solve the problem, please do not reply. Otherwise I will vote negatively. All necessary information is available in the screenshots. USING HEAP-BASED PRIORITY QUEUE IS MANDATORY. THE PROGRAMMING LANGUAGE IS JAVA. THANKS.

In this task, you are supposed to implement a Java program for the scheduling problem of a famous online order delivery company by using heap-based priority queue. The manager is trying to find how many couriers work in the order delivery part. For each courier in the order delivery, the expense of the company increases; but according to the standards of this company, the average waiting time for all customers should not exceed a given amount of time. So, the manager needs to optimize this number and calls for your help in this task. This company has the data of predict delivery time of customers. Your program should use these data to calculate average waiting times and find the minimum number of couriers needs to meet the average waiting time requirement. You must use your own implementation of heap-based priority queue by taking inspiration from your textbook or web. You are not allowed to use any external library or jar file. The input data are stored in a plain .txt file. The first line of the file shows the number of customers. The subsequent lines contain four integers, each separated by one or more whitespace characters (space or tab). These represent, respectively, the customer id, the registration year of the customer to the company (the company was founded in 1968), arrival time for order (in 1 minutes from a given point, e.g. 12:00 am) and service time (in minutes). Here is the sampleinput 1. txt file content: For example, from the sampleinput 1 .txt file content above, it is seen that there are 12 customers. The first customer with id 1 gives order at minute 1, and his order is delivered in 10 minutes. He has been a customer of the company for 28 years (e.g. 2022 - 1994). The sixth customer with id 6 gives order at minute 7 , and his order is delivered in 14 minutes. He has been a customer of the company for 48 years (2022 - 1974). The seventh customer with id 7 gives order at minute 9 , and his order is delivered in 10 minutes. The first and seventh customers have a customer of the company for 28 years, which means that their priorities are the same. You are asked to write a simulation program that reads customer data from sampleinput1.txt file and calculates the minimum number of couriers required for a given maximum average waiting time. The company assigns priority to its customers in order to provide them some special benefits. One of them is that they do not have to wait in the queue for order delivery service. The priority is defined considering the period of time that a customer has been with the company. Long-time customers of the company have higher priority than others. Your implementation must obey the following requirements: - There may be at most 200 customers in the data file. - The customer with the highest priority should be examined first. - In case of having two customers with the same highest priority, the customer who has waited longer should be selected first. - If more than one couriers is available at a given time; the customer is assigned to the courier with a lower id. - When a courier starts giving a service to a customer, the courier should finish his service with this customer even though another customer with a higher priority gives order to company. - Once a customer is assigned to a courier, the courier immediately starts delivering order of that customer and is not available during the service time given for that customer. After the service of that customer carries out, the courier becomes available immediately. - The waiting time of a customer is the duration (difference) between the given order time of the customer and the time he is assigned to a courier. In your implementation, you must use a heap-based priority queue to store customers who are waiting for a courier (i.e., to store customers who have gave order to their order have not been delivered yet). If you do not use such a heap-based priority queue to store these customers, then you will get no points from this task of homework. Firstly, you should read input txt file from the user. Then, you should read the maximum average waiting time. Your program should calculate the minimum number of courier required for meeting this maximum average waiting time. Please check your program with this input file as well as the others that you will create. Please note that we will use other input files when grading your assignments. Sample run is shown as follows, green texts represent user inputs: As a hint, you use the heap data structure to hold customers that are waiting for a courier and to find the customer with the highest priority. Update the heap whenever a new customer gives order or a customer's order is delivered. In order to find the optimum number of couriers needed, repeat the simulation for increasing number of couriers and return the minimum number of 3 waiters that will achieve the maximum average waiting time constraint. Display the simulation for which you find the optimum number of couriers

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

More Books

Students also viewed these Databases questions

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago