Copyrigt c Sanjoy Dasgupta Figure. (a) Te feasible region for a linear program wit two variables (see tet for details). (b) Contour lines of te objective function: for different values of (profit). Te optimal solution is a verte of te polygon, indicated by a little circle. 400 400 300 300 00 00 c = 50000 00 00 c = 60000 c = 0000 0 00 00 300 400 500 600 0 00 00 300 400 500 600 Note nine: Linear programming CSE 0 Linear constraints and objective functions. Introductory eample Suppose tat a company produces two products, and wises to decide te level of production of eac so as to maimize profits. Let be te amount of Product produced every mont, and let be te amount of Product. Eac unit of Product generates a profit of 00 dollars, wile Product is more lucrative, bringing in 600 dollars. Tere are certain limitations on (besides te obvious one, ). First, cannot be more tan 00, and cannot be more tan 300 presumably because of supply limitations. Also, because of labor constraints (fied number of workers), te total amount produced cannot eceed 400. Wat are te best levels of production? We represent te situation by a linear program, as follows: "! # %$ & $ ' ( $ ) Eac constraint is a linear inequality. Te set of solutions *+, wic satisfy tese constraints is called te feasible region, and is precisely te polygon sown in Figure.(a). We wis to maimize te linear function - (called te objective function, wic in tis case represents total profit) over all te points of tis polygon. Figure.(b) sows te contour lines. ( /0 for various values of. Notice tat tey are parallel because tey all ave te same slope. Look at te line for ; te part of tis line lying inside te polygon represents feasible solutions (ie. solutions satisfying
Copyrigt c Sanjoy Dasgupta te constraints) wic all give a profit of dollars. In oter words, tis amount of profit is acievable. Te maimization task is essentially to move te contour line as far upwards as possible (tat is, to increase te profit as muc as possible), as long as it still touces te polygon (as long as tere is a feasible solution wit tat level of profit). Te optimal point is terefore a verte of te polygon.. Continuation Suppose te company now decides to introduce a tird, luury product. Eac unit sold yields a profit of 400 dollars. Te supply restrictions remain te same as before, as do te labor constraints. It turns out tat Product 3 requires some of te same macinery as Product, but uses it tree times more eavily; tis gives a constraint 3 ' 4 $. Here s te new linear program. "! 5 # 6 7 4.. ( ( 4 8 4 4 Tis time tere are tree variables, so te corresponding picture is tree-dimensional (Figure.). Te feasible region is a polyedron, eac of wose faces is a particular constraint. Te optimum, as before, is at a verte..3 Linear Programming A general linear program is given by linear constraints (using 9 $ :;< ) and a linear objective function (eiter to be maimized or minimized). Tere are tree possibilities for te feasible region.. Te feasible region is a bounded polyedron. In tis case, te optimum solution is at a verte of tis polyedron. It could be te case tat an entire face of te polyedron acieves te optimum value (can you come up wit an eample of tis?), in wic case any of its vertices will do.. Te feasible region is unbounded. Here s a simple eample:.. =. (Can you draw it?) In tis case, te optimum solution migt lie at a verte wit finite coordinates. Or, it migt lie at infinity. 3. Tere is no feasible region. Tat is, te constraints cannot be satisfied.
Copyrigt c Sanjoy Dasgupta 3 Figure. Te feasible region for tis 3-variable linear programming problem is a polyedron, and te optimal solution (indicated wit a little circle) is one of its vertices. Te arrows sow a possible sequence of vertices troug wic te simple algoritm migt iterate, starting wit te origin. 3 Any linear program can be solved by a illclimbing procedure called te simple algoritm. It starts from any verte (of te feasible polyedron) and repeatedly moves to an adjacent verte of better objective value, if one eists. Wen it gets to a verte wit no better neigbor, it stops: tis is te optimal solution. It also detects cases and 3 above. Network flow Consider te network of Figure.. A flow > in tis network consists of flows along eac edge: >?A@ B> @BC, etc. In order to be valid, suc a flow must satisfy capacity constraints: $ >?D@E$' $ >?AF $ $ > @BC $&.
Copyrigt c Sanjoy Dasgupta 4 Figure. A network wit edge capacities. 3 a c s 3 t b d as well as conservation constraints (flow into a node equals flow out of tat node): >?A@6 #> FG@ > @BC >?AF #> CHF > FG@ > FGI. In order to find te maimum flow, we need to maimize >?D@J #>?DF. Notice tat tis is a linear program! In oter words, maimum flow reduces to linear programming. If we ad known tis earlier, we would not ave ad to develop a special algoritm for ma-flow! Actually, in a sense we didn t it turns out tat our algoritm essentially simulates wat simple would do on te LP version of a flow problem. 3 A production sceduling eample We ave demand estimates for our product for all monts of 004 K KL M M MNKO D and tey are very uneven, ranging from 440 to 90. We currently ave 30 employees, eac of wom produces 0 units of te product eac mont at a salary of 000 dollars; we ave no stock of te product. How can we andle suc fluctuations in demand? Tree ways:. overtime, but tis is epensive since it costs 80% more tan regular wages, and as limitations because workers can only put in 30% overtime;. iring and firing, but iring a worker costs 30 dollars, wile firing costs 500; 3. storing surplus, but te wareouse costs are 8 dollars per item per mont. Tis rater elaborate problem can be formulated and solved as a linear program. As in all suc reductions, a crucial first step is defining te variables. PR number of workers during S t mont; PUT '. production in S t mont. V number of items produced by overtime in mont S. W B> number of workers ired/fired at te beginning of mont S. X amount stored at te end of mont S ; X T 0.
Copyrigt c Sanjoy Dasgupta 5 We must now write te constraints. Te total amount produced per mont consists of regular production plus overtime, & P V M Te number of workers can potentially cange at te start of eac mont, and can of course never be negative. P P +Y W Z > P [> W \ M Te amount stored at te end of eac mont is wat we started wit, plus te amount we produced, minus te demand for te mont. X X ]Y ( Z K X M And overtime is limited, $ V $ P M Finally, wat is te objective function? It is to minimize te total cost, ^`_ & 8a P ' & 8a W #b 8a > #ca X 7 c 8a V M One ting wort pointing out is tat te optimal solution need not be integral. It migt be to fire M ' workers, or to make )L& d Meb items. In tis case, we must judiciously round off te answers fire 0 workers, for instance. Some LP packages enable you to interactively try out different rounding scemes. 4 Boolean formulas: a case were LP fails A Boolean formula applies f and, or, notg operations to its inputs and returns a Boolean answer. As an eample, if *+.ij, k*+ mln*+iopj,, oq* mlril j, ten *s,, taking 0 to mean false and to mean true. In tis formula, te variables are.ij. A literal is a variable or te negation of a variable: for instance,. ijo M M M. Tere is a vast diversity of possible Boolean formulas, and it is terefore convenient to require tat tey be written in a standardized format. A popular option is conjunctive normal form (CNF): and-of-or s. Our eample above can be rewritten as *+.ij, k*+ lti, oq*+ lrj, oq* ulpiel j, M Indeed, any Boolean formula can be put into tis form, ve owvj8on oyv6z, were eac clause v is an or of literals. Different clauses can ave vastly different sizes: one migt ave 00 literals wile anoter as only tree. A furter standardization is to restrict clauses to at most 3 literals, and tis is called 3CNF. Here is a simple question one migt ask about Boolean formulas. 3SAT Input: Boolean formula uestion: Is *+. M M M} {, )? *+ M M M {, in 3CNF. satisfiable (is tere an assignment 5 M M M} {~qf} "g for wic
Copyrigt c Sanjoy Dasgupta 6 Our toy formula is satisfiable, for eample wit te assignment iq j=q (many oter assignments work too). How do we solve tis problem in general? Let s try epressing it as a linear program. Eac variable must be eiter 0 or ; for our eample, we can write tis as $ $ [ $ i $ [ $ j $ M We also want eac clause to be satisfied. Noting tat is just Z, te relevant constraints, one per clause, are: u (i u (j * Z, (ie ƒ* Z j, M Is it true tat any feasible solution to tese linear inequalities is a satisfying assignment of? Sadly, tis is not te case: just set all variables to /. And so 3SAT cannot be solved in tis way. Te lack of integrality wic was just a minor inconvenience in our previous application turns out to completely derail tis one. In fact, te news gets muc worse. () It is strongly believed tat tere is no polynomial-time algoritm for 3SAT.