# How to Use linearProgramming

Looking at a single constraint

The live graph above is designed to help students understand the constraint

5 x + 3 y <= 30.

It shows the x- and y-axes and the line 5 x + 3 y = 30. The student can look at the value of the function

f(x, y) = 5 x + 3 y

by dragging the reddish-brown sphere around the display. The value of the function at the polnt marked by the sphere is displayed numerically in the upper right hand corner and graphically by the bar at the right side. The bar is red when the function is positive and blue when it is negative.

The curriculum developer can specify what is shown by using the following parameters.

• sw1 -- This parameter specifies the range of the x-axis in the form [xLow, xHigh]

• sw2 -- This parameter specifies the range of the y-axis in the form [yLow, yHigh]

• sw3 -- This parameter specifies the range of the function f(x, y) in the form [fLow, fHigh]

• sw4 -- This parameter specifies the function f(x, y). This function must be entered carefully. WARNING: You must not enter rational numbers in the form 5/3. This form is evaluated using integer division and will result in 1. The correct form is 5.0/3.0.

• sw5 -- This parameter specifies the constraining value. For example, for the constraint 5 x + 3 y <= 30 the value of sw530.

• sw6 and sw7 -- These two parameters specify the lines drawn on the graph in addition to the x- and y-axes. The simplest case is shown in the graph above. One additional line is drawn from the point (0, 10) to the point (6, 0). For this example sw6 is 1 specifying a single line segment and sw7 is [0, 10, 6, 0] specifying the two endpoints -- (0, 10) and (6, 0) of that line segment. A more complicated example is shown below. In the example below a line made up of two line segments is drawn and sw6 is 2 specifying a line made up of two segments. In the same example sw7 is [0, 5, 4.2857, 2.857, 6, 0] specifying the three points defining the two line segments -- one line segment goes from the point (0, 5) to the point (4.2857, 2.857) and then the second line segment goes on from that point to the point (6, 0).

Maximizing a function subject to linear constraints

This same example is intended to help students understand maximizing (or minimizing) an objective function subject to linear constraints. As the user moves the reddish-brown sphere around the value of the objective function is shown numerically at the upprer right and graphically by the red bar on the right side. For this example, the value of the parameter sw5 is set to 0 so that the bar is red when the objective function is positive and blue when it is negative.

The html code for these two examples is shown below. Notice that the parameters must be entered twice in different forms. Each form is recognized by some but not all browsers. The relevant code is highlighted in red and in blue. Be careful to enter the parameters as shown. We recommend that you copy the code from one of the examples below and edit the appropriate entries. HTML code for the first example HTML code for the second example

To use this Shock Wave Lite Applet download linearProgramming.dcr and place it in the same directory (folder) as the html files in which it appears. Follow the procedure for downloading and saving a file from your browser. For example, with Internet Explorer and MacOS X hold down the option key while clicking the link.