5 views

Uploaded by akg299

Greedy Programming

- AOR (Lecture 1) Part 1-1
- Chap 2-Graphical Methods
- Basics of Or
- Lp Intro
- Lecture 12
- Exam Solution
- Course 8th Sem
- Brook Moldoveanu April16
- Optimal Choice
- 67439_optimisasi Di Industri Migas Slides by Ss_sdr_01112017
- 2013 - 06473863 - Probabilistic Spinning Reserve Provision Model in Multi-Control Zone Power System
- 5r1simulatedannealing
- Content
- Bio-Inspired Techniques to Telecommunication
- elenco_abil
- 119495-329703-1-SM
- 03 - Engineering Teams (1)
- Operation Research Question Paper
- Development and Application of a Hybrid Genetic Algorithm for Resource Optimization and Management
- Basics of Afp Optimizer

You are on page 1of 35

Deliverables

Greedy Paradigm

Interval Scheduling

Huffman compression

Minimizing Lateness

Greedy paradigm

Primarily used in Optimization problems to find

the maximum or minimum value satisfying

given constraints.

a sequence of steps (piecewise) where each step

is considered a partial solution, which is

extended progressively to get complete solution.

Choice of steps

Choice of each step in greedy is based on following

It must be feasible

It must be irrevocable

5 Pillars of Greedy Technique

Proof of correctness is necessary and important.

1. A candidate set, from which a solution is created

2. A selection function, which chooses the best candidate to be

added to the solution

3. A feasibility function that is used to determine if a candidate

can be used to contribute to a solution

4. An objective function, which assigns a value to a solution, or

a partial solution, and

5. A solution function, which will indicate when we have

discovered a complete solution

General Greedy Algorithm

a[1:n]; sol ;

for i 1 to n do

x SELECT(a); //as per some optimization criteria

if FEASIBLE(sol, x) then solution UNION(sol, x);

return sol

feasibility criteria and Union integrates the element x in the

solution

Coin Change Problem

An amount and collection of coins to reach to that amount Objective is to

minimize the number of coins

Greedy theory says always return the largest coin

if coins are of denomination 32, 8, 1 it has the greedy choice property because

no amount over 32 can be made without omitting 32.

property because 40 can be made with two 20 coins but it returns 30,5,5 coins

Similarly if denominations are 1, 10, 21, 34, 70, 100, 350 140 Greedy: 100, 34,

1, 1, 1, 1, 1, 1 Optimal: 70, 70

Interval Scheduling Problem

Given set S = {a1, , an} of activities and activity start and

finish times, e.g.

i 1 2 3 4 5 6 7 8 9 10 11

si 1 3 0 5 3 5 6 8 8 2 12

fi 4 5 6 7 8 9 10 11 12 13 14

Activities are compatible if their time intervals do not

overlap, i.e., ai is compatible with aj is si fj or sj fi.

To find Subset of non overlapping intervals so that number

of intervals are maximum.

6/7/2012 8:57 PM Copyright @ gdeepak.Com 8

Earliest Start Time

Shortest interval First

Fewest Conflicts First

Interval Scheduling Algorithm

Interval that ends first and remove the intervals that

overlap with these and recurse.

Sort jobs by finish times so that f1 f2 ... fn.

A

for j = 1 to n

{

if (job j compatible with A)

A A {j}

}

return A

Efficient greedy algorithm

Once youve identified a reasonable greedy heuristic:

Prove that it always gives the correct answer

Develop an efficient solution

Is our greedy approach correct?

Stays ahead argument: show that no matter what other

solution someone provides you, the solution provided by

your algorithm always stays ahead, in that no other

choice could do better

Is our greedy approach correct?

Stays ahead argument

Let r1, r2, r3, , rk be the solution found by our approach

r1 r2 r3

rk

Let o1, o2, o3, , ok of another optimal solution

o1 o2 o3

ok

Show our approach stays ahead of any other solution

Stays ahead

r1 r2 r3

rk

o1 o2 o3

ok

Stays ahead

r1 r2 r3

rk

o1 o2 o3

ok

finish(r1) finish(o1)

Stays ahead

r2 r3

rk

o2 o3

ok

remaining 2k tasks

Optimal Merge Sort

Suppose there are 3 sorted lists L1, L2, and L3, of sizes 30, 20, and 10,

respectively, which need to be merged into a combined sorted list but

we can merge only two at a time.

We intend to find an optimal merge pattern which minimizes the total

number of comparisons.

Merge L1 & L2,: 30 + 20 = 50 comparisons , then merge the list & L3:

50 + 10 = 60 comparisons total number of comparisons: 50 + 60 = 110.

list (size 30) then merge the list with L1: 30 + 30 = 60 total number of

