• No results found

Note nine: Linear programming CSE Linear constraints and objective functions. 1.1 Introductory example. Copyright c Sanjoy Dasgupta 1

N/A
N/A
Protected

Academic year: 2021

Share "Note nine: Linear programming CSE Linear constraints and objective functions. 1.1 Introductory example. Copyright c Sanjoy Dasgupta 1"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

Figure 1.1 (a) The feasible region for a linear program with two variables (see text for details). (b) Contour lines of the objective function:    for different values of  (profit).

The optimal solution is a vertex of the polygon, indicated by a little circle.

0 x x 100 200 300 400 500 600 400 300 200 100 1 2 0 x x 100 200 300 400 500 600 400 300 200 100 1 2 c = 60000 c = 120000 c = 150000

Note nine: Linear programming

CSE 101

1 Linear constraints and objective functions

1.1 Introductory example

Suppose that a company produces two products, and wishes to decide the level of production of each so as to maximize profits. Let   be the amount of Product 1 produced every month,

and let be the amount of Product 2. Each unit of Product 1 generates a profit of 100 dollars,

while Product 2 is more lucrative, bringing in 600 dollars. There are certain limitations on

 (besides the obvious one,  ). First, cannot be more than 200, and cannot be

more than 300 – presumably because of supply limitations. Also, because of labor constraints (fixed number of workers), the total amount produced cannot exceed 400. What are the best levels of production?

We represent the situation by a linear program, as follows:

 "!  #   %$ &   $ '    ( $ )    

Each constraint is a linear inequality. The set of solutions *+   , which satisfy these

con-straints is called the feasible region, and is precisely the polygon shown in Figure 1.1(a). We wish to maximize the linear function   -  (called the objective function, which in this

case represents total profit) over all the points of this polygon.

Figure 1.1(b) shows the contour lines . (  /0 for various values of . Notice that

they are parallel – because they all have the same slope. Look at the line for 12 ; the

(2)

the constraints) which all give a profit of 12 dollars. In other words, this amount of profit

is achievable. The maximization task is essentially to move the contour line as far upwards as possible (that is, to increase the profit as much as possible), as long as it still touches the polygon (as long as there is a feasible solution with that level of profit). The optimal point is therefore a vertex of the polygon.

1.2 Continuation

Suppose the company now decides to introduce a third, luxury product. Each unit sold yields a profit of 1400 dollars. The supply restrictions remain the same as before, as do the labor constraints. It turns out that Product 3 requires some of the same machinery as Product 2, but uses it three times more heavily; this gives a constraint  3 ' 4 $  . Here’s the new

linear program.  "! 5 #  6 7 ) 4 . $ &   $ '  . ( (4 $ )   8 ' 4 $   4  

This time there are three variables, so the corresponding picture is three-dimensional (Fig-ure 1.2). The feasible region is a polyhedron, each of whose faces is a particular constraint. The optimum, as before, is at a vertex.

1.3 Linear Programming

A general linear program is given by linear constraints (using 9

$

:;< ) and a linear

ob-jective function (either to be maximized or minimized). There are three possibilities for the feasible region.

1. The feasible region is a bounded polyhedron.

In this case, the optimum solution is at a vertex of this polyhedron. It could be the case that an entire face of the polyhedron achieves the optimum value (can you come up with an example of this?), in which case any of its vertices will do.

2. The feasible region is unbounded. Here’s a simple example:

.. =  

.  

(Can you draw it?) In this case, the optimum solution might lie at a vertex with finite coordinates. Or, it might lie at infinity.

3. There is no feasible region.

(3)

Figure 1.2 The feasible region for this 3-variable linear programming problem is a polyhe-dron, and the optimal solution (indicated with a little circle) is one of its vertices. The arrows show a possible sequence of vertices through which the simplex algorithm might iterate, start-ing with the origin.

x1

x3

2

x

Any linear program can be solved by a hillclimbing procedure called the simplex algorithm. It starts from any vertex (of the feasible polyhedron) and repeatedly moves to an adjacent vertex of better objective value, if one exists. When it gets to a vertex with no better neighbor, it stops: this is the optimal solution. It also detects cases 2 and 3 above.

2 Network flow

Consider the network of Figure 2.1. A flow> in this network consists of flows along each edge:

>?A@B>@BC , etc. In order to be valid, such a flow must satisfy capacity constraints:

 $ > ?D@E$ '

 $ > ?AF $ 

 $ >@BC $ &

(4)

Figure 2.1 A network with edge capacities.

b

d

a

c

t

s

1 3 1 3 1 2 1 1 2

