Sunteți pe pagina 1din 28

• Problema comis-voiajorului pentru grafuri

orientate (ATSP - Asymmetric Traveling


Salesman Problem)
• Aplicaţii
– Programare liniară

08.12.21 Curs 6 - Branch and Bound 1


Curs 6 - Branch and Bound
• probleme NP (s0  sf cu un număr minim de
stărilor intermediare, prin decizii)
• funcţie cost
• limită inferioară
• regulă pentru împărţirea problemei
– Graful stărilor şi deciziilor poate fi parcurs:
• în adâncime (Depth First Strategy)
• în lăţime (Breadth First Strategy)
• alegând descendenţii vârfului curent pe cel mai aproape de
starea finală (Best First Strategy)

08.12.21 Curs 6 - Branch and Bound 2


Curs 6 - Branch and Bound
Problema comis-voiajorului pentru grafuri
orientate
– se calculează limitele soluţiei
– se împarte problema în subprobleme
– se selectează nodul pe care îl prelucrăm
n n
min  d ij xij , avand restrictiile
i 1 j 1

 n n
  xij , i  1,..., n , xij , j  1,..., n
 j 1, j  i i 1,i  j


  xij  S ,   S  V , xij   0,1 , i, j  1,..., n
i , jS
08.12.21 Curs 6 - Branch and Bound 3
Curs 6 - Branch and Bound
• ATSP – A matrice de legături
Limitarea
– se scade pe fiecare linie cel mai mic element al liniei, li
(A1)
– se scade de pe fiecare coloană a matricei A1 cel mai mic
element al coloanei respective, cj (A2)
– se determină o limită inferioară a drumului optim:
 li c j
i j

08.12.21 Curs 6 - Branch and Bound 4


Curs 6 - Branch and Bound
• ATSP – A matrice de legături
Împărţirea problemei (ramificarea)
– se caută în matricea redusă acea valoare 0, acea pereche
(i,j), pentru care suma celui mai mic element nenul de le
linia i şi a celui mai mic element nenul de pe coloana j
este maximă ( (i,j) = max A3) (arcul a cărui omitere costă
cel mai mult)
– se construiesc două probleme:
• una în care (i,j) este soluţie (se elimină linia i şi coloana j din
A2, având dji = )
• una în care (i,j) este omisă din soluţie (dij = )

08.12.21 Curs 6 - Branch and Bound 5


Curs 6 - Branch and Bound
• ATSP – A matrice de legături
Strategia de căutare a soluţiilor (în adâncime – alegând mai
întâi soluţia care include perechea (i,j))
graf original - min pe
A linii

3 3 93 13 33 9
4 4 77 42 21 16
16 45 17 36 16 28
7 39 90 80 56 7
25 28 46 88 33 25
3 3 88 18 46 92
08.12.21
58
Curs 6 - Branch and Bound 6
Curs 6 - Branch and Bound
• ATSP

etapa 1 - A1
min pe col 0 0 15 8 0 0 23
0 90 10 30 6
0 73 38 17 12
29 1 20 0 12
32 83 73 49 0
3 21 63 8 0

0 85 15 43 89

08.12.21 Curs 6 - Branch and Bound 7


Curs 6 - Branch and Bound
• ATSP
• LI = 81
calcul min pe
linii si pe
etapa 1 - A2 coloane
81 3 1 48 2 17 6
2 0 75 2 30 6
12 0 58 30 17 12
1 29 1 12 0 12
32 32 83 58 49 0
3 3 21 48 0 0
35 0 85 0 35 89
08.12.21 Curs 6 - Branch and Bound 8
Curs 6 - Branch and Bound
• ATSP

etapa 2 - A3 (suma minime)


83 3 1 48 2 17 6
2 3 50 4 19 8
12 15 60 14 29 18
(6,3)
1 4 2 3 18 7
32 35 33 80 49 38
3 6 4 51 5 9
35 38 36 83 37 52

08.12.21 Curs 6 - Branch and Bound 9


Curs 6 - Branch and Bound
• ATSP – problema “1”, problema “0”

(6,3) fără (6,3)


0 75 2 30 6 0 75 2 30 6
0 58 30 17 12 0 58 30 17 12
29 1 12 0 29 1 12 0 12
32 83 58 49 0 32 83 58 49 0
3 21 48 0 0 3 21 48 0 0
0 85 0 35 89 0 85 35 89

08.12.21 Curs 6 - Branch and Bound 10


Curs 6 - Branch and Bound
• ATSP – problema “1”: +(6,3)

min linii, col 1 2 4 5 6


0 0 0 0 0 0
1 0 0 2 30 6
2 0 0 30 17 12
3 0 29 1 12 0
4 0 32 83 49 0
5 0 3 21 0 0
0

08.12.21 Curs 6 - Branch and Bound 11


Curs 6 - Branch and Bound
• ATSP – problema “1”: +(6,3)
• LI = 81
A2 min linii+col 1 2 4 5 6
0 3 1 2 17 6
1 2 0 2 30 6
2 12 0 30 17 12
3 1 29 1 12 0
4 32 32 83 49 0
5 3 3 21 0 0
81

08.12.21 Curs 6 - Branch and Bound 12


Curs 6 - Branch and Bound
• ATSP – problema “1”: +(6,3)

A3 suma minime 1 2 4 5 6
(4,6) 38 3 1 2 17 6
1 2 3 4 19 8
2 12 15 14 29 18
3 1 4 2 3 18
4 32 35 33 49 38
5 3 6 4 5 9

08.12.21 Curs 6 - Branch and Bound 13