comparisons: 30 + 60 = 90.

Merge sort example

Huffman Compression

File f has one million characters. If only a, b, c, d, e, f chars come in the file then the

total size of the file is 8 million bits

If we represent these with 000 001 010 011 101 111 then only 3 million bits

0 1 00 11 10 11 will give us less then 2 million bits

leaves of the binary tree will represent the bit strings

It will give us the prefix free code. use greedy for making the binary tree and then

assign 0 to every left node and 1 to every right node. The nodes with larger frequency

will be nearer to the root and with lesser frequency will be towards the leaves.

Huffman Example

Knapsack

Given n objects and a knapsack. Object i has weight wi and the

knapsack has a capacity M.

then a profit of pixi is earned. The objective is to obtain a filling of

the knapsack that maximizes the total profit earned.

should be M. The profits and weights are positive

Partial Knapsack-Greedy

0/1 knapsack

1st is optimal but greedy will give 2nd solution

Algorithm for partial knapsack

Input Set S of items with weight wi , benefit bi and total weight W

Output amount xi of each item i to maximize benefit with weight

W for each item i in S

xi=0

vi=bi/wi

w=0

while w<W

remove item i with highest vi

xi=min(wi, W-w)

w=w+min(wi, W-w)

Job deadlines

Single resource processes one job at a time.

Job j requires tj units of processing time and is due at time dj.

If j starts at time sj, it finishes at time fj = sj + tj.

Lateness: lj = max { 0, fj - dj }.

Goal: Schedule all jobs to minimize maximum lateness

L=max lj.

1 2 3 4 5 6

tj 3 2 1 4 3 2

dj 6 8 9 9 14 15

6/7/2012 8:57 PM Copyright @ gdeepak.Com 27

Minimizing lateness

Consider jobs in ascending order of processing time tj

1 2

tj 1 10

dj 100 10

Consider jobs in ascending order of slack dj - tj

1 2

tj 1 10

dj 2 10

Minimizing Lateness

T 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

J 1 1 1 2 2 3 4 4 4 4 5 5 5 6 6

D 6 6 6 8 8 9 9 9 9 9L 14 14 14 15 15

Single Job-Single resource

There is no preemption and these have to be allocated

processor. Only one processor is available. Objective is to

minimize the sum of the finishing times

f1=t1

f2=t1+t2

fi=t1+t2++ti

:

fn=nt1+(n-1)t2++tn

So t1 should be smallest and so on

Questions, Suggestions and Comments

Question 1

Greedy Approach the shortest path is

A) 9

B) 23

C) 5

D) 17

Question 2

Greedy Technique is related to the theory of

A) Calculus

B) Probability

C) Matroid

D) Algebra

Question 3

For those problems where Greedy gives the optimal

solution, the complexity is better as compared to the

implementation of the same problem with Dynamic

Programming.

A) True

B) False

??

Given a question, Can you find whether greedy strategy

work in general is NP-Complete.

- AOR (Lecture 1) Part 1-1Uploaded bysyed
- Chap 2-Graphical MethodsUploaded byJas Rosy
- Basics of OrUploaded byhimanshu_ymca01
- Lp IntroUploaded byBishwajit Chowdhury
- Lecture 12Uploaded bypradeep_nayak43
- Exam SolutionUploaded byMohammed Abushammala
- Course 8th SemUploaded byArthyParthasarathy
- Brook Moldoveanu April16Uploaded bymicamo4711
- Optimal ChoiceUploaded byDaniel Chiqui Castañeda
- 67439_optimisasi Di Industri Migas Slides by Ss_sdr_01112017Uploaded byRay Yuda
- 2013 - 06473863 - Probabilistic Spinning Reserve Provision Model in Multi-Control Zone Power SystemUploaded byElmonster10
- 5r1simulatedannealingUploaded byAchmad P. Rifai
- ContentUploaded bykunalc-1
- Bio-Inspired Techniques to TelecommunicationUploaded bySnigdha Patnaik
- elenco_abilUploaded byaskafjwpij98u
- 119495-329703-1-SMUploaded byTuvshuu Tsevegmid
- 03 - Engineering Teams (1)Uploaded byWeiwei Zhao
- Operation Research Question PaperUploaded byDrNavleen Kaur
- Development and Application of a Hybrid Genetic Algorithm for Resource Optimization and ManagementUploaded bymanique_abeyrat2469
- Basics of Afp OptimizerUploaded byanon_743966179
- 00119248Uploaded bysudhialamanda
- [9]ImprovingCustomerServiceOperationsatAmazonUploaded byssanchet1981
- ENSAYOS EXPERIMENTALES DE IDENTIFICACIÓN MODAL PARA LA PROTECCIÓN SISMICA DEL PATRIMONIO HISTÓRICO DE TIERRAUploaded byzerlopez
- ISKE2007 Ma XiaokeUploaded byManish Agarwal
- energies-08-11380Uploaded bykaifee2121
- Neutrosophic Sets and Systems, vol. 15/ 2017. JournalUploaded byMia Amalia
- Screening Location Strategies LoweUploaded byiruiz85
- DirectAlgoUploaded bygaurav_lboro
- Absil_Bib.pdfUploaded bymarcus1818
- A Framework for Automatic CMOS OpAmp SizingUploaded byRagini Kumari

