Академический Документы
Профессиональный Документы
Культура Документы
Introduction
Some problems are so complicated that are not
possible to solve for an optimal solution.
In these problems, it is still important to find a good
feasible solution close to the optimal.
A heuristic method is a procedure to find a very good
feasible solution of a considered problem.
Procedure should be efficient to deal with very large
problems, and is an iterative algorithm.
Heuristic methods usually fit a specific problem rather
than a variety of problems.
409
Introduction
For a new problem, OR team would need to start from
scratch to develop a heuristic method.
This changed with the development of metaheuristics.
A metaheuristic is a general solution method that
provides:
a general structure;
guidelines for developing a heuristic method for a
particular type of problem.
410
Nature of metaheuristics
Example: maximize
f (x ) 12 x 5 975 x 4
subject to 0
31
411
412
413
414
Nature of metaheuristics
How to overcome this drawback?
What happens in large problems with many variables?
Metaheuristic: solution method that orchestrates the
interaction between local improvement procedures
and a process to escape from local optima in a robust
way.
A trial solution after a local optimum can be inferior to
this local optimum.
415
Solutions by metaheuristics
416
Metaheuristics
Advantage: deals well with large complicated
problems.
Disadvantage: no guarantee to find optimal solution
or even a nearly optimal solution.
When possible, an algorithm that can guarantee
optimality should be used instead.
Can be applied to nonlinear or integer programming.
Most commonly is applied to combinatorial
optimization.
417
418
Common characteristics
Derivative freeness: methods rely on evaluations of
objective function; search direction follows heuristic
guidelines.
Intuitive guidelines: concepts are usually bio-inspired.
Slowness: slower than derivative-based optimization
for continuous optimization problems.
Flexibility: allows any objective function (even
structure of data-fitting model).
419
Common characteristics
Randomness: stochastic methods use random
numbers to determine search directions; may be
global optimizers given enough computation time
(optimistic view).
Analytic opacity: knowledge based on empirical
studies due to randomness and problem-specific
nature.
Iterative nature: need of stopping criteria to
determine when to terminate the optimization
process.
420
421
422
423
Solving example
Sub-tour reversal 3-4 of
1-2-3-4-5-6-7-1
1-2-4-3-5-6-7-1
424
425
Example
Iteration 1: starting with 1-2-3-4-5-6-7-1 (Distance =
69), 4 possible sub-tour reversals that improve
solution are:
Reverse 2-3:
Reverse 3-4:
Reverse 4-5:
Reverse 5-6:
1-3-2-4-5-6-7-1
1-2-4-3-5-6-7-1
1-2-3-5-4-6-7-1
1-2-3-4-6-5-7-1
Distance = 68
Distance = 65
Distance = 65
Distance = 66
426
Example
Iteration 2: continuing with 1-2-4-3-5-6-7-1 only 1 sub-tour
reversal leads to improvement; reverse 3-5-6: 1-2-4-6-53-7-1 with Distance = 64.
Algorithm stops. Last solution is final solution.
This solution is not the optimal!
427
10
Tabu Search
Fred Glover, 1977
Includes a local search procedure, allowing nonimprovement moves to the best solution.
Referred to as steepest ascent/mildest descent
approach.
To avoid cycle in local optimum, a tabu list is added.
Tabu list records forbidden moves, knows as tabu
moves.
Thus, it uses memory to guide the search.
Can include intensification or diversification.
428
11
each iteration?
5. How long should a tabu move remain in the tabu list?
6. Which stopping rule should be used?
430
431
12
Added constraints
Constraint 1: link AD can only be included together
with link DE.
Constraint 2: at most one of the three links AD, CD
and AB can be included.
Previous solution violates both constraints.
432
433
13
Solving example
Initial solution: solution of unconstrained version
Cost = 20 + 10 + 5 + 15 + 200 (why?) = 250
Delete
BE
CE
Cost
75 + 200 = 275
BE
AC
70 + 200 = 270
BE
AB
60 + 100 = 160
CD
AD
60 + 100 = 160
CD
AC
65 + 300 = 365
DE
CE
85 + 100 = 185
DE
AC
80 + 100 = 180
DE
AD
75 + 0
= 75
Minimum
434
435
14
Iteration 2
Options to add a link are AD, BE and CD.
Add
Delete
BE
CE
100 + 0 = 100
Cost
BE
AC
95 + 0 = 95
BE
AB
85 + 0 = 85
CD
DE*
60 + 100 = 160
CD
CE
95 + 100 = 195
AD
DE*
(Tabu move)
AD
CE
85 + 100 = 185
AD
AC
80 + 100 = 180
Minimum
*A
436
Iteration 3
Options to add a link are AB, AD and CD.
Add
Delete
AB
BE*
Cost
(Tabu move)
AB
CE
100 + 0 = 100
AB
AC
95 + 0 = 95
AD
DE*
60 + 100 = 160
AD
CE
95 + 0
= 95
AD
AC
90 + 0
= 90
CD
DE*
70 + 0
= 70
CD
CE
105 + 0
= 105
Minimum
*A
437
15
438
16
Solving problem
Initial trial solution: 1-2-3-4-5-6-7-1 Distance = 69
Iteration 1: choose to reverse 3-4.
Deleted links: 2-3 and 4-5
Added links (tabu list): 2-4 and 3-5
New trial solution: 1-2-4-3-5-6-7-1 Distance = 65
Solving problem
Only two immediate neighbors:
Reverse 6-5-3: 1-2-4-3-5-6-7-1 Distance = 65. (This
would delete links 4-6 and 3-7 that are in the tabu list.)
Reverse 3-7: 1-2-4-6-5-7-3-1 Distance = 66
441
17
442
Iteration 4
Four immediate neighbors:
Reverse 2-4-6-5-7: 1-7-5-6-4-2-3-1 Distance = 65
Reverse 6-5: 1-2-4-5-6-7-3-1 Distance = 69
Reverse 5-7: 1-2-4-6-7-5-3-1 Distance = 63
Reverse 7-3: 1-2-4-5-6-3-7-1 Distance = 64
18
444
Simulated Annealing
Kirkpatrick, Gelatt, Vecchi, 1983
Suitable for continuous and discrete optimization
problems.
Effective in finding near optimal solutions for largescale combinatorial problems such as TSP.
Enables search process to escape from local minima.
Instead of steepest ascent/mildest descent approach
as in tabu search, it tries to search for the tallest hill.
Early iterations take steps in random directions.
445
19
Simulated Annealing
Principle analogous to metals behavior when cooled at
a controlled rate.
Value of objective function analogous to energy in
thermodynamic systems:
At high temperatures, it is likely to accept a new point
with higher energy.
At low temperatures, likelihood of accepting a new
point with higher energy is much lower.
446
Simulated Annealing
Let
Zc = objective function value for current trial solution.
Zn = objective function value for candidate of next trial
solution.
T = tendency to accept Zn if not better than current
solution.
447
20
Simulated Annealing
Move selection rule: among all immediate neighbors
of current solution, select one randomly. To maximize,
accept or reject candidate as follows:
If Zn
If Zn
Prob{acceptance} e x , where x
Zn
Zc
T
(For minimization problems reverse Zn and Zc.)
If candidate is rejected, repeat for another immediate
neighbor.
448
Zn - Zc
T
Prob{acceptance} = e x
0.01
0.990
-0.25
0.779
-1
0.368
-3
0.050
-5
0.007
21
450
451
22
452
23
Solving problem
Suppose that Iteration 2 results in reversing 3-5-6, to
obtain 1-2-4-6-5-3-7-1, with Zn= 64.
Suppose now that Iteration 3 results in reversing 3-7,
to obtain 1-2-4-6-5-7-3-1, with Zn= 66. As Zn > Zc:
Prob{acceptance} e
Zn Zc
T
e 2/13.8
0.865
454
Maximize
f ( x1 ,
, xn )
subject to
Lj
xj
U j , for j 1,
,n
xj = Lj + (Uj Lj)/2.
2. Neighborhood structure: any feasible solution, see
random selection of immediate neighbor.
455
24
Uj
Lj
reset x j
xj
N (0,
), for j 1,
,n
456
Example
Initial solution: x = 15.5, Zc = f(15.5) = 3 741 121, and
T1 = 748 224. = (31 - 0)/6 = 5.167.
Iteration 1: x = 15.5 + N(0, 5.167) = 15.5 7.5 = 8.
Zn = f(8) = 3 055 616. As
Zn
Zc
T
3055616 3714121
748224
Prob{acceptance} e
0.916
0.916
0.400
457
25
GENETIC
ALGORITHMS
Genetic Algorithms
Motivation
What evolution brings us?
Vision
Hearing
Smelling
Taste
Touch
Learning and reasoning
26
Genetic Algorithms
Introduced by John Holland in 1975.
Randomized search algorithms based on mechanics of
natural selection and genetics.
Principle of natural selection through survival of the
fittest with randomized search.
Search efficiently in large spaces.
Robust with respect to the complexity of the search
problem.
Use a population of solutions instead of searching only
one solution at a time: easily parallelized algorithms.
460
Basic elements
Candidate solution is encoded as a string of characters
in binary or real. Bit string is called a chromosome.
Solution represented by a chromosome is the
individual. A number of individuals form a population.
Population is updated iteratively; each iteration is
called a generation.
Objective function is called the fitness function.
Fitness value is maximized.
Multiple solutions are evaluated in parallel.
461
27
Definitions
Population: a collection of solutions for the studied
(optimization) problem.
Individual: a single solution in a GA.
Chromosome: (bit string) representation of a single
solution.
Gene: part of a chromosome, usually representing a
variable characterizing part of the solution.
462
Definitions
Encoding: conversion of a solution to its equivalent bit
string representation (chromosome).
Decoding: conversion of a chromosome to its
equivalent solution.
Fitness: scalar value denoting the suitability of a
solution.
463
28
GA terminology
Generation t
population
y
individual
solution
fitness
(2,0)
(1,1)
(0,3)
(1,2)
(1,1)
gene
chromosome
464
29
Genetic algorithm
Define Initial Population
Parents
Fitness Function
Increment Generation
Assess Fitness
Children
Best Individuals
Selection
Mutation
Crossover
Genetic Algorithm
466
Termination criteria
Number of generations
(restart GA if best solution is not satisfactory).
Fitness of best individual.
Average fitness of population.
Difference of best fitness (across generations).
Difference of average fitness (across generations).
467
30
Reproduction
Three steps:
Selection
Crossover
Mutation
In GAs, the population size is often kept constant.
User is free to choose which methods to use for all
three steps.
468
Roulette-wheel selection
individuals fitness
p = 0.16
p = 0.23
p = 0.11
p = 0.07
p = 0.19
p = 0.24
01100
10001
11010
00111
11000
10110
34
48
23
15
41
50
selection
01100
10001
10001
11000
10110
10110
Sum = 211
469
31
Roulette-wheel selection
1
16%
1
2
23%
6
24%
2
3
4
5
5
19%
4
7%
3
11%
470
Tournament selection
Select pairs randomly
Fitter individual wins
deterministic
probabilistic
constant probability of winning
probability of winning depends on fitness
471
32
Crossover
Exchange parts of chromosome with a crossover
probability (pc is about 0.8)
Select crossover points randomly
One-point crossover:
0
crossover point
0
1
472
N-point crossover
Select N points for exchanging parts
Exchange multiple parts
Two-point crossover:
crossover points
0
0
473
33
Uniform crossover
Exchange bits using a randomly generated mask
Uniform crossover:
0
mask
474
Mutation
Crossover is used to search the solution space
Mutation is needed to escape from local optima
Introduces genetic diversity
Mutation is rare (pm is about 0.01)
Uniform mutation:
0
mutated bit
475
34
GA iteration
10010110
01100010
10100100
10011001
01111101
...
...
...
Elitism
Selection
Crossover
Mutation
10010110
01100010
10100100
10011101
01111001
...
...
...
reproduction
Current
generation
Next
generation
476
Spaces in GA iteration
fitness operators
gene-space
generation N
01100
10001
11010
00111
11000
10110
(de)coding
problem-space
fitness-space
12
17
26
7
24
22
34
48
23
15
41
50
fitness function
geneticoperators
generation N+1
01011
10111
11001
00011
11010
01010
477
35
Handling constraints
Explicit: in the fitness function
penalty function
barrier function
setting fitness of unfeasible solutions to zero
(search may be very inefficient due to unfeasible
solutions)
479
36
480
f ( x, y )
3(1 x )2 e
x 2 ( y 1)2
10
x 3
x
5
y5 e
x2 y 2
1
e
3
( x 1)2 y 2
481
37
482
Example: settings
Search domain: [-3,3] [-3,3]
8-bit binary coding
Search space size = 28 28 = 65536
Each generation with 20 individuals
Fitness value = value of peaks function minimum
function value across population
One-point crossover scheme: 1.0 crossover rate
Uniform mutation: 0.01 mutation rate
Elitism of the best 2 individuals across generations
30 generations
483
38
Initial population
5th generation
10th generation
484
Fitness
Best
Average
Poorest
-5
0
10
15
Generations
20
25
30
485
39
486
gene.
6. Stopping criteria: stop after 5 consecutive
generations without improvement.
Fitness value is just the objective function value in
this example.
6 generations were enough in this example.
487
40
488
41
490
ANT COLONY
OPTIMIZATION
42
492
Curiosities:
Ant colonies exist for more than 100 million years.
Myrmecologists estimate that there are around 20,000 species of ants.
493
43
Fotos: http://iridia.ulb.ac.be/~mdorigo/ACO/RealAnts.html
494
Artificial ants
Artificial ants move in graphs
nodes / arcs
environment is discrete
Food Source
Destination
Nest
Source
44
Choose trail
13
i =1
pijk
Ant 1, t=0
f ( ij )
12
j =2
13
i =1
Deposit pheromone
Ant 1, t=1
12
j =2
j =3
Environment (time)
updates pheromones
13
i =1
Ant 2, t=2
12
ij
(t 1)
ij
(t ) (1
ij
j =2
496
Mathematical framework
Choose node
ij
pijk
ij
ij
, if
ij
0, otherwise
N\ j
Pheromone update
(l 1) (l ) (1
k
ij
Q f , if (i, j )
0, otherwise
k
ij
)
S
Initialization
Set ij = 0
For l =1: Nmax
Build a complete tour
For i = 1 to n
For k = 1 to m
Choose node
Update N
Apply Local Heuristic
end
end
Analyze solutions
For k = 1 to m
Compute fk
end
Update pheromones
end
497
45
498
5
2
17
499
46
Step #2
2
Step #3
Step #4
2
2
2
17
500
17
2
2
17
2
5
2
2
501
47
vs
ACO balances the heuristic information with the
experience (pheromone) information
502
Iteration l = 1, ant m = 1
All paths have the same pheromone intensity 0=0.5.
Pheromone trail and heuristic information have the same
weight = 1, = 1, = 0.1.
An ant is randomly placed.
The probability to choose is, in this case, based only on
heuristic information:
p12=30%
p13=14%
p14=26%
p15=30%
Step #1
503
48
Iteration l = 1, ant m = 1
Step #2
32%
Step #3
53%
22%
47%
46%
Step #5
Step #4
100%
f1
2 2 2
17 12.36
504
Iteration l = 1, ant m = 2
All paths have the same pheromone intensity 0=0.5.
Pheromone trail and heuristic information have the same
weight = 1, = 1, = 0.1.
An ant is randomly placed.
The probability to choose is, in this case, based only on
heuristic information:
p12=30%
p13=14%
p14=26%
p15=30%
Step #1
505
49
Iteration l = 1, ant m = 2
Step #3
Step #2
39%
27%
34%
35%
65%
Step #5
Step #4
100%
f2
5 2 2 10.47
506
507
50
l 1
0 .5 0 .5 0 .5 0 .5 0 .5
0.08
0.095
0 .5 0 .5 0 .5 0 .5 0 .5
0.08
0.095
0 .5 0 .5 0 .5 0 .5 0 .5
0.08
0.095
0 .5 0 .5 0 .5 0 .5 0 .5
0.08
00.95
0 .5 0 .5 0 .5 0 .5 0 .5
0.08
0.095
Considering the pheromone dropped by the best ant of the present iteration
l 1
0 .5 0 .5 0 .5 0 .5 0 .5
0.095
0 .5 0 .5 0 .5 0 .5 0 .5
0.095
0 .5 0 .5 0 .5 0 .5 0 .5
0.095
0 .5 0 .5 0 .5 0 .5 0 .5
00.95
0 .5 0 .5 0 .5 0 .5 0 .5
0.095
508
Iteration l = 2, ant m = 1
The pheromone trails have different intensities.
Pheromone trail and heuristic information have the same
weight = 1, = 1, = 0.1.
An ant is randomly placed.
The probability to choose is:
p41=19%
p42=26%
p43=23%
p45=32%
Step #1
509
51
Iteration l = 2, ant m = 1
Step #2
46%
32%
Step #3
71%
22%
29%
Step #5
Step #4
100%
f1
2 2 2
5 10.47
510
Iteration l = 2, ant m = 2
The pheromone trails have different intensities.
Pheromone trail and heuristic information have the same
weight = 1, = 1, = 0.1.
An ant is randomly placed.
The probability to choose is:
p21=26%
p23=29%
p24=26%
p25=19%
Step #1
511
52
Iteration l = 2, ant m = 2
Step #2
Step #3
24%
37%
24%
63%
52%
Step #4
Step #3
100%
f2
5 2 2 2 10.47
512
The reinforcement
produced by each ant is
0,095.
513
53
l 1
0.45
0.45
0.45
0.45
0.55
0.55
0.45
0.45
0.45
0.45
0.45
0.55
0.45
0.45
0.45
0.45
0.45
0.55
0.45
0.45
0.45
0.45
0.45
0.55
0.45
0
0.095
0
0
0
0
0
0.095
0
0
0
0
0
0.095
0
0
0
0
0
00.95
0.095
0
0
0
0
0
0.095
0
0
0
0
0
0.095
0
0
0
0
0
0.095
0
0
0
0
0
00.95
0.095
0
0
0
0
0.095
0.095
0.095
00.95
0.095
514
Pheromone update
= update_phero(solution, f(solution), , )
515
54
Fujitsu-Siemens logistics
516
Order # 1
A
B
Component stock
A
B
B
Order # 2
Exponential
C
A
B
C
E
Order # 3
A
C
D
E
Order # 1
Orders
Order # 3
Order # 2
Order # 1
A
Scheduling
B
decision process
C
517
55
Optimization results
Best optimization result for a specific day
Method
fL
Orders at correct
date
Orders delay
max (T)
(T)
T[s]
GA
25.12
12
23
2.61
32
ACO
25.12
23
23
2.61
954
(fL)
T[s]
GA
25.93
1.06
11.64
0.24
32.1
0.95
ACO
25.35
0.16
11.96
0.40
934.6
20.30
518
Comparing results
ACO takes less iterations to find the optimum
GA is much faster than ACO
519
56
Comparing results
GA and ACO present similar performances
ACO has less variation between runs
520
57