Question
Problem1:(20 pts)Inthebin packing problem, itemsof different weights (or sizes) must be packed into a finite number of bins each with the capacity Cin a way
Problem1:(20 pts)Inthebin packing problem, itemsof different weights (or sizes) must be packed into a finite number of bins each with the capacity Cin a way that minimizes the number of bins used.Thedecision version of the bin packing problem(deciding if objects will fit into <= k bins) isNP-complete. There is no known polynomial time algorithm to solve the optimization version of the bin packing problem. In this homework you will be examiningthreegreedy approximation algorithms to solvethe bin packing problem.First-Fit:Put each item as you come to it into the first (earliest opened) bin into which it fits. If there is no available bin then open a new bin.First-Fit-Decreasing: First sort the items in decreasing order by size, then use First-Fit on the resulting list.Best Fit:Place the items in the order in which they arrive. Place the next item into thebin which will leave the least room left over after the item is placed in the bin. If it does not fit in any bin, start a new bin.a) Give pseudo code and the running time for each of the approximation algorithms.b) Implementthe algorithmsin Python,C++ or C. Your program named binpackshould read in a text file named bin.txt with multiple test cases as explained below and output to the terminal the number of bins each algorithm calculated for each test case.Submit a README file and your programto TEACH.Example bin.txt: The first line is the number of test cases,followed by the capacity of bins for thattest case, the number of itemsand then the weight of each item. You can assume that the weight of an item does not exceed the capacity of a bin for that problem.31065 10 2 5 4 410204 4 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 61043 8 2 7Sample output:Test Case 1 First Fit: 4, First Fit Decreasing: 3, Best Fit: 4 Test Case 2First Fit: 15, First Fit Decreasing: 10, Best Fit:15Test Case 2 First Fit: 3, First Fit Decreasing: 2, Best Fit: 2c) Randomly generateat least 20 bin packing instances.Summarize the results for each algorithm. Which algorithm performs better? How often?Note: Submit a description of how the inputs were generated not the code used to produce the random inputs.CS 325-Homework Assignment 81Problem1:(20 pts)Inthebin packing problem, itemsof different weights (or sizes) must be packed into a finite number of bins each with the capacity Cin a way that minimizes the number of bins used.Thedecision version of the bin packing problem(deciding if objects will fit into <= k bins) isNP-complete. There is no known polynomial time algorithm to solve the optimization version of the bin packing problem. In this homework you will be examiningthreegreedy approximation algorithms to solvethe bin packing problem.First-Fit:Put each item as you come to it into the first (earliest opened) bin into which it fits. If there is no available bin then open a new bin.First-Fit-Decreasing: First sort the items in decreasing order by size, then use First-Fit on the resulting list.Best Fit:Place the items in the order in which they arrive. Place the next item into thebin which will leave the least room left over after the item is placed in the bin. If it does not fit in any bin, start a new bin.a) Give pseudo code and the running time for each of the approximation algorithms.b) Implementthe algorithmsin Python,C++ or C. Your program named binpackshould read in a text file named bin.txt with multiple test cases as explained below and output to the terminal the number of bins each algorithm calculated for each test case.Submit a README file and your programto TEACH.Example bin.txt: The first line is the number of test cases,followed by the capacity of bins for thattest case, the number of itemsand then the weight of each item. You can assume that the weight of an item does not exceed the capacity of a bin for that problem.31065 10 2 5 4 410204 4 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 61043 8 2 7Sample output:Test Case 1 First Fit: 4, First Fit Decreasing: 3, Best Fit: 4 Test Case 2First Fit: 15, First Fit Decreasing: 10, Best Fit:15Test Case 2 First Fit: 3, First Fit Decreasing: 2, Best Fit: 2c) Randomly generateat least 20 bin packing instances.Summarize the results for each algorithm. Which algorithm performs better? How often?Note: Submit a description of how the inputs were generated not the code used to produce the random inputs. CS 325-Homework Assignment 82Problem 2:(10 pts)An exact solution to the bin packing optimization problem can be found using 0-1 integer programming(IP)see the formaton the Wikipedia page. Write an integer programfor each of the following instances of bin packing and solve with the software of your choice. Submit a copy of the code and interpret the results.a)Six items S= { 4, 4, 4, 6, 6, 6} and bin capacity of 10b)Five items S = { 20, 10, 15, 10, 5} and bin capacity of 20Note: The version of LINDO that you have access to on the OSU server has a limit of 50 integer variables.Therefore, LINDO will only be able to solve problems with at most 6items.CS 325-Homework Assignment 82Problem 2:(10 pts)An exact solution to the bin packing optimization problem can be found using 0-1 integer programming(IP)see the formaton the Wikipedia page. Write an integer programfor each of the following instances of bin packing and solve with the software of your choice. Submit a copy of the code and interpret the results.a)Six items S= { 4, 4, 4, 6, 6, 6} and bin capacity of 10b)Five items S = { 20, 10, 15, 10, 5} and bin capacity of 20Note: The version of LINDO that you have access to on the OSU server has a limit of 50 integer variables.Therefore, LINDO will only be able to solve problems with at most 6items.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started