Send Close Add comments: (status displays here)
Got it!  This site "www.robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Formulating a linear programming problem
by RS  admin@robinsnyder.com : 1024 x 640


1. Formulating a linear programming problem
The first step in using linear programming is to recognize a problem for which linear programming provides a possible solution and then to formulate that problem in a form that can be solved using the linear programming method. For two dependent variables, a graphical method can be used. For more than two dependent variables, a computer software for solving linear programming problems must be used.

The key to using linear programming is being able to recognize linear objective functions and linear constraints. We will now look at a common linear programming problem known generically as a resource allocation problem. (Note: the numbers have been fabricated for example purposes and may or may not represent actual values).

The goal, or objective, is to maximize profit (contribution). Any costs not mentioned are assumed to not be relevant to the problem of how much to produce. But what is profit? From the problem, the profit is $2 for each production lot of Galaxy bars (lots) produced plus $3 for each production lot of Continental bars (lots) produced. But, how many lots of Galaxy bars (lots) should be produced and how many lots of Continental bars (lots) should be produced? We do not know. That is the question to be answered. In order to formulate and solve the problem, let us introduce variable x1 to represent the number of lots of Galaxy bars (lots) produced and variable x2 to represent the number of lots of Continental bars (lots) produced. Then profit (contribution) z is
z = 2 x1 + 3 x2

We are assuming that we can sell everything that can be produced. How would you handle the situation where not everything that could be produced could be sold? (Hint: Do not produce it if it cannot be sold.)

What are the constraints? Obviously, production cannot be negative. So the following hold.
x1 >= 0.0 x2 >= 0.0

What about the constraints on the amount of each ingredient that is available? For example, there are only 18 tons of milk (tons) available. For each lot of Galaxy bars (lots) produced, 3 tons of milk (tons) are required. For each lot of Continental bars (lots) produced, 1 tons of Continental bars (lots) are required. Thus
3 x1 + 1 x2 <= 18

Likewise, for the other ingredients.
1 x1 + 2 x2 <= 12 3 x1 + 3 x2 <= 21

This can be expressed in matrix notation as follows. (omitted).

(XLS omitted)

The linear programming problem, be expressed in "LPSolves" textual specification format, appears as follows.
linear program var x1 "Galaxy bars (lots)" x2 "Continental bars (lots)" max 2 x1 + 3 x2 "profit ($)" st 3 x1 + 1 x2 <= 18 "milk (tons)" 1 x1 + 2 x2 <= 12 "cocoa (tons)" 3 x1 + 3 x2 <= 21 "sugar (tons)" end

Note the following. Since there are only two dependent variables, we will use the graphical method to solve the problem. Then, a computer solution to the same problem will be presented.

2. Graphical solution
The graphical method of linear programming can only be used for two independent variables (i.e., x1 and x2) and one dependent variable (i.e., z), since people have great difficulty visualizing 3-D space, let alone 4-D space (i.e., hyperspace) or, in the case of n dependent variables, n-D space. However, there is great value in learning the graphical method of linear programming in that the intuition developed with the graphical method can be used to intelligently interpret data received from the output of a computer program that solves a linear programming system of hundreds, or thousands, of variables. Later sections will give some examples of important linear programming problems that do have a large number of variables.

The general method for the graphical solution of a linear programming problem with two independent variables is as follows. This method will now be used to solve the problem.

The constraints, numbered for convenience, are as follows.
#1: 3 x1 + 1 x2 <= 18 "milk (tons)" #2: 1 x1 + 2 x2 <= 12 "cocoa (tons)" #3: 3 x1 + 3 x2 <= 21 "sugar (tons)"

Converted to equalities, the constraints appear as follows.
#1: 3 x1 + 1 x2 = 18 #2: 1 x1 + 2 x2 = 12 #3: 3 x1 + 3 x2 = 21

Two points are needed for each line. The points, expressed in the form (x1, x2) are as follows.
#1: (0.0, 18.0) and ( 6.0, 0.0) #2: (0.0, 6.0) and (12.0, 0.0) #3: (0.0, 7.0) and ( 7.0, 0.0)

The scale can be determined as follows. (XLC omitted)
Plot the lines. (omitted)

To determine the feasible region, determine which side of the line is feasible for each inequality. Since the point (0.0, 0.0) is not on any of the lines, evaluate the inequalities for that point.
#1: 3 * 0 + 1 * 0 = 0.0 and 0.0 <= 18 is true #2: 1 * 0 + 2 * 0 = 0.0 and 0.0 <= 12 is true #3: 3 * 0 + 3 * 0 = 0.0 and 0.0 <= 21 is true

Thus, the point (0.0, 0.0) is on the feasible side of all three constraints. The feasible region thus appears as follows. (omitted)

(XLC omitted)
The feasible region is a convex region. A convex region is a region in which any point in the region can be connected by a line segment to any other point in the region without any point on that line segment falling outside the region.

(XLC omitted)
It follows that the optimal solution, if it exists, must be on the boundary of the convex region.

To plot the projection of the objective function
z = 2 x1 + 3 x2 "profit ($)"

in the x1-x2 plane, pick a value of z, then plot the line. Do this for two values of z.

Picking z as 12, the objective function is
12 = 2 x1 + 3 x2

which, using algebra, is the line
x2 = -2/3 x1 + 4.

Two points on this line are (0.0, 4.0) and (6.0, 0.0).

Picking z as 24, the objective function is
24 = 2 x1 + 3 x2

which, using algebra, is the line
x2 = -2/3 x1 + 8.

Two points on this line are (0.0, 8.0) and (12.0, 0.0).

After plotting the lines for two values of z, determine in which direction the line is increasing. This line can be moved in the increasing direction for maximization problems until it leaves the feasible region. For minimization problems, move the line in the decreasing direction. This can be seen in the following chart (omitted).

(XLC omitted)
The point at which the z-line leaves the feasible region must be either In this case, the intersection is the point at which the lines
#2: 1 x1 + 2 x2 = 12

and
#3: 3 x1 + 3 x2 = 21

intersect. The intersection point must satisfy both equations simultaneously. There are two equations and two unknowns. Therefore, mathematically, one of three possibilities exist. In this case, we know from the structure of the problem that the lines intersect at a single point. One way to determine the point is as follows. For example, since
#2: 1 x1 + 2 x2 = 12

then
x1 = 12 - 2 x2

Note that we could just as easily have solved for x2 in terms of x1.

Substitute this result for x1 into
#3: 3 x1 + 3 x2 = 21

to get
3 (12 - 2 x2) + 3 x2 = 21

Since variable x1 has been removed, there is now one equation and one unknown. (Aside: This method is a simple example of the divide and conquer problem solving method).

Algebra can be used to obtain the following.
36 - 6 x2 + 3 x2 = 21 (distribute the 3) - 3 x2 = - 15 (collect terms) 3 x2 = 15 (multiply both sides by -1) x2 = 5 (divide both sides by 3)

Since x2 is 5, this result can be substituted into
x1 = 12 - 2 x2

to obtain
x1 = 12 - 2 * 5 = 12 - 10 = 2

So, the objective function
z = 2 x1 + 3 x2

is maximized then x1 is 2 and x2 is 5. The value of the objective function at that point is determined by substituting the optimum values for x1 and x2 into the objective function, as follows.
z = 2 * 2 + 3 * 5 = 4 + 15 = 19

Returning to the original problem, 19 is the total profit contribution.

3. Short answer questions
1. What is a convex region? Draw a simple convex region.

by RS  admin@robinsnyder.com : 1024 x 640