Optimization and Simulation Optimization Michel Bierlaire - - PowerPoint PPT Presentation

optimization and simulation
SMART_READER_LITE
LIVE PREVIEW

Optimization and Simulation Optimization Michel Bierlaire - - PowerPoint PPT Presentation

Optimization and Simulation Optimization Michel Bierlaire Transport and Mobility Laboratory School of Architecture, Civil and Environmental Engineering Ecole Polytechnique F ed erale de Lausanne M. Bierlaire (TRANSP-OR ENAC EPFL)


slide-1
SLIDE 1

Optimization and Simulation

Optimization Michel Bierlaire

Transport and Mobility Laboratory School of Architecture, Civil and Environmental Engineering Ecole Polytechnique F´ ed´ erale de Lausanne

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 1 / 108

slide-2
SLIDE 2

Introduction

Outline

1

Introduction

2

Classical optimization problems

3

Greedy heuristics

4

Neighborhood and local search

5

Diversification Variable Neighborhood Search Simulated annealing Comments

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 2 / 108

slide-3
SLIDE 3

Introduction

General framework

Z = h(X, Y , U) + εz εy εu εx εz External input — y Control — u Complex system — state x Indicators — z

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 3 / 108

slide-4
SLIDE 4

Introduction

General framework

Assumptions Control U is deterministic. Z(u) = h(X, Y , u) + εz Various features of Z are considered: mean, variance, quantile, etc. (z1(u), . . . , zm(u)) They are combined in a single indicator: f (u) = g(z1(u), . . . , zm(u))

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 4 / 108

slide-5
SLIDE 5

Introduction

General framework: example

Riccardo at Satellite X: number of customers in the bar Y : arrivals of customers u: service time of Riccardo Z(u): waiting time of the customers z1(u): mean waiting time z2(u): maximum waiting time f (u) = g(z1(u), z2(u)) = z1 + z2

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 5 / 108

slide-6
SLIDE 6

Introduction

General framework: the black box

εy εx εz External input — y Control — u Complex system — state x Indicators — z f (u)

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 6 / 108

slide-7
SLIDE 7

Introduction

Optimization problem

min

u∈Rn f (u)

subject to u ∈ U ⊆ Rn u: decision variables f (u): objective function u ∈ U: constraints U: feasible set If U is a finite set: combinatorial optimization.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 7 / 108

slide-8
SLIDE 8

Classical optimization problems

Outline

1

Introduction

2

Classical optimization problems

3

Greedy heuristics

4

Neighborhood and local search

5

Diversification Variable Neighborhood Search Simulated annealing Comments

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 8 / 108

slide-9
SLIDE 9

Classical optimization problems

The knapsack problem

Patricia prepares a hike in the mountain. She has a knapsack with capacity W kg. She considers carrying a list of n items. Each item has a utility ui and a weight wi. What items should she take to maximize the total utility, while fitting in the knapsack?

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 9 / 108

slide-10
SLIDE 10

Classical optimization problems

Modeling

Decision variables xi = 1 if item i goes into the knapsack,

  • therwise

Objective function max f (x) =

n

  • i=1

uixi Constraints

n

  • i=1

wixi ≤ W xi ∈ {0, 1} i = 1, . . . , n

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 10 / 108

slide-11
SLIDE 11

Classical optimization problems

Brute force algorithm

Enumeration As U is finite, all solutions can be enumerated. Each object can be in or out, for a total of 2n combinations. For each of them, we must:

Check that the weight is feasible. If so, calculate the utility and check if it is the largest so far.

Computational time About 2n floating point operations per combination. Assume a 1 Teraflops processor: 1012 floating point operations per second.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 11 / 108

slide-12
SLIDE 12

Classical optimization problems

Brute force algorithm

Computational time If n = 34, about 1 second to solve. If n = 40, about 1 minute. If n = 45, about 1 hour. If n = 50, about 1 day. If n = 58, about 1 year. If n = 69, about 2583 years, more than the Christian Era. If n = 78, about 1,500,000 years, time elapsed since Homo Erectus appeared on earth. If n = 91, about 1010 years, roughly the age of the universe.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 12 / 108

