Search and Optimization Strategies
Tecniche di Programmazione – A.A. 2012/2013
Summary
A.A. 2012/2013Tecniche di programmazione2
 Definitions
 Branch & Bound
 Greedy
 Local Search
Definitions
Search and Optimization Strategies
Search vs Optimization
A.A. 2012/2013Tecniche di programmazione4
 A search algorithm is an algorithm for finding an item
with specified properties among a collection of items
 Specified properties: usually “local” properties, defined by some
“feasibility” criteria
 Collection: explicit, or virtual (implicit)
 An optimization algorithm aims ad finding the best
possible solution, according to an objective function,
among all possible feasible solutions for a given
problem
Objective function
A.A. 2012/2013Tecniche di programmazione5
 Must be computable for all feasible solutions
 May be undefined for unfeasible (or incomplete) solutions
 Maximization problems
 Objective function = value, goodness
 Must find the maximum value of objective function
 Minimization problems
 Objective function = cost
 Must find the minimum value of objective function
A.A. 2012/2013Tecniche di programmazione6
Types of problems
 Search problems: is there (at least one) feasible solution?
 Ex: magical square
 Ex: Hamiltonian cycle
 Optimization problems: what is the best solution?
 In these problems finding feasible solutions is usually easy
 Ex: Hamiltonian cycle on a complete graph (Hamiltonan bee)
 Hybrid problems (search + optimization): are there any valid
solutions? And what is the best?
 Ex: travelling salesman problem
A.A. 2012/2013Tecniche di programmazione7
Representation
S: Solutions
V:Valid (feasible) solutions
M: best solutions
s
s
s
f(s)
Objective
function
A.A. 2012/2013Tecniche di programmazione8
Classification
 Search problems
 S V
 |V| = 0 ?
 Find a s V
 Optimization problems
 S =V
 find max(f(s))
 Hybrid problems
 S V
 find max(f(s))
 such that s V
Exact techniques
A.A. 2012/2013Tecniche di programmazione9
 Exhaustive generation of all possible solutions
 Iteratively
 Recursively
 Optimizing recursive techniques
 Visit order
 Generate non-useless solutions: Branch and Bound
 Recognize equivalent sub-problems: Dynamic Programming
1 2
3 4
5 6
7 8
Approximate Tecniques
A.A. 2012/2013Tecniche di programmazione10
 Greedy
 Pseudo-random
 Hill climber
1
2
3
Approximate solutions
A.A. 2012/2013Tecniche di programmazione11
 Optimum solution: the absolute best
 Optimal solution: a solution that
 approximates the optimum one (might be coincident, but we
don’t know)
 can no longer be improved with the chosen optimization
technique
 Locally optimum solution: optimum solution in a
continuous domain
Intuitively…
A.A. 2012/2013Tecniche di programmazione12
x
f(x)
Optimum
solution
Optimal
solution
Locally
optimum
solutions
Computational Intelligence
A.A. 2012/2013Tecniche di programmazione13
 Evolutionary Algorithms
 Genetic Algorithms
 Genetic Programming
 Simulated annealing
 Tabu-Search
Branch & Bound
Search and Optimization Strategies
A.A. 2012/2013Tecniche di programmazione15
Introduction
 Branch and Bound is an exact method for exploring all
solutions based on their implicit enumeration
 All solutions are considered, but not one-by-one. In fact
B&B:
 Considers disjoints subsets of solutions (branching)
 Evaluates them according to an estimate of the objective
function (bounding), by eliminating (pruning) those subsets that
may not contain the optimum solution
A.A. 2012/2013Tecniche di programmazione16
Definition
 z*: a sub-optimal estimate of the final result
 Initialized to + for minimization problems
 Initialized to - for maximization problems
 z(r)
E : the exact solution of sub-problem P(r)
 z(r)
B: a super-optimal estimate of solutions of sub-problem
P(r)
 lower bound for minimization problems
 upper bound for maximization problems
A.A. 2012/2013Tecniche di programmazione17
General algorithm (I)
 Branch-and-bound is a divide-et-impera method:
 Divide a given problem (and its set of feasible solutions) in sub-
