400 likes | 581 Views
ELEC 7770 Advanced VLSI Design Spring 2008 Linear Programming – A Mathematical Optimization Technique. Vishwani D. Agrawal James J. Danaher Professor ECE Department, Auburn University, Auburn, AL 36849 vagrawal@eng.auburn.edu http://www.eng.auburn.edu/~vagrawal/COURSE/E7770_Spr08/course.html.
E N D
ELEC 7770Advanced VLSI DesignSpring 2008Linear Programming – A Mathematical Optimization Technique Vishwani D. Agrawal James J. Danaher Professor ECE Department, Auburn University, Auburn, AL 36849 vagrawal@eng.auburn.edu http://www.eng.auburn.edu/~vagrawal/COURSE/E7770_Spr08/course.html ELEC 7770: Advanced VLSI Design (Agrawal)
What is Linear Programming • Linear programming (LP) is a mathematical method for selecting the best solution from the available solutions of a problem. • Method: • State the problem and define variables whose values will be determined. • Develop a linear programming model: • Write the problem as an optimization formula (a linear expression to be minimized or maximized) • Write a set of linear constraints • An available LP solver (computer program) gives the values of variables. ELEC 7770: Advanced VLSI Design (Agrawal)
Types of LPs • LP – all variables are real. • ILP – all variables are integers. • MILP – some variables are integers, others are real. • A reference: • S. I. Gass, An Illustrated Guide to Linear Programming, New York: Dover, 1990. ELEC 7770: Advanced VLSI Design (Agrawal)
A Single-Variable Problem • Consider variable x • Problem: find the maximum value of x subject to constraint, 0 ≤ x ≤ 15. • Solution: x = 15. Constraint satisfied x 15 0 Solution x = 15 ELEC 7770: Advanced VLSI Design (Agrawal)
Single Variable Problem (Cont.) • Consider more complex constraints: • Maximize x, subject to following constraints: • x ≥ 0 (1) • 5x ≤ 75 (2) • 6x ≤ 30 (3) • x ≤ 10 (4) 0 5 10 15 x (1) (2) (3) (4) All constraints satisfied Solution, x = 5 ELEC 7770: Advanced VLSI Design (Agrawal)
A Two-Variable Problem • Manufacture of chairs and tables: • Resources available: • Material: 400 boards of wood • Labor: 450 man-hours • Profit: • Chair: $45 • Table: $80 • Resources needed: • Chair • 5 boards of wood • 10 man-hours • Table • 20 boards of wood • 15 man-hours • Problem: How many chairs and how many tables should be manufactured to maximize the total profit? ELEC 7770: Advanced VLSI Design (Agrawal)
Formulating Two-Variable Problem • Manufacture x1 chairs and x2 tables to maximize profit: P = 45x1 + 80x2 dollars • Subject to given resource constraints: • 400 boards of wood, 5x1 + 20x2 ≤ 400 (1) • 450 man-hours of labor, 10x1 + 15x2 ≤ 450 (2) • x1 ≥ 0 (3) • x2 ≥ 0 (4) ELEC 7770: Advanced VLSI Design (Agrawal)
Solution: Two-Variable Problem 40 30 20 10 0 P = 2200 Best solution: 24 chairs, 14 tables Profit = 45×24 + 80×14 = 2200 dollars Man-power constraint (1) Tables, x2 (24, 14) Material constraint (3) P = 0 (4) 0 10 20 30 40 50 60 70 80 90 Chairs, x1 increasing (2) Profit decresing ELEC 7770: Advanced VLSI Design (Agrawal)
Change Profit of Chair to $64/Unit • Manufacture x1 chairs and x2 tables to maximize profit: P = 64x1 + 80x2 dollars • Subject to given resource constraints: • 400 boards of wood, 5x1 + 20x2 ≤ 400 (1) • 450 man-hours of labor, 10x1 + 15x2 ≤ 450 (2) • x1 ≥ 0 (3) • x2 ≥ 0 (4) ELEC 7770: Advanced VLSI Design (Agrawal)
Solution: $64 Profit/Chair P = 2880 40 30 20 10 0 Best solution: 45 chairs, 0 tables Profit = 64×45 + 80×0 = 2880 dollars Man-power constraint (1) Tables, x2 (24, 14) Material constraint (3) P = 0 (4) 0 10 20 30 40 50 60 70 80 90 Chairs, x1 (2) increasing Profit decresing ELEC 7770: Advanced VLSI Design (Agrawal)
A Dual Problem • Explore an alternative. • Questions: • Should we make tables and chairs? • Or, auction off the available resources? • To answer this question we need to know: • What is the minimum price for the resources that will provide us with same amount of revenue as the profits from tables and chairs? • This is the dual of the original problem. ELEC 7770: Advanced VLSI Design (Agrawal)
Formulating the Dual Problem • Revenue received by selling off resources: • For each board, w1 • For each man-hour, w2 • Minimize 400w1 + 450w2 • Subject to constraints: • 5w1 + 10w2 ≥ 45 • 20w1 + 15w2 ≥ 80 • w1 ≥ 0 • w2 ≥ 0 ELEC 7770: Advanced VLSI Design (Agrawal)
The Duality Theorem • If the primal has a finite optimal solution, so does the dual, and the optimum values of the objective functions are equal. ELEC 7770: Advanced VLSI Design (Agrawal)
Primal problem Fixed resources Maximize profit Variables: x1 (number of chairs) x2 (number of tables) Maximize profit 45x1+80x2 Subject to: 5x1 + 20x2 ≤ 400 10x1 + 15x2 ≤ 450 x1 ≥ 0 x2 ≥ 0 Solution: x1 = 24 chairs, x2 = 14 tables Profit = $2200 Dual Problem Fixed profit Minimize value Variables: w1 ($ value/board of wood) w2 ($ value/man-hour) Minimize value 400w1+450w2 Subject to: 5w1 + 10w2 ≥ 45 20w1 + 15w2 ≥ 80 w1 ≥ 0 w2 ≥ 0 Solution: w1 = $1, w2 = $4 value = $2200 Primal-Dual Problems ELEC 7770: Advanced VLSI Design (Agrawal)
LP for n Variables n minimize Σcj xj Objective function j =1 n subject to Σaij xj ≤ bi,i = 1, 2, . . ., m j =1 n Σcij xj = di,i = 1, 2, . . ., p j =1 Variables: xj Constants: cj, aij, bi, cij, di ELEC 7770: Advanced VLSI Design (Agrawal)
Algorithms for Solving LP • Simplex method • G. B. Dantzig, Linear Programming and Extension, Princeton, New Jersey, Princeton University Press, 1963. • Ellipsoid method • L. G. Khachiyan, “A Polynomial Algorithm for Linear Programming,” Soviet Math. Dokl., vol. 20, pp. 191-194, 1984. • Interior-point method • N. K. Karmarkar, “A New Polynomial-Time Algorithm for Linear Programming,” Combinatorica, vol. 4, pp. 373-395, 1984. • Course website of Prof. Lieven Vandenberghe (UCLA), http://www.ee.ucla.edu/ee236a/ee236a.html ELEC 7770: Advanced VLSI Design (Agrawal)
Basic Ideas of Solution methods Extreme points Extreme points Objective function Objective function Constraints Constraints Interior-point methods: Successively iterate with interior spaces of analytic convex boundaries. Simplex: search on extreme points. ELEC 7770: Advanced VLSI Design (Agrawal)
Integer Linear Programming (ILP) • Variables are integers. • Complexity is exponential – higher than LP. • LP relaxation • Convert all variables to real, preserve ranges. • LP solution provides guidance. • Rounding LP solution can provide a non-optimal solution. ELEC 7770: Advanced VLSI Design (Agrawal)
Solving TSP: Five Cities Distances (dij) in miles (symmetric TSP, general TSP is asymmetric) ELEC 7770: Advanced VLSI Design (Agrawal)
Search Space: No. of Tours • Asymmetric TSP tours • Five-city problem: 4 × 3 × 2 × 1 = 24 tours • Nine-city problem: 362,880 tours • 14-city problem: 87,178,291,200 tours • 50-city problem: 49! = 6.08×1062 tours Time for enumerative search assuming 1 μs per tour evaluation = 1.93×1055 years ELEC 7770: Advanced VLSI Design (Agrawal)
A Greedy Heuristic Solution Tour length = 10 + 5 + 12 + 6 + 27 = 60 miles (non-optimal) ELEC 7770: Advanced VLSI Design (Agrawal)
ILP Variables, Constants and Constraints 4 x14 ε [0,1] d14 = 12 5 x15 ε [0,1] 1 d15 = 27 Integer variables: xij = 1, travel i to j xij = 0, do not travel i to j Real variables: dij = distance from i to j x12 ε [0,1] d12 = 18 x13 ε [0,1] d13 = 10 2 3 x12 + x13 + x14 + x15 = 2 four other similar equations ELEC 7770: Advanced VLSI Design (Agrawal)
Objective Function and ILP Solution 5 i - 1 Minimize ∑ ∑ xij × dij i = 1 j = 1 ∑ xij = 2 for all i j ≠ i ELEC 7770: Advanced VLSI Design (Agrawal)
ILP Solution d54 = 6 4 5 d45 = 6 1 d21 = 18 d13 = 10 2 3 d32 = 5 Total length = 45 but not a single tour ELEC 7770: Advanced VLSI Design (Agrawal)
Additional Constraints for Single Tour • Following constraints prevent split tours. For any subset S of cities, the tour must enter and exit that subset: ∑ xij ≥ 2 for all S, |S| < 5 i ε S j ε S Remaining set At least two arrows must cross this boundary. Any subset ELEC 7770: Advanced VLSI Design (Agrawal)
ILP Solution 4 d54 = 6 d41 = 12 5 1 d25 = 20 d13 = 10 2 3 d32 = 5 Total length = 53 ELEC 7770: Advanced VLSI Design (Agrawal)
Characteristics of ILP • Worst-case complexity is exponential in number of variables. • Linear programming (LP) relaxation, where integer variables are treated as real, gives a lower bound on the objective function. • Recursive rounding of relaxed LP solution to nearest integers gives an approximate solution to the ILP problem. • K. R. Kantipudi and V. D. Agrawal, “A Reduced Complexity Algorithm for Minimizing N-Detect Tests,” Proc. 20th International Conf. VLSI Design, January 2007, pp. 492-497. ELEC 7770: Advanced VLSI Design (Agrawal)
Why ILP Solution is Exponential? LP solution found in polynomial time (bound on ILP solution) Must try all 2n roundoff points Second variable Constraints First variable Objective (maximize) ELEC 7770: Advanced VLSI Design (Agrawal)
ILP Example: Test Minimization • A combinational circuit has n test vectors that detect m faults. Each test detects a subset of faults. Find the smallest subset of test vectors that detects all m faults. • ILP model: • Assign an integer variable ti ε[0,1] to ith test vector such that ti = 1, if we select ti, otherwise ti= 0. • Define an integer constant fij ε [0,1] such that fij = 1, if ith vector detects jth fault, otherwise fij = 0. Values of constants fij are determined by fault simulation. ELEC 7770: Advanced VLSI Design (Agrawal)
Test Minimization by ILP n minimize Σti Objective function i=1 n subject to Σfij ti ≥ 1,j = 1, 2, . . ., m i=1 ELEC 7770: Advanced VLSI Design (Agrawal)
3V3F: A 3-Vector 3-Fault Example Test vector i Variables: t1, t2, t3 ε [0,1] Minimize t1 + t2 + t3 Subject to: t1 + t2 ≥ 1 t2 + t3 ≥ 1 t1 + t3 ≥ 1 Fault j ELEC 7770: Advanced VLSI Design (Agrawal)
3V3F: Solution Space t3 ILP solutions (optimum) 1 Non-optimum solution 1st LP solution (0.5, 0.5, 0.5) Rounding and 2nd ILP solution (1.0, 0.5, 0.5) t2 1 Rounding and 3rd LP solution (1.0, 1.0, 0.0) 1 t1 ELEC 7770: Advanced VLSI Design (Agrawal)
3V3F: LP Relaxation and Rounding ILP – Variables: t1, t2, t3 ε [0,1] Minimize t1 + t2 + t3 Subject to: t1 + t2 ≥ 1 t2 + t3 ≥ 1 t1 + t3 ≥ 1 • LP relaxation: t1, t2, t3 ε (0.0, 1.0) • Solution: t1 = t2 = t3 = 0.5 • Recursive rounding: • round one variable, t1 = 1.0 • Two-variable LP problem: • Minimize t2 + t3 • subject to t2 + t3 ≥ 1.0 • LP solution t2 = t3 = 0.5 • (2) round a variable, t2 = 1.0 • ILP constraints are satisfied • solution is t1 = 1, t2 = 1, t3 = 0 ELEC 7770: Advanced VLSI Design (Agrawal)
Recursive Rounding Algorithm • Obtain a relaxed LP solution. Stopif each variable in the solution is an integer. • Round the variable closest to an integer. • Remove any constraints that are now unconditionally satisfied. • Go to step 1. ELEC 7770: Advanced VLSI Design (Agrawal)
Recursive Rounding • ILP has exponential complexity. • Recursive rounding: • ILP is transformed into k LPs with progressively reducing number of variables. • A solution that satisfies all constraints is guaranteed; this solution is often close to optimal. • Number of LPs, k, is the size of the final solution, i.e., the number of non-zero variables in the test minimization problem. • Recursive rounding complexity is k × O(np), where k ≤ n, n is number of variables. ELEC 7770: Advanced VLSI Design (Agrawal)
Four-Bit ALU Circuit ELEC 7770: Advanced VLSI Design (Agrawal)
ILP vs. Recursive Rounding 100 75 50 25 0 ILP Recursive Rounding CPU s 0 5,000 10,000 15,000 Vectors ELEC 7770: Advanced VLSI Design (Agrawal)
N-Detect Tests (N = 5) ELEC 7770: Advanced VLSI Design (Agrawal)
Finding LP/ILP Solvers • R. Fourer, D. M. Gay and B. W. Kernighan, AMPL: A Modeling Language for Mathematical Programming, South San Francisco, California: Scientific Press, 1993. Several of programs described in this book are available to Auburn users. • B. R. Hunt, R. L. Lipsman, J. M. Rosenberg, K. R. Coombes, J. E. Osborn and G. J. Stuck, A Guide to MATLAB for Beginners and Experienced Users, Cambridge University Press, 2006. • Search the web. Many programs with small number of variables can be downloaded free. ELEC 7770: Advanced VLSI Design (Agrawal)