Curs 6 - Branch and Bound
• ATSP – problema “0”: -(6,3)
0 75 2 30 6
0 58 30 17 12
29 1 12 0 12
32 83 58 49 0
3 21 48 0 0
0 85 35 89

08.12.21 Curs 6 - Branch and Bound 14


Curs 6 - Branch and Bound
• ATSP – problema “0”: -(6,3)
• LI = 129

min linii, col 1 2 3 4 5 6


48 0 0 48 0 0 0 48
1 0 0 75 2 30 6
2 0 0 58 30 17 12
3 0 29 1 12 0 12
4 0 32 83 58 49 0
5 0 3 21 48 0 0
6 0 0 85 35 89
0 129
08.12.21 Curs 6 - Branch and Bound 15
Curs 6 - Branch and Bound
• ATSP – problema “11”: +(6,3) +(4,6)

A2 min linii, col 1 2 4 5


0 0 0 0 0
1 0 0 2 30
2 0 0 30 17
3 0 29 1 12 0
5 0 3 21 0

08.12.21 Curs 6 - Branch and Bound 16


Curs 6 - Branch and Bound
• ATSP – problema “11”: +(6,3) +(4,6)
• LI = 81

min linii+col 1 2 4 5
0 3 1 2 17
2 0 2 30
17 0 30 17
1 29 1 12 0
3 3 21 0
81

08.12.21 Curs 6 - Branch and Bound 17


Curs 6 - Branch and Bound
• ATSP – problema “11”: +(6,3) +(4,6)

A2 suma min 1 2 4 5
(2,1) 20 3 1 2 17
1 2 3 4 19
2 17 20 19 34
3 1 4 2 3 18
5 3 6 4 5

08.12.21 Curs 6 - Branch and Bound 18


Curs 6 - Branch and Bound
• ATSP – problema “10”: +(6,3) -(4,6)

calcul min pe linii 1 2 4 5 6

1 0 0 2 30 6
2 0 0 30 17 12
3 0 29 1 12 0
4 32 32 83 49
5 0 3 21 0 0
32

08.12.21 Curs 6 - Branch and Bound 19


Curs 6 - Branch and Bound
• ATSP – problema “10”: +(6,3) -(4,6)
• LI = 113

calcul min pe coloane 1 2 4 5 6


32 0 0 0 0 0 0
1 0 2 30 6
2 0 30 17 12
3 29 1 12 0
4 0 51 17
5 3 21 0 0
113

08.12.21 Curs 6 - Branch and Bound 20


Curs 6 - Branch and Bound
• ATSP – problema “111”: +(6,3) +(4,6) +(2,1)

min pe linii 2 4 5

1 2 2 30
3 0 1 12 0
5 0 21 0
2

08.12.21 Curs 6 - Branch and Bound 21


Curs 6 - Branch and Bound
• ATSP – problema “111”: +(6,3) +(4,6) +(2,1)

A1 min col 2 4 5
1 0 0 1
1 0 28
3 1 12 0
5 21 0

08.12.21 Curs 6 - Branch and Bound 22


Curs 6 - Branch and Bound
• ATSP – problema “111”: +(6,3) +(4,6) +(2,1)
• LI = 84

A2 min pe coloane 2 4 5
3
1 0 28
3 0 12 0
5 20 0
84

08.12.21 Curs 6 - Branch and Bound 23


Curs 6 - Branch and Bound
• ATSP – problema “111”: +(6,3) +(4,6) +(2,1)

A3 2 4 5 A3 2 4 5
3 20 12 28 (1,4) 40 20 12 28
1 28 0 28 1 28 40 56
3 12 0 12 0 3 12 32 24 40
5 20 20 0
5 20 40 32

08.12.21 Curs 6 - Branch and Bound 24


Curs 6 - Branch and Bound
• ATSP – problema “110”: +(6,3) +(4,6) -(2,1)
• LI = 101

min linii 1 2 4 5 min pe col 1 2 4 5


20 3 0 0 0 3
1 0 0 2 30 1 0 2 30
2 17 30 17 2 13 0
3 0 29 1 12 0 3 29 1 12 0
5 0 3 21 0 5 3 21 0
17 101

08.12.21 Curs 6 - Branch and Bound 25


Curs 6 - Branch and Bound
• ATSP – problema “1111”: +(6,3) +(4,6) +(2,1) +(1,4)
• Drumul optim = 104

A1 nula 2 5
(5,2), (3,5) 20
3 0 0 0
5 20 20
20 104

08.12.21 Curs 6 - Branch and Bound 26


Curs 6 - Branch and Bound
• ATSP – problema “1110”: +(6,3) +(4,6) +(2,1) -(1,4)
• LI = 112

min linii 2 4 5 min col 2 4 5


28 0 0 0 0
1 28 28 1 0
3 0 0 12 0 3 0 12 0
5 0 20 0 5 20 0
28 112

08.12.21 Curs 6 - Branch and Bound 27


Curs 6 - Branch and Bound
• ATSP – problema “1111”: +(6,3) +(4,6) +(2,1) +(1,4) +(5,2)
+(3,5)
• 18 + 7 + 4 + 13 + 46 + 16 = 104
81
+(6,3) -(6,3)

81 129
+(6,3), +(4,6) +(6,3), -(4,6)

81 113
+(6,3), +(4,6), +(2,1) +(6,3), +(4,6), -(2,1)
84 101
+(6,3), +(4,6), +(2,1), +(1,4) +(6,3), +(4,6), +(2,1), -(1,4)
104 112
08.12.21 Curs 6 - Branch and Bound 28

S-ar putea să vă placă și