problems to be analyzed separately.
 Keep a list P of open sub-problems
 At each step, select one current problem P(r)
General algorithm (II)
A.A. 2012/2013Tecniche di programmazione18
 If P(r) has no feasible solutions, it is closed
 If P(r) has (at least one) solution, and may be solved up to
the optimum z(r)
E
 P(r) is closed
 Its solution, with value z(r)
E, may possibly replace z*, if it
improves it
General algorithm (III)
A.A. 2012/2013Tecniche di programmazione19
 Se P(r) has solutions, but it’s difficult to be solved up to
the optimum, we try to show that it may not yield a
better solution than the already known ones.
 We compute a super-optimal estimate z(r)
B of its solutions:
 If z(r)
B is not better than z*, all solutions in P(r) are dominated
by the best known-solution, and P(r) may be closed
 If z(r)
B is better than z*, P(r) is broken into sub-problems that
are inserted in the list P. P(r) is closed, and the sub-problems
will be opened, eventually.
General algorithm (IV)
A.A. 2012/2013Tecniche di programmazione20
 Proceed until P is empty
 When P is empty, then z* is the exact optimum solution
for the original problem.
The solution tree
A.A. 2012/2013Tecniche di programmazione21
P0
P1 P2
P21 P22
P11 P12
P111 P112
P12
Node: sub-problem
Leaf node: closed sub-problem
Ingredients of a B&B algorithm
A.A. 2012/2013Tecniche di programmazione22
 Strategy of visit of the search tree: criteria to choose the
next sub-problem to be analyzed out of the list P
 Bounding technique: how to evaluate the super-optimal
estimate z(r)
B
 Branching rule: how to split the current problem P(r) into
smaller sub-problems.
Main features
A.A. 2012/2013Tecniche di programmazione23
 Advantages:
 Finds optimum solution
 May limit the number of visited solutions
 May give a partial (approximate) solution, if stopped earlier
 Disadvantages:
 Computation time for visiting the solution tree depends on the
strategy
 The worst case is to visit all possible nodes, anyway
 Time needed to compute z(r)
B.
Greedy
Search and Optimization Strategies
A.A. 2012/2013Tecniche di programmazione55
Introduction
 A greedy algorithm searches for a globally optimal
solution, by choosing locally optimum ones.
 The adopted technique is shortsighted:
 Every choice made at any step is never re-considered again
 No back-tracking
 Basic principle: define an “attractiveness” for every partial
solution
 Attractiveness (it: appetibilità) = estimate of how much, probably,
we are close to the optimum.
General structure (I)
A.A. 2012/2013Tecniche di programmazione56
 If the attractiveness {ai} of partial solutions are known
since the beginning, and may not be modified
Greedy ({a1, a2, …an})
S  ø
sort {ai} in decreasing attractiveness order
for each ai do
if ai may be added to S
then S  S  {ai}
return S
General structure (II)
A.A. 2012/2013Tecniche di programmazione57
 If attractiveness may be modified by the effects of
previous choices
Greedy2 ({a1, a2, …an})
S  ø
compute attractiveness of ai
while there are element to choose do
choose the most-attractive ai
if ai may be added to S
then S  S  {ai}
update the remaining ai
return S
Example
A.A. 2012/2013Tecniche di programmazione58
 Find the minimum number of coins to give change to a
customer.
 We assume we have a list of possible coin values, and
their availability is infinite
A.A. 2012/2013Tecniche di programmazione59
Example
 Available coins
 20, 10, 5, 2, 1
 Change to give
 55
A.A. 2012/2013Tecniche di programmazione60
Algorithm
 At each step, select the highest-valued coin, whose value
is less than the remaining change
Remaining change Chosen coin
55 20
35 20
15 10
5 5
A.A. 2012/2013Tecniche di programmazione61
Features
 Advantages
 Extremely simple algorithm
 Very fast computational time
 Disadvantages
 The solution is optimal, non necessarily optimum
