1b, Meta-Heuristics
1b, Meta-Heuristics
META-HEURISTICS
MEHRDAD MOHAMMADI & PATRICK MEYER
CONTENT
1. INTRODUCTION
2. OPTIMIZATION METHODS
3. SOLUTION ALGORITHMS
5. METAHEURISTIC ALGORITHMS
INTRODUCTION 3
Optimization? Why?
DECISION MAKING
► Problem formulation,
► Problem modeling,
► Problem optimization and
► Solution implementation
OR - METAHEURISTICS 14/01/2019
INTRODUCTION 4
Optimization Models
Optimization Models
OR - METAHEURISTICS 14/01/2019
INTRODUCTION 5
Optimization vs. Complexity
► Complexity of Algorithms
► An algorithm needs two important resources to solve a problem: time and space
OR - METAHEURISTICS 14/01/2019
INTRODUCTION 6
Optimization vs. Complexity
► Complexity of Algorithms
► An algorithm needs two important resources to solve a problem: time and space
Complexity Size n
10 20 30 40 50
O(n) 10 μs 20 μs 30 μs 40 μs 50 μs
O(n2) 100 µs 400 µs 900 µs 1600 µs 2500 µs
O(2n) 1000 µs 106 µs 6.4E10 µs 12.7 days 35.7 years
O(n!) 1.8E5 µs 19 cen. 1.6E15 cen. 4.2E30 cen. …
OR - METAHEURISTICS 14/01/2019
INTRODUCTION 7
Traveling Salesman Problem (TSP)
𝑛−1 !
► Ω = for a symmetric problem
2
OR - METAHEURISTICS 14/01/2019
OPTIMIZATION METHODS 8
Terminology
Optimization Methods
Problem-specific
Metaheuristics
Heuristics
► Metaheuristic:
“Upper level general methodologies that can be used as guiding strategies in designing
underlying heuristics to solve specific optimization problems”
OR - METAHEURISTICS 14/01/2019
OPTIMIZATION METHODS 10
Metaheuristics
OR - METAHEURISTICS 14/01/2019
OPTIMIZATION METHODS 11
Metaheuristics
Intensification Diversification
Best algorithms
are good in both
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 12
How to Search?
Heuristic Algorithms
Mechanism
· Greedy Search · SA, VNS, TS, ... · GA, ICA, PSO, ... · LS + EA
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 13
Construction Mechanism: Greedy Search
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 14
Greedy Search for TSP
- Step 1: Select a node randomly (if not given) and name it current node
- Step 2: Go to the next node which is the closest one to the current node
- Step 5: Connect current node to the starting node and return the tour.
- Complexity: O(n2)
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 15
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 16
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 17
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 18
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 19
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 20
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 21
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 22
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 23
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 24
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 25
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 26
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
SOLUTION ALGORITHMS 27
Greedy Search for TSP
7 5
10 9
3
1
2
OR - METAHEURISTICS 14/01/2019
LOCAL SEARCH OPTIMIZATION 46
History of Hikers
OR - METAHEURISTICS 14/01/2019
LOCAL SEARCH OPTIMIZATION 47
History of Hikers
► Hiker 1
► Strategy: “I am sportive and I explore all the possible
trails”
► Result: He is hiking infinitely in the mountain.
Local Optimum
Local Optimum
OR - METAHEURISTICS Global Optimum
14/01/2019
LOCAL SEARCH OPTIMIZATION 48
History of Hikers
► Hiker 2
► Strategy: “As long as I can go down, I do it”
► Result: He will be trapped in a local valley
Local Optimum
Local Optimum
OR - METAHEURISTICS
Global Optimum 14/01/2019
LOCAL SEARCH OPTIMIZATION 49
History of Hikers
► Hiker 3
► Strategy: “I go down, but sometimes I may take paths
that do not go up too much”
► Result: He arrives to lower alleys comparing to Hiker 2
and he may be trapped in a local valley
Local Optimum
Local Optimum
OR - METAHEURISTICS Global Optimum
14/01/2019
LOCAL SEARCH OPTIMIZATION 50
History of Hikers
► Hiker 4
► Strategy: “As long as possible, I take paths with high
slope, but sometimes I may take paths that do not go
up too much. I also memorize and avoid from the trails
already taken”
► Result: Same as the 3rd hiker but may spend less
time to arrive
Forbidden path
► Note: short memories avoids
infinite loops and may save time
Local Optimum
Local Optimum
OR - METAHEURISTICS Global Optimum
14/01/2019
LOCAL SEARCH OPTIMIZATION 51
Principales
► Local search algorithms move from solution to solution in the search space by
applying local changes, until a solution deemed optimal is found or a time bound is
elapsed.
► Requirements:
A. Initial solution
B. Local search operators (searching neighbors))
OR - METAHEURISTICS 14/01/2019
LOCAL SEARCH OPTIMIZATION 52
LS for TSP
1 4 8 7 5 2 10 9 3 6
► Step 3: If the new solution is better than the previous one, replace them
and go to Step 2; if not go to Step 4.
► Operator Insertion
- Select two nodes i and j, and insert j next to i
1 4 8 7 5 2 10 9 3 6
1 4 8 10 7 5 2 9 3 6
► Operator Swap
- Select two nodes i and j, and swap their position
1 4 8 7 5 2 10 9 3 6
1 4 10 7
OR - METAHEURISTICS
5 2 8 9 3
14/01/2019
6
LOCAL SEARCH OPTIMIZATION 54
LS for TSP
► Neighborhood Search
► Operator Reversion
- Select two nodes i and j, and reverse in-between permutation
1 4 8 7 5 2 10 9 3 6
1 4 10 2 5 7 8 9 3 6
► Operator 2-opt
- Select two edges, change their place
1 4 8 7 5 2 10 9 3 6
1 4 2 10 5 8 7 9 3 6
OR - METAHEURISTICS 14/01/2019
LOCAL SEARCH OPTIMIZATION 57
Discussion
► Advantage
- Good Intensification (They exploit around carefully)
- Use very little memory
- Providing better solution comparing to greedy and approximation
searches
► Disadvantage
- Getting trap in local optima
- Require problem-specific operators (sometimes)
- Their performance highly depends on the initial solution (They need good
enough initial solutions to work well)
OR - METAHEURISTICS 14/01/2019
METAHEURISTIC ALGORITHMS 58
Genetic Algorithm (GA)
OR - METAHEURISTICS 14/01/2019
METAHEURISTIC ALGORITHMS 59
Genetic Algorithm (GA): Principles
► Each individual is evaluated based on its properties (Fitness value); this evaluation
helps to survive
OR - METAHEURISTICS 14/01/2019
METAHEURISTIC ALGORITHMS 60
Genetic Algorithm (GA): General Framework
Evolution Evolution
Generation 1
Generation 2
Generation 3
(Collectively/Individually) (Collectively/Individually)
…
Improvement Improvement
(Changes) (Changes)
Generation I
(Collectively/Individually) (Collectively/Individually)
… Stop
Improvement Improvement
(Changes) (Changes)
OR - METAHEURISTICS 14/01/2019
METAHEURISTIC ALGORITHMS 61
Genetic Algorithm (GA): Solution Representation
Solution Representation
► Solution Representation (SR)
- A vector, A matrix or A structure of Data that corresponds to a solution
- Permutation of N cities is a SR in TSP
5 1 8 4 3 2 7 6
Facilities 1 1
1 2 3
Customers
1 1 0 1
Facilities
Customers
2 0 1 0 2
3 0 1 1 3
4 1 0 1
OR - METAHEURISTICS
4 14/01/2019
3
METAHEURISTIC ALGORITHMS 62
Genetic Algorithm (GA): Individuals Population
Solution Representation
Permutations of N Cities
Individual Selection
1 2 5 4 1 3 7 8 6
2 5 7 6 8 2 1 3 4
Crossover & Mutation
Individuals
3 1 6 8 2 4 3 7 5
Next Generation
…
…
…
…
…
…
…
…
…
No
Termination?
P 3 4 8 1 2 7 6 5
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 63
Genetic Algorithm (GA): Individuals Evaluation
Solution Representation
3 1 6 8 2 4 3 7 5 113
Next Generation
…
…
…
…
…
…
…
…
…
…
…
…
No
P 3 4 8 1 2 7 6 5 134 Termination?
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 64
Genetic Algorithm (GA): Individual Selection
Solution Representation
No
Termination?
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 65
Genetic Algorithm (GA): Crossover
Solution Representation
1 1 0 1 0 0 1 0 1 1 0 1 1 1 0 1
Crossover & Mutation
0 1 0 0 1 1 0 1 2XO 0 1 0 1 0 0 0 1
1 1 0 1 0 0 1 0 1 1 0 0 1 1 1 0
Next Generation
► Infeasible solutions No
Termination?
- Remove, Repair, Penalty
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 66
Genetic Algorithm (GA): Mutation
Solution Representation
- Swap
Individual Selection
-1 … Insertion
5 4 2 6 3 7 8 1 5 4 3 2 6 7 8
No
Termination?
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 67
Genetic Algorithm (GA): Next Generation
Solution Representation
► Strategy 1: Elitism
Individuals Evaluation
- Next Generation = Elites (20%) + XO Inds. (70%) +
Mutated Inds (10%).
Individual Selection
Gent. i Gent. i+1
Elites
Crossover & Mutation
XO Next Generation
P P
M No
Termination?
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 68
Genetic Algorithm (GA): Next Generation
Solution Representation
► Strategy 2: Merging
Individuals Population
- Merging Pop = Elites U XO Inds. U Mutated Inds.
- Next Generation = First P individuals are transferred
Individuals Evaluation
Gent. i Gent. i+1
Individual Selection
Sort
P & Select P Crossover & Mutation
first P
XO Next Generation
No
Termination?
M
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 69
Genetic Algorithm (GA): Termination Criteria
Solution Representation
Individuals Evaluation
► Strategy 2: Max CPU Time
- GA is terminated after a given amount of time
Individual Selection
► Strategy 3: Max NFC
- GA is terminated after evaluating a max number of
solutions Crossover & Mutation
- Each time we call Fitness Function, a new solution is
evaluated
Next Generation
► Strategy 4: No Improvement
- GA is terminated if no improvement achieved for a No Termination?
specific number of iterations
Yes
OR - METAHEURISTICS 14/01/2019
Results
METAHEURISTIC ALGORITHMS 70
Hybrid Algorithms
► Why Hybrid?
- Better Intensification and Diversification LS
- Lower CPU Time
OR - METAHEURISTICS 14/01/2019
METAHEURISTIC ALGORITHMS 72
Other EAs
OR - METAHEURISTICS 14/01/2019
METAHEURISTIC ALGORITHMS 73
Other EAs
OR - METAHEURISTICS 14/01/2019