Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code in python. Please dont answer only some questions. It is one program and you need to code it . If you dont know

Please code in python. Please dont answer only some questions. It is one program and you need to code it . If you dont know the answer, dont response it

  • Online BPP - Next Fit

  • Online BPP - First Fit

  • Online BPP - Best Fit

  • Offline BPP - First Fit Decreasing (presorted)

  • Offline BPP - Best Fit Decreasing (presorted)

The data that will be provided to you will all be "offline", i.e. is provided to you at once. That said, for the sake of comparison, we will use both the online and offline algorithms above.

As in previous assignments, you are permitted to utilize publicly available code for the individual algorithms and integrate them into your program. You should acknowledge each source with a comment pointing to its URL before the relevant function with the borrowed code.

Output:

The focus of this assignment is more on the accuracy of the approximation rather than the algorithm's efficiency. So while you might want to track the times for the sake of curiosity, our tables and graphs should reflect the approximations themselves. To that end, the column headings of your table, and the data beneath them, should be the following:

  • Trial No. - 1, 2, 3, etc.

  • File Name - the file name from which you read the input for that trial

  • Items - the number of items (weights) found in that file

  • Optimal Answer - the number of bins in an optimal solution (compute this by adding up all the weights in the file and dividing by a bin-capacity of 100. The data has been "hard-wired" to exactly fit an integer number of bins.)

  • Online NF - the number of bins computed by the Online BPP Next Fit approximation algorithm

  • Online FF - the number of bins computed by the Online BPP First Fit approximation algorithm

  • Online BF - the number of bins computed by the Online BPP Best Fit approximation algorithm

  • Offline FFD - the number of bins computed by the Offline BPP First Fit Decreasing approximation algorithm

  • Offline BFD - the number of bins computed by the Offline BPP Best Fit Decreasing approximation algorithm

The graph should similarly compare the number of bins required in an optimal solution and the five algorithms. One graph per trial.

Tasks:

[1] Like in the previous assignment, you will need a function that reads all the files in a directory. You should download the data files from our Google drive into a local directory.

[2] For each file, read in the weights of the n items into a list.

[3] Implement each of the five approximation algorithms mentioned above. For the two "offline" versions that require presorting the data in non-increasing (decreasing) order, you may use Python's built-in sorting function or call any other sorting algorithm of your choosing. You may also use your choice of data structure for finding a bin with a suitable or best-fit capacity. (The slides mention using a "balanced binary search tree", but you are not required to use this data structure.)

[4] Create a Pandas DataFrame structured according to the output columns mentioned above and populate another row for each trial.

[5] Create an appropriate bar graph showing the results of a given trial (optimal solution and the five approximate solutions).

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

Define dashboard.

Answered: 1 week ago