algorithms and their applications cs2004 (2012-2013) dr stephen swift 10.1 tabu search and ils

29
Algorithms and their Applications CS2004 (2012-2013) Dr Stephen Swift 10.1 Tabu Search and ILS

Upload: della-welch

Post on 01-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Algorithms and their Applications

CS2004 (2012-2013)

Dr Stephen Swift

10.1 Tabu Search and ILS

Previously On CS2004 – Part 1

So far we have looked at:Concepts of Computation and AlgorithmsComparing algorithmsSome mathematical foundationThe Big-Oh notationComputational ComplexityData StructuresSorting AlgorithmsGraphs and Graph Algorithms

Tabu Search and ILS Slide 2

Previously On CS2004 – Part 2

We then moved focus to Heuristic Search Algorithms:

ConceptsFitnessRepresentationSearch Space

MethodsHill ClimbingStochastic Hill ClimbingRandom Restart Hill ClimbingSimulated Annealing

Tabu Search and ILS Slide 3

IntroductionIn this lecture we are going to look into two Heuristic Search methods:

Tabu Search (TS)Iterated Local Search (ILS)We are then going to look into some of the implementation details involved in applying ILS to the Scales problem

Representation improvementsAn Updatable Fitness FunctionPerformance

Tabu Search and ILS Slide 4

HeuristicsA “rule of thumb”No guarantees on quality of solutionUsually fast and are widely usedSometimes we run them multiple times and analyse the resultsStudied experimentally on benchmark datasetsTabu Search and ILS Slide 5

Popular HeuristicsHill Climbing

Always go up hill (accept only better quality solutions)Simulated Annealing

The concepts of annealing and temperatureIterated Local Search

See later slideTabu Search

See later slideGenetic Algorithms

Simulated evolutionSee later lecture

Ant Colony OptimisationPheromones and cooperationSee later lecture

……

Slide 6Tabu Search and ILS

Local View of Search

Tabu Search and ILS Slide 7

Tabu (Taboo) SearchTabu search tries to model human memory processes

Key idea: Use aspects of search history (memory) to escape from local minima

A tabu-list is maintained throughout the search

Associate tabu attributes with candidate solutions or solution componentsMoves according to the items on the list are forbidden

Tabu Search and ILS Slide 8

Flow Chart of a Standard Tabu Search Algorithm

Initialise solution Create a candidate

list of solutions

Update Tabu & AspirationConditions

Final solution

No

Yes

Tabu Search and ILS Slide 9

Choose the best admissible solution

Stopping conditions satisfied?

Evaluate solutions

START

END

Tabu Search and ILS Slide 10

Tabu Search – Key ConceptsA search (similar to Hill Climbing) that remembers sets of points in the search space

These are called the Tabu list and are to be avoided

The idea is that this helps in avoiding local optimaHowever if a point is evaluated to be better than any points discovered so far, then the Tabu list may be updated

Aspiration Criteria

Tabu Search Stopping ConditionsSome immediate stopping conditions:

No feasible solution in the neighborhood of solutionThe maximum amount of iterations or CPU time has been exceededThe number of iterations since the last improvement is larger than a specified numberEvidence can be given than an optimum solution has been obtained

Tabu Search and ILS Slide 11

Parameters of Tabu SearchLocal search procedureNeighborhood structureTabu attributesAspiration conditionsForm of tabu movesMaximum size of tabu listStopping rule

Tabu Search and ILS Slide 12

Pros and Cons for Tabu SearchPros:

The use of a Tabu listCan be applied to both discrete and continuous solution spacesA meta-heuristic that guides a local search procedure to explore the solution space beyond local optimalityFor larger and more difficult problems (scheduling, quadratic assignment and vehicle routing), tabu search obtains solutions that rival and often surpass the best solutions previously found by other approaches

Cons:Too many parameters to be determinedNumber of iterations could be very largeGlobal optimum may not be found, depends on parameter settingsTabu list can grow out of control

Tabu Search and ILS Slide 13

Tabu Search and ILS Slide 14

Iterated Local Search (ILS)Key ConceptsILS uses another local search algorithm as part of the algorithm

E.g. Hill Climbing

It uses information regarding previously discovered local optima (and/or starting points) to locate new (and hopefully better) local optimaThe key algorithmic steps are as follows:

s0 = Generate initial solutions* = LocalSearch(s0)history = Repeat

history = history s* [Remember previous optima and maybe start]scurrent = Perturb(s*,history) [Try to avoid similar starting

points]scurrent* = LocalSearch(scurrent)s* = Accept(s*, scurrent*, history) [Often just accept best]

Until termination condition met

Care must be taken to assure that the perturbation step is not just mimicking the local search algorithmNote: Random Restart Hill Climbing is NOT ILS – Why?

