Heuristics Definition a heuristic is an inexact algorithm

  • Slides: 21
Download presentation
Heuristics Definition – a heuristic is an inexact algorithm that is based on intuitive

Heuristics Definition – a heuristic is an inexact algorithm that is based on intuitive and plausible arguments which are “likely” to lead to reasonable solutions for a given problem, but are not guaranteed to do so. Note: These slides adapted from Y. Fathi, North Carolina State University, lecture notes IE 589 D.

Heuristics Common characteristics among heuristic procedures: • Speed: A heuristic procedure usually has a

Heuristics Common characteristics among heuristic procedures: • Speed: A heuristic procedure usually has a relatively small computational requirement. • Feasible solutions: A heuristic procedure usually finds a feasible solution for the given problem. • Common sense: Many heuristic procedures are based on common sense, or an adaptation of an exact method for simpler problems. • Search: A heuristic procedure may or may no involve a “search” in the set of feasible solutions. • No guarantee of optimality: A heuristic does not guarantee the solution it obtains is optimal for the given problem.

Heuristics Why use a heuristic method to solve a discrete optimization problem (integer problem)?

Heuristics Why use a heuristic method to solve a discrete optimization problem (integer problem)? : • The problem is difficult (e. g. known to be NP-Hard), and we must solve relatively “large” instances of the problem. • Needed in the branch and bound and implicit enumeration approaches for solving IPs. The better the heuristic, the faster the B&B or implicit enumeration will solve. • When you don’t necessarily need an optimal solution, but need a good solution fast.

Heuristics Greedy Algorithms – also called single pass heuristics, constructive methods, myopic algorithms. •

Heuristics Greedy Algorithms – also called single pass heuristics, constructive methods, myopic algorithms. • Incremental Feature – construct a sequence, or subset, one item at a time. • No backtracking – once item has been sequenced, no resequencing occurs. • Greedy selection – most profitable selection made from among available alternatives.

Heuristics Greedy Algorithm Example – Knapsack Problem Max s. t. Greedy Method • Sort

Heuristics Greedy Algorithm Example – Knapsack Problem Max s. t. Greedy Method • Sort items by pj/ wj • Load sack until an item won’t fit. • Skip that item and go to the next item that fits. • Continue step 3 till done

Heuristics Greedy Algorithm Example – Knapsack Problem Max s. t. Greedy Method - II

Heuristics Greedy Algorithm Example – Knapsack Problem Max s. t. Greedy Method - II • Sort items by pj/ wj • Load sack until an item won’t fit. • Once an item does not fit, compare the value of the item that doesn’t fit to the value of all items loaded so far, if the item is more valuable, throw out the previous items and put this item into the knapsack. • Continue step 3 till done

Heuristics Greedy Algorithm Example – PDS 1 Sequencing Problem Sequence a series of jobs

Heuristics Greedy Algorithm Example – PDS 1 Sequencing Problem Sequence a series of jobs to minimize the maximum lateness (Lmax) for a set of jobs to be processed on a single machine. Each job belongs to a given part family. A setup time occurs when changing between part families. Greedy Method - I • Sequence all jobs by earliest due date. Greedy Method - II • Sequence all jobs within a family by earliest due date. • Then, sequence families by choosing family with earliest due date first.

Heuristics Greedy Algorithm Ex. – Traveling Salesman Problem Given a collection of cities, find

Heuristics Greedy Algorithm Ex. – Traveling Salesman Problem Given a collection of cities, find the shortest/cheapest way to visit all cities, starting from a “home city” and returning home upon completion of the tour. Greedy Method – I Closest Unvisited City Algorithm, or Nearest Neighbor Algorithm • Starting with any city, go to the nearest neighbor that has not been visited. • Continue step 1 until all cities have been visited. • Return to initial city to complete tour. What can be done to strengthen this greedy algorithm?

Heuristics Example Closest Unvisited City Algorithm for TSP TO FROM City 1 2 3