- g Cp CommandsUploaded byakg299
- Logistics E CommerceUploaded byPrateek Vyas
- Report 4Uploaded byakg299
- 17-Article Text-50-1-10-20180621Uploaded byakg299
- Bossy PantsUploaded byakg299
- Report 2Uploaded byakg299
- Image CaptionTemplate ReportUploaded byakg299
- Image Captioning TRUploaded byakg299
- Age Declaration FormUploaded bysushil.singh.c
- Image Captioning TRUploaded byakg299
- Ucs742 AssignmentUploaded byakg299
- SlidesUploaded byakg299
- Report 3Uploaded byakg299
- PosterUploaded byakg299
- Bench Match FrameUploaded byakg299
- Srs TemplateUploaded byakg299
- Class DiagramUploaded byakg299
- Linked List GfgUploaded byakg299
- Gfg Array Questions ImportantUploaded byakg299
- Technology Analyst.pdfUploaded byakg299
- top interview questions.txtUploaded byakg299
- Business Operations Associate.pdfUploaded byakg299
- Image Caption Technical ReportUploaded byakg299
- ZS Campus Name 2018 Student DataUploaded byakg299
- Array ClassificationUploaded byakg299
- readme.txtUploaded byAyrton Wagner
- AMCAT Test SyllabusUploaded byHarsha Nihanth
- Array Classification (Autosaved)Uploaded byakg299
- Readme.docxUploaded byakg299
- Capstone GanttUploaded byakg299

- A Study on Neutrosophic Cubic Graphs with Real Life Applications in IndustriesUploaded byAnonymous 0U9j6BLllB
- Holtrop & Mennen - An Approximate Power Prediction MethodUploaded byjimmyy90
- Types for Dyadic InteractionUploaded byprimeentelechy1844
- logic 11-14Uploaded bynomercykilling
- In1K-SS-C38987Uploaded bydanifrujina
- GD T Wall Chart TabloidUploaded byLuis Angel Martinez Soto
- 21Uploaded byVivek Srivastav
- Cubical Homology in Digital ImagesUploaded bySEP-Publisher
- Week 1.pdfUploaded byAiman Alammari
- Rushton ImpellerUploaded bylinda
- 481552Uploaded byAn Zamb
- MP 94Sp Interval-Class Content in Equally Tempered Pitch-Class Sets - Common Scales Exhibit optimum Tonal Consonance.pdfUploaded byFabian Moss
- All Single SlitUploaded byMahtab Alam
- gditechnology-151220144934Uploaded bybharath kishore reddy
- StringUploaded byUmair Adil
- 5 S1 ProbabilityUploaded byArvin Taylor
- Curriculum 2013 MTech VLSIUploaded byVenkat Ramanan
- 5 IJAEST Volume No 1 Issue No 1 Analysis of ion Buckling and Post Buckling of Composite Structure by Generalized Differential Quadrature Method (GDQM)Uploaded byiserp
- UAV Over-The-Horizon Disaster Management Demonstration ProjectsUploaded bydrober
- MIT18 05S14 Prac Exam1aUploaded byPoonam Naidu
- Lecture 2Uploaded byBarış Biçer
- Gas_Liquids Separators—Quantifying Separation Performance—Part 2Uploaded byMubarik Ali
- Physical Electronics Slides of Chapter 7 All SlidesUploaded byLina Al-Saleh
- Alshehri Naeem Spring 2010 -Quantification of Reservoir Uncertainty for Optimal Decision MakingUploaded byWladimir Rondan
- Kwok Et Al-1999-Journal of Polymer Science Part B Polymer PhysicsUploaded byAyyanna Habal
- Fact Sheet Functional AnalysisUploaded byPete Jacopo Belbo Caya
- Vehicle License Plate Recognition SystemUploaded bydips032
- Horizontal Curve FormulaeUploaded byKevin Co Obligado
- 14 Algorithm 832_ UMFPACK V4 3-an unsymmetric-pattern multifrontal method.pdfUploaded byMaritza L M Capristano
- Centrifugal Pump Alfred FranklinUploaded byAlfred Franklin V