Académique Documents
Professionnel Documents
Culture Documents
(remplissage de sacs)
Johanne Cohen
Johanne.Cohen@loria.fr
Laboratoire LORIA
1. Présentation du problème.
3. Inapproximation.
R EMARQUE :
Problème de décision 6= problème de construction.
x ∈ YP b1 ssi f (x) ∈ YP b2
2
Le problème du Bin Packing(remplissage de sacs) – p.11/65
Complexité
Théorème 1: Le problème du bin Packing est NP-complet.
Preuve:
B=S
∀s ∈ S, w(s) = W(s)
F (S, W) = P
W(s)
c= s∈S
2
k=2
2
Le problème du Bin Packing(remplissage de sacs) – p.11/65
Illustration de la transformation
a2 a3 a5
S2 = {a2 , a3 , a5 }
1. Présentation du problème.
3. Inapproximation.
• DΠ : un ensemble d’instances.
• SΠ (I): un ensemble fini non-vide de solutions pour
chaque instance I de DΠ
• une fonction d’évaluation mΠ
Pour chaque instance I de DΠ , et pour chaque
candidat σ ∈ SΠ (I) :
mΠ (I, σ) est la valeur de la solution (un rationnel).
A(I)
Le rapport d’un algorithme A est RA (I) = OP TΠ (I) .
RA = inf {r ≥ 1 : RA (I) ≤ r, ∀I ∈ DΠ }
1. j = 1
2. Pour i allant de 1 à n faire
(a) Si bi peut être mis dans Sj , Sj ← Sj ∪ {bi }
(b) Sinon
i. j ← j + 1
ii. Sj ← {bi }
3. retourner j
Le problème du Bin Packing(remplissage de sacs) – p.18/65
Illustration de l’algo. Next Fit.
1boite de cap 1
1 boite de cap α
2α sacs
Le problème du Bin Packing(remplissage de sacs) – p.19/65
Facteur d’approximation de l’algo. Next Fit
Théorème 2:L’algorithme Next Fit retourne une solution à un
facteur 2 de l’optimal.
Preuve:
P
Notons β = b∈B w(b) et k la valeur retournée par l’algo.
OP T ≥ β/c
Considérons i tel que bi ∈ Sj et bi+1 ∈ Sj+1
il existe α tel que α ≤ ` ≤ i, b` ∈ Sj
Pi Pi+1
`=α w(b) ≤ c et c < `=α w(b) ≤ 2c
Pi+1
Globalement, kc < 2 `=α w(b) donc k ≤ 2β/c ≤ 2OP T
S2 b2 b4
S3 b5 b6
k=1
S2 b2 b4
S3 b5 b6
k=1
S2 b2 b4
S3 b5 b6
k=2
S2 b2 b4
S3 b5 b6
k=2
S2 b2 b4
S3 b5 b6
k=3
S2 b2 b4
S3 b5 b6
k=3
R EMARQUE
Pn
Proposition 1: OP T ≥ ( i=1 w(bi ))/c.
Car la borne inférieure correspond à une solution où tous
les sacs sont pleins.
S2 b2
S3 b4
S1 b1
S2 b2
S3 b3
1 élément par sac.
E XEMPLE : c = 10, w(b1 ) = 8, w(b2 ) = 7, w(b3 ) = 5, w(b4 ) = 5
2
Le problème du Bin Packing(remplissage de sacs) – p.24/65
Facteur d’approximation
Théorème 3: L’algorithme First Fit Decreasing retourne une
solution à un facteur 2 de l’optimal.
Preuve:
C AS 1 O Ù w(bn ) ≥ c/2: l’algorithme glouton est optimal.
S1 b1
S2 b2
S3 b3
Au plus 2 éléments par sac.
E XEMPLE : c = 10, w(b1 ) = 8, w(b2 ) = 7, w(b3 ) = 5, w(b4 ) = 5
2
Le problème du Bin Packing(remplissage de sacs) – p.24/65
Facteur d’approximation
Théorème 3: L’algorithme First Fit Decreasing retourne une
solution à un facteur 2 de l’optimal.
Preuve:
C AS 1 O Ù w(bn ) ≥ c/2: l’algorithme glouton est optimal.
S1 b1
S2 b2
S3 b3 b4
Au plus 2 éléments par sac.
E XEMPLE : c = 10, w(b1 ) = 8, w(b2 ) = 7, w(b3 ) = 5, w(b4 ) = 5
2
Le problème du Bin Packing(remplissage de sacs) – p.24/65
Suite de la preuve.
Théorème 3: L’algorithme First Fit Decreasing retourne une
solution à un facteur 2 de l’optimal.
C AS 2 O Ù w(bn ) < c/2:
Soit bj la boite pour laquelle le sac k a été crée.
a1 a6 a2 a6 a4
a4 a3 a5 a5 a1 a2
a3
a1 a6 a2 a6 a4
a4 a3 a5 a5 a1 a2
a3
w(a ) = 4
Plan
1. Présentation du problème.
3. Inapproximation.
0 f(x) α (|x|)f(x)
0 f(x) α (|x|)f(x)
1. I 0 = F (I)
2. Appliquer l’algo. A sur l’instance I 0 .
3. Si le nombre de sacs est ≥ 3, retourner faux,
4. sinon, retourner vrai.
Complexité: ?
1. I 0 = F (I)
2. Appliquer l’algo. A sur l’instance I 0 .
3. Si le nombre de sacs est ≥ 3, retourner faux,
4. sinon, retourner vrai.
1. I 0 = F (I)
2. Appliquer l’algo. A sur l’instance I 0 .
3. Si le nombre de sacs est ≥ 3, retourner faux,
4. sinon, retourner vrai.
Complexité: polynomiale
2
Le problème du Bin Packing(remplissage de sacs) – p.37/65
Résultat d’inapproximabilité.
Théorème 3: Si P 6= N P , il n’existe pas d’algorithme
polynomiale d’approximation pour le problème Bin Packing
ayant un rapport inferieure à 3/2 − .
Preuve: par l’absurde.
1. Présentation du problème.
3. Inapproximation.
T [i − 1, w1 − w(bi ), w2 ] = V
T [i, w1 , w2 ] = V ssi
ou T [i − 1, w1 , w2 − w(bi )] = V
Le problème du Bin Packing(remplissage de sacs) – p.41/65
Algo. résouvant le prob. Bin packing (k = 2
Représentation
décimal 13
binaire 1011
unaire
1. Présentation du problème.
3. Inapproximation.
5. Divers.
Instance I Instance J
x=((9,9,8,7,6,6,5,4,3,3,3),12) x g=((7,7,7,5,5,5,3,3),12)
9 3 7
9 3 7
7 3 5
8 4 7 3
5 3
6 6 5 5
Le problème du Bin Packing(remplissage de sacs) – p.58/65
Comparaison entre l’optimal de I et de J.
1. Chaque rangement de I peut être remplacé par un
rangement de J :
m∗ (J) ≤ m∗ (I)
Instance J Instance I
x g=((7,7,7,5,5,5,3,3),12) x=((9,9,8,7,6,6,5,4,3,3,3),12)
7 5 6 3
7 5 7 4
5 3 5 3
7 3 7 3
9
8
9
Le problème du Bin Packing(remplissage de sacs) – p.58/65
Comparaison entre l’optimal de I et de J.
Donc:
∗ ∗ ∗
m (J) ≤ m (I) ≤ m (J) + α
0 1
(M + M ) ≤ m∗ (I) + 1 ≤ (1 + 2δ)m∗ (I) + 1
1−δ
1. δ ← (r − 1)/2
2. J ← I\ {de boîtes de cap. < δc}
2 0
l m
3. α ← (r−1)
2
n
avec n 0 de nbre de boîtes de J .
Algorithme polynomiale
Algorithme polynomiale :
Construire les nouvellles instances J et J 0 : O(n).
calculer l’optimal de J 0 : O(nq p(n))
q dépend de r
p est un polynome.
Algorithme polynomiale
Qualité de la solution notée m(I):