The Greedy Method. Introduction. 0/1 Knapsack Problem



Similar documents
Generalizing the degree sequence problem

To Fill or not to Fill: The Gas Station Problem

Formulating & Solving Integer Problems Chapter

1 Example 1: Axis-aligned rectangles

PAS: A Packet Accounting System to Limit the Effects of DoS & DDoS. Debish Fesehaye & Klara Naherstedt University of Illinois-Urbana Champaign

Heuristic Static Load-Balancing Algorithm Applied to CESM

Feature selection for intrusion detection. Slobodan Petrović NISlab, Gjøvik University College

Luby s Alg. for Maximal Independent Sets using Pairwise Independence

An MILP model for planning of batch plants operating in a campaign-mode

1. Measuring association using correlation and regression

This circuit than can be reduced to a planar circuit

General Auction Mechanism for Search Advertising

J. Parallel Distrib. Comput.

Logical Development Of Vogel s Approximation Method (LD-VAM): An Approach To Find Basic Feasible Solution Of Transportation Problem

CS 2750 Machine Learning. Lecture 3. Density estimation. CS 2750 Machine Learning. Announcements

How To Calculate An Approxmaton Factor Of 1 1/E

Figure 1. Inventory Level vs. Time - EOQ Problem

The Development of Web Log Mining Based on Improve-K-Means Clustering Analysis

Project Networks With Mixed-Time Constraints

Availability-Based Path Selection and Network Vulnerability Assessment

What is Candidate Sampling

The OC Curve of Attribute Acceptance Plans

INSTITUT FÜR INFORMATIK

Module 2 LOSSLESS IMAGE COMPRESSION SYSTEMS. Version 2 ECE IIT, Kharagpur

Using Multi-objective Metaheuristics to Solve the Software Project Scheduling Problem

8.5 UNITARY AND HERMITIAN MATRICES. The conjugate transpose of a complex matrix A, denoted by A*, is given by

Joint Scheduling of Processing and Shuffle Phases in MapReduce Systems

Rate Monotonic (RM) Disadvantages of cyclic. TDDB47 Real Time Systems. Lecture 2: RM & EDF. Priority-based scheduling. States of a process

Examensarbete. Rotating Workforce Scheduling. Caroline Granfeldt

benefit is 2, paid if the policyholder dies within the year, and probability of death within the year is ).

PSYCHOLOGICAL RESEARCH (PYC 304-C) Lecture 12

AN APPOINTMENT ORDER OUTPATIENT SCHEDULING SYSTEM THAT IMPROVES OUTPATIENT EXPERIENCE

Support Vector Machines

Software project management with GAs

Descriptive Models. Cluster Analysis. Example. General Applications of Clustering. Examples of Clustering Applications

Institute of Informatics, Faculty of Business and Management, Brno University of Technology,Czech Republic

Enabling P2P One-view Multi-party Video Conferencing

2008/8. An integrated model for warehouse and inventory planning. Géraldine Strack and Yves Pochet

Real-Time Process Scheduling

POLYSA: A Polynomial Algorithm for Non-binary Constraint Satisfaction Problems with and

Sciences Shenyang, Shenyang, China.

Optimization of network mesh topologies and link capacities for congestion relief

On the Optimal Control of a Cascade of Hydro-Electric Power Stations

