Introduction to computation Lirong Xia
Today’s schedule Ø Computation Ø Linear programming: a useful and generic technic to solve optimization problems Ø Basic computational complexity theorem • how can we formally measure computational efficiency? • how can we say a problem is harder than another? 2
The last battle strength minerals gas supply Zealot 1 100 0 2 Stalker 2 125 50 2 Archon 10 100 300 4 mineral gas supply Ø Available resource: 2000 1500 30 Ø How to maximize the total strength of your troop? 3
Computing the optimal solution str m g s Z Ø Variables 1 100 0 2 S 2 125 50 2 • x Z : number of Zealots A • x S : number of Stalkers 10 100 300 4 • x A : number of Archons 2000 1500 30 Resource Ø Objective: maximize total strength Ø max 1 x Z + 2 x S + 10 x A Ø Constraints • mineral: 100 x Z + 125 x S + 100 x A ≤ 2000 • gas: 0 x Z + 50 x S + 300 x A ≤ 1500 • supply: 2 x Z + 2 x S + 4 x A ≤ 30 4 • x Z , x S , x A ≥ 0, integers
Linear programming (LP) Ø Given • Variables x: a row vector of m positive real numbers • Parameters (fixed) • c: a row vector of m real numbers • b: a column vector of n real numbers • A: an n � m real matrix Ø Solve max cx T s.t. Ax T ≤ b, x ≥ 0 Ø Solutions • x is a feasible solution, if it satisfies all constraints • x is an optimal solution, if it maximizes the objective function among all feasible solutions 5
General tricks Ø Possibly negative variable x • x = y – y ’ Ø Minimizing cx T • max -cx T Ø Greater equals to ax T ≥ b • - ax T ≤ - b Ø Equation ax T = b • ax T ≥ b and ax T ≤ b Ø Strict inequality ax T < b • no “theoretically perfect” solution • ax T ≤ b - ε 6
Integrality constraints Ø Integer programming (IP): all variables are integers Ø Mixed integer programming (MIP): some variables are integers 7
Efficient solvers Ø LP: can be solved efficiently • if there are not too many variables and constraints Ø IP/MIP: some instances might be hard to solve • practical solver: CPLEX free for academic use! 8
Q & A time 9
Recommend
More recommend