43
1 Thomas Stidsen Informatics and Mathematical Modelling / Operations Research TABU search and Iterated Local Search – classical OR methods Thomas Stidsen [email protected] Informatics and Mathematical Modeling Technical University of Denmark

TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

Embed Size (px)

Citation preview

Page 1: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

1Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

TABU search and Iterated Local Search– classical OR methods

Thomas Stidsen

[email protected]

Informatics and Mathematical Modeling

Technical University of Denmark

Page 2: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

2Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

OutlineTSP optimization problem

Tabu Search (TS) (most important)

Iterated Local Search (ILS)

Page 3: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

3Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Traveling Salesman Problem (TSP)

Objective: Find a tour of minimal length that visitsall cities exactly once.

Page 4: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

4Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

2-opt����

����

����

����

����

����

What is the neighborhood ?

Page 5: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

5Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

2-optSelect two non-consecutive links:

����

����

����

����

����

����

Page 6: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

2-optDelete the links:

����

����

����

����

����

����

Page 7: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

7Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

2-optReconnect (only one possibility):

����

����

����

����

����

����

Page 8: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

8Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Local search for TSPConcepts:Solutions space S, TSP: All feasible toursvisiting all citiesObjective function f : S → R, TSP: Length oftourNeighborhood N(s) ⊂ S, TSP: All feasibletours that can be obtained by remove twoedges in the tour s and replacing them with twonew edges (2-opt).

Page 9: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

9Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

TABU searchWhen humans solve problems they useexperience and memory. Try to do the same ina local search.

Random Restart + Simulated annealing (SA) +simple ILS : No memory.

TS: Incorporates memory.

Page 10: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

10Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Mountain Climbing using memoryRemember our drunk mountain climber ? Now he issober ...

Look all around you ...

Choose the next step which increases yourheight as much as possible not going back toa place where you were before !

Page 11: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

11Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

TABU search featuresIs difficult to analyze mathematically.

More work is needed for designing andimplementing a TS heuristic compared to a SAheuristic.

Has been applied with success to a wide rangeof combinatorial optimization problems.

Page 12: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

12Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Tabu search historyRoots go back to the seventies.

Proposed in its current form by Fred Glover in1986.

An enourmous amount of applications andvariations of TS have been proposed sincethen.

Page 13: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

13Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

From Hill climbing (decenting) to Tabu searchProblem with hill climbing: We are stuck in alocal optimum.

Possible solution: Allow moves that do notimprove the solution or perhaps even make thesolution worse.

New problem introduced: Cycling (next slide).

Page 14: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

14Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

CyclingCost: 900

Cost: 800

CyclingCost: 850

OptCost: 775

The tabu search way of handling cycling:Remember previously visited solutionssomehow.

Why is Tabu Search called Tabu Search?

Page 15: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

15Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Tabu SearchTabu search Strategies for avoiding cycling:

Remember all solutions encountered so far(strict Tabu Search).

Remember the last j solutions (cycles of length≥ j + 1 are possible).

Remember the last j moves that have beenperformed.

Remember changing attributes of the last jsolutions.

Page 16: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

16Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Basic Tabu Search algorithmChoose initial solution ss∗ = s; k = 1;repeatGenerate V ⊆ N(s, k) ⊆ N(s)Choose the best s′ in Vs = s′

if f(s) < f(s∗) then s∗ = sk = k + 1

until stopping condition is metreturn s∗

Page 17: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

17Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Application of TABUPoints to consider when applying TS to a specificproblem:

Initial solution.

Definition of tabu-based neighborhoodN(s, k) ⊆ N(s).

Definition of candidate set V ⊆ N(s, k).

Stopping condition.

Page 18: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

18Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Neighbors and movesA neighbour s′ ∈ N(s) is obtained by applying a move m.

A move m identifies the changes needed in order toobtain s′ = s ⊕ m.

M(s) is the set of moves that can be applied to s.

Page 19: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

19Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Neighbors and movesThere is a one-to-one relationship between neighboursand moves:

N(s) = {s′|∃m ∈ M(s) with s′ = s ⊕ m}

If every move has an inverse then we candefine tabus using moves. When a move hasbeen performed, its inverse is tabu in thefollowing iterations.

Even if the inverse move is tabu for j iterationscycling with length less than j can occur (seenext slide).

Page 20: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

20Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Inverse moves and cycling

� ���

� � � � ���

� � �� �

��� � �� �

��� � �

� ���

� � �

� � � � � � �� � � � � � � � ��� � � �� � � � � � � � ��� � � � � �� � � � �� � � � � � � � ��� � � �� � � � � � � � �

Cycling occurs even though inverse movesnever are used.

Page 21: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

21Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Tabu tenurenumber of iterations that asolution/move/attribute is tabu

may be static or dynamic — depends onproblem type and instance size

Dynamic tabu tenure.

Static tabu tenures are the easiest to implement.

Page 22: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

22Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Reactive tabu searchVary tabu tenure according to search history:increase tabu tenure when the same solution isvisited over and over again. Decrease tabu tenurewhen no duplicate solutions have been spotted forsome time.

Page 23: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

23Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Aspiration criterioncondition for overriding tabu status

global best: neighbour is a new best solution(this is the most common asp. criterion).

region best: neighbour is a new best amongsolutions having a certain property.

recent best: neighbour is the best among themost recently visited solutions.

attribute based: store best objective value seenfor each attribute. Similar to region best.

Page 24: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

24Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Tabu search memory: Short-termTabu lists which help to escape local optima and tomake the search avoid recently visited solutions.

Page 25: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

25Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Tabu search memory: Long-termIntensification: Information on elite solutionswhich extract the “core” of good solutions anddirect the search according to this.

Diversification: Information on the whole searchtrajectory which drives the search into newunexplored areas (diversification).