as well as conservation constraints (flow into a node equals flow out of that node):

>?A@6 #> FG@  >@BC

> ?AF #> CHF  > FG@ > FGI

...

In order to find the maximum flow, we need to maximize>1?D@J #> ?DF. Notice that this is a linear

program!

In other words, maximum flow reduces to linear programming. If we had known this earlier, we would not have had to develop a special algorithm for max-flow! Actually, in a sense we didn’t – it turns out that our algorithm essentially simulates what simplex would do on the LP version of a flow problem.

3 A production scheduling example

We have demand estimates for our product for all months of 2004 – K2KL MMMN2KOD – and they

are very uneven, ranging from 440 to 920. We currently have 30 employees, each of whom produces 20 units of the product each month at a salary of 2000 dollars; we have no stock of the product. How can we handle such fluctuations in demand? Three ways:

1. overtime, but this is expensive since it costs 80% more than regular wages, and has limitations because workers can only put in 30% overtime;

2. hiring and firing, but hiring a worker costs 320 dollars, while firing costs 500; 3. storing surplus, but the warehouse costs are 8 dollars per item per month.

This rather elaborate problem can be formulated and solved as a linear program. As in all such reductions, a crucial first step is defining the variables.

PRQ

 number of workers duringSth month; PUT  '  .  Q  production inS th month. V Q

 number of items produced by overtime in monthS.

W

Q

B>

Q

 number of workers hired/fired at the beginning of monthS.

X

Q

 amount stored at the end of monthS;

X

T

(5)

We must now write the constraints. The total amount produced per month consists of regular production plus overtime,

 Q  &  P Q V Q M

The number of workers can potentially change at the start of each month, and can of course never be negative. P Q  P Q+Y  W QZ > Q  P Q 1[> Q 1 W Q \1M

The amount stored at the end of each month is what we started with, plus the amount we produced, minus the demand for the month.

X Q  X Q]Y  ( QZ K Q  X Q 1M

And overtime is limited,

 $ V Q

$

P Q

M

Finally, what is the objective function? It is to minimize the total cost,

 ^`_ & 8a Q P Q '& 8a Q W Q #b8a Q > Q #ca Q X Q 7c8a Q V Q M

One thing worth pointing out is that the optimal solution need not be integral. It might be to fire 1M' workers, or to make)L&d Meb items. In this case, we must judiciously round off the

answers – fire 10 workers, for instance. Some LP packages enable you to interactively try out different rounding schemes.

4 Boolean formulas: a case where LP fails

A Boolean formula applies f and, or, notg operations to its inputs and returns a Boolean

an-swer. As an example, if h

*+.i2j , k*+mln*+iopj ,, oq*mlril j , 

then

h

*s1 ,  , taking 0 to mean false and 1 to mean true. In this formula, the variables

are.i2j . A literal is a variable or the negation of a variable: for instance,. i2jOMMM.

There is a vast diversity of possible Boolean formulas, and it is therefore convenient to require that they be written in a standardized format. A popular option is conjunctive normal

form (CNF): and-of-or’s. Our example above can be rewritten as

h

*+.i2j , k*+ lti , oq*+ lrj , oq*ulpiEl j , M

Indeed, any Boolean formula can be put into this form, vEowvJ 8onxxxoyv6z , where each clause

v

Q

is an or of literals.

Different clauses can have vastly different sizes: one might have 100 literals while another has only three. A further standardization is to restrict clauses to at most 3 literals, and this is called 3CNF. Here is a simple question one might ask about Boolean formulas.

3SAT

Input: Boolean formula

h

*+ MMM|{ , in 3CNF.

Question: Is

h

satisfiable (is there an assignment 5MMM}|{~qf}1"g for which

h

*+.MMM}|{

,

(6)

Our toy formula is satisfiable, for example with the assignment €i q12j=q (many

other assignments work too). How do we solve this problem in general?

Let’s try expressing it as a linear program. Each variable must be either 0 or 1; for our example, we can write this as

 $  $ [ $ i $ [ $ j $ M

We also want each clause to be satisfied. Noting that is just 

Z

 , the relevant constraints,

one per clause, are:

u (i   u (j   *‚ Z  , (iE ƒ*‚ Z j ,  M

Is it true that any feasible solution to these linear inequalities is a satisfying assignment of

h

? Sadly, this is not the case: just set all variables to 1/2. And so 3SAT cannot be solved in this way. The lack of integrality which was just a minor inconvenience in our previous application turns out to completely derail this one.

In fact, the news gets much worse.

References

Related documents