Search and Optimization Strategies


Published on

Search and Optimization Strategies

Branch & Bound
Local Search

Teaching material for the course of "Tecniche di Programmazione" at Politecnico di Torino in year 2012/2013. More information:

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Search and Optimization Strategies

  1. 1. Search and Optimization StrategiesTecniche di Programmazione – A.A. 2012/2013
  2. 2. SummaryA.A. 2012/2013Tecniche di programmazione2 Definitions Branch & Bound Greedy Local Search
  3. 3. DefinitionsSearch and Optimization Strategies
  4. 4. Search vs OptimizationA.A. 2012/2013Tecniche di programmazione4 A search algorithm is an algorithm for finding an itemwith 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 bestpossible solution, according to an objective function,among all possible feasible solutions for a givenproblem
  5. 5. Objective functionA.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
  6. 6. A.A. 2012/2013Tecniche di programmazione6Types 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 validsolutions? And what is the best? Ex: travelling salesman problem
  7. 7. A.A. 2012/2013Tecniche di programmazione7RepresentationS: SolutionsV:Valid (feasible) solutionsM: best solutionssssf(s)Objectivefunction
  8. 8. A.A. 2012/2013Tecniche di programmazione8Classification 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. 9. Exact techniquesA.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 Programming1 23 45 67 8
  10. 10. Approximate TecniquesA.A. 2012/2013Tecniche di programmazione10 Greedy Pseudo-random Hill climber123
  11. 11. Approximate solutionsA.A. 2012/2013Tecniche di programmazione11 Optimum solution: the absolute best Optimal solution: a solution that approximates the optimum one (might be coincident, but wedon’t know) can no longer be improved with the chosen optimizationtechnique Locally optimum solution: optimum solution in acontinuous domain
  12. 12. Intuitively…A.A. 2012/2013Tecniche di programmazione12xf(x)OptimumsolutionOptimalsolutionLocallyoptimumsolutions
  13. 13. Computational IntelligenceA.A. 2012/2013Tecniche di programmazione13 Evolutionary Algorithms Genetic Algorithms Genetic Programming Simulated annealing Tabu-Search
  14. 14. Branch & BoundSearch and Optimization Strategies
  15. 15. A.A. 2012/2013Tecniche di programmazione15Introduction Branch and Bound is an exact method for exploring allsolutions based on their implicit enumeration All solutions are considered, but not one-by-one. In factB&B: Considers disjoints subsets of solutions (branching) Evaluates them according to an estimate of the objectivefunction (bounding), by eliminating (pruning) those subsets thatmay not contain the optimum solution
  16. 16. A.A. 2012/2013Tecniche di programmazione16Definition 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-problemP(r) lower bound for minimization problems upper bound for maximization problems
  17. 17. A.A. 2012/2013Tecniche di programmazione17General 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. 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 tothe optimum z(r)E P(r) is closed Its solution, with value z(r)E, may possibly replace z*, if itimproves it
  19. 19. General algorithm (III)A.A. 2012/2013Tecniche di programmazione19 Se P(r) has solutions, but it’s difficult to be solved up tothe optimum, we try to show that it may not yield abetter 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 dominatedby 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 thatare inserted in the list P. P(r) is closed, and the sub-problemswill be opened, eventually.
  20. 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 solutionfor the original problem.
  21. 21. The solution treeA.A. 2012/2013Tecniche di programmazione21P0P1 P2P21 P22P11 P12P111 P112P12Node: sub-problemLeaf node: closed sub-problem
  22. 22. Ingredients of a B&B algorithmA.A. 2012/2013Tecniche di programmazione22 Strategy of visit of the search tree: criteria to choose thenext sub-problem to be analyzed out of the list P Bounding technique: how to evaluate the super-optimalestimate z(r)B Branching rule: how to split the current problem P(r) intosmaller sub-problems.
  23. 23. Main featuresA.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 thestrategy The worst case is to visit all possible nodes, anyway Time needed to compute z(r)B.
  24. 24. GreedySearch and Optimization Strategies
  25. 25. A.A. 2012/2013Tecniche di programmazione55Introduction A greedy algorithm searches for a globally optimalsolution, 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 partialsolution Attractiveness (it: appetibilità) = estimate of how much, probably,we are close to the optimum.
  26. 26. General structure (I)A.A. 2012/2013Tecniche di programmazione56 If the attractiveness {ai} of partial solutions are knownsince the beginning, and may not be modifiedGreedy ({a1, a2, …an})S  øsort {ai} in decreasing attractiveness orderfor each ai doif ai may be added to Sthen S  S  {ai}return S
  27. 27. General structure (II)A.A. 2012/2013Tecniche di programmazione57 If attractiveness may be modified by the effects ofprevious choicesGreedy2 ({a1, a2, …an})S  øcompute attractiveness of aiwhile there are element to choose dochoose the most-attractive aiif ai may be added to Sthen S  S  {ai}update the remaining aireturn S
  28. 28. ExampleA.A. 2012/2013Tecniche di programmazione58 Find the minimum number of coins to give change to acustomer. We assume we have a list of possible coin values, andtheir availability is infinite
  29. 29. A.A. 2012/2013Tecniche di programmazione59Example Available coins 20, 10, 5, 2, 1 Change to give 55
  30. 30. A.A. 2012/2013Tecniche di programmazione60Algorithm At each step, select the highest-valued coin, whose valueis less than the remaining changeRemaining change Chosen coin55 2035 2015 105 5
  31. 31. A.A. 2012/2013Tecniche di programmazione61Features Advantages Extremely simple algorithm Very fast computational time Disadvantages The solution is optimal, non necessarily optimum
  32. 32. Non-optimum solutionA.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
  33. 33. Local SearchSearch and Optimization Strategies
  34. 34. ApplicabilityA.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”
  35. 35. Iterative improvementA.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
  36. 36. A.A. 2012/2013Tecniche di programmazione74Example
  37. 37. MovesA.A. 2012/2013Tecniche di programmazione75 We must define a set of moves to lead from onesolution to another The set of possible moves defined the neighborhood ofa solution Moves are often implemented as small variations(mutation) on the encoded solution
  38. 38. A.A. 2012/2013Tecniche di programmazione76Example: TSP (I)“2-opt”neighborhood
  39. 39. A.A. 2012/2013Tecniche di programmazione77Example: TSP(II)3-opt neighborhood
  40. 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 improvementof the objective function If all moves worsen the objective function, quit.
  41. 41. A.A. 2012/2013Tecniche di programmazione79Hill Climbing (II)X = startinc configurationE = eval(X)do {N = n_moves(X)for (i=0; i<N; ++i)Ei = eval(move(X,i))if (all Ei  E)return Xi* = { i | max(Ei) }X = move(X, i*)E = Ei*} while(1)
  42. 42. FeaturesA.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 incrementallycomputed
  43. 43. A.A. 2012/2013Tecniche di programmazione81Problems (I) Foothill: getting trapped in local maximaHillclimber final pointStartReal maximum
  44. 44. A.A. 2012/2013Tecniche di programmazione82Problems (II) Mesa: wide regions with null or negligible variation of theobjective function Needle in the haystack: isolated peak in a desolatedlandscape
  45. 45. A.A. 2012/2013Tecniche di programmazione83Variants 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 anamount higher that a fixed threshold …etc…
  46. 46. A.A. 2012/2013Tecniche di programmazione84Example111 fitness 10011 fitness 12101 fitness 20110 fitness 5First ascentBest ascent011 fitness 12101 fitness 20Neighborhood definition:‘complement one bit’
  47. 47. A.A. 2012/2013Tecniche di programmazione85Random Restart Hill Climbing Repeat the Hill Climbing procedure starting from many initialstarting pointsX = random configurationBest = Xdo {X’ = HillClimber(X)if (Eval(X’) > Eval(Best))Best = X’X = random configuration} while( ! Enough )
  48. 48. A.A. 2012/2013Tecniche di programmazione86Simulated Annealing Stochastic approach for function minimization The name is taken from the physical process ofcrystallization of a liquid into solid state The minimum of the cost function corresponds to thecrystal state of the substance (minimum energy) Simulated Annealing gradually “lowers” the “temperature”until the system “freezes”
  49. 49. A.A. 2012/2013Tecniche di programmazione87Algorithm (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 beaccepted, with a probability The probability to accept “bad” moves depends on Amount of worsening (DE) Temperature (simulated) of the system
  50. 50. A.A. 2012/2013Tecniche di programmazione88Algorithm(II)current = start statefor time = 1 to forever doT = schedule[time]if T = 0 return currentnext = a randomly chosen successor of currentdE = value(next) – value(current)if dE > 0 then current = nextelse current = next with probability edE/Tend for
  51. 51. A.A. 2012/2013Tecniche di programmazione89Features The system may “jump out” of local minima by acceptingworse solutions At higher temperatures, worsening jumps are easier, atlower temperature they become unlikely Temperature is gradually reduced At T=0, the algorithm converges to the locally optimumsolution (hill climbing behavior)
  52. 52. A.A. 2012/2013Tecniche di programmazione90Boltzmann distributiondEP(accettazione)1T=maxT=0
  53. 53. Other local search algorithmsA.A. 2012/2013Tecniche di programmazione91 Tabu Search Ant Colony Genetic Algorithms
  54. 54. ResourcesA.A. 2012/2013Tecniche di programmazione92
  55. 55. Licenza d’usoA.A. 2012/2013Tecniche di programmazione93 Queste diapositive sono distribuite con licenza Creative Commons“Attribuzione - Non commerciale - Condividi allo stesso modo (CCBY-NC-SA)” Sei libero: di riprodurre, distribuire, comunicare al pubblico, esporre in pubblico,rappresentare, eseguire e recitare questopera di modificare questopera Alle seguenti condizioni: Attribuzione — Devi attribuire la paternità dellopera agli autori originalie in modo tale da non suggerire che essi avallino te o il modo in cui tuusi lopera. Non commerciale — Non puoi usare questopera per fini commerciali. Condividi allo stesso modo — Se alteri o trasformi questopera, o se lausi per crearne unaltra, puoi distribuire lopera risultante solo con unalicenza identica o equivalente a questa.