Non-optimum solution
A.A. 2012/2013Tecniche di programmazione62
 Input:
 Coins of 6, 4, 1
 Change to give:
 9
 Greedy solution:
 4 coins: 6, 1, 1, 1
 Optimum solution :
 3 coins: 4, 4, 1
Local Search
Search and Optimization Strategies
Applicability
A.A. 2012/2013Tecniche di programmazione72
 Suitable for problems where:
 There is an underlying “structure” in the solution space
 There is a clear objective function
 The search space is too vast
 Exact algorithms are not knows
 “Similar solutions have similar cost”
Iterative improvement
A.A. 2012/2013Tecniche di programmazione73
 A family of methods
 Common basic idea
 Start from an initial (random) configuration
 Consider various possible moves starting from that configuration
 Accept or refuse such moves, depending on the objective function
 When you cannot improve anymore, start again
A.A. 2012/2013Tecniche di programmazione74
Example
Moves
A.A. 2012/2013Tecniche di programmazione75
 We must define a set of moves to lead from one
solution to another
 The set of possible moves defined the neighborhood of
a solution
 Moves are often implemented as small variations
(mutation) on the encoded solution
A.A. 2012/2013Tecniche di programmazione76
Example: TSP (I)
“2-opt”neighborhood
A.A. 2012/2013Tecniche di programmazione77
Example: TSP(II)
3-opt neighborhood
Hill Climbing (I)
A.A. 2012/2013Tecniche di programmazione78
 For every configuration, evaluate all possible moves
 (explore the whole neighborhood)
 Refuse all moves that worsen the objective function
 Accept the move that leads to the highest improvement
of the objective function
 If all moves worsen the objective function, quit.
A.A. 2012/2013Tecniche di programmazione79
Hill Climbing (II)
X = startinc configuration
E = eval(X)
do {
N = n_moves(X)
for (i=0; i<N; ++i)
Ei = eval(move(X,i))
if (all Ei  E)
return X
i* = { i | max(Ei) }
X = move(X, i*)
E = Ei*
} while(1)
Features
A.A. 2012/2013Tecniche di programmazione80
 Greedy
 Simple to implement
 No backtracking => no recursion, no memory
 Needs “clever” definition of moves
 Sometimes, the objective function may be incrementally
computed
A.A. 2012/2013Tecniche di programmazione81
Problems (I)
 Foothill: getting trapped in local maxima
Hillclimber final point
Start
Real maximum
A.A. 2012/2013Tecniche di programmazione82
Problems (II)
 Mesa: wide regions with null or negligible variation of the
objective function
 Needle in the haystack: isolated peak in a desolated
landscape
A.A. 2012/2013Tecniche di programmazione83
Variants
 First-ascent
 Accept the first move that improves the objective function
 Best-ascent
 Evaluate all moves and accept the best one
 Threshold-accept
 Accept the first move that improves the current configuration by an
amount higher that a fixed threshold
 …etc…
A.A. 2012/2013Tecniche di programmazione84
Example
111 fitness 10
011 fitness 12
101 fitness 20
110 fitness 5
First ascent
Best ascent
011 fitness 12
101 fitness 20
Neighborhood definition:
‘complement one bit’
A.A. 2012/2013Tecniche di programmazione85
Random Restart Hill Climbing
 Repeat the Hill Climbing procedure starting from many initial
starting points
X = random configuration
Best = X
do {
X’ = HillClimber(X)
if (Eval(X’) > Eval(Best))
Best = X’
X = random configuration
} while( ! Enough )
A.A. 2012/2013Tecniche di programmazione86
Simulated Annealing
 Stochastic approach for function minimization
 The name is taken from the physical process of
crystallization of a liquid into solid state
 The minimum of the cost function corresponds to the
crystal state of the substance (minimum energy)
 Simulated Annealing gradually “lowers” the “temperature”
until the system “freezes”
A.A. 2012/2013Tecniche di programmazione87
Algorithm (I)
 Start with a random solution
 Choose a solution in the neighborhood
 If the energy of the new solution is less than the current one,
accept the move
 If the energy is more than the current one, the move may be
accepted, with a probability
 The probability to accept “bad” moves depends on
 Amount of worsening (DE)
 Temperature (simulated) of the system
