TNK104 Applied Optimization
Review Session
Lecture 11
2
TNK104 Applied Optimization I
Topological Sort
Given a directed acyclic graph G = (V, E), visit and print the vertices in an order such that each vertex v is printed before any vertex u with (v, u) ∈ E
Observation: At least one vertex has in degree = 0 in a directed acyclic graph
A possible solution is v4 , v8 , v3 , v2 , v1 , v5 , v7 , v6
Topological Sort (cont’d)
3
TNK104 Applied Optimization I
Time complexity?
Topological Sort (cont’d)
4
TNK104 Applied Optimization I
Time complexity?
Linear O(V+E)
Shortest Path
5
TNK104 Applied Optimization I
Shortest Path Tree
6
TNK104 Applied Optimization I
Consider the problem of finding shortest paths from v5 to all other vertices for the example graph
By the way: Is the solution always a tree?
Solution:
Solution Representation of the Shortest Path Tree
7
TNK104 Applied Optimization I
Dijkstra’s Algorithm
8
TNK104 Applied Optimization I
Let’s “decode” by executing it …
Time complexity?
Dijkstra’s Algorithm
9
TNK104 Applied Optimization I
Greedy algorithm (detailed in lect 3)
Efficient: complexity O(V^2) (depends on implementation of the priority queue)
But! Does not work with negative weights (see examples in the self-study material)
Alternative: Bellman-Ford (dynamic programming approach)
robust, but less efficient: O(EV)
Output: graph, highlight the shortest path
�code example:
shortest_path= digraph(arcs_to_last(:,1),arcs_to_last(:,2)); highlight(p,shortest_path_to_last_graph);
IP (integer) and MIP (mixed-integer) Model
10
TNK104 Applied Optimization I
The Convex Hull
11
TNK104 Applied Optimization I
Convex hull: The minimum convex set containing all integer solutions
→ Solve ILP = Solve the LP over the convex hull!
Objective
The Convex Hull (cont’d)
12
TNK104 Applied Optimization I
Objective
LP optimum
New LP optimum
13
Acknowledgement: Numerical example from L. Wolsey, Integer Programming, John Wiley & Sons, 1998
TNK104 Applied Optimization I
Example of Structured Valid Inequality: Cover Inequalities
Consider the set of solutions defined by
Cover Inequalities: A General Definition
14
TNK104 Applied Optimization I
Another example: Cover inequalities for Knapsack problem
Separation Problem
15
TNK104 Applied Optimization I
We are only interested in finding useful valid inequalities
Does the current fractional point (LP) violate some valid inequality?
that is, is there a valid inequality separating the point from the convex full?
Separation Problem (cont’d)
16
TNK104 Applied Optimization I
Inexact Algorithms: A Classification
17
TNK104 Applied Optimization I
RE: Greedy Algorithm – A General Definition
18
Note that the following algorithms are greedy:
Because they are based on a greedy principle/strategy!
[1] Black, Paul E. (2 February 2005). "greedy algorithm". Dictionary of Algorithms and Data Structures.
U.S. National Institute of Standards and Technology (NIST). Retrieved 17 August 2012.
Greedy Algorithm for Binary Knapsack
19
TNK104 Applied Optimization I
Example 1: Knapsack Capacity W = 25 and
Item | A | B | C | D |
Price | 12 | 9 | 9 | 5 |
Size | 24 | 10 | 10 | 7 |
Greedy Algorithm for Binary Knapsack (cont’d)
20
TNK104 Applied Optimization I
Does the algorithm guarantee optimality?
Example 2: Knapsack Capacity = 30
Possible greedy approach: take largest ratio: (Solution: A and B. Size=5+20=25. Price=50+140=190
Optimal: B and C. Size=20+10=30. Price=140+60=200
What are the lesson we learned?
Item | A | B | C |
Price | 50 | 140 | 60 |
Size | 5 | 20 | 10 |
Ratio | 10 | 7 | 6 |
Greedy Algorithm for Binary Knapsack (cont’d)
21
TNK104 Applied Optimization I
Does the algorithm guarantee optimality?
Example 2: Knapsack Capacity = 30
Possible greedy approach: take largest ratio: (Solution: A and B. Size=5+20=25. Price=50+140=190
Optimal: B and C. Size=20+10=30. Price=140+60=200
What are the lesson we learned?
Greedy doesn't work for 0-1 Knapsack Problem
Item | A | B | C |
Price | 50 | 140 | 60 |
Size | 5 | 20 | 10 |
Ratio | 10 | 7 | 6 |
Metaheuristics
Nikolaos Pappas, ITN, LiU
22
TNK104 Applied Optimization I
Examples of meta heuristics:
Local Optima
Nikolaos Pappas, ITN, LiU
23
TNK104 Applied Optimization I
A local optimum can be very far from the global optimum in objective value
One dimension
Two dimensions
Tabu Search
24
TNK104 Applied Optimization I
→ No cycles
→ Avoid moves leading back to a visited local optimum
The Tabu Search Algorithm
25
TNK104 Applied Optimization I
Crucial Aspects of Tabu Search
26
TNK104 Applied Optimization I
(2-exchange for TSP: edges deleted, edges added, or both?)
→ may easily get stuck in local optimum, or cycling!
→ may fail to find good solutions
An Illustration of Tabu Search for k-Cardinality Tree
27
TNK104 Applied Optimization I
k-cardinality tree: Find a minimum-cost tree of cardinality k (i.e., k links).
Neighbourhood definition:
An Illustration of Tabu Search for k-Cardinality Tree (cont’d)
28
TNK104 Applied Optimization I
Consider tabu search with tabu list length = 1 (simplification)
29
TNK104 Applied Optimization I
An Illustration of Tabu Search for k-Cardinality Tree (cont’d)
30
TNK104 Applied Optimization I
An Illustration of Tabu Search for k-Cardinality Tree (cont’d)
An Illustration of Tabu Search for k-Cardinality Tree (cont’d)
TNK104 Applied Optimization I
Lagrangian Relaxation
TNK104 Applied Optimization I
TNK104 Applied Optimization I
Lagrangian Relaxation (cont’d)
Lagrangian Relaxation for Knapsack (cont’d)
TNK104 Applied Optimization I
Subgradient Optimization
TNK104 Applied Optimization I
Subgradient Optimization (cont’d)
TNK104 Applied Optimization I
Questions?
Good luck!