n + d + q = 24 and.05n +.1d +.25q = 2 { n + d + q = 24 (3) n + 2d + 5q = 40 (2)

v a 1 b 1 i, a 2 b 2 i,..., a n b n i.

Parallel greedy algorithms for packing unequal circles into a strip or a rectangle. Timo Kubach, Andreas Bortfeldt und Hermann Gehring

Ants Can Schedule Software Projects

SPEE Recommended Evaluation Practice #6 Definition of Decline Curve Parameters Background:

Forecasting the Direction and Strength of Stock Market Movement

A New Task Scheduling Algorithm Based on Improved Genetic Algorithm

DEFINING %COMPLETE IN MICROSOFT PROJECT

Chapter 4 ECONOMIC DISPATCH AND UNIT COMMITMENT

Method for Production Planning and Inventory Control in Oil

Calculation of Sampling Weights

Robust Design of Public Storage Warehouses. Yeming (Yale) Gong EMLYON Business School

Mining Multiple Large Data Sources

How To Solve An Onlne Control Polcy On A Vrtualzed Data Center

Research Article Enhanced Two-Step Method via Relaxed Order of α-satisfactory Degrees for Fuzzy Multiobjective Optimization

Application of Multi-Agents for Fault Detection and Reconfiguration of Power Distribution Systems

Activity Scheduling for Cost-Time Investment Optimization in Project Management

Optimal Joint Replenishment, Delivery and Inventory Management Policies for Perishable Products

Network Aware Load-Balancing via Parallel VM Migration for Data Centers

A multi-start local search heuristic for ship scheduling a computational study

Inventory Rebalancing and Vehicle Routing in Bike Sharing Systems

Logistic Regression. Lecture 4: More classifiers and classes. Logistic regression. Adaboost. Optimization. Multiple class classification

Power-of-Two Policies for Single- Warehouse Multi-Retailer Inventory Systems with Order Frequency Discounts

Linear Circuits Analysis. Superposition, Thevenin /Norton Equivalent circuits

Sngle Snk Buy at Bulk Problem and the Access Network

Extending Probabilistic Dynamic Epistemic Logic

The Retail Planning Problem Under Demand Uncertainty

Solution: Let i = 10% and d = 5%. By definition, the respective forces of interest on funds A and B are. i 1 + it. S A (t) = d (1 dt) 2 1. = d 1 dt.

Schedulability Bound of Weighted Round Robin Schedulers for Hard Real-Time Systems

CHOLESTEROL REFERENCE METHOD LABORATORY NETWORK. Sample Stability Protocol

Preventive Maintenance and Replacement Scheduling: Models and Algorithms

Many e-tailers providing attended home delivery, especially e-grocers, offer narrow delivery time slots to

8 Algorithm for Binary Searching in Trees

Credit Limit Optimization (CLO) for Credit Cards

1. Fundamentals of probability theory 2. Emergence of communication traffic 3. Stochastic & Markovian Processes (SP & MP)

A Binary Particle Swarm Optimization Algorithm for Lot Sizing Problem

Proceedings of the Annual Meeting of the American Statistical Association, August 5-9, 2001

A DYNAMIC CRASHING METHOD FOR PROJECT MANAGEMENT USING SIMULATION-BASED OPTIMIZATION. Michael E. Kuhl Radhamés A. Tolentino-Peña

Feasibility of Using Discriminate Pricing Schemes for Energy Trading in Smart Grid

Allocating Collaborative Profit in Less-than-Truckload Carrier Alliance

DISSERTATION. Titel der Dissertation. Facility Location and Related Problems. Verfasser. Dipl.-Ing. Martin Romauch. angestrebter akademischer Grad

Finite Math Chapter 10: Study Guide and Solution to Problems

A Simple Approach to Clustering in Excel

Transcription:

The Greedy Method Introducton We have completed data structures. We now are gong to look at algorthm desgn methods. Often we are lookng at optmzaton problems whose performance s exponental. For an optmzaton problem, we are gven a set of constrants and an optmzaton functon. o Solutons that satsfy the constrants are called feasble solutons. o A feasble soluton for whch the optmzaton functon has the best possble value s called an optmal soluton. Cheapest lunch possble: Works by gettng the cheapest meat, frut, vegetable, etc. In a greedy method we attempt to construct an optmal soluton n stages. o At each stage we make a decson that appears to be the best (under some crteron) at the tme. o A decson made at one stage s not changed n a later stage, so each decson should assure feasblty. Consder gettng the best major: What s best now, may be worst later. Consder change makng: Gven a con system and an amount to make change for, we want mnmal number of cons. o A greedy crteron could be, at each stage ncrease the total amount of change constructed as much as possble. In other words, always pck the con wth the greatest value at every step. o A greedy soluton s optmal for some change systems. Machne schedulng: o Have a number of jobs to be done on a mnmum number of machnes. Each job has a start and end tme. o Order jobs by start tme. o If an old machne becomes avalable by the start tme of the task to be assgned, assgn the task to ths machne; f not assgn t to a new machne. o Ths s an optmal soluton. Note that our Huffman tree algorthm s an example of a greedy algorthm: o Pck least weght trees to combne. Heurstc we are not wllng to take the tme to get an optmal soluton, but we can be satsfed wth a pretty good soluton. 0/1 Knapsack Problem Problem descrpton: o Pack a knapsack wth a capacty of c. The Greedy Method Page 1

o From a lst of n tems, we must select the tems that are to be packed n the knapsack. o Each object has a weght of w and a proft of p. In a feasble knapsack packng, the sum of the weghts packed does not exceed the knapsack capacty. n An optmal packng s a feasble one wth maxmum proft p x subject to the constrants w x c n = 1 and { 0,1}, 1 n x o We are to fnd the values of x where x = 1 f object s packed nto the knapsack and x = 0 f object s not packed. Greedy strateges for ths problem: o From the remanng objects, select the object wth maxmum proft that fts nto the knapsack. o From the remanng objects, select the one that has mnmum weght and also fts nto the knapsack. o From the remanng objects, select the one wth maxmum p / w that fts nto the knapsack. Consder a knapsack nstance where n = 4, w = [ 2, 4,6,7], p = [ 6,10,12,13], and c = 11. o Look at the above three strateges. None of the above algorthms can guarantee the optmal soluton. o Ths s not surprsng snce ths problem s a NP-hard problem. Of the above three algorthms, the thrd one s probably the best heurstc. = 1 Topologcal Orderng Greedy crtera for the unnumbered nodes, assgn a number to a node for whch all predecessors have been numbered. Algorthm Intally, for each node wth predecessor count of zero, put t n a contaner (stack, queue, anythng wll do). 1. Remove a node wth predecessor count of zero from the contaner, number t, then lst t. 2. For each successor, decrement ts predecessor count. 3. If a successor now has a predecessor count of zero, add t to the contaner. Complexty assume an adjacency lst. 1. Fnd predecessor count. Ο (e), where e s number of edges. 2. Lst node for each successor, update predecessor count. Ο ( e + n), snce f have lots of nodes wth no predecessors, n could be more than e. Matchngs and Coverngs n a Graph The Greedy Method Page 2

Matchng a set of edges, no two of whch have a vertex n common. A perfect match s one n whch all vertces are matched. A maxmum matchng s matchng that cannot be extended by the addton of an edge. For an example see Fgure 1. Fgure 1 Matchng Many problems that seem unrelated to matchng can be formulated ths way. Edge coverng fnd mnmum number of edges (not necessarly ndependent) to cover (touch) all vertces. Stable marrage problem we want to fnd a matchng such that there exsts no stuaton n whch two ndvduals would rather be matched wth each other than the people they are currently matched wth. Bpartte Cover Bpartte graph (two parts) two ndependent sets of vertces such that all edges are between elements of dfferent sets. Complete bpartte every vertex of one set s adjacent to every vertex of second set. Examples of bpartte graphs: o Would-work-for graph n whch one set of nodes s jobs and another set s employees. o Want to marry (n Utah) where the node sets are men and women. Cover a subset A' of the set A s sad to cover the set B ff every vertex n B s connected to at least one vertex of A'. o Sze of the cover the number of vertces n A'. o Mnmum cover there s no smaller subset of A that covers B. Bpartte cover gven two types of nodes X and Y, X' s a node cover f X' s a subset of X such that every node n Y s connected to a node n X' va an edge. We want the cover of the mnmum sze. The Greedy Method Page 3

A coverng for Fgure 2 s {1, 2, 3, 17}. Show the mnmum cover for the bpartte graph shown n Fgure 2. o The cover s {1, 16, 17}. Fgure 2 Bpartte Graph Examples: o Suppose you have a set of nterpreters and a set of languages that need to be nterpreted. Edges represent can nterpret. We want to fnd the mnmal number of nterpreters to hre so that you can nterpret all languages. o Set of people and a set of categores (male, Asan, CS major, sngle,...). We want to form a commttee wth representaton from all groups. Set cover gven a collecton of subsets, fnd a mnmum number of subsets such that ther unon s the unverse. o Can you see how to map ths problem to the bpartte cover problem? Nodes for each subset. Nodes for each element. Edges represent contans. Ths ablty to map one problem nto another s key to usng knowledge of algorthms communty. Ths s lkely the reason why I always try to fnd smlartes between thngs that seem dfferent (e.g., cleanng up for company). NP-hard no one has developed a polynomal tme algorthm. o Also called ntractable or exponental. o We use greedy algorthms to approxmate. Greedy crteron Select the vertex of A that covers the largest number of uncovered vertces of B. Also keep a Boolean array that tells whether each node s covered or not. o Ths dea could be mplemented va a max tournament tree of wllcover take the bggest. Shortest Paths Gven a dgraph wth each edge n the graph havng a nonnegatve cost (or length). Try to fnd the shortest paths (n a dgraph) from a node to all other nodes. Greedy crteron From the vertces to whch the shortest path has not been generated, select one that results n the least path length (the smallest one). Have a reached set of nodes and an unreached set of nodes. 1. Intally, only the start node s reached. The Greedy Method Page 4

2. Use a mn prorty queue to store the total path lengths of each of the reached nodes to ts successors. 3. Whle prorty queue s not empty Pck the shortest total length node. If t has already been reached, dscard. Else count t as reached. Enqueue the total path lengths of each of the reached nodes to ts successors. For example, consder the dgraph Fgure 3 n and calculate the shortest path. Fgure 3 Shortest Path Mnmal Spannng Trees Problem select a subset of the edges such that a spannng tree s formed and the weght of the edges s mnmal. Example need to connect all stes to sewer system - want to mnmze the amount of ppe. Consder the spannng tree shown n Fgure 4. Fgure 4 Spannng Tree Prm s algorthm o Greedy crteron From the remanng edges, select a least-cost edge whose addton to the set of selected edges forms a tree. Tree set of vertces already n MST Succ set of vertces not n Tree but n Succ[Tree] Place any vertex (to serve as root) n MST. The Greedy Method Page 5

1. Fnd the smallest edge that connects Tree wth Succ 2. Add the edge to the MST and update Tree and Succ Uses a greedy method obtan a globally optmal soluton by means of a locally optmal soluton. Usng Fgure 4 and Prm s algorthm, we add the edges n the followng order: (1,6), (6,5), (5,4), (4,3), (3,2), and (2, 7). How do we fnd smallest edge? (sort or prorty queue) Kruskal s algorthm o Greedy crteron From the remanng edges, select a least-cost edge that does not result n a cycle when added to the set of already selected edges. Let each vertex be a separate component. 1. Examne each edge n ncreasng order of cost. 2. If edge connects vertces n same component, dscard t. Otherwse, add edge to MST. Update components. Usng Fgure 4 and Kruskal s algorthm, we add the edges n the followng order: (1,6), (3,4), (2,7), (2,3), (4,5), and (5,6). How do we fnd smallest edge? (sort or prorty queue) More Traversals of a Graph or Dgraph Tour vst each vertex n a graph exactly once and fnsh at the vertex started from. Euleran tour fnd a path/tour through the graph such that every edge s vsted exactly once. (Easy check nodal degree; f all are even, t s possble.) Hamltonan tour fnd a path through the graph such that every vertex s vsted exactly once. (NP complete) See Fgure 5 for dfferent tours. Fgure 5 Dfferent Tours The Greedy Method Page 6