Problem 1 §
Algorithm is one that assigns every one element to the set with the smaller sum.
(a) §
- We first establish that the cost of the algorithm ALG=∑x∈Sx where S is the bigger one of A,B.
- let X={x1…xn} where xi is the i-th processed element by ALG.
- ALG=∑x∈Sx−xj+xj where xj is the last item added to set S
- ! Looking at the first term, we can establish ∑x∈Sx−xj≤21(∑i<jxi)……(1)
- i.e. Sum in S before xj≤Average of total before xj
- We know this because Sum in S before xj is the smaller sum of A,B, and thus the average is bigger than the minimum of the two.
- Then we also establish ∑i<jxi≤∑i<jxi+∑i>jxi=∑x∈Xx−xj
- i.e. Sum before xi ≤ sum before xj and sum after xj = total sum excluding xj
- ! This implies 21∑i<jxi≤21(∑x∈Xx−xj)…….(2)
- & (1) and (2) together shows ∑x∈Sx−xj≤21(∑x∈Xx−xj)=21∑x−21xj……(3)
- We thus show ALG≤21∑x−21xj+xj=21∑x+21xj……(4)
- We know from the lecture (makespan, lemma 1 and 2) that 21∑x≤OPT and xj≤OPT
- first, because optimal solution cannot be smaller than the total / 2
- second, because optimal solution cannot be smaller than any element
-
- Thus we establish ALG≤OPT+21OPT=23OPT
- Thus proven
(b) §
- We first investigate the trivial cases when X has repectively 1,2 and 3 elements
- Case n=1
- OPT=x1, ALG=x1 thus α=1
- Case n=2
- OPT=max[x1,x2], ALG=max[x1,x2] thus α=1
- We then investigate the case when n≥3
- As we also know that x1>x2>x3>⋯>xn in the order of assignment by ALG, we can state both that:
- ix1+⋯+xi≥xi thus x1+⋯+xi≥ixi……(1)
- xj≥n−jxi+1+⋯+xn thus xj≥xi+1+⋯+xn……(2)
- (1)−(2) yields ∑k=1…ixk−xj≥
Problem 2 §
Code §
Results §
Problem 3 §
Results §
Number of Clusters | Initialization | Runtime | Quality |
---|
2 | random | 0.09817 | 2.26508 |
2 | k-means++ | 0.09790 | 2.26508 |
4 | random | 0.15675 | 0.77163 |
4 | k-means++ | 0.15921 | 0.72164 |
6 | random | 0.20530 | 0.39536 |
6 | k-means++ | 0.21513 | 0.35047 |
8 | random | 0.26586 | 0.23331 |
8 | k-means++ | 0.28957 | 0.20059 |