You are on page 1of 24

Linear Programming (LP) (Chap.

• Suppose all the numbers below are real numbers. • Given a linear function (called objective function)
– f(x1, x2,…, xn)=c1x1+ c2x2+…+ cnxn=j=1n cjxj.

• With constraints:
– j=1n aijxj bi for i=1,2,…,m and – xj0 for j=1,2,…,n. (nonnegativity)

• Question: find values for x1, x2,…, xn, which maximize f(x1, x2,…, xn). • Or if change bi to bi , then minimize f(x1, x2,…, xn).

LP examples
– Political election problem:
• Certain issues: building roads, gun control, farm subsidies, and gasoline tax. • Advertisement on different issues • Win the votes on different areas: urban, suburban, and rural. • Goal: minimize advertisement cost to win the majority of each area. (See page 772, (29.6) –(29.10))

– Flight crew schedule, minimize the number of crews:
• Limitation on number of consecutive hours, • Limited to one model each month,…

– Oil well location decision with maximum of oil output:
• A location is associated a cost and payoff of barrels of oil. • Limited budget.

– Add constraints: xi'0 and xi'' 0. 3 . – Replace each occurrence of xi with xi'-xi''.may not have nonnegativity constraints: – delete xi but introduce two variables xi' and xi''.Change a LP problem to standard format • If some variables. such as xi. • There may be equality constraints: – Replace j=1n aijxj =bi with j=1n aijxj bi and j=1n aijxj bi . – Then change j=1n aijxj bi to j=1n -aijxj  -bi for minimization or j=1n aijxj bi to j=1n -aijxj -bi for maximization.

then introduce new variable s. whereas all the right-hand side variables are called nonbasic variables. xn non-basic variables.2. • All the left-hand side variables are called basic variables. sm basic variables. • Change standard form to slack form: – – – – If j=1n aijxj  bi. x1.…. • Initially. and set: si= bi .Linear program in slack form • Except nonnegativity constraints. s1. x1. If j=1n aijxj  bi. all other constraints are equalities. s1.…. (i=1.j=1n aijxj and si0. and set: si= j=1n aijxj -bi and si0.…. 4 .m). then introduce new variable s.

v) for each edge (u. 5 . • Maximize xt with the constraints: • xv  xu+w(u.Formatting problems as LPs • (Single pair) Shortest path : – A weighted direct graph G=<V. compute d which is the weight of the shortest path from s to t.v)E. introduce a variable xv: the weight of the shortest path from s to v. a source s and a destination t.E> with weighted function w: ER. – Change to LP: • For each vertex v. and xs =0.

or to say. 6 . A flow is a function f : VVR that satisfies: • Capacity constraints: for all u. how much comes in.t}. a capacity function on each edge c(u.v)=0.v)= -f(v. f(u. or to say.v) c(u. – Find a maximum flow from s to t.Formatting problems as LPs • Max-flow problem: – A directed graph G=<V. total flow out of a vertex other s or t is 0. also that much comes out. • Skew symmetry: for all u.u).vV. vV f(u.vV.v). f(u.E>. • Flow conservation: for all uV-{s.v) 0 and a source s and a sink t.

Example of max-flow problem 7 .

• for all uV-{s.vV.Formatting Max-flow problem as LPs • Maximize vV f(s.t}.v)= -f(v.v) c(u. • for all u. vV f(u.vV. f(u. f(u. 8 .v).v)=0.u).v) with constraints: • for all u.

….….…. x2.….m and – xj0 for j=1.Linear Programming (LP) (Chap. • With constraints: – j=1n aijxj bi for i=1. then minimize f(x1.2.….n. 9 . xn)=c1x1+ c2x2+…+ cnxn=j=1n cjxj. x2. xn.…. (nonnegativity) • Question: find values for x1.29) • Suppose all the numbers below are real numbers.2. • Or if change bi to bi . which maximize f(x1. xn). x2. x2. • Given a linear function (called objective function) – f(x1. xn).

• Initially. then introduce new variable s. x1. 10 . • All the left-hand side variables are called basic variables. and set: si= bi . • Change standard form to slack form: – – – – If j=1n aijxj  bi. and set: si= j=1n aijxj -bi and si0. all other constraints are equalities.…. sm basic variables. x1. s1.j=1n aijxj and si0.Linear program in slack form • Except nonnegativity constraints. then introduce new variable s. xn non-basic variables.2. If j=1n aijxj  bi. s1.m). whereas all the right-hand side variables are called nonbasic variables.…. (i=1.….

The Simplex algorithm for LP • It is very simple • It is often very fast in practice. • Illustrate by an example. 11 . even its worst running time is not poly.

x1-x2-3x3 x5=24. x6 0 (29.62) (29.59) (29.4x1-x2-2x3 x1 . x3 .58) (29. x3 0 z= 3x1+x2+2x3 x4=30. x5 . x2 .61) (29.63) (29.2x1-2x2-5x3 x6=36.57) (29.64) • Change to slack form: 12 . x2 . x4 .56) • Subject to: – – – – – – – – – x1+x2+3x3  30 2x1+2x2+5x3  24 4x1+x2+2x3  36 x1 .An example of Simplex algorithm • Maximize 3x1+x2+2x3 (29.60) (29.

13 . x3. resulting in a greater objective value each time: • Select a nonbasic variable xe whose coefficient in objective function is positive. in this example. x2. – The feasible solutions keep the same. • increase value of xe as much as possible without violating any of constraints. x6 are nonnegative. – as long as all of x1. x5.Simplex algorithm steps • Feasible solutions (infinite number of them): – A solution whose values satisfy constraints. x4. • xe is changed to basic and some other variable to nonbasic. • basic solution: – set all nonbasic variables to 0 and compute all basic variables • Iteratively rewrite the set of equations such that – No change to the underlying LP problem. – However the basic solution changes.

So only to 9.x2.64) • Try to increase the value of x1: – Change x1to basic variable by rewriting (29.Simplex algorithm example • Basic solution: (x1.x3.4x1-x2-2x3 (29.0.62) (29. – – – – z= 3x1+x2+2x3 x4=30. – The result is z=3  0+0+2  0=0. • x1=9-x2/4 –x3/2 –x6/4 . 12: x5.63) (29.24. Not maximum.0.x5.2x1-2x2-5x3 x6=36.x4.30.x1-x2-3x3 x5=24.36).64) to: – Note: x6 becomes nonbasic. 9: x6.61) (29.x6) =(0. – Replace x1 with above formula in all equations to get: 14 • 30: x4 will be OK.

30. and a basic variable. and x6 is leaving variable.67) x1=9-x2/4 –x3/2 –x6/4 (29. with z=27. called entering variable.0.70) This operation is called pivot. x3.0. – x2.6.69) x5=6-3x2/2 –4x3 +x6/2 (29. – It can be checked the original solution (0. and changes their roles. and x1. 15 .24. – The basic solution for this is (9. – It can be seen the pivot operation is equivalent. • In the example.Simplex algorithm example • • • • • z=27+x2/4 +x3/2 –3x6/4 (29. called leaving variable.36) satisfies the new equations. – x1 is entering variable.0). x6 are nonbasic.21.0. x4.0. – A pivot chooses a nonbasic variable. x5 becomes basic.68) x4=21-3x2/4 –5x3/2 +x6/4 (29.

Simplex algorithm example • We continue to try to find a new variable whose value may increase.68) limits it to 18. So rewrite (29. since z will decrease. – x2 and x3 are OK. Suppose we select x3.69) to 42/5. • How far can we increase x3 : – (29. (29.70) to: • x3=3/2-3x2/8 –x5/4+x6/8 – Replace x3 with this in all the equations to get: 16 .70) to 3/2. – x6 will not work. (29.

73) (29.0) with z=111/4.  respectively.3/2.72) (29.74) • The basic solution is (33/4.73) to x2=4-8x3/3 –2x5/3+x6/3 • Replace in all equations to get: 17 . (29.Simplex algorithm example • The LP equations: – – – – z=111/4+x2/16 –x5/8 .0. (29.72).71) (29. So rewrite (29. • Now we can only increase x2.74) limits x2 to 132.4.11x6/16 x1=33/2. (29.73).x2/16 +x5/8 .0.5x6/16 x3=3/2-3x2/8 –x5/4+x6/8 x4=69/4+3x2/16 +5x5/8-x6/16 (29.69/4.

Simplex algorithm example • LP equations: – – – – z=28-x3/6 –x5/6-2x6/3 x1=8+x3/6 +x5/6-x6/3 x2=4-8x3/3 –2x5/3+x6/3 x4=18-x3/2 +x5/2.0). x3 . • The basic solution is (8.4. • At this point. • The original variables are x1.58) =3  8+4+2  0=28. this is the state with optimal solution. 18 . all coefficients in objective functions are negative.0.18. So no further rewrite can be done. x2. with values (8.0) with objective value z=28.4. In fact. the objective value of (29.0.

Simplex algorithm --Pivot N: indices set of nonbasic variables B: indices set of basic variables A: aij b: bi c: ci v: constant coefficient. e: index of entering variable l: index of leaving variable z=v+jNcjxj xi=bi.jNaijxj for iB 19 .

Formal Simplex algorithm +m 20 .

• Feasible solution: a set of values for xi’s which satisfy all constraints. 21 .7 (page 803): – Assuming that INITIALIZE-SIMPLEX returns a slack form for which the basic solution is feasible. or it +n ) terminates with a feasible solution in at most ( mm iterations. • Unbound: has feasible solutions but does not have a finite optimal objective value. SIMPLEX either reports that a linear program is unbounded.Running time of Simplex • Lemma 29.

Two variable LP problems • Example: – – – – – – Maximize x1+x2 (29. x2 0 (29.x2  8 (29.13) 5x1.2x2  -2 (29.14) x1 . • By prune-and-search approach.12) 2x1+x2  10 (29.11) Subject to: 4x1.15) • Can be solved by graphical approach. 22 .

Find maximum via graph 23 .

– Given an integer mxn matrix A and an integer m-vector b. 24 .Integer linear program • A linear program problem with additional constraint that all variables must take integral values. (Prove it??) • However the general linear program problem is poly time solvable. – this problem is NP-complete. whether there is an integer n-vector x such that Ax<=b.