grasp – a speedy introduction · grasp – a speedy introduction thomas stidsen ... elements only...

29
1 Thomas Stidsen DTU-Management / Operations Research GRASP – A speedy introduction Thomas Stidsen [email protected] DTU-Management Technical University of Denmark

Upload: phungnhan

Post on 13-Jul-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

1Thomas Stidsen

DTU-Management / Operations Research

GRASP – A speedy introductionThomas Stidsen

[email protected]

DTU-Management

Technical University of Denmark

Page 2: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

2Thomas Stidsen

DTU-Management / Operations Research

GRASPGRASP is an abbreviation for

Greedy

Randomized

Adaptive

Search

Procedure.It was “invented” by Feo and Resende in 1989.

Page 3: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

3Thomas Stidsen

DTU-Management / Operations Research

Overview of GRASPGRASP consists of 2 phases:

Greedy Randomized Adaptive phase(generating a solution).

Local Search (finding a local minimum).

Page 4: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

4Thomas Stidsen

DTU-Management / Operations Research

Greedy Randomized Adaptive phaseThe first phase consists of 3 parts:

1. Greedy algorithm.

2. Adaptive function.

3. Probabilistic selection.

Page 5: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

5Thomas Stidsen

DTU-Management / Operations Research

Greedy algorithmA greedy algorithm always makes the choicethat looks best at the moment. It makes alocally optimal choice in the hope that thischoice will lead to a globally optimal solution.

Greedy algorithms do not always yield optimalsolutions (eg. 0-1-knapsack), but in some casesit does (eg. Minimum spanning tree).

Page 6: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

6Thomas Stidsen

DTU-Management / Operations Research

Mathematical Model for Knapsack problemobjective: maximize

i

ci · xi

s.t.∑

i

wi · xi ≤ W

xi ∈ 0, 1

The profit weight ratio:PF = ci

wi

Page 7: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

7Thomas Stidsen

DTU-Management / Operations Research

Greedy algorithm for 0-1 knapsackprocedure greedy_knapsack()

calculate profit vs. weight ratiowhile the smallest item can still fit in do

Add largest PF = ci

wi

elementUpdate remaining weight

return solution

Page 8: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

8Thomas Stidsen

DTU-Management / Operations Research

Example: 0-1-Knapsackproblem

item 1

item 2

item 3

knapsack

120

10 20 30

value: 60 100

Page 9: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

9Thomas Stidsen

DTU-Management / Operations Research

Example: 0-1-Knapsackproblem

knapsack knapsack

180

120

100

100

60 60

120

knapsack

220 160

Page 10: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

10Thomas Stidsen

DTU-Management / Operations Research

Greedy algorithm for the CLP ?How can we make a greedy algorithm for theChristmas lunch problem ? Lets remember acouple of facts:

We want to maximize the interest count.

A person at a table can only achieve a positiveinterest from other persons at a table.

If a table is empty and a person is put there,there is no gain ...

Page 11: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

11Thomas Stidsen

DTU-Management / Operations Research

Greedy algorithm for the CLPSo, we will make the greedy algorithm the followingway:

procedure greedy_clp()for each table doPlace one un-seated person randomly chosenwhile still room at the table do

Add the person with the largest interest gainreturn solution

Page 12: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

12Thomas Stidsen

DTU-Management / Operations Research

Probabilistic selectionIn the greedy algorithm the selection of the nextelement to add to the solution is (often !)deterministic.

The probabilistic selection process selectscandidates among which we choose the nextelement to be added to the presently partialsolution. The list of candidates is formallydenoted the Restricted Candidate List (RCL).

Page 13: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

13Thomas Stidsen

DTU-Management / Operations Research

Restricted Candidate ListConstruction:

Select the β best elements (β = 1: purelygreedy, β = n completely random).Selects the elements that are not more thanα% away from the best element. (α = 0:purely greedy, α = ∞: purely random).Select elements above an absolutethreshold of γ.

Selection:Equally probability.Weighted probability.

Page 14: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

14Thomas Stidsen

DTU-Management / Operations Research

Adaptive functionModify the function which guides the greedyalgorithm based on the element selected for thesolution we are constructing.

The construction is called dynamic in contrastto the static approach which assigns a score toelements only before starting the construction(example: TSP links).

Page 15: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

15Thomas Stidsen

DTU-Management / Operations Research

GRASP main codeprocedure grasp()

CurrentBest = 0while 〈 more time 〉

Solution = ConstructSolution()NewSolution = LocalSearch(Solution)if 〈 NewSolution better than CurrentBest 〉 then

CurrentBest = NewSolutionreturn CurrentBest

Page 16: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

16Thomas Stidsen

DTU-Management / Operations Research

Greedy Randomized solution constructionprocedure ConstructSolution()

Solution = ∅for 〈 solution construction not finished 〉

CandidateList = MakeCandidateList()s = SelectElement(CandidateList)Solution = Solution ∪sChangeGreedyFunction();

return Solution

Page 17: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

17Thomas Stidsen