slide-13
SLIDE 13

Classical optimization problems

Combinatorial optimization

The set of feasible solutions is finite. But the number of feasible solutions grows exponentially with the size

  • f the problem.

No optimality condition can be exploited.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 13 / 108

slide-14
SLIDE 14

Classical optimization problems

Traveling salesman problem

The problem Consider n cities. For any pair (i, j) of cities, the distance dij between them is known. Find the shortest possible itinerary that starts from the home town of the salesman, visit all other cities, and come back to the origin. Feasible solutions Number of feasible solutions: (n − 1)! ≈

  • 2π/n − 1)

n − 1 e n−1 Again, the number of feasible solutions grows exponentially with the size of the problem.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 14 / 108

slide-15
SLIDE 15

Classical optimization problems

TSP: example

Lausanne, Geneva, Zurich, Bern G Z B L 279 64 158 104 228 125 Home town: Lausanne 3 possibilities: L → B → Z → G → L: 572 km L → B → G → Z → L: 769 km L → Z → B → G → L: 575 km

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 15 / 108

slide-16
SLIDE 16

Classical optimization problems

Integer linear optimization problem

Linear optimization min

x∈Rn cTx

subject to Ax = b x ≥ 0. where A ∈ Rm×n, b ∈ Rm and c ∈ Rn. Integer Linear optimization min

x∈Rn cTx

subject to Ax = b x ∈ N. where A ∈ Rm×n, b ∈ Rm and c ∈ Rn.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 16 / 108

slide-17
SLIDE 17

Classical optimization problems

Feasible set

Polyhedron 1 2 3 1 2 3 4 5 Intersection polyhedron/integer lattice 1 2 3 1 2 3 4 5

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 17 / 108

slide-18
SLIDE 18

Greedy heuristics

Outline

1

Introduction

2

Classical optimization problems

3

Greedy heuristics

4

Neighborhood and local search

5

Diversification Variable Neighborhood Search Simulated annealing Comments

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 18 / 108

slide-19
SLIDE 19

Greedy heuristics

Greedy heuristics

Principles Step by step construction of a feasible solution. At each step, a local optimization is performed. Decisions taken at previous steps are definitive. Properties Easy to implement. Short computational time. May generate poor solutions.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 19 / 108

slide-20
SLIDE 20

Greedy heuristics

Greedy heuristics

The knapsack problem Sort the items by decreasing order of ui/wi. For each item in this order, put it in the sack if it fits. The traveling salesman problem Start from home. At each step, select the closest city as the next one.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 20 / 108

slide-21
SLIDE 21

Greedy heuristics

TSP: 12 cities (euclidean dist.)

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 21 / 108

slide-22
SLIDE 22

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 22 / 108

slide-23
SLIDE 23

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 23 / 108

slide-24
SLIDE 24

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 24 / 108

slide-25
SLIDE 25

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 25 / 108

slide-26
SLIDE 26

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 26 / 108

slide-27
SLIDE 27

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 27 / 108

slide-28
SLIDE 28

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 28 / 108

slide-29
SLIDE 29

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 29 / 108

slide-30
SLIDE 30

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 30 / 108

slide-31
SLIDE 31

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 31 / 108

slide-32
SLIDE 32

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 32 / 108

slide-33
SLIDE 33

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 33 / 108

slide-34
SLIDE 34

Greedy heuristics

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8 6.6 9.9 4.5 9.7 9 . 6.8 1 3 . 8 1 . 9 9.5 34.7 14.5 3 5 . 7 Longueur : 165.6

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 34 / 108

slide-35
SLIDE 35

Greedy heuristics

Integer optimization

Intuitive approach Solve the continuous relaxation. Round the solution.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 35 / 108

slide-36
SLIDE 36

Greedy heuristics

Example

min

x∈R2 −3x1 − 13x2

subject to 2x1 + 9x2 ≤ 40 11x1 − 8x2 ≤ 82 x1, x2 ≥ x1, x2 ∈ N

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 36 / 108

slide-37
SLIDE 37

Greedy heuristics

Relaxation: feasible set

