elg7186_10_HillClimb..

SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Hardware/Software
Codesign of
Embedded Systems
OPTIMIZATION II
Voicu Groza
SITE Hall, Room 5017
562 5800 ext. 2159
Groza@SITE.uOttawa.ca
1
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
• Hill Climbing
• Simulated Annealing
• Tabu search
2
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Hill Climbing (Gradient Descent)
Trying to maximize a
function
1. Pick a random point
in the search space.
2. Consider all the
neighbours of the
http://www.ndsu.nodak.edu/instruct/juell/vp/cs724s00/hill_climbing/
hill_climbing.html
current state.
3. Choose the neighbour with the best quality and
move to that state.
4. Repeat 2 through 4 until all the neighbouring states
are of lower quality.
5. Return the current state as the solution state.
3
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Hill Climbing Algorithm
Function HILL-CLIMBING(Problem) returns a solution state
Inputs:
Problem, problem
Local variables: Current, a node
Next, a node
Current = MAKE-NODE(INITIAL-STATE[Problem])
Loop do
Next = a highest-valued successor of Current
If VALUE[Next] < VALUE[Current] then return Current
Current = Next
End
(Russell, 1995)
4
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problems in Hill Climbing
Tendency to get stuck at foothills, a
plateau or a ridge. If the algorithm
reaches any of them, it will fail to
find a solution.
http://www.cs.nott.ac.uk/~gxk/courses/g5baim/Hill%
20Climbing/Hill02-problems.html
• Local maxima = states that are better than
all its neighbours but are not better than
some other states farther away.
• Foothills are potential traps for the algorithm.
• A plateau is a flat area of the search space in which a whole set of
neighbouring states have the same value. On a plateau, it is not possible to
determine the best direction in which to move by making local comparisons.
• Possible solutions:
• Try several runs, multi-start hill-climb: each starting at a random point in the
search space.
• Increase the size of the neighbourhood
There is no guarantee to find a global optimum.
5
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Simulated Annealing





Motivated by the physical annealing process
Material is heated and slowly cooled into a uniform structure
Simulated annealing mimics this process
The first SA algorithm was developed in 1953 (Metropolis)
Compared to hill climbing the main differences are that
 SA allows downwards steps;
 a move is selected at random and then decides whether to accept it
 In SA better moves are always accepted. Worse moves are
not always accepted!?
Dr. Graham Kendall, The University of Nottingham, UK
6
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
To accept or not
to accept - SA?
The law of thermodynamics states that
at temperature t, the probability of an
increase in energy of magnitude, δE,
is given by
P(δE) = exp(-δE /kt)
where k is Boltzmann’s constant
P = exp(-c/t) > r
Probability of accepting with
high temperature
Change in
Evaluation Temperature
Function
of System exp(-C/T)
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
where
0.904837418
0.818730753
0.740818221
0.670320046
0.60653066
0.548811636
0.496585304
0.449328964
0.40656966
0.367879441
0.332871084
0.301194212
0.272531793
0.246596964
0.22313016
0.201896518
0.182683524
0.165298888
0.149568619
0.135335283
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
exp(-C/T)
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
0.367879441
0.135335283
0.049787068
0.018315639
0.006737947
0.002478752
0.000911882
0.000335463
0.00012341
4.53999E-05
1.67017E-05
6.14421E-06
2.26033E-06
8.31529E-07
3.05902E-07
1.12535E-07
4.13994E-08
1.523E-08
5.6028E-09
2.06115E-09
Temp = 100
Temp = 10
1
• Example
Change in
Evaluation Temperature
Function
of System
SImulated Annealing Acceptance Probability
Probability of Acceptance
– c is change in the
evaluation function
– t the current temperature
– r is a random number
between 0 and 1
Probability of accepting with low
temperature
3
5
7
9
11
13
15
17
19
Change in Evaluation
7
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
To accept or not to accept - SA?

The probability of accepting a worse state is a
function of both the temperature of the system
and the change in the cost function

As the temperature decreases, the probability of
accepting worse moves decreases