DTU-Management / Operations Research

Additions to the GRASP schemeUse different adaptive functions during theexecution of the algorithm.

Settings of the Restricted Candidate Listdynamic.

Page 18: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

18Thomas Stidsen

DTU-Management / Operations Research

More informationThe website

http://www.graspheuristic.org

contains an annotated bibliography of GRASP.This is a good starting point for every form ofwork with the GRASP metaheuristic.

Object-oriented framework developed byAndreatta, Carvalho and Ribero.

Page 19: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

19Thomas Stidsen

DTU-Management / Operations Research

Pros and consPRO: Simple structure (means often easy toimplement),

PRO: If you can construct a greedy algorithm,extension to GRASP is often easy.

PRO: Can be used for HUGE optimizationproblems.

CONS: dependent on a “natural” greedyalgorithm, no escape from local optimum.

CONS: may easily re-discover the samesolution many times

Page 20: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

20Thomas Stidsen

DTU-Management / Operations Research

(Adaptive) Large Neighbourhood SearchA recently developed method is: LargeNeighbourhood Search (LNS) or Adaptive LargeNeighbourhood Search (ALNS).

LNS first suggested in 1998 by Shaw: "Usingconstraint programming and local searchmethods to solve vehicle routing problems".

ALNS first suggested in 2006 by Ropke andPisinger: "An adaptive large neighborhoodsearch heuristic

Both LNS and ALNS are similar to GRASP andhave shown VERY interesting results.

Page 21: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

21Thomas Stidsen

DTU-Management / Operations Research

LNS IThe basic idea in LNS is to use DESTROY andREPAIR methods to create new solutions (based onthe current solution):

A destroy method removes a part of thesolution ...

A repair method recreates the whole (feasible)solution.

Page 22: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

22Thomas Stidsen

DTU-Management / Operations Research

LNS IIThe basic idea in LNS is to use DESTROY andREPAIR methods to create new solutions (based onthe current solution):

Together destroy and repair methods form aneighbourhood, typically a very largeneighbourhood.

The destroy method is often stochastic, i.e. verysimply deleting a certain part of the solution.

The repair method is very often a kind of greedyconstructive algorithm.

Page 23: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

23Thomas Stidsen

DTU-Management / Operations Research

LNS III : Pseudo codeprocedure LNS()

Generate feasible solution x

xb = xrepeat

xt = r(d(x))if accept(xt,x) then x = xt

if c(xt) < c(xb)) then xb = xt

until time limitreturn xb

Page 24: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

24Thomas Stidsen

DTU-Management / Operations Research

ALNS IAdaptive Large Neighbourhood Search is basicallyan extension of LNS: Instead of having one destroyand one repair method, ALNS allows many differentdestroy and repair methods:

In each iteration a destroy and repair methodsis chosen probabilistically.

The chance for being chosen is adaptivelychosen so that successful repair and destroymethods are rewarded for their success.

Page 25: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

25Thomas Stidsen

DTU-Management / Operations Research

LNS II : Pseudo codeprocedure ALNS()

Generate feasible solution x

xb = x, ρ− = (1, ..., 1), ρ+ = (1, ..., 1)repeat

select destroy and repair methods d ∈ Ω−

and r ∈ Ω+ using ρ− and ρ+

xt = r(d(x))if accept(xt,x) then x = xt

if c(xt) < c(xb)) then xb = xt

update ρ− and ρ+

until time limitreturn xb

Page 26: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

26Thomas Stidsen

DTU-Management / Operations Research

How to select destroy and repairThe probability for choosing repair/destroy operatornumber j is:

φ− =ρ−

∑|Ω−|k=1

Page 27: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

27Thomas Stidsen

DTU-Management / Operations Research

How to adjust ρ− and ρ+ IFor every iteration exactly one destroy and onerepair method. The used methods (and only them)are given a value Ψ = MAX(ω1, ω2, ω3, ω4), whereω1 ≥ ω2 ≥ ω3 ≥ ω4.

ω1: reward if new solution is new global best

ω2: reward if new solution is better than thecurrent one

ω3: reward if new solution is accepted

ω4: "reward" if new solution is rejected

Page 28: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

28Thomas Stidsen

DTU-Management / Operations Research

How to adjust ρ− and ρ+ IIFinally, the new ρ− and ρ+ for the selected destroyand repair methods, ρ−

aand ρ+

a:

ρ−a

= λρ−a

+ (1 − λ)ρ−a

Where λ ∈ [0, 1]

Page 29: GRASP – A speedy introduction · GRASP – A speedy introduction Thomas Stidsen ... elements only before starting the construction (example: TSP ... A recently developed method

29Thomas Stidsen

DTU-Management / Operations Research

LNS and ALNS commentsBoth methods have shown excellent results.

Both methods can be considered to begeneralizations of GRASP (complete destroyand probabilistic repair ...)

A somewhat similar method "VariableNeighbourhood Search" is described in thebook ... but I much prefer the handed out articleby Roepke and Pisinger.