1 2 3 4 5 1 2 3 4 5 6 7 8 9 10

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 37 / 108

slide-38
SLIDE 38

Greedy heuristics

Optimal solution of the relaxation

1 2 3 4 5 1 2 3 4 5 6 7 8 9 10

  • Opt. solution relaxation (9.2, 2.4)
  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 38 / 108

slide-39
SLIDE 39

Greedy heuristics

Integrality constraints

1 2 3 4 5 1 2 3 4 5 6 7 8 9 10

  • Opt. solution relaxation (9.2, 2.4)
  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 39 / 108

slide-40
SLIDE 40

Greedy heuristics

Infeasible neighbors

1 2 3 4 5 1 2 3 4 5 6 7 8 9 10 Infeasible neighbors

  • Opt. solution relaxation (9.2, 2.4)
  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 40 / 108

slide-41
SLIDE 41

Greedy heuristics

Solution of the integer optimization problem

1 2 3 4 5 1 2 3 4 5 6 7 8 9 10 Infeasible neighbors

  • Opt. solution relaxation (9.2, 2.4)

Optimal solution (integer)

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 41 / 108

slide-42
SLIDE 42

Greedy heuristics

Issues

There are 2n different ways to round. Which one to choose? Rounding may generate an infeasible solution. The rounded solution may be far from the optimal solution.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 42 / 108

slide-43
SLIDE 43

Neighborhood and local search

Outline

1

Introduction

2

Classical optimization problems

3

Greedy heuristics

4

Neighborhood and local search

5

Diversification Variable Neighborhood Search Simulated annealing Comments

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 43 / 108

slide-44
SLIDE 44

Neighborhood and local search

Neighborhood and local search

Concept The feasible set is too large. At each iteration, restrict the optimization problem to a small feasible subset. Ideally, the small subset can be enumerated. Typically, it consists of solutions obtained from simple modifications

  • f the current solution.

The small subset is called a neighborhood.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 44 / 108

slide-45
SLIDE 45

Neighborhood and local search

Integer optimization: neighborhood

Consider the current iterate x ∈ Zn. For each k = 1, . . . , n, define 2 neighbors by increasing and decreasing the value of xk by one unit. The neighbors yk+ and yk− are defined as yk+

i

= yk−

i

= xi, ∀i = k, yk+

k

= xk + 1, yk+

k

= xk − 1. Example x = (3, 5, 2, 8) y2+ = (3, 6, 2, 8) y2− = (3, 4, 2, 8)

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 45 / 108

slide-46
SLIDE 46

Neighborhood and local search

Integer optimization: neighborhood

x

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 46 / 108

slide-47
SLIDE 47

Neighborhood and local search

Integer optimization: neighborhood

The concept of neighborhood is fairly general. It must be defined based on the structure of the problem. Creativity is required here. x

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 47 / 108

slide-48
SLIDE 48

Neighborhood and local search

Local search

Consider the integer optimization problem min

x∈Zn f (x)

subject to x ∈ F. Consider the neighborhood structure V (x), where V (x) is the set of neighbors of x. At each iteration k, consider the neighbors in V (xk) one at a time. For each y ∈ V (xk), if f (y) < f (xk), then xk+1 = y and proceed to the next iteration. If f (y) ≥ f (xk), ∀y ∈ V (xk), xk is a local minimum. Stop.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 48 / 108

slide-49
SLIDE 49

Neighborhood and local search

Local search: example

min

x∈R2 −3x1 − 13x2

subject to 2x1 + 9x2 ≤ 40 11x1 − 8x2 ≤ 82 x1, x2 ∈ N

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 49 / 108

slide-50
SLIDE 50

Neighborhood and local search

Local search: example

1 2 3 4 5 1 2 3 4 5 6 7 8 9 10

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 50 / 108

slide-51
SLIDE 51

Neighborhood and local search

Local search: example

x0 = (6, 0) - Neighborhood: E - N - O - S 1 2 3 4 5 1 2 3 4 5 6 7 8 9 10

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 51 / 108

slide-52
SLIDE 52

Neighborhood and local search

Local search: example