A.A. 2012/2013Tecniche di programmazione88
Algorithm(II)
current = start state
for time = 1 to forever do
T = schedule[time]
if T = 0 return current
next = a randomly chosen successor of current
dE = value(next) – value(current)
if dE > 0 then current = next
else current = next with probability edE/T
end for
A.A. 2012/2013Tecniche di programmazione89
Features
 The system may “jump out” of local minima by accepting
worse solutions
 At higher temperatures, worsening jumps are easier, at
lower temperature they become unlikely
 Temperature is gradually reduced
 At T=0, the algorithm converges to the locally optimum
solution (hill climbing behavior)
A.A. 2012/2013Tecniche di programmazione90
Boltzmann distribution
dE
P(accettazione)
1T=max
T=0
Other local search algorithms
A.A. 2012/2013Tecniche di programmazione91
 Tabu Search
 Ant Colony
 Genetic Algorithms
Resources
A.A. 2012/2013Tecniche di programmazione92
Licenza d’uso
A.A. 2012/2013Tecniche di programmazione93
 Queste diapositive sono distribuite con licenza Creative Commons
“Attribuzione - Non commerciale - Condividi allo stesso modo (CC
BY-NC-SA)”
 Sei libero:
 di riprodurre, distribuire, comunicare al pubblico, esporre in pubblico,
rappresentare, eseguire e recitare quest'opera
 di modificare quest'opera
 Alle seguenti condizioni:
 Attribuzione — Devi attribuire la paternità dell'opera agli autori originali
e in modo tale da non suggerire che essi avallino te o il modo in cui tu
usi l'opera.
 Non commerciale — Non puoi usare quest'opera per fini commerciali.
 Condividi allo stesso modo — Se alteri o trasformi quest'opera, o se la
usi per crearne un'altra, puoi distribuire l'opera risultante solo con una
licenza identica o equivalente a questa.
 http://creativecommons.org/licenses/by-nc-sa/3.0/