If t = 0, no worse moves are accepted (i.e. hill
climbing)
8
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Algorithm
The most common way of implementing an SA
algorithm is to implement hill climbing with an accept
function and modify it for SA
Function SIMULATED-ANNEALING(Problem, Schedule)
returns a solution state
Inputs:
Problem, a problem
Schedule, a mapping from time to temperature
Local Variables : Current, a node
Next, a node
T=“temperature” controlling the probability of downward steps
Current = MAKE-NODE(INITIAL-STATE[Problem])
Russell/Norvig
9
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Algorithm
For i = 1 to  do
T = Schedule[i]
If T = 0 then return Current
Next = a randomly selected successor of Current
E = VALUE[Next] – VALUE[Current]
if E > 0 then Current = Next
else Current = Next only with probability exp(- E/T)
10
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Algorithm - Observations
•
The cooling schedule is hidden in this algorithm,
and important are
–
–
–
–
•
Starting Temperature
Final Temperature
Temperature Decrement
Iterations at each temperature
The algorithm assumes that annealing will
continue until temperature is zero - this is not
necessarily the case
11
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Cooling Schedule Starting Temperature
•
Must be hot enough to allow moves to almost
neighbourhood state (else we are in danger of
implementing hill climbing)
•
Must not be so hot that we conduct a random
search for a period of time
•
Problem is finding a suitable starting temperature
12
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Cooling Schedule –
Starting Temperature
•
Starting Temperature - Choosing
– If we know the maximum change in the cost
function we can use this to estimate
– Start high, reduce quickly until about 60% of
worse moves are accepted. Use this as the
starting temperature
– Heat rapidly until a certain percentage are
accepted the start cooling
13
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Cooling Schedule Final Temperature
• It is usual to let the temperature decrease until it reaches zero
However, this can make the algorithm run for a lot longer,
especially when a geometric cooling schedule is being used
• In practice, it is not necessary to let the temperature reach zero
because the chances of accepting a worse move are almost the
same as the temperature being equal to zero
• => the stopping criteria can either be a suitably low temperature
or when the system is “frozen” at the current temperature (i.e.
no better or worse moves are being accepted)
14
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Cooling Schedule Temperature Decrement
Theory states that:
•
should allow enough iterations at each temperature so
that the system stabilises at that temperature
•
the number of iterations at each temperature to achieve
this might be exponential to the problem size
=> compromise:
– doing a large number of iterations at a few temperatures, or
– a small number of iterations at many temperatures or
– a balance between the two
15
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Cooling Schedule Temperature Decrement
• Linear
– temp = temp - x
• Geometric
– temp = temp * α
– Experience has shown that α should be between 0.8
and 0.99, with better results being found in the higher
end of the range. Of course, the higher the value of α,
the longer it will take to decrement the temperature to
the stopping criterion
16
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Cooling Schedule Iterations
POSSIBLE APPROACHES:
1. A constant number of iterations at each temperature
2. Lundy, 1986: do only one iteration at each temperature,
but to decrease the temperature very slowly
•
•
3.
t = t/(1 + βt)
where β is a suitably small value
Dynamically change the number of iterations as the
algorithm progresses:
–
–
at lower temperatures a large number of iterations are done
so that the local optimum can be fully explored
at higher temperatures, the number of iterations can be less
17
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problem Specific Decisions
•
The cooling schedule is all about SA but there are other
decisions which we need to make about the problem
•
These decisions are not just related to SA
18
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problem Specific Decisions Cost Function
•
•
The evaluation function is calculated at every iteration
Often the cost function is the most expensive part of the
algorithm
=> Need to evaluate the cost function as efficiently as possible
– Use Delta Evaluation
– Use Partial Evaluation
•
The cost function should be designed to lead the search
– Avoid cost functions where many states return the same value.
This can be seen as representing a plateau in the search space
which the search has no knowledge about which way it should
proceed
19
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problem Specific Decisions Cost Function
•
•
Many cost functions cater for the fact that some
solutions are illegal. This is achieved using constraints
Hard Constraints : these constraints cannot be violated in
a feasible solution
Soft Constraints : these constraints should, ideally, not be
violated but, if they are, the solution is still feasible
– Hard constraints are given a large weighting. The solutions which
violate those constraints have a high cost function
– Soft constraints are weighted depending on their importance
– Weights can be dynamically changed as the algorithm
progresses. This allows hard constraints to be accepted at the
start of the algorithm but rejected later
20
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problem Specific Decisions Neighbourhood
•
•
•
•
•
How do you move from one state to another?
When you are in a certain state, what other states are
reachable?
Some results have shown that the neighbourhood
structure should be symmetric. That is, if you move from
state i to state j then it must be possible to move from
state j to state i
However, a weaker condition can hold in order to ensure
convergence.
Every state must be reachable from every other.
Therefore, it is important, when thinking about your
problem to ensure that this condition is met
21
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problem Specific Decisions Performance
•
•
What is performance?
– Quality of the solution returned
– Time taken by the algorithm
We already have the problem of finding suitable SA
parameters (cooling schedule)
22
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problem Specific Decisions Initialisation
– Start with a random solution and let the annealing
process improve on that.
– Might be better to start with a solution that has been
heuristically built (e.g. for the TSP problem, start with
a greedy search)
23
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Problem Specific Decisions Hybridisation
… or mimetic algorithms:
Combine two search algorithms
– Often a population based search strategy is used as
the primary search mechanism, and a local search
mechanism is applied to move each individual to a
local optimum
– It may be possible to apply some heuristic to a solution
in order to improve it
24
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Example: VLSI Floorplanning
with Simulated Annealing
Modules are displayed as yellow rectangles; terminals are marked by small
black rectangles. Connections between modules are displayed using red
lines. This display of nets is sometimes known as a "rat's nest" diagram.
On the left, it displays a diagram of a floorplan and its estimated cost.
On the right, it
displays
annealing status
information,
controls, and a
plot of maximum
(red), average
(black), and
minimum (green)
accepted
configuration
costs at each
temperature.
http://foghorn.cadlab.lafayette.edu/cadapplets/fp/fpApplet.html
25
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Modifications –
Acceptance Probability
•
•
•
The probability of accepting a worse move is normally
based on the physical analogy (based on the Boltzmann
distribution)
Is there any reason why a different function will not
perform better for all, or at least certain, problems?
Why should we use a different acceptance criteria?
– The one proposed does not work. Or we suspect we might be
able to produce better solutions
– The exponential calculation is computationally expensive.
– (Johnson, 1991) found that the acceptance calculation took
about one third of the computation time
26
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
time(n)
SA Modifications –
Acceptance Probability
•
•
•
•
•
time(0)
time(1)
time(2)
time(3)
time(4)
time(5)
time(6)
time(7)
time(8)
time(9)
time(10)
time(11)
time(12)
time(13)
time(14)
time(15)
time(16)
time(17)
time(18)
time(19)
time(20)
t = t / (1 + ßt)
100
90.90909091
83.33333333
76.92307692
71.42857143
66.66666667
62.5
58.82352941
55.55555556
52.63157895
50
47.61904762
45.45454545
43.47826087
41.66666667
40
38.46153846
37.03703704
35.71428571
34.48275862
33.33333333
Johnson experimented with
P(δ) = 1 – δ/t
This approximates the exponential
A better approach was found by building
a look-up table of a set of values over the range δ/t
During the course of the algorithm δ/t was rounded to the
nearest integer and this value was used to access the
look-up table
This method was found to speed up the algorithm by
about a third with no significant effect on solution quality
27
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Modifications - Cooling
•
•
•
•
If you plot a typical cooling schedule you are likely to find
that at high temperatures many solutions are accepted
If you start at a too higher temperature a random search
is emulated and until the temperature cools sufficiently
any solution can be reached and could have been used
as a starting position
At lower temperatures, a plot of the cooling schedule, is
likely to show that very few worse moves are accepted;
almost making simulated annealing emulate hill climbing
Taking this one stage further, we can say that simulated
annealing does most of its work during the middle stages
of the cooling schedule
28
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Modifications - Cooling
•
•
•
•
•
•
Connolly suggested annealing at a constant temperature!
But what temperature?
It must be high enough to allow movement but not so low
that the system is frozen
But, the optimum temperature will vary from one type of
problem to another and also from one instance of a
problem to another instance of the same problem
One solution to this problem is to spend some time
searching for the optimum temperature and than stay at
that temperature for the remainder of the algorithm
The final temperature is chosen as the temperature that
returns the best cost function during the search phase
29
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Modifications Neighbourhood
•
•
•
The neighbourhood of any move is normally the same
throughout the algorithm but…
The neighbourhood could be changed as the algorithm
progresses
For example, a cost function based on penalty values can
be used to restrict the neighbourhood if the weights
associated with the penalties are adjusted as the
algorithm progresses
30
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Modifications –
Cost Function
•
•
•
The cost function is calculated at every iteration of the
algorithm
Various researchers (e.g. Burke,1999) have shown that
the cost function can be responsible for a large proportion
of the execution time of the algorithm
Some techniques have been suggested which aim to
alleviate this problem: (Rana, 1996) - Coors Brewery
– GA but could be applied to SA
– The evaluation function is approximated (one tenth of a second)
– Potentially good solution are fully evaluated (three minutes)
31
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
SA Modifications –
Cost Function
•
•
(Ross, 1994) uses delta evaluation on the timetabling problem
– Instead of evaluating every timetable as only small
changes are being made between one timetable and the
next, it is possible to evaluate just the changes and
update the previous cost function using the result of that
calculation
(Burke, 1999) uses a cache
– The cache stores cost functions (partial and complete)
that have already been evaluated
– They can be retrieved from the cache rather than having
to go through the evaluation function again
32
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Tabu Search Overview
• Tabu – socially or culturally proscribed: forbidden to be
used, mentioned, or approached because of social or
cultural rather than legal prohibitions.
(http://encarta.msn.com/dictionary_1861698691/taboo.html)
• The Tabu search proceeds according to the supposition that
there is no point in accepting a new (poor) solution unless it
is to avoid a path already investigated.
• Tabu search is based on introducing flexible memory
structures in conjunction with strategic restrictions (Tabu
lists) and aspiration levels as a means for exploiting
search spaces.
33
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Characteristics
•
Always performs best move or least non-improving
move
• Employs a memory to diversify or intensify the search
• Is deterministic (although probabilistic elements may
exist)
• Three main strategies:
– Forbidding strategy: control what enters the tabu list
– Freeing strategy: control what exits the tabu list and
when
– Short-term strategy: manage interplay between the
forbidding strategy and freeing strategy to select trial
solutions
34
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Basic Ingredients of Tabu Search
• To exploit memory in tabu search => classify a subset of the moves in a
neighborhood as forbidden (or tabu)*
• A neighborhood is constructed to identify adjacent solutions that can
be reached from current solution.
• The classification depends on the history of the search, and particularly
on the recency or frequency that certain move or solution
components, called attributes, have participated in generating past
solutions*.
• A tabu list records forbidden moves, which are referred to as tabu
moves [5].
• Tabu restrictions are subject to an important exception. When a tabu
move has a sufficiently attractive evaluation where it would result in a
solution better than any visited so far, then its tabu classification may be
overridden. A condition that allows such an override to occur is called
an aspiration criterion*.
* Glover, F. and Laguna, M., “Tabu Search.,” Norwell, MA: Kluwer Academic Publishers, 1997
35
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Components of Tabu Search
•
•
•
•
•
•
•
•
Encoding
Initial solution
Objective Function
Move operator
Definition of Neighbourhood
Structure of Tabu list(s)
Aspiration criteria (optional)
Termination criteria
procedure tabu search
begin
initialize Tabu List (TL) = empty
generate a (current} solution S
let S* = S be the best solution so far
repeat
repeat
select the best point B in the
neighbourhood of S: N(S)
if(B is not Tabu: B TL)
accept move: S=B
update Tabu List: TL = TL  B
if(eval(B) > eval(S*))
S* = B
else if (eval(B) > eval(S*))
accept move: S = B
update best: S* = B
end
until (acceptable move found)
until (halting-criterion)
36
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Components
Initial Solution
– Random
– Constructive
Memory Aspects
1.Recency (short term)
How recently was I here?
2.Frequency (long term)
How often have I been here ?
3.Quality (aspiration)
How good is being here?
4.Influence (aspiration)
How far away am I from where I have just been ?
37
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Components
Tabu List Specifics
• The main objective of the tabu list is to avoid “cycles”,
thus making a global optimizer rather than a local
optimizer.
• Length – fixed or dynamic (generally 7 to 20)
• Content - “from” attributes, “to” attributes; “move”
attributes; the more specific, the less restrictive
• Frequency - tallying similar solutions through tabu
content. Usually used in penalty form rather than
strict tabu.
38
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Components
Neighbourhood
•
•
•
•
Complete (deterministic)
Partial (probabilistic)
First improvement
Only improving
Aspiration criteria specifics
•
•
•
•
•
Best so far (Global)
Best in neighbourhood (Local)
Dissimilar to existing solution (diversification)
Similar to existing solution (intensification)
High influence – degree of change in structure or feasibility
39
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Basic Tabu Search Algorithm
• Step 1: Choose an initial solution i in S. Set i* = i and k=0.
• Step 2: Set k=k+1 and generate a subset V* of solution in N(i,k) such
that either one of the Tabu conditions is violated or at least one of the
aspiration conditions holds.
• Step 3: Choose a best j in V* and set i=j.
• Step 4: If f(i) < f(i*) then set i* = i.
• Step 5: Update Tabu and aspiration conditions.
• Step 6: If a stopping condition is met then stop. Else go to Step 2.
40
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Tabu Search Stopping Conditions
Some immediate stopping conditions could be the following:
1. N(i, K+1) = 0. (no feasible solution in the neighborhood of solution i)
2. K is larger than the maximum number of iterations allowed.
3. The number of iterations since the last improvement of i* is larger than
a specified number.
4. Evidence can be given than an optimum solution has been obtained.
Hillier and Lieberman outlined the tabu search stopping criterion by, for
example, using a fixed number of iterations, a fixed amount of CPU
time, or a fixed number of consecutive iterations without an
improvement in the best objective function value. Also stop at any
iteration where there are no feasible moves into the local neighborhood
of the current trial solution.
41
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Initial solution
(i in S)
Create a candidate
list of solutions
Update Tabu &
Aspiration
Conditions
Flowchart of a Tabu
Search Algorithm
Evaluate solutions
No
Choose the best
admissible solution
Stopping conditions
satisfied ?
Yes
Final solution
42
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Example : N-Queens Problem
• Consists of placing n queens on an n n
chessboard in such a way that no two queens
capture each other (aspiration criterion)
1
1
2
3
4
Q
2
3
4
Q
Q
Q
43
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Encoding
• The n-queens problem can be represented as a
permutation problem.
• Let the queens be indexed by i
• Mark queen i with the row’s index i
• Let (i) be the index of the column where queen i is placed
• A configuration is given by the permutation
 = {(1),(2),…(n)}
1 2 3 4
1
Q
2 Q
3
Q
4
Q
Q1: (1) = 3
Q2: (2) = 1
Q3: (3) = 4
Q4: (4) = 2
 = {3,1,4,2}
44
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Neighbourhood
•
Swaps (pair-wise exchanges) can be used to define
neighborhoods in permutation problems.
Current solution
=
4 5 3 6 7 1 2
move operator
Swap queens 2 and 6
’ = 4 1 3 6 7 5 2
45
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Structure of Tabu List
•
To prevent the search from repeating swapping
combinations tried in the recent past, we will classify
all swaps Tabu for three iterations.
2 3 4 5 6 7
* Each cell contains the #
iterations remaining until the
corresponding queens are allowed
to exchange positions again
1
2
*
3
4
Tabu
Memory
5
6
46
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Iteration - 0
1 2 3 4 5 6 7
Current solution
4 5 3 6 7 1 2
2 3 4 5 6 7
swap
1 7
value
-2
2
2 4
-2
2 6
-2
5 6
-2
1 5
1
1
3
4
Tabu
Memory
5
6
1
Q
2
Q
3
Q
4
Q
5
Q
6 Q
7
Q
# collisions = 4
Top 5 (of 21)
Candidates
47
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Iteration - 1
Swap Q1 with Q7
From Iteration 0:
4 5 3 6 7 1 2
Current solution:
2 5 3 6 7 1 4
2 3 4 5 6 7
1
3
2
3
4
Tabu
Memory
5
6
swap
2 4
value
-1
1 6
0
2 5
0
1 2
1
1 3
1
1 2 3 4 5 6 7
1
Q
2
Q
3
Q
4
Q
5
Q
6 Q
7
Q
# collisions = 2
Top 5 (of 20)
Candidates
48
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Iteration - 2
swap Q2 with Q4
From Iteration 1:
2 5 3 6 7 1 4
Current solution:
2 6 3 5 7 1 4
2 3 4 5 6 7
1
2
2
3
3
4
Tabu
Memory
5
6
swap
1 3
value
0
1 7
1
Tabu
2 4
1
Tabu
4 5
1
6 7
1
1 2 3 4 5 6 7
1
Q
2
Q
3
Q
4
Q
5
Q
6 Q
7
Q
# collisions = 1
Top 5 (of 19)
Candidates
49
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Iteration - 3
1 2 3 4 5 6 7
swap Q1 with Q3
From Iteration 2:
2 6 3 5 7 1 4
Current solution
3 6 2 5 7 1 4
2 3 4 5 6 7
1
3
1
2
2
3
4
Tabu
Memory
5
6
swap
1 3
value
0 Tabu
1 7
0
5 7
1
6 7
1
1 2
2
Tabu
1
Q
2
Q
3
Q
4
Q
5
Q
6 Q
7
Q
# collisions = 1
Top 5 (of 18)
Candidates
50
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Iteration - 4
1 2 3 4 5 6 7
swap Q5 with Q7
From Iteration 3:
3 6 2 5 7 1 4
Current solution
3 6 2 5 4 1 7
2 3 4 5 6 7
1
2
2
1
3
4
Tabu
Memory
5
3
6
swap
4 7
value
-1
5 7
-1
1 5
0
2 5
0
2 4
2
Tabu
1
Q
2
Q
3
Q
4
Q
5
Q
6 Q
7
Q
# collisions = 2
Tabu
Top 5 (of 18)
Candidates
51
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Iteration - 5
swap Q4 with Q7
From Iteration 4:
3 6 2 5 4 1 7
Current solution
3 6 2 7 4 1 5
2 3 4 5 6 7
swap
1 3
1
1
2
1 6
3
4
Tabu
Memory
3
2
5
6
value
-1
Tabu
0
*
5 7
0
5 6
1
1 7
2
Top 5 (of 18)
Candidates
1 2 3 4 5 6 7
1
Q
2
Q
3
Q
4
Q
5
Q
6 Q
7
Q
# collisions = 1
Tabu
*
Satisfies
aspiration
criterion!!!
52
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Iteration - 6
swap Q1 with Q3
From Iteration 5:
3 6 2 7 4 1 5
Current solution
2 6 3 7 4 1 5
2 3 4 5 6 7
1
2
3
4
Tabu
Memory
2
1
5
6
1 2 3 4 5 6 7
1
Q
2
Q
3
Q
4
Q
5
Q
6 Q
7
Q
# collisions = 0
Search Terminates
53
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Example*
– Minimum spanning tree problem with constraints.
– Objective: Connects all nodes with minimum costs
Costs
B
B
20
A
30
10
C
5
20
E
A
30
10
25
15
C
5
E
25
D
40
15
D
40
An optimal solution without
considering constraints
Constraints 1: Link AD can be included only if link DE also is included. (penalty:100)
Constraints 2: At most one of the three links – AD, CD, and AB – can be included.
(Penalty of 100 if selected two of the three, 200 if all three are selected.)
* Hillier, F.S. and Lieberman, G.J., “Introduction to Operations Research.” New York, NY: McGraw-Hill. 8th Ed., 2005
54
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Example
Iteration 1
Cost=50+200 (constraint penalties)
B
20
A
30
10
C
5
E
25
Delete 15
D
40 Add
Add
Delete
Cost
BE
BE
BE
CE
AC
AB
75+200=275
70+200=270
60+100=160
CD
CD
AD
AC
60+100=160
65+300=365
DE
DE
DE
CE
AC
AD
85+100=185
80+100=180
75+0=75
New cost = 75 (iteration 2)
( local optimum)
Constraints 1: Link AD can be included only if link DE also is included. (penalty:100)
Constraints 2: At most one of the three links – AD, CD, and AB – can be included.
(Penalty of 100 if selected two of the three, 200 if all three are selected.)
* Hillier, F.S. and Lieberman, G.J., “Introduction to Operations Research.” New York, NY: McGraw-Hill. 8th Ed., 2005
55
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Example
Tabu list: DE
Iteration 2 Cost=75
Delete
B
20
A
30
10
C
5
25
15
D
40
Add
E
Add
Delete
Cost
AD
AD
AD
DE*
CE
AC
Tabu move
85+100=185
80+100=180
BE
BE
BE
CE
AC
AB
100+0=100
95+0=95
85+0=85
CD
CD
DE*
CE
60+100=160
95+100=195
Tabu
* A tabu move will be considered only if it would
result in a better solution than the best trial
solution found previously (Aspiration Condition)
Iteration 3 new cost = 85 Escape local optimum
Constraints 1: Link AD can be included only if link DE also is included. (penalty:100)
Constraints 2: At most one of the three links – AD, CD, and AB – can be included.
(Penalty of 100 if selected two of the three, 200 if all three are selected.)
* Hillier, F.S. and Lieberman, G.J., “Introduction to Operations Research.” New York, NY: McGraw-Hill. 8th Ed., 2005
56
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Example
Tabu list: DE & BE
Iteration 3 Cost=85
B
Tabu
20
A
30
10
25
15
C
5
E
Add
D
40
Tabu
Delete
Add
Delete
Cost
AB
AB
AB
BE*
CE
AC
Tabu move
100+0=100
95+0=95
AD
AD
AD
DE*
CE
AC
60+100=160
95+0=95
90+0=90
CD
CD
DE*
CE
70+0=70
105+0=105
* A tabu move will be considered only if it would
result in a better solution than the best trial
solution found previously (Aspiration Condition)
Iteration 4 new cost = 70 Override tabu status
Constraints 1: Link AD can be included only if link DE also is included. (penalty:100)
Constraints 2: At most one of the three links – AD, CD, and AB – can be included.
(Penalty of 100 if selected two of the three, 200 if all three are selected.)
* Hillier, F.S. and Lieberman, G.J., “Introduction to Operations Research.” New York, NY: McGraw-Hill. 8th Ed., 2005
57
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Example
B
20
A
30
10
C
5
25
15
D
40
E
Optimal Solution
Cost = 70
Additional iterations only find
inferior solutions
* Hillier, F.S. and Lieberman, G.J., “Introduction to Operations Research.” New York, NY: McGraw-Hill. 8th Ed., 2005
58
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
• Pros:
Pros and Cons
– Allows non-improving solution to be accepted in order to escape
from a local optimum
– The use of Tabu list
– Can be applied to both discrete and continuous solution spaces
– For 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 [1].
• Cons:
– Too many parameters to be determined
– Number of iterations could be very large
– Global optimum may not be found, depends on parameter
settings
59
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Advanced Topics
• Intensification: penalize solutions far from
the current solution
• Diversification: penalize solutions close to
the current solution
60
SITE, 2008 - HARDWARE/SOFTWARE CODESIGN OF EMBEDDED SYSTEMS
Some Convergence Results
• Memory Tabu Search converges to the
global optimum with probability one if
randomly generated vectors (x) follows
Gaussian or uniform distribution [6].
• Convergent Tabu Search converges to the
global optimum with probability one [3].
61