x0 = (0, 3) - Neighborhood: E - N - O - S 1 2 3 4 5 1 2 3 4 5 6 7 8 9 10

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 52 / 108

slide-53
SLIDE 53

Neighborhood and local search

Local search: example

x0 = (6, 0) - Neighborhood : N - O - S - E 1 2 3 4 5 1 2 3 4 5 6 7 8 9 10

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 53 / 108

slide-54
SLIDE 54

Neighborhood and local search

Local search: comments

The algorithm stops at a local minimum, that is a solution better than all its neighbors. The outcome depends on the starting point and the structure of the neighborhood. The neighborhood must be sufficiently large to increase the chances of improvement, and sufficiently small to avoid a lengthy enumeration. Example of a neighborhood too small: one neighbor at the west. Example of a neighborhood too large: each feasible point is in the neighborhood. It is good practice to use symmetric neighborhoods: y ∈ V (x) ⇐ ⇒ x ∈ V (y).

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 54 / 108

slide-55
SLIDE 55

Neighborhood and local search

The knapsack problem

max

x∈{0,1}n uTx

subject to wTx ≤ W .

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 55 / 108

slide-56
SLIDE 56

Neighborhood and local search

The knapsack problem: neighborhood

Current solution: for each item i, xi = 0 or xi = 1. Neighbor solution: select an item j, and change the decision: xj ← 1 − xj. Warning: check feasibility. Generalization: neighborhood of size k: select k items, and change the decision for them (checking feasibility).

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 56 / 108

slide-57
SLIDE 57

Neighborhood and local search

The knapsack problem: neighborhood

A neighborhood of size k modifies k variables. Number of neighbors: n! k!(n − k)! k = 1: n neighbors. k = n: 1 neighbor. Example : W = 300. i 1 2 3 4 5 6 7 8 9 10 11 12 U 80 31 48 17 27 84 34 39 46 58 23 67 W 84 27 47 22 21 96 42 46 54 53 32 78 First solution: empty sack.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 57 / 108

slide-58
SLIDE 58

Neighborhood and local search

The knapsack problem: local search

k 1 2 3 4 5 6 7 8 9 10 11 12 wT xc uT xc uT x∗ 1 1 84 80

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 58 / 108

slide-59
SLIDE 59

Neighborhood and local search

The knapsack problem: local search

k 1 2 3 4 5 6 7 8 9 10 11 12 wT xc uT xc uT x∗ 1 1 84 80 80 2 1 1 111 111 80

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 59 / 108

slide-60
SLIDE 60

Neighborhood and local search

The knapsack problem: local search

k 1 2 3 4 5 6 7 8 9 10 11 12 wT xc uT xc uT x∗ 2 1 1 111 111 1 27 31 111 1 84 80 111 3 1 1 1 158 159 111

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 60 / 108

slide-61
SLIDE 61

Neighborhood and local search

The knapsack problem: local search

k 1 2 3 4 5 6 7 8 9 10 11 12 wT xc uT xc uT x∗ 3 1 1 1 158 159 1 1 74 79 159 1 1 131 128 159 1 1 111 111 159 4 1 1 1 1 180 176 159

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 61 / 108

slide-62
SLIDE 62

Neighborhood and local search

The knapsack problem: local search

k 1 2 3 4 5 6 7 8 9 10 11 12 wT xc uT xc uT x∗ 4 1 1 1 1 180 176 1 1 1 96 96 176 1 1 1 153 145 176 1 1 1 133 128 176 1 1 1 158 159 176 5 1 1 1 1 1 201 203 176

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 62 / 108

slide-63
SLIDE 63

Neighborhood and local search

The knapsack problem: local search

k 1 2 3 4 5 6 7 8 9 10 11 12 wT xc uT xc uT x∗ 5 1 1 1 1 1 201 203 1 1 1 1 117 123 203 1 1 1 1 174 172 203 1 1 1 1 154 155 203 1 1 1 1 179 186 203 1 1 1 1 180 176 203 6 1 1 1 1 1 1 297 287 203

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 63 / 108

slide-64
SLIDE 64

Neighborhood and local search