Iterated Local Search – Part 1 ILS can be interpreted as walks in the space of local optimaPerturbation is key

Needs to be chosen so that it cannot be undone easily by subsequent local searchIt may consist of many perturbation stepsStrong perturbation: more effective escape from local optima but similar drawbacks as random restartWeak perturbation: short subsequent local search phase but risk of revisiting previous optima

Acceptance criteria: usually either the more recent or the bestTabu Search and ILS Slide 15

Iterated Local Search – Part 2Often leads to very good performanceOnly requires few lines of additional code to existing local search algorithmState-of-the-art results with further optimisations

Tabu Search and ILS Slide 16

ILS and The Scales – Part 1We are going to look at some performance considerations that can be applied to all Heuristic Search Methods applied to the Scales ProblemWe will then look at how we implement ILS to tackle the Scales Problem

Tabu Search and ILS Slide 17

ILS and The Scales – Part 2

RepresentationAt the moment we are representing a solution as a Binary String or Array of IntegersIs this a good idea?How much redundancy is there in the representation?Each digit or part is either 0 or 1This just needs one bit, but we are using 32 bits!!!

Tabu Search and ILS Slide 18

ILS and The Scales – Part 3

RepresentationWe can save space and thus efficiency (speed) by just using the number of bits we needFor n weights and b bits (32) we would need the following number of integers (m)

to represent our weight/scales allocation

We would need 32 integers for 1000 weights...

Tabu Search and ILS Slide 19

b

nm

ILS and The Scales – Part 4Luckily the latest version of Java comes with a built in class!

import java.util.BitSet;

public class BitSetTest { public static void main(String args[]) { int n = 25; BitSet bs = new BitSet(n); bs.set(0,n,true); ShowBits(bs,n); bs.flip(0,n); ShowBits(bs,n); bs.set(17,true); ShowBits(bs,n); } private static void ShowBits(BitSet bs,int n) { for(int i=0;i<n;++i) System.out.print((bs.get(i))?"1":"0"); System.out.println(); }}Tabu Search and ILS Slide 20

Output:111111111111111111111111100000000000000000000000000000000000000000010000000

ILS and The Scales – Part 5

FitnessOur fitness function for the Scales problem is an O(n) algorithmHowever note the following:If we record and remember the LHS and RHS totals and the position (index) of the last small changeIf we changed a ‘1’ to a ‘0’ (moved from right to left)

NewLHS = LHS + weight(index)NewRHS = RHS – weight(index)

If we changed a ‘0’ to a ‘1’ (moved from left to right)

NewLHS = LHS – weight(index)NewRHS = RHS + weight(index)

Tabu Search and ILS Slide 21

ILS and The Scales – Part 6

FitnessThus we have created an updatable fitness function

New Fitness = Old Fitness + Value based on small change

We have reduced our time complexity from O(n) to O(1)I.e. For 1000 weights our program could be up to 1000 times faster!!!Combining this with the more compact representation discussed previously we now have a much more efficient algorithm

Tabu Search and ILS Slide 22

ILS and The Scales – Part 7

ImplementationWe will base our algorithms on the Random Restart Hill Climbing methodWe will reuse any code we might haveWe need a way of generating starting positions that are not entirely randomThese starting positions should be generated such that they are different to any previous starting points and local optimaThere are many ways of doing this, the version we are going to look at is a very simple version

Tabu Search and ILS Slide 23

ILS and The Scales – Part 8

ImplementationWe generate the first starting point randomlyWe also remember the local optimaWe bias the way that each bit is generated based on the recorded starting points and local optimaGiven m recorded points we generate a biased probabilityLet bij be the ith bit of starting point j (0 or 1)

Tabu Search and ILS Slide 24

ILS and The Scales – Part 9

ImplementationLet p1i be the biased probability that position i was a one previouslyWe set the starting point at position i to one with probability 1.0-p1i and to zero otherwise

Tabu Search and ILS Slide 251

11

1

m

b

p

m

jij

i

ILS and The Scales – Part 10

ResultsExperiments were conducted on 10,000 weights generated randomly (UR) between 100 and 1000100 RepeatsAll methods were allowed 10,000 fitness function calls

Worst Fitness = 5524223.536RMHC = 65.418RRHC = 8.248ILSHC = 8.192

Tabu Search and ILS Slide 26

ILS and The Scales – Part 11

ResultsILS is less than 1% better than RRHC!Better ways of combining the starting positions and previously discovered local optima might results in a better performance…

Tabu Search and ILS Slide 27

This Weeks Laboratory

Tabu Search and ILS Slide 28

The next laboratory session has no new worksheetsUse this time to make sure that you have caught up with any worksheets that are outstanding

Next LectureThere are no more lectures until the start of next term!The next topic we will study is:

ApplicationsParameter optimisation

Slide 29Tabu Search and ILS