Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSIS-385 HW4: Optimal & Near-Optimal Algorithms for Knapsack & Bin Packing, Assignments of Algorithms and Programming

A university homework assignment for a computer science course, csis-385, where students are required to implement optimal brute-force and near-optimal greedy algorithms for the knapsack and bin packing problems. An overview of the problems, the deliverables, and the algorithm details. Students are expected to generate input files, run their programs, and test their solutions using provided input generators.

Typology: Assignments

Pre 2010

Uploaded on 08/09/2009

koofers-user-s1p
koofers-user-s1p 🇺🇸

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download CSIS-385 HW4: Optimal & Near-Optimal Algorithms for Knapsack & Bin Packing and more Assignments Algorithms and Programming in PDF only on Docsity! CSIS-385: Homework 4 (Big Project) This project can be completed in groups of size 3 or smaller. See schedule for due date. Deliverables will be described in two weeks. Overview: Implement 4 Algorithms: Implement Optimal Brute-Force algorithms for the Knapsack and Bin Packing Problems. Implement Near-Optimal Greedy algorithms for the Knapsack and Bin Packing Problems Knapsack Problem (not the continuous Knapsack problem): The sack can hold 100 lbs. You are given N items that each have a weight and a value. Your goal is to fill the sack with the most valuable subset of items. To solve this problem optimally requires considering all possible subsets 2N. Bin Packing Problem: You can buy an infinite number of suitcases (bins) that can each store 10 lbs worth of stuff. You are given N items where each item has a different weight. Your goal is to pack all N items using the minimum number of suitcases (bins). To solve this problem optimally requires consider all permutations N! Optimal Brute-Force Algorithms: These algorithms must consider all possibilities in order to find the optimal solution. For the Knapsack Problem, you have to generate all the subsets of N items. Some of the subsets won’t fit into the sack. For example, if items A and B each weigh 60 lbs. then you don’t have to consider any subset with both A and B. Depending upon the weights of items, you can find an optimal solution without considering all 2N subsets. Your optimal algorithm should be as efficient as possible. For the Bin Packing Problem, you have to generate all the permutations (orderings) of N items. One or more of the permutations are optimal, which means that if we pack items in this particular order then we will use the minimum number of suitcases. Some of the items may have the same weight, so you don’t have to consider all permutations. For example, if items A and B each weigh 2 lbs., then there is no difference between considering permutation {A, B} and {B, A}. In fact, each pair of items with identical weights cuts the number of permutations in half. Your optimal algorithm should be as efficient as possible. Near-Optimal Greedy Algorithms: Try to develop clever algorithms for solving the two problems. Rather than try all possibilities, these algorithms should take some greedy steps, i.e., decisions that are optimal at the time but may not lead to a final optimal solution. A general strategy is to take N greedy steps to generate a solution and then backtrack, i.e., make different decisions to try to improve the solution. Backtracking can take two forms: (1) undo a greedy decision and try the next best decision and (2) adjust or modify an existing solution incrementally if the solution can be improved. You should try several different variations, but you must submit your best algorithm for each of the two problems. Algorithm Details For the Knapsack Problem, your programs should input a file where each line represents an item: Item Number, Weight, and Value. 1 51 32 2 44 25 3 10 8 Your program should output a list of the items that were placed in the sack, their total weight (which should be close to 100 lbs.), and their total value. For the Bin Packing Problem, your program should input a file where each line represents an item: Item Number, Weight 1 5.3 2 1.2 3 2.33 4 9 1: {1,2,3} 8.83 2: {4} 9 Input Generators: To test your program, you should create random input generators for each problem. For the Knapsack Problem, the generator should make N/2 items with random weights and values between 0 and 50, and N/2 items with random weights and values between 0 and 20. The example has three items. Item 2 has a weight of 44 and a value of 25. The example has four times. Item 3 has a weight of 2.33. Your program should output a list of each bin, the items in each bin, and weight of each bin
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved