Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

HEURISTICAS TSP

Prof. John Willmer Escobar Velásquez.

1
TWO CLASSES OF HEURISTIC ALGORITHMS FOR TSP

1) CONSTRUCTIVE ALGORITHMS
build a Hamiltonian circuit starting from the input
data of the original problem (i.e. n, cost matrix cij).

2) LOCAL SEARCH ALGORITHMS (tour improvement)


starting from an initial feasible Hamiltonian circuit
(tour), try to find a tour with a lower cost through
a sequence of “moves” corresponding to “arc
exchanges” or “vertex exchanges”.

2
CONSTRUCTIVE ALGORITHMS (iterative algorithms)

Main ingredients

a) choice of the “initial partial circuit”


(subtour) or of the “initial vertex”;

b) choice of the vertex to be inserted, at


each iteration, into the current subtour
(or into the current “path”);
c) choice of the position of the selected
vertex in the current solution.
3
Example 1 (Alg. Nearest Neighbour) 3
2

4
2
5 Opt = 27
1

6 3
8 5
7 9

Initial vertex: 1 3
4 4
4 6
3
9
8
3 2
7
2 2 7
2

3 5

7
6
4 4
3
9
8
2

2
7
Solution cost: 32

4
Example 1 (Alg. Nearest Neighbour) 3
2

4
2
5 Opt = 27
1

6 3
8 5
7 9

Initial vertex: 6 3
4 4
4 6
3
9
8
3 2
7
2 2 2
7
3 5

5
7
4 6
4 4
3

8
2

2
7
Solution cost: 29

5
Example 1 (Alg. Nearest Neighbour)
2 2
Opt = 27
3 5

4
1

6 3
8 5
Initial vertex: 7 (second vertex: 6) 7 9
4 6
4 4 3
3
9
8

2 2 3 2
7
3 5 2
7

5
7
6
4 4 3
3

8
3 2

Solution cost: 29

6
Example 1 (Alg. Nearest Neighbour) 3
2

4
2
5 Opt = 27
1

6 3
8 5
7 9

Initial vertex: 7 (second vertex: 8) 3


4 4
4 6
3
9
8
3 2
7
2 2 2
3 5 7

3
7
6
4 4 3
3

8
3

2
7

Solution cost: 27
(optimal solution)
7
Example 1 (Alg. Nearest Neighbour) 3
2

4
2
5 Opt = 27
1

6 3
8 5
7 9

Initial vertex: 8 3
4 4
4 6
3
9
8
3 2
7
2 2 2
3 5 7

3
7
6
4 4
3 9
8
2
2
7
Solution cost: 32
(same solution as that found with
“Initial vertex”: 1)
8
Example 2
4 4
33
X 5 5

44
X 66 33
6 6

77
X
X 3 3

99 55 66 X
88
X
2 2
1212
12
1 1

n=6
Optimal solution X
Optimal solution cost: Opt = 33

9
Example 2 (Alg. Nearest Neighbour) 4
3 5

4
6 3
6

7
3

Initial vertex: 1 9 5 6

8 2
12
1

3 5 Opt = 33
4

3
6

7
3

9 5
Solution cost: 35
8 2

Same solution found with “Initial vertex”: 2


10
Example 2 (Alg. Nearest Neighbour) 4
3 5

4
6 3
6

7
3

Initial vertex: 5 9 5 6

8 2
12
1

3 5 Opt = 33
4
4
6

7
3

8 2

1
No feasible solution found
(with alternative choices as well)
11
Example 2 (Alg. Nearest Neighbour) 4
3 5

4
6 3
6

7
3

Initial vertex: 3 9 5 6

8 2
12
1

3 5
4 Opt = 33
4
3
6

3
9 6

8 2 Solution cost: 33
1
(Optimal solution)

Same solution found with “Initial vertex”: 4, 6


12
Example B 14
14

4 4
2 4 4 4 6
2 4 6

4
3 4
3
3 3 8
1 3 3 3 3 3 8
1 3 3 3
3
3
4
4
3 5 7
3 4 5 4 7
4 4

n=8
Optimal solution
Optimal solution cost: Opt = 30

13
Example B (Alg. Nearest Neighbour) 14

4 4
2 4 6

4
3
3 3 8
3 3 3
Initial vertex: 1 1
3
4
3 5 7
4 4
14
Opt = 30

2 4 6

3
8
1
3 3 3 3 3
3

3 5 7

Solution cost: 35
Same solution found with “Initial vertex”: 2, 3, 4, 5, 6, 7, 8
14
Example 3 3
77
2 7
3
33
3
3 33
3 4 555
55
5
2
n=6 1
9999
Optimal solution 4
33
3 4
4 44 3
33
Optimal solution cost = 21 33 44 4
4

ALGORITHM NEAREST NEIGHBOUR: 55 6


3 33
Initial vertex Solution Cost
1 25 ( 24 )
2 24 ( 22, 26 )
3 24 ( 25, 29 )
4 24 ( 25 )
5 24 ( no feasible sol. found )
6 22 ( . . . >= 24 )
15

You might also like