Search and Optimization Strategies

  • 1.
    Search and OptimizationStrategies Tecniche di Programmazione – A.A. 2012/2013
  • 2.
    Summary A.A. 2012/2013Tecniche diprogrammazione2  Definitions  Branch & Bound  Greedy  Local Search
  • 3.
  • 4.
    Search vs Optimization A.A.2012/2013Tecniche di programmazione4  A search algorithm is an algorithm for finding an item with specified properties among a collection of items  Specified properties: usually “local” properties, defined by some “feasibility” criteria  Collection: explicit, or virtual (implicit)  An optimization algorithm aims ad finding the best possible solution, according to an objective function, among all possible feasible solutions for a given problem
  • 5.
    Objective function A.A. 2012/2013Tecnichedi programmazione5  Must be computable for all feasible solutions  May be undefined for unfeasible (or incomplete) solutions  Maximization problems  Objective function = value, goodness  Must find the maximum value of objective function  Minimization problems  Objective function = cost  Must find the minimum value of objective function
  • 6.
    A.A. 2012/2013Tecniche diprogrammazione6 Types of problems  Search problems: is there (at least one) feasible solution?  Ex: magical square  Ex: Hamiltonian cycle  Optimization problems: what is the best solution?  In these problems finding feasible solutions is usually easy  Ex: Hamiltonian cycle on a complete graph (Hamiltonan bee)  Hybrid problems (search + optimization): are there any valid solutions? And what is the best?  Ex: travelling salesman problem
  • 7.
    A.A. 2012/2013Tecniche diprogrammazione7 Representation S: Solutions V:Valid (feasible) solutions M: best solutions s s s f(s) Objective function
  • 8.
    A.A. 2012/2013Tecniche diprogrammazione8 Classification  Search problems  S V  |V| = 0 ?  Find a s V  Optimization problems  S =V  find max(f(s))  Hybrid problems  S V  find max(f(s))  such that s V
  • 9.
    Exact techniques A.A. 2012/2013Tecnichedi programmazione9  Exhaustive generation of all possible solutions  Iteratively  Recursively  Optimizing recursive techniques  Visit order  Generate non-useless solutions: Branch and Bound  Recognize equivalent sub-problems: Dynamic Programming 1 2 3 4 5 6 7 8
  • 10.
    Approximate Tecniques A.A. 2012/2013Tecnichedi programmazione10  Greedy  Pseudo-random  Hill climber 1 2 3
  • 11.
    Approximate solutions A.A. 2012/2013Tecnichedi programmazione11  Optimum solution: the absolute best  Optimal solution: a solution that  approximates the optimum one (might be coincident, but we don’t know)  can no longer be improved with the chosen optimization technique  Locally optimum solution: optimum solution in a continuous domain
  • 12.
    Intuitively… A.A. 2012/2013Tecniche diprogrammazione12 x f(x) Optimum solution Optimal solution Locally optimum solutions
  • 13.
    Computational Intelligence A.A. 2012/2013Tecnichedi programmazione13  Evolutionary Algorithms  Genetic Algorithms  Genetic Programming  Simulated annealing  Tabu-Search
  • 14.
    Branch & Bound Searchand Optimization Strategies
  • 15.
    A.A. 2012/2013Tecniche diprogrammazione15 Introduction  Branch and Bound is an exact method for exploring all solutions based on their implicit enumeration  All solutions are considered, but not one-by-one. In fact B&B:  Considers disjoints subsets of solutions (branching)  Evaluates them according to an estimate of the objective function (bounding), by eliminating (pruning) those subsets that may not contain the optimum solution
  • 16.
    A.A. 2012/2013Tecniche diprogrammazione16 Definition  z*: a sub-optimal estimate of the final result  Initialized to + for minimization problems  Initialized to - for maximization problems  z(r) E : the exact solution of sub-problem P(r)  z(r) B: a super-optimal estimate of solutions of sub-problem P(r)  lower bound for minimization problems  upper bound for maximization problems
  • 17.
    A.A. 2012/2013Tecniche diprogrammazione17 General algorithm (I)  Branch-and-bound is a divide-et-impera method:  Divide a given problem (and its set of feasible solutions) in sub- problems to be analyzed separately.  Keep a list P of open sub-problems  At each step, select one current problem P(r)
  • 18.
    General algorithm (II) A.A.2012/2013Tecniche di programmazione18  If P(r) has no feasible solutions, it is closed  If P(r) has (at least one) solution, and may be solved up to the optimum z(r) E  P(r) is closed  Its solution, with value z(r) E, may possibly replace z*, if it improves it
  • 19.
    General algorithm (III) A.A.2012/2013Tecniche di programmazione19  Se P(r) has solutions, but it’s difficult to be solved up to the optimum, we try to show that it may not yield a better solution than the already known ones.  We compute a super-optimal estimate z(r) B of its solutions:  If z(r) B is not better than z*, all solutions in P(r) are dominated by the best known-solution, and P(r) may be closed  If z(r) B is better than z*, P(r) is broken into sub-problems that are inserted in the list P. P(r) is closed, and the sub-problems will be opened, eventually.
  • 20.
    General algorithm (IV) A.A.2012/2013Tecniche di programmazione20  Proceed until P is empty  When P is empty, then z* is the exact optimum solution for the original problem.
  • 21.
    The solution tree A.A.2012/2013Tecniche di programmazione21 P0 P1 P2 P21 P22 P11 P12 P111 P112 P12 Node: sub-problem Leaf node: closed sub-problem
  • 22.
    Ingredients of aB&B algorithm A.A. 2012/2013Tecniche di programmazione22  Strategy of visit of the search tree: criteria to choose the next sub-problem to be analyzed out of the list P  Bounding technique: how to evaluate the super-optimal estimate z(r) B  Branching rule: how to split the current problem P(r) into smaller sub-problems.
  • 23.
    Main features A.A. 2012/2013Tecnichedi programmazione23  Advantages:  Finds optimum solution  May limit the number of visited solutions  May give a partial (approximate) solution, if stopped earlier  Disadvantages:  Computation time for visiting the solution tree depends on the strategy  The worst case is to visit all possible nodes, anyway  Time needed to compute z(r) B.
  • 24.
  • 25.
    A.A. 2012/2013Tecniche diprogrammazione55 Introduction  A greedy algorithm searches for a globally optimal solution, by choosing locally optimum ones.  The adopted technique is shortsighted:  Every choice made at any step is never re-considered again  No back-tracking  Basic principle: define an “attractiveness” for every partial solution  Attractiveness (it: appetibilità) = estimate of how much, probably, we are close to the optimum.
  • 26.
    General structure (I) A.A.2012/2013Tecniche di programmazione56  If the attractiveness {ai} of partial solutions are known since the beginning, and may not be modified Greedy ({a1, a2, …an}) S  ø sort {ai} in decreasing attractiveness order for each ai do if ai may be added to S then S  S  {ai} return S
  • 27.
    General structure (II) A.A.2012/2013Tecniche di programmazione57  If attractiveness may be modified by the effects of previous choices Greedy2 ({a1, a2, …an}) S  ø compute attractiveness of ai while there are element to choose do choose the most-attractive ai if ai may be added to S then S  S  {ai} update the remaining ai return S
  • 28.
    Example A.A. 2012/2013Tecniche diprogrammazione58  Find the minimum number of coins to give change to a customer.  We assume we have a list of possible coin values, and their availability is infinite
  • 29.
    A.A. 2012/2013Tecniche diprogrammazione59 Example  Available coins  20, 10, 5, 2, 1  Change to give  55
  • 30.
    A.A. 2012/2013Tecniche diprogrammazione60 Algorithm  At each step, select the highest-valued coin, whose value is less than the remaining change Remaining change Chosen coin 55 20 35 20 15 10 5 5
  • 31.
    A.A. 2012/2013Tecniche diprogrammazione61 Features  Advantages  Extremely simple algorithm  Very fast computational time  Disadvantages  The solution is optimal, non necessarily optimum
  • 32.
    Non-optimum solution A.A. 2012/2013Tecnichedi programmazione62  Input:  Coins of 6, 4, 1  Change to give:  9  Greedy solution:  4 coins: 6, 1, 1, 1  Optimum solution :  3 coins: 4, 4, 1
  • 33.
    Local Search Search andOptimization Strategies
  • 34.
    Applicability A.A. 2012/2013Tecniche diprogrammazione72  Suitable for problems where:  There is an underlying “structure” in the solution space  There is a clear objective function  The search space is too vast  Exact algorithms are not knows  “Similar solutions have similar cost”
  • 35.
    Iterative improvement A.A. 2012/2013Tecnichedi programmazione73  A family of methods  Common basic idea  Start from an initial (random) configuration  Consider various possible moves starting from that configuration  Accept or refuse such moves, depending on the objective function  When you cannot improve anymore, start again
  • 36.
    A.A. 2012/2013Tecniche diprogrammazione74 Example
  • 37.
    Moves A.A. 2012/2013Tecniche diprogrammazione75  We must define a set of moves to lead from one solution to another  The set of possible moves defined the neighborhood of a solution  Moves are often implemented as small variations (mutation) on the encoded solution
  • 38.
    A.A. 2012/2013Tecniche diprogrammazione76 Example: TSP (I) “2-opt”neighborhood
  • 39.
    A.A. 2012/2013Tecniche diprogrammazione77 Example: TSP(II) 3-opt neighborhood
  • 40.
    Hill Climbing (I) A.A.2012/2013Tecniche di programmazione78  For every configuration, evaluate all possible moves  (explore the whole neighborhood)  Refuse all moves that worsen the objective function  Accept the move that leads to the highest improvement of the objective function  If all moves worsen the objective function, quit.
  • 41.
    A.A. 2012/2013Tecniche diprogrammazione79 Hill Climbing (II) X = startinc configuration E = eval(X) do { N = n_moves(X) for (i=0; i<N; ++i) Ei = eval(move(X,i)) if (all Ei  E) return X i* = { i | max(Ei) } X = move(X, i*) E = Ei* } while(1)
  • 42.
    Features A.A. 2012/2013Tecniche diprogrammazione80  Greedy  Simple to implement  No backtracking => no recursion, no memory  Needs “clever” definition of moves  Sometimes, the objective function may be incrementally computed
  • 43.
    A.A. 2012/2013Tecniche diprogrammazione81 Problems (I)  Foothill: getting trapped in local maxima Hillclimber final point Start Real maximum
  • 44.
    A.A. 2012/2013Tecniche diprogrammazione82 Problems (II)  Mesa: wide regions with null or negligible variation of the objective function  Needle in the haystack: isolated peak in a desolated landscape
  • 45.
    A.A. 2012/2013Tecniche diprogrammazione83 Variants  First-ascent  Accept the first move that improves the objective function  Best-ascent  Evaluate all moves and accept the best one  Threshold-accept  Accept the first move that improves the current configuration by an amount higher that a fixed threshold  …etc…
  • 46.
    A.A. 2012/2013Tecniche diprogrammazione84 Example 111 fitness 10 011 fitness 12 101 fitness 20 110 fitness 5 First ascent Best ascent 011 fitness 12 101 fitness 20 Neighborhood definition: ‘complement one bit’
  • 47.
    A.A. 2012/2013Tecniche diprogrammazione85 Random Restart Hill Climbing  Repeat the Hill Climbing procedure starting from many initial starting points X = random configuration Best = X do { X’ = HillClimber(X) if (Eval(X’) > Eval(Best)) Best = X’ X = random configuration } while( ! Enough )
  • 48.
    A.A. 2012/2013Tecniche diprogrammazione86 Simulated Annealing  Stochastic approach for function minimization  The name is taken from the physical process of crystallization of a liquid into solid state  The minimum of the cost function corresponds to the crystal state of the substance (minimum energy)  Simulated Annealing gradually “lowers” the “temperature” until the system “freezes”
  • 49.
    A.A. 2012/2013Tecniche diprogrammazione87 Algorithm (I)  Start with a random solution  Choose a solution in the neighborhood  If the energy of the new solution is less than the current one, accept the move  If the energy is more than the current one, the move may be accepted, with a probability  The probability to accept “bad” moves depends on  Amount of worsening (DE)  Temperature (simulated) of the system
  • 50.
    A.A. 2012/2013Tecniche diprogrammazione88 Algorithm(II) current = start state for time = 1 to forever do T = schedule[time] if T = 0 return current next = a randomly chosen successor of current dE = value(next) – value(current) if dE > 0 then current = next else current = next with probability edE/T end for
  • 51.
    A.A. 2012/2013Tecniche diprogrammazione89 Features  The system may “jump out” of local minima by accepting worse solutions  At higher temperatures, worsening jumps are easier, at lower temperature they become unlikely  Temperature is gradually reduced  At T=0, the algorithm converges to the locally optimum solution (hill climbing behavior)
  • 52.
    A.A. 2012/2013Tecniche diprogrammazione90 Boltzmann distribution dE P(accettazione) 1T=max T=0
  • 53.
    Other local searchalgorithms A.A. 2012/2013Tecniche di programmazione91  Tabu Search  Ant Colony  Genetic Algorithms
  • 54.
  • 55.
    Licenza d’uso A.A. 2012/2013Tecnichedi programmazione93  Queste diapositive sono distribuite con licenza Creative Commons “Attribuzione - Non commerciale - Condividi allo stesso modo (CC BY-NC-SA)”  Sei libero:  di riprodurre, distribuire, comunicare al pubblico, esporre in pubblico, rappresentare, eseguire e recitare quest'opera  di modificare quest'opera  Alle seguenti condizioni:  Attribuzione — Devi attribuire la paternità dell'opera agli autori originali e in modo tale da non suggerire che essi avallino te o il modo in cui tu usi l'opera.  Non commerciale — Non puoi usare quest'opera per fini commerciali.  Condividi allo stesso modo — Se alteri o trasformi quest'opera, o se la usi per crearne un'altra, puoi distribuire l'opera risultante solo con una licenza identica o equivalente a questa.  http://creativecommons.org/licenses/by-nc-sa/3.0/