Heuristics Example Closest Unvisited City Algorithm for TSP TO FROM City 1 2 3 4 5 6 1 - 3 6 9 24 1 2 1 - 7 3 2 14 3 14 6 - 3 3 7 4 3 2 5 - 11 9 5 5 20 13 4 - 18 6 7 15 11 2 4 -

Heuristics Greedy Algorithm TSP – based on Minimum Spanning Tree 1. Find the minimum

Heuristics Greedy Algorithm TSP – based on Minimum Spanning Tree 1. Find the minimum spanning tree (MSP). 2. Double up each edge of the MSP, this guarantees each node has an even number of edge. Known as a Euler path. 3. Trace the Eulerean path. 4. Skip each city already visited on the Eulerean path.

Minimal Spanning Tree Objective: Find the minimum distance such that all nodes are visited

Minimal Spanning Tree Objective: Find the minimum distance such that all nodes are visited once (i. e. no cycles). 2 3 7 1 9 6 2 3 3 3 1 4 6 4 3 5

Minimal Spanning Tree One possible spanning tree, Z = 26 (note, no cycles). 2

Minimal Spanning Tree One possible spanning tree, Z = 26 (note, no cycles). 2 3 7 1 4 9 6 3 4 3 5

Minimal Spanning Tree Algorithm: Step 1 – Select an arbitrary node initially. Identify a

Minimal Spanning Tree Algorithm: Step 1 – Select an arbitrary node initially. Identify a node that is closest and include the arc connecting these two nodes in the spanning tree. Step 2 – Out of the remaining nodes, determine the one that is closest to a node already selected in the spanning tree. Include the arc connecting these two nodes in the spanning tree. Whenever there is a tie for the closest node, it is broken arbitrarily.

Minimal Spanning Tree Start with node 1. Node 2 is closest. 2 3 7

Minimal Spanning Tree Start with node 1. Node 2 is closest. 2 3 7 1 9 6 2 3 3 3 1 4 6 4 3 5

Minimal Spanning Tree Node 3 is closest to partial spanning tree {(1, 2)}. Remove

Minimal Spanning Tree Node 3 is closest to partial spanning tree {(1, 2)}. Remove any cycles. 3 9 2 6 2 1 3 3 3 1 6 4 4 3 5

Minimal Spanning Tree Node 4 is closest to partial spanning tree {(1, 2), (2,

Minimal Spanning Tree Node 4 is closest to partial spanning tree {(1, 2), (2, 3)}. Remove any cycles. 3 9 2 6 2 1 3 3 3 1 6 4 3 5

Minimal Spanning Tree Node 5 is closest to partial spanning tree {(1, 2), (2,

Minimal Spanning Tree Node 5 is closest to partial spanning tree {(1, 2), (2, 3), (3, 4)}. Remove any cycles. 3 2 3 3 3 1 6 6 2 1 9 4 5

Minimal Spanning Tree Node 6 is only remaining node. Remove any cycles. 3 2

Minimal Spanning Tree Node 6 is only remaining node. Remove any cycles. 3 2 2 1 3 3 3 1 6 4 5 Minimal spanning tree is {(1, 2), (2, 3), (3, 4), (3, 5), (5, 6)}. Z = 12.

TSP Heuristic 2. Double up each edge of the MSP, this guarantees each node

TSP Heuristic 2. Double up each edge of the MSP, this guarantees each node has an even number of edge. Known as a Euler path. 2 3 2 1 3 3 3 1 6 4 5

TSP Heuristic 3. Trace the Eulerean path. 4. Skip each city already visited on

TSP Heuristic 3. Trace the Eulerean path. 4. Skip each city already visited on the Eulerean path. 2 3 2 1 3 3 3 1 6 4 5

TSP Heuristic 3. Trace the Eulerean path. 4. Skip each city already visited on

TSP Heuristic 3. Trace the Eulerean path. 4. Skip each city already visited on the Eulerean path. 2 3 2 1 3 3 3 1 6 4 5