DOC PREVIEW
UF COP 3530 - Exam 2

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Exam 2maxLevel (40%)removeMin (74%)RemedyAlgorithm Design MethodsSome Methods Not CoveredOptimization ProblemMachine SchedulingBin PackingMin Cost Spanning TreeFeasible And Optimal SolutionsGreedy MethodContainer LoadingGreedy SolutionContainer Loading With 2 Ships0/1 Knapsack ProblemSlide 19Slide 20Slide 21Greedy Attempt 3Slide 250/1 Knapsack Greedy HeuristicsSlide 27Slide 28Exam 2•LZW not on syllabus.•73% / 75%maxLevel (40%)removeMin (74%)201062 815403025 35718Remedy•Lower the cutoffs.•Another test.•Best of two scores.•Options–Next Tu or Th.–Make up exam tonight, CSE 404.Algorithm Design Methods•Greedy method.•Divide and conquer.•Dynamic Programming.•Backtracking.•Branch and bound.Some Methods Not Covered•Linear Programming.•Integer Programming.•Simulated Annealing.•Neural Networks.•Genetic Algorithms.•Tabu Search.Optimization ProblemA problem in which some function (called the optimization or objective function) is to be optimized (usually minimized or maximized) subject to some constraints.Machine SchedulingFind a schedule that minimizes the finish time.optimization function … finish timeconstraints•each job is scheduled continuously on a single machine for an amount of time equal to its processing requirement•no machine processes more than one job at a timeBin PackingPack items into bins using the fewest number of bins.optimization function … number of binsconstraints•each item is packed into a single bin•the capacity of no bin is exceededMin Cost Spanning TreeFind a spanning tree that has minimum cost.optimization function … sum of edge costsconstraints•must select n-1edges of the given n vertex graph•the selected edges must form a treeFeasible And Optimal SolutionsA feasible solution is a solution that satisfies the constraints.An optimal solution is a feasible solution that optimizes the objective/optimization function.Greedy Method•Solve problem by making a sequence of decisions.•Decisions are made one by one in some order.•Each decision is made using a greedy criterion.•A decision, once made, is (usually) not changed later.Container Loading•Ship has capacity c.•m containers are available for loading.•Weight of container i is wi.•Each weight is a positive number.•Sum of container weights > c.•Load as many containers as is possible without sinking the ship.Greedy Solution•Load containers in increasing order of weight until we get to a container that doesn’t fit.•Does this greedy algorithm always load the maximum number of containers?•Yes. May be proved using a proof by induction (see text).Container Loading With 2 ShipsCan all containers be loaded into 2 ships whose capacity is c (each)?•Same as bin packing with 2 bins.Are 2 bins sufficient for all items?•Same as machine scheduling with 2 machines.Can all jobs be completed by 2 machines in c time units?•NP-hard.0/1 Knapsack Problem0/1 Knapsack Problem•Hiker wishes to take n items on a trip.•The weight of item i is wi. •The items are to be carried in a knapsack whose weight capacity is c.•When sum of item weights <= c, all n items can be carried in the knapsack.•When sum of item weights > c, some items must be left behind.•Which items should be taken/left?0/1 Knapsack Problem•Hiker assigns a profit/value pi to item i.•All weights and profits are positive numbers.•Hiker wants to select a subset of the n items to take.The weight of the subset should not exceed the capacity of the knapsack. (constraint)Cannot select a fraction of an item. (constraint)The profit/value of the subset is the sum of the profits of the selected items. (optimization function)The profit/value of the selected subset should be maximum. (optimization criterion)0/1 Knapsack ProblemLet xi = 1 when item i is selected and let xi = 0 when item i is not selected. i = 1npi ximaximizei = 1nwi xi <= csubject toand xi = 0 or 1 for all iGreedy Attempt 3Be greedy on profit density (p/w).Select items in decreasing order of profit density.n = 2, c = 7w = [1, 7]p = [10, 20]only item 1 is selectedprofit (value) of selection is 10not best selection!Greedy Attempt 3Be greedy on profit density (p/w).Works when selecting a fraction of an item is permittedSelect items in decreasing order of profit density, if next item doesn’t fit take a fraction so as to fill knapsack.n = 2, c = 7w = [1, 7]p = [10, 20]item 1 and 6/7 of item 2 are selected0/1 Knapsack Greedy Heuristics•Select a subset with <= k items.•If the weight of this subset is > c, discard the subset.•If the subset weight is <= c, fill as much of the remaining capacity as possible by being greedy on profit density.•Try all subsets with <= k items and select the one that yields maximum profit.0/1 Knapsack Greedy Heuristics•(best value - greedy value)/(best value) <= 1/(k+1)k 0% 1% 5% 10% 25%0 239 390 528 583 6001 360 527 598 6002 483 581 600Number of solutions (out of 600) within x% of best.Number of solutions (out of 600) within x% of best.0/1 Knapsack Greedy Heuristics•First sort into decreasing order of profit density.•There are O(nk) subsets with at most k items.•Trying a subset takes O(n) time.•Total time is O(nk+1) when k > 0.•(best value - greedy value)/(best value) <=


View Full Document

UF COP 3530 - Exam 2

Download Exam 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Exam 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Exam 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?