The knapsack problem: local search

k 1 2 3 4 5 6 7 8 9 10 11 12 wT xc uT xc uT x∗ 6 1 1 1 1 1 1 297 287 1 1 1 1 1 213 207 287 1 1 1 1 1 270 256 287 1 1 1 1 1 250 239 287 1 1 1 1 1 275 270 287 1 1 1 1 1 276 260 287 1 1 1 1 1 201 203 287 1 1 1 1 1 1 1 339 321 287 1 1 1 1 1 1 1 343 326 287 1 1 1 1 1 1 1 351 333 287 1 1 1 1 1 1 1 350 345 287 1 1 1 1 1 1 1 329 310 287 1 1 1 1 1 1 1 375 354 287

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 64 / 108

slide-65
SLIDE 65

Neighborhood and local search

TSP: 12 cities

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 65 / 108

slide-66
SLIDE 66

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 66 / 108

slide-67
SLIDE 67

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 67 / 108

slide-68
SLIDE 68

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 68 / 108

slide-69
SLIDE 69

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 69 / 108

slide-70
SLIDE 70

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 70 / 108

slide-71
SLIDE 71

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 71 / 108

slide-72
SLIDE 72

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 72 / 108

slide-73
SLIDE 73

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 73 / 108

slide-74
SLIDE 74

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 74 / 108

slide-75
SLIDE 75

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 75 / 108

slide-76
SLIDE 76

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 76 / 108

slide-77
SLIDE 77

Neighborhood and local search

Initial solution from greedy algorithm

1 2 3 4 5 6 7 H 9 10 11 8 6.6 9.9 4.5 9.7 9 . 6.8 1 3 . 8 1 . 9 9.5 34.7 14.5 3 5 . 7 Length : 165.6

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 77 / 108

slide-78
SLIDE 78

Neighborhood and local search

Neighborhood: 2-OPT

2-OPT Select two cities. Swap their position in the tour. Visit all intermediate cities in reverse order. Example Current tour: A–B–C–D–E–F–G–H–A Exchange C and G to obtain A–B–G–F–E–D–C–H–A.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 78 / 108

slide-79
SLIDE 79

Neighborhood and local search

Neighborhood: 2-OPT(1,9)

Example Try to improve the solution using 2-OPT swapping 1 and 9. Before: H–8–7–11–6–5–1–2–3–4–10–9–H (length: 165.6) After : H–8–7–11–6–5–9–10–4–3–2–1–H (length: 173.3) No improvement.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 79 / 108

slide-80
SLIDE 80

Neighborhood and local search

Neighborhood: 2-OPT(1,9)

1 2 3 4 5 6 7 H 9 10 11 8 6.6 9.9 4.5 9.7 9 . 6.8 1 3 . 8 1 . 9 9.5 34.7 14.5 3 5 . 7 Length: 165.6

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 80 / 108

slide-81
SLIDE 81

Neighborhood and local search

Neighborhood: 2-OPT(1,9)

1 2 3 4 5 6 7 H 9 10 11 8 6.6 9.9 4.5 9.7 9 . 18.4 14.5 34.7 9.5 1 . 9 1 3 . 8 3 1 . 7 Length: 173.3

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 81 / 108

slide-82
SLIDE 82

Neighborhood and local search

Local search

Consider each pair of nodes. Apply 2-OPT. Select the best tour.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 82 / 108

slide-83
SLIDE 83

Neighborhood and local search

Current tour

1 2 3 4 5 6 7 H 9 10 11 8 6.6 9.9 4.5 9.7 9 . 6.8 1 3 . 8 1 . 9 9.5 34.7 14.5 3 5 . 7 Length: 165.6

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 83 / 108

slide-84
SLIDE 84

Neighborhood and local search

Best neighbor: 2-OPT(8,4)

1 2 3 4 5 6 7 H 9 10 11 8 13.7 9.5 1 . 9 1 3 . 8 6.8 9 . 9.7 4.5 9.9 17.9 14.5 3 5 . 7 Length: 155.8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 84 / 108

slide-85
SLIDE 85

Neighborhood and local search

