Top Banner
A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006
21

A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

A Hybrid Heuristic for the Traveling Salesman Problem

R. Baraglia, J. I. Hildalgo, R. Perego

CMPSC 580, Spring 2006

Page 2: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

I didn’t even think “difficultly” was a word.

Page 3: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Genetic Algorithms(from Eiben and Schoenauer)

Page 4: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Simple Example

Find the 8-bit vector which maximizes the number of 1’s in the vector – the “MAXONES” problem.

Answer is obvious: 11111111

Can a genetic algorithm find it?

Page 5: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Example (continued)

Initialize population (random):

10010101 11001011

01001010 01011001

01010100 10001110

Page 6: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Example (continued)

Evaluate fitness:

f(10010101) = 4 f(11001011) = 5

f(01001010) = 3 f(01011001) = 4

f(01010100) = 3 f(10001110) = 3

Page 7: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Example (continued)

Select genitors (parents):

Random, but biased toward fitter individuals:

f(10010101) = 4 f(11001011) = 5

f(01001010) = 3 f(01011001) = 4

f(01010100) = 3 f(10001110) = 3

Page 8: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Example (continued)

10010101 11001011

10010101 10010011

Variation operators: crossover and mutation

10110101 10010001

Page 9: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Example (concluded)

Evaluate and replace (next generation):

10010101(4) 11001011(5)

01001010(3) 10110101(5)

11010101(5) 10010010(3)

Survivors

Offspring

…Now repeat: select, mate, replace…

Page 11: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Compact GA (CGA)

Instead of maintaining a population of individuals, just keep a description, or model, of the population. Example:

A Possible Population:1 2 3 4 50 1 0 0 11 1 0 0 01 0 0 0 10 1 0 0 01 1 1 0 1

Model:(.6, .8, .1, 0, .6)

For each bit position, maintain theprobability that some element ofthe population has a “1” in that position.Example (with 5-bit chromosomes):

Page 12: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Compact GA (continued)

Start with uniform random model:

(.5, .5, .5, .5, .5)

Randomly generate two (or more) individuals according to this probability distribution; find fitness:

1 1 0 1 0; fitness = 3.21

0 1 1 0 0; fitness = 1.98

Page 13: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Compact GA (continued)

Old model: (.5, .5, .5, .5, .5)

1 1 0 1 0; fitness = 3.21 (winner)

0 1 1 0 0; fitness = 1.98 (loser)

Reward 1’s in winner; penalize 1’s in loser:

New model: (.6, .5, .4, .6, .5)

Repeat the process using the new probabilities

Page 14: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Compact GA (continued)

Ideally, process will converge– this is the “solution” found by the CGA:

(.5, .5, .5, .5, .5)

(.6, .5, .4, .6, .5)

(.7, .4, .3, .6, .5)

(1, 0, 0, 1, 1) [“solution”]

Page 15: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Compact GA for TSPSave a description of population in the form

of a probability matrix. Example:

1

2

34

5

Population: 1,4,5,2,3 1,2,5,3,4 1,5,3,4,2 1,3,5,2,4

0

.5 0

.5 .25 0

.75 .5 .5 0

.25 .75 .75 .25 0

1

2

3

4

5

1 2 3 4 5

Probability of edge (i,j):

Page 16: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

CGA for TSP (continued)

Constructing a new tour:

Pick random start city:

(4, _

Pick another city:

1

Decide whether to include

1 with a 75% probability:

YES

0

.5 0

.5 .25 0

.75 .5 .5 0

.25 .75 .75 .25 0

1

2

3

4

5

1 2 3 4 5

Probability of edge (i,j):

Page 17: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

CGA for TSP (continued)

(4, 1, _

Pick another city:

5

Decide whether to include

1 with a 25% probability:

NO

So try another city, … etc.

0

.5 0

.5 .25 0

.75 .5 .5 0

.25 .75 .75 .25 0

1

2

3

4

5

1 2 3 4 5

Probability of edge (i,j):

Page 18: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

CGA for TSP (continued)

0

.5 0

.5 .25 0

.75 .5 .5 0

.25 .75 .75 .25 0

1

2

3

4

5

1 2 3 4 5

Probability of edge (i,j):

Constructing a new tour:

Process might get “stuck”(repeated “NO” results). In thiscase, pick the city with highestprobability of being connectedto most recently added city:

(4,1,3,5,…

Page 19: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Hybrid Approach

Combine Genetic Algorithm (problem-independent method) with heuristic specifically designed for TSP.

Make one “genetic step”, then improve the solution using the heuristic.

Page 20: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

A Simple Heuristic for Improving TSP Solutions

2-opt: look at all possible pairs of edges in the tour, see if tour length can be improved by reordering cities as follows. Repeat until no more improvement is possible:

(Can have 3-opt, 4-opt, etc.; more expensive)

Page 21: A Hybrid Heuristic for the Traveling Salesman Problem R. Baraglia, J. I. Hildalgo, R. Perego CMPSC 580, Spring 2006.

Slides not completed yet