For many problems the long term memory canbe the difference between a mediocremetaheuristic and a state of the artmeteheuristic. Unfortunately it is difficult to setup a general framework for how to uselong-term memory - it is problem dependent.

Page 26: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

26Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Intuitive comparison of local search methods

Start

Iteration 4

Iteration 2

Iteration 1

Iteration 6

Iteration 7

Iteration 3Iteration 5

Low qualityarea

High quality area

Global optimum

High quality area

Start

Solution space model Random restart

Simulated annealing Tabu search

Page 27: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

27Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Tricks for quickly searching the neighborhoodThe process of evaluating the neighborhoodcan often be speeded up by using∆-computations:

Page 28: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

28Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Tricks for quickly searching the neighborhoodSometimes the cost of a move in iteration t canbe computed faster by using the cost of themove in iteration t − 1 and modifying this costaccording to the move performed in iterationt − 1.

It can occasionally be profitable to search theneighborhood in a special order and usinginformation from the last move evaluation tocalculate the cost of the current move

Page 29: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

29Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

TS OverviewPros:

Generates good solutions quickly.Many examples of TS algorithms yieldingstate of the art results for many problems.The heuristic has been applied to manyproblems areas. When faced with a newproblem it is easy to find a paper thatdescribes a tabu search algorithm for asimilar problem (to get inspired).There are many ways to twist and tune theheuristic - helps you to get good results.

Page 30: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

30Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

TS OverviewCons:

There are many ways to twist and tune theheuristic - this is time consuming.For many applications you have to come upwith some special tricks to ensure that thetabu search does enough diversification(probably using long term memory). Thetabu list is not always enough.May not be the ideal metaheuristic when theneighbourhood is to large to be searchedexhaustively.Enormous amount of literature about TS.The quality of some papers is questionable.

Page 31: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

31Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

TS for Christmas Lunch ISo how does TS work for the Christmas LunchProblem ? In TABU.java:

The neighborhood: Run through a triple forloop: For every table and every seat at thattable, for every other table, for every seat at thatother table: Try to swap the two persons. If newvalue is better and non-tabu, save this swap.

Add tabu

Check if best has been improved.

This version is SLOW: DeepClone and tabusolutions are also evaluated ...

Page 32: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

32Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

TS for Christmas Lunch IIDataObject.java:

The matrix representation is chosen. Thismakes the swap operation very fast.

The evaluation function takes time ...

Page 33: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

33Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Iterated Local Search (ILS)Descent algorithm maps from the set ofsolutions S to the set S∗ ⊆ S of solutions localyoptimal w.r.t. the chosen neighborhood.

The set S∗ is usually much smaller than the setS.

It seems profitable to search S∗ instead of S.

We would expect to find better solutions byrandomly sampling S∗ compared to randomlysampling S.

Page 34: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

34Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

How to search S∗?Simplest approach: Use random restart:

Problem: we tend to get solutions close to themean of S∗.

Better approach: ILS:

1. Generate initial solution.2. Perform local search to reach local optima.3. Modify the current solution somehow.4. Iterate step 2 - 3 as desired.

Page 35: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

35Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

ILSproc IteratedLocalSearch

s0 = GenerateInitialSolution;s∗ = LocalSearch(s0);repeat

scurrent = Perturb(s∗,history);s∗current

= LocalSearch(scurrent);s∗ = Accept(s∗, s∗

current, history);

until termination condition metend

Page 36: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

36Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

ILS commentsNote: Accept operates on the solution obtainedafter pertubation AND local search, not rightafter the permutation.

First used on a location problem by Baxter in1981 and on the TSP by Baum in 1986according to Thomas Stützle.

The name Iterated Local Search was firstinvented much later (in the 90s).

Page 37: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

37Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Important pointsPerturb (Diversification)

Make changes that no easily are undone bylocal search (perturbation should be strongeror different from local search moves).Perhaps use history to determine thestrength of the pertubation.

Pertubation can sometimes be seen as ruiningpart of the solution (dropping bombs!)

Page 38: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

38Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Important pointsLocalSearch (Intensification)

Tradeoff between speed and strength oflocal search.Use succesfull local search procedure fromscientific literature if available.

Accept

Simple: only accept improvements or acceptall solutions.More advanced: accept certain deterioratingsolutions, use history.

Page 39: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

39Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Example ILS applied to TSPLocal seach: 3-opt

Perturb: A special 4-opt move calleddouble-bridged move. Is not easy to undo usingsimpler moves.

Accept: Accept only improving solutions

Page 40: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

40Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

ILS applied to TSPAccept = Better : Accept only improvingsolutions.

Accept = RW : Random walk (in S∗), accept allsolutions.

Time limit: 120 sec on PII-266 Mhz (experiments byLorenco, Martin and Stützle)

Page 41: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

41Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Example ILS applied to TSPSpeed:

Time limit: 120 sec on PII-266 Mhz (experiments byLorenco, Martin and Stützle)

Page 42: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

42Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

ILS OverviewPros:

Easy to implement a simple ILS. Usually gooddescent algorithms already exists.

Compared to SA it quickly gives you goodsolutions and gradually improves upon it.

For some problems it yields state of the artresults.

Page 43: TABU search and Iterated Local Search · Thomas Stidsen 2 Informatics and Mathematical Modelling / Operations Research Outline TSP optimization problem Tabu Search (TS) (most important)

43Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

ILS OverviewCons:

It may require a deep understanding of theproblem and a lot of trial and error to come upwith a good pertubation method.

If we are using a bad pertubation method wemight either keep returning to the same localoptima or our metaheuristic may resemblerandom restart.

May not be the ideal metaheuristic when theneighbourhood is to large to be searchedexhaustively.

No usefull theory