Best neighbor: 2-OPT(8,9)

1 2 3 4 5 6 7 H 9 10 11 8 13.7 9.5 1 . 9 1 3 . 8 6.8 9 . 9.7 4.5 26.1 14.5 17.9 6.6 Length: 143.0

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 85 / 108

slide-86
SLIDE 86

Neighborhood and local search

Best neighbor: 2-OPT(11,7)

1 2 3 4 5 6 7 H 9 10 11 8 13.7 9.5 1 . 9 1 3 . 8 6.8 9 . 10.4 4.5 22.0 14.5 17.9 6.6 Length: 139.5

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 86 / 108

slide-87
SLIDE 87

Neighborhood and local search

Best neighbor: 2-OPT(7,10)

1 2 3 4 5 6 7 H 9 10 11 8 13.7 9.5 1 . 9 1 3 . 8 6.8 9 . 16.3 14.5 22.0 4.5 9.9 6.6 Length: 137.5

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 87 / 108

slide-88
SLIDE 88

Neighborhood and local search

Best neighbor: 2-OPT(10,9)

1 2 3 4 5 6 7 H 9 10 11 8 13.7 9.5 1 . 9 1 3 . 8 6.8 9 . 20.5 14.5 1 1 . 4.5 9.9 6.6 Length: 130.7

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 88 / 108

slide-89
SLIDE 89

Diversification

Outline

1

Introduction

2

Classical optimization problems

3

Greedy heuristics

4

Neighborhood and local search

5

Diversification Variable Neighborhood Search Simulated annealing Comments

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 89 / 108

slide-90
SLIDE 90

Diversification Variable Neighborhood Search

Variable Neighborhood Search

aka VNS Idea: consider several neighborhood structures. When a local optimum has been found for a given neighborhood structure, continue with another structure.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 90 / 108

slide-91
SLIDE 91

Diversification Variable Neighborhood Search

VNS: method

Input V1, V2, . . . , VK neighborhood structures. Initial solution x0. Initialization xc ← x0 k ← 1 Iterations Repeat Apply local search from xc using neighborhood Vk x+ ← LS(xc, Vk) If f (x+) < f (xc), then xc ← x+, k ← 1. Otherwise, k ← k + 1. Until k = K.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 91 / 108

slide-92
SLIDE 92

Diversification Variable Neighborhood Search

VNS: example for the knapsack problem

Neighborhood of size k: modify k variables. Local search: current iterate: xc

randomly select a neighbor x+ if w Tx+ ≤ W and uTx+ > uTxc, then xc ← x+

Repeat 1000 times, for any k. The complexity is therefore independent of k.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 92 / 108

slide-93
SLIDE 93

Diversification Variable Neighborhood Search

VNS: example for the knapsack problem

50 100 150 200 250 300 2 4 6 8 10 12 14 16 18 20 1 2 3 4 5 6 7 8 9 10 11 12 uTx Neighborhood Iterations

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 93 / 108

slide-94
SLIDE 94

Diversification Simulated annealing

Simulated annealing

Analogy with metallurgy Heating a metal and then cooling it down slowly improves its properties. The atoms take a more solid configuration. In optimization: Local search can both decrease and increase the objective function. At “high temperature”, it is common to increase. At “low temperature”, increasing happens rarely. Simulated annealing: slow cooling = slow reduction of the probability to increase.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 94 / 108

slide-95
SLIDE 95

Diversification Simulated annealing

Simulated annealing

Modify the local search. For the sake of simplicity: consider a neighborhood structure containing

  • nly feasible solutions.

Let xk be the current iterate Select y ∈ V (xk). If f (y) ≤ f (xk), then xk+1 = y. Otherwise, xk+1 = y with probability e− f (y)−f (xk )

T

with T > 0. Concretely, draw r between 0 and 1. Accept y as next iterate if e− f (y)−f (xk )

T

> r

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 95 / 108

slide-96
SLIDE 96

Diversification Simulated annealing

Simulated annealing

Prob(xk+1 = y) =

  • 1

if f (y) ≤ f (xk) e− f (y)−f (xk )

T

