ADVANCED ALGORITHMS
LECTURE 8: GREEDY, LOCAL SEARCH
1
r
ADVANCED ALGORITHMS 2 LECTURE 8 ANNOUNCEMENTS Homework 2 out - - PowerPoint PPT Presentation
1 r LECTURE 8: GREEDY, LOCAL SEARCH ADVANCED ALGORITHMS 2 LECTURE 8 ANNOUNCEMENTS Homework 2 out Wednesday Friday Contacting the TAs: adv-algorithms-ta-fall18@googlegroups.com 3 LECTURE 8 LAST CLASS Greedy algorithm
LECTURE 8: GREEDY, LOCAL SEARCH
1
r
LECTURE 8
ANNOUNCEMENTS
▸ Homework 2 out Wednesday Friday ▸ Contacting the TAs: adv-algorithms-ta-fall18@googlegroups.com
2
LECTURE 8
LAST CLASS
3
▸ Greedy algorithm for minimum spanning tree ▸ Simple algorithm — add one edge at a time, add one vertex to
connected component
▸ Analysis tricky (see lecture notes) ▸ Meta argument — useful strategy to analyze greedy — inductively
prove that there exists an optimal solution that includes all greedy choices.
post
a link to Jeff Erickson's notes
Interval scheduling
LECTURE 8
MAXIMUM COVERAGE
4
Hiring problem: suppose we have n people, each with a set of skills from some universe {1,…,m}. Pick k people so as to maximize the total # of distinct skills
▸ Each person — set ▸ Want to maximize union of chosen sets Si ⊆ {1,2,…, m}
k
partofthe input
Gree.dz
thni
start
with person
with most
skills
f
update the value of r
7
all the others
vi
3
s
in
Max
valve 5 5
n
jrm
Repeat
times
LECTURE 8
GREEDY ALGORITHM — BUILDING A SOLUTION
5
Value of
i
number of elements in Si that
are not in
thesets chosen
so far
Say
we picked
5
K S
so far
valli
s U5331
Break
ties arbitrarily
LECTURE 8
OPTIMAL?
6
▸ {1,2,3}, {4}, {1,2,4}, {3,5}
S
S
53 Sg k
2
greedy
union has size _4
S
S
1
7
Sz
Sa
ri
LECTURE 8
CAN GREEDY BE REALLY BAD?
7
No
LECTURE 8
CAN GREEDY BE REALLY BAD?
8
value of optimal solution.
▸ Example of “approximation algorithm”
sizeof the union ofthechosen sets
I Ie
O63
Last class argument
F
an optimum soles
for
the
full problem
that
includes the choices we've made
so far
LECTURE 8
HOW TO PROVE THIS? WHAT ABOUT THE FIRST STEP?
9
Greedy
value ofsolution
yµ
Si
Y
Let the
union of the option
Y
sets
be denoted U
Sistax
f
Sik
Yj
Si Us u
us
claim
Claim
14,1
3
lutz
lute
Isr It
Israel
Say S
3
lutz
Choice of the greedy alg
isonly better
ie
Isi Is
Is't
1413
IYal
3
Claim
1
1 z ly l t
l U 141
animism
above but with
just the
RED portion
LECTURE 8
KEY OBSERVATION — CAN ALWAYS MAKE “PROGRESS”
10
I
tj
1
1314g.lt
l E
t
Hit f
114
LECTURE 8
INDUCTIVE CLAIM
11
IYj l
t.ly It t.lu I
stowed 1
Yjl
l t
lyj1
l
Ll told
1H
I I
1
Intuitively distance
1481 1 to lul drops
by atleast
afactor
A E
LECTURE 8
APPROXIMATION
12
I
14h13
l
I Ul
E
I E lul
t
LECTURE 8 13
Can we improve it?
LECTURE 8
EXAMPLE — MATCHING
14
Matching: suppose we have n children, n gifts and “happiness” values Hij. Assign gifts to children to maximize “total happiness”
▸ We saw: greedy does not give optimal cost
LECTURE 8
IMPROVING A SOLUTION
15
y
Check if
F children
i
j
such that
swapping the gifts
improves total
m
in
Heta
thn
LECTURE 8
WHAT IF WE CANNOT IMPROVE?
16
Children
Gifts
I
e
we
are at
a solution where
I
J
2
A i j
swapping gifts dadoes not
it
F
make the solution better
n
child i
fi
where4 is a
permutation
Hip
t Hj Pj 3
Hi pj
Hj ti
LECTURE 8
WHAT IF WE CANNOT IMPROVE?
17
least (1/2) * OPT
OPT
assignment
9
i 921
En
l
H p
1 Hap 1
Hmp
3 f H
Hag
1
t Hn g
LECTURE 8
APPROXIMATION
18
LECTURE 8
CLASSIC EXAMPLE — GRADIENT DESCENT
19 Warning: multivariate calculus coming up
D ⊆ ℝn
argminx∈D f(x)
LECTURE 8
LOCAL SEARCH
20
argminx∈D f(x)
LECTURE 8
LOCAL SEARCH
21
argminx∈D f(x)
▸ What is a good direction to move? ▸ Need domain D to be convex