Search and Optimization Strategies
-
Upload
fulvio-corno -
Category
Education
-
view
602 -
download
0
description
Transcript of Search and Optimization Strategies
Search and Optimization Strategies
Tecniche di Programmazione – A.A. 2012/2013
Summary
A.A. 2012/2013 Tecniche di programmazione 2
Definitions
Branch & Bound
Greedy
Local Search
Definitions
Search and Optimization Strategies
Search vs Optimization
A.A. 2012/2013 Tecniche di programmazione 4
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/2013 Tecniche di programmazione 5
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/2013 Tecniche di programmazione 6
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/2013 Tecniche di programmazione 7
Representation
S: Solutions
V: Valid (feasible) solutions
M: best solutions
s
s
s f(s)
Objective
function
A.A. 2012/2013 Tecniche di programmazione 8
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/2013 Tecniche di programmazione 9
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/2013 Tecniche di programmazione 10
Greedy
Pseudo-random
Hill climber
1
2 3
Approximate solutions
A.A. 2012/2013 Tecniche di programmazione 11
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/2013 Tecniche di programmazione 12
x
f(x)
Optimum
solution
Optimal
solution
Locally
optimum
solutions
Computational Intelligence
A.A. 2012/2013 Tecniche di programmazione 13
Evolutionary Algorithms
Genetic Algorithms
Genetic Programming
Simulated annealing
Tabu-Search
Branch & Bound
Search and Optimization Strategies
A.A. 2012/2013 Tecniche di programmazione 15
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/2013 Tecniche di programmazione 16
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/2013 Tecniche di programmazione 17
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/2013 Tecniche di programmazione 18
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/2013 Tecniche di programmazione 19
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/2013 Tecniche di programmazione 20
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/2013 Tecniche di programmazione 21
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/2013 Tecniche di programmazione 22
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/2013 Tecniche di programmazione 23
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/2013 Tecniche di programmazione 55
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/2013 Tecniche di programmazione 56
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/2013 Tecniche di programmazione 57
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/2013 Tecniche di programmazione 58
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/2013 Tecniche di programmazione 59
Example
Available coins
20, 10, 5, 2, 1
Change to give
55
A.A. 2012/2013 Tecniche di programmazione 60
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/2013 Tecniche di programmazione 61
Features
Advantages
Extremely simple algorithm
Very fast computational time
Disadvantages
The solution is optimal, non necessarily optimum
Non-optimum solution
A.A. 2012/2013 Tecniche di programmazione 62
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/2013 Tecniche di programmazione 72
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/2013 Tecniche di programmazione 73
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/2013 Tecniche di programmazione 74
Example
Moves
A.A. 2012/2013 Tecniche di programmazione 75
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/2013 Tecniche di programmazione 76
Example: TSP (I)
“2-opt”neighborhood
A.A. 2012/2013 Tecniche di programmazione 77
Example: TSP(II)
3-opt neighborhood
Hill Climbing (I)
A.A. 2012/2013 Tecniche di programmazione 78
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/2013 Tecniche di programmazione 79
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/2013 Tecniche di programmazione 80
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/2013 Tecniche di programmazione 81
Problems (I)
Foothill: getting trapped in local maxima
Hillclimber final point
Start
Real maximum
A.A. 2012/2013 Tecniche di programmazione 82
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/2013 Tecniche di programmazione 83
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/2013 Tecniche di programmazione 84
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/2013 Tecniche di programmazione 85
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/2013 Tecniche di programmazione 86
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/2013 Tecniche di programmazione 87
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/2013 Tecniche di programmazione 88
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/2013 Tecniche di programmazione 89
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/2013 Tecniche di programmazione 90
Boltzmann distribution
dE
P(accettazione)
1 T=max
T=0
Other local search algorithms
A.A. 2012/2013 Tecniche di programmazione 91
Tabu Search
Ant Colony
Genetic Algorithms
Resources
A.A. 2012/2013 Tecniche di programmazione 92
Licenza d’uso
A.A. 2012/2013 Tecniche di programmazione 93
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/