if f (y) > f (xk) If T is high (hot temperature), high probability to increase. If T is low, almost only decreases.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 96 / 108

slide-97
SLIDE 97

Diversification Simulated annealing

Simulated annealing

Example : f (xk) = 3 0.2 0.4 0.6 0.8 1 1 2 3 4 5 6 7 8 9 Prob(xk+1 = y) T f (y) = 3.5 f (y) = 4 f (y) = 5 f (y) = 6

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 97 / 108

slide-98
SLIDE 98

Diversification Simulated annealing

Simulated annealing

In practice, start with high T for flexibility. Then, decrease T progressively.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 98 / 108

slide-99
SLIDE 99

Diversification Simulated annealing

Simulated annealing

Input Initial solution x0 Initial temperature T0, minimum temperature Tf Neighborhood structure V (x) Maximum number of iterations K Initialize xc ← x0, x∗ ← x0, T ← T0

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 99 / 108

slide-100
SLIDE 100

Diversification Simulated annealing

Simulated annealing

Repeat k ← 1 While k < K

Randomly select a neighbor y ∈ V (xc) δ ← f (y) − f (xc) If δ < 0, xc = y. Otherwise, draw r between 0 and 1

If r < exp(−δ/T), then xc = y

If f (xc) < f (x∗), x∗ = xc. k ← k + 1

Reduce T Until T ≤ Tf

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 100 / 108

slide-101
SLIDE 101

Diversification Simulated annealing

Example: traveling salesman problem

120 140 160 180 200 220 240 260 280 300 320 100 200 300 400 500 600 700 800 900 1000 f (x) T Iter. xc T x∗

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 101 / 108

slide-102
SLIDE 102

Diversification Simulated annealing

Best solution found

1 2 3 4 5 6 7 H 9 10 11 8 13.7 9.5 1 . 9 10.1 1 2 . 7 6.8 18.4 14.5 1 1 . 4.5 9.9 6.6 Length : 128.8

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 102 / 108

slide-103
SLIDE 103

Diversification Simulated annealing

Practical comments

Parameters must be tuned. In particular, the reduction rate of the temperature must be specified.

Let δt be a typical increase of the objective function. In the beginning, we want such an increase to be accepted with probability p0 (e.g. p0 = 0.999) At the end, we want such an increase to be accepted with probability pf (e.g. pf = 0.00001) We allow for M updates of the temperature. So, for m = 0, . . . , M, T = − δt ln(p0 + pf −p0

M

m)

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 103 / 108

slide-104
SLIDE 104

Diversification Comments

Heuristics: general framework

Exploration Neighborhood Intensification Local search Diversification Escape from local minima

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 104 / 108

slide-105
SLIDE 105

Diversification Comments

Exploration: comments

Neighborhood structure It is a “vehicle” to explore the solution space. Must be able to (potentially) reach any solution Must be tailored to the problem

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 105 / 108

slide-106
SLIDE 106

Diversification Comments

Intensification: comments

Local search. Exploit the neighborhood structure to find better solutions. Many variants are possible:

exhaustive search: evaluate all neighbors limited search: evaluate a given number of neighbors randomized search: select the neighbors randomly

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 106 / 108

slide-107
SLIDE 107

Diversification Comments

Diversification: comments

How to avoid being blocked in local minimum? Apply an algorithm from multiple starting points.

How to choose starting point? How to avoid shooting in the dark?

Allow the algorithm to proceed upwards: simulated annealing

Climb the mountain to find another valley. How to decide when it is time to climb or to go down?

Change the structure of the neighborhood: variable neighborhood search

How to choose the neighborhood structures?

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 107 / 108

slide-108
SLIDE 108

Diversification Comments

Meta-heuristics

Methods designed to escape from local optima are sometimes called “meta-heuristics”. Plenty of variants are available in the literature. In general, success depends on exploiting well the properties of the problem at hand. VNS is one of the simplest to code. Additional bio-inspired methods have also been proposed and applied: genetic algorithms, ant colony optimization, etc.

  • M. Bierlaire (TRANSP-OR ENAC EPFL)

Optimization and Simulation 108 / 108