Skip to main content
Engineering LibreTexts

8.2: Linear Optimization

  • Page ID
  • written by: Danny Hsiao, Jenny Ou, and Huey Shann Sue

    2.1 Introduction

    Linear optimization is a method applicable for the solution of problems in which the objective function and the constraints appear as linear functions of the decision variables. The constraint equations may be in the form of equalities or inequalities[1]. In other words, linear optimization determines the way to achieve the best outcome (for example, to maximize profit or to minimize cost) in a given mathematical model and given some lists of requirements represented as linear equations [2].

    2.2 Applications

    Linear optimization can be applied to numerous fields, in business or economics situations, and also in solving engineering problems. It is useful in modeling diverse types of problems in planning, routing, scheduling, assignment and design [2].

    2.2.1 Some examples of applications in different industries

    Petroleum refineries

    One of the early industrial applications of linear optimization has been made in the petroleum refineries. An oil refinery has a choice of buying crude oil from different sources with different compositions at different prices. It can manufacture different products, such as diesel fuel, gasoline and aviation fuel, in varying quantities. A mix of the purchased crude oil and the manufactured products is sought that gives the maximum profit.

    Manufacturing firms

    The sales of a firm often fluctuate, therefore a company has various options. It can either build up an inventory of the manufactured products to carry it through the period of peak sales, or to pay overtime rates to achieve higher production during periods of high demand. Linear optimization takes into account the various cost and loss factors and arrive at the most profitable production plan.

    Food-processing industry

    Linear optimization has been used to determine the optimal shipping plan for the distribution of a particular product from different manufacturing plants to various warehouses.


    The optimal routing of messages in a communication network and the routing of aircraft and ships can also be determined by linear optimization method.

    2.3 Characteristics of Linear Optimization

    The characteristics of a linear optimization problem are:

    1. The objective function is of the minimization type
    2. All the constraints are of the equality type
    3. All the decision variables are non-negative

    Any linear optimization problem can be expressed in the standard form by using the following transformation:

    1) The maximization of a function quad f(x_1, x_2, ..., x_n)is equivalent to the minimization of the negative of the same function.

    For example:

    Minimize quad f = c_1x_1 + c_2x_2+ ... + c_nx_n

    is equivalent to

    Maximize quad f'= -f = -c_1x_1 - c_2x_2 - ... - c_nx_n

    Consequently, the objective function can be stated in the minimization form in any linear optimization problem.

    2) If a constraint appears in the form of a "less than or equal to" type of inequality as

    quad a_{k1}x_1 + a_{k2}x_2 + ... + a_{kn}x_n \le\ b_k

    it can be converted into the equality form by adding a non-negative slack variable quad x_{n+1}as follows:

    quad a_{k1}x_1 + a_{k2}x_2 + ... + a_{kn}x_n + x_{n+1} = b_k

    Similarly, if the constraint is in the form of a "greater than or equal to" type of inequality, it can be converted into the equality form by subtracting the surplus variable quad x_{n+1}.

    3) In most engineering optimization problems, the decision variables represent some physical dimensions, hence the variables quad x_jwill be non-negative.

    However, a variable may be unrestricted in sign in some problems. In such cases, an unrestricted variable (which can take a positive, negative or zero value) can be written as the difference of two non-negative variables.

    Thus, if quad x_jis unrestricted in sign, it can be written as quad x_j = x_j' - x_j'' , where

    quad  0\le\ x_j'and quad  0\le\ x_j''

    It can be seen that quad x_jwill be negative, zero or positive, depending on whether quad x_j''is greater than, equal to, or less than quad x_j'

    2.4 Example 1

    This example comes from Seborg, Edgar, and Mellinchamp (with some corrections).

    A chemical company is mixing chemical component, A and B to produce product, E and F. The chemical reaction is listed below:

     A+B =E


    The conditions of this production is listed as below:

    Cost of Materials

    Maximum Available per day

    Fixed Cost









    Value of Products

    Maximum Production Rate







    The profit of this production can be simply described as the function below:




    FrVrC.P. − F.C.



     F_s=Flow Rates of Products

     F_r=Flow Rates of Raw Materials

     V_s=Values of Products

     V_r=Values of Raw Materials

     C.P.=Cost of Production

     F.C.=Fixed Cost

    2.4.1 Constraints

    • : 0 < F_A < 40,000
    • : 0 < F_B < 30,000
    • : 0 < F_E < 30,000
    • : 0 < F_F < 30,000
    • :  \frac{1}{3} F_F + \frac{2}{3} F_E \ 0

    2.4.2 Solution

    F_A = \frac{1}{2} F_E + \frac{1}{3} F_F

    F_B = \frac{1}{2} F_E + \frac{2}{3} F_F

     Profit = \sum_{s} F_s V_s-\sum_{r} F_r V_r - C.P. -F.C.

      = (0.4F_E+0.33F_F)-(0.15F_A+0.2F_B) - (0.15F_E+0.05F_F) -(350+200)


     \frac{1}{2} F_E + \frac{1}{3} F_F>0

     F_F>-\frac{3}{2} F_E ...........(1)


     \frac{1}{2} F_E + \frac{1}{3} F_F<40,000

     F_F<120,000-\frac{3}{2} F_E ...........(2)


     \frac{1}{2} F_E + \frac{2}{3} F_F>0

     F_F>-\frac{3}{4} F_E ...........(3)


     \frac{1}{2} F_E + \frac{2}{3} F_F<30,000

     F_F<45,000-\frac{3}{4} F_E ...........(4)

    Solution using Mathematica


    profit = 0.25 FE + 0.28 FF - 0.15 FA - 0.2 FB - 350 - 200

    sol = Maximize[ profit, {FA > 0, FB > 0, FA < 40000, FB < 30000, FE > 0, FE < 30000, FF > 0, FF < 30000, FA == (1/2) FE + (1/3) FF, FB == (1/2) FE + (2/3) FF}, {FE, FF}]

    OUTPUT: {3875., {FE -> 30000., FF -> 22500.}}

    Solution using "Solver" in Excel.

    sing Solver in Excel to solve the same problem.  Note that some of the constraints are cutoff.

    Result is FE = 30,000, FF = 22500.

    If only process ! or process 2 were running a full capacity, the profit would be less.

    2.4.3 Linear Optimization

    The above is an example of linear optimization. It is often used in oil refinery to figure out maximal profit in response to market competition.

    2.4.4 Graph

     series of linear constraints on two variables produces a region of possible values for those variables. Solvable problems will have a feasible region in the shape of a simple polygon.

    2.5 Example 2

    Example of Linear Optimization Problem in Excel

    Written by: Jennifer Campbell, Katherine Koterba, MaryAnn Winsemius

    2.5.1 Part 1: Organize Given Information

    As stated in the Linear Optimization section example above, there are three categories of information needed for solving an optimization problem in Excel: an objective function, constraints, and decision variables.

    We will use the following example to demonstrate another application of linear optimization. We will be optimizing the profit for Company X’s trucking business.

    To reach capacity, Company X must move 100 tons of cargo per day by truck. Company X’s trucking fee is $250/ton. Besides the weight constraint, the company can only move 50,000 ft^3 of cargo per day due to limited volume trucking capacity. The following amounts of cargo are available for shipping each day:


    ompany X.JPG

    2.5.2 Part 2: Set Up the Problem Using Excel

    Solver is an Add-in for Microsoft Excel. It will be used to optimize Company X’s profit. If ‘Solver’ is not on the ‘Tools’ menu in Excel, then use the following steps to enable it:

    For Windows 2007:

    • Click on the Office button at the top left corner of the screen. Click on the “Excel Options” button on the bottom right of the menu.
    • Select “Add-ins.” Make sure that “Excel Add-ins” is selected in the “Manage” drop down list. Click “Go.”
    • A new window will appear entitled “Add-ins.” Select “Solver Add-in” by checking the box. Click “Go.”
    • A Configuration window will appear. Allow Office to install the Add-in.
    • The solver has been successfully installed. (See Windows Help for more instruction.)

    Use the figure below to set up your Excel worksheet.

    igure 1 - Excel Worksheet.JPG

    Enter in the following formulas to the cells as shown below:

    igure 2 - Excel Sheet with Formulas.JPG

    2.5.3 Part 3: Running Solver

    • Click on the “Data” tab and select “Solver”. A dialog box will appear.
    • Enter the parameters as shown in the figure below.

    igure 3 - Solver Parameters.JPG

    Detailed steps are as follows:

    • In “Set Target Cell,” enter the cell corresponding to the company’s profit (B4).
    • Select “Max” under “Equal To.”
    • Click on the “Options” tab and check the “Assume Linear Model” box.
    • For “By Changing Cells:” select the cells in column B corresponding the cargo amounts (B9, B10, B11).
    • To add constraints, select “Add” under “Subject to the Constraints” A dialog box will open.
    • In the “Cell Reference:” field, enter the cell location of the decision value that is subject to constraint (i.e. B9).
    • Use the pull-down menu in the middle to select the appropriate inequality relation (i.e. <=)
    • In the “Constraint:” field, enter the cell location of the constraint value (i.e. D17).
    • Continue to click the “Add.”
    • Repeat above steps until all of the constraints are entered. Then click “OK.”
    • When all the proper settings have been entered, click “Solve.”
    • A “Solver Results” box will appear. Select “Keep Solver Solution” and click “OK.”.

    The solved worksheet is below.

    igure 4 - Excel Sheet with Solution.JPG

    2.6 Sensitivity Report

    Written by Michael Chisholm and Doug Sutherland, Dec. 2009

    Excel's solver program allows us to analyze how our profit would change if we had an alteration in our constraint values. These values can change due to a variety of reasons such as more readily available resources, technology advancements, natural disasters limiting resources, etc.

    First, it analyzes whether the constraints are binding or non-binding. The binding constraints limit the profit output where the non-binding constraints do not limit the overall process. If the non-binding constraints were changed, the profit would not be effected as long the change in these constraints lies within the allowable increase and decrease that is indicated within the sensitivity report. If the binding constraints are changed, the profit will be directly affected. The affect on the profit is shown with shadow price values, also displayed in the sensitivity report. The shadow price is the resulting increase or decrease in profit per unit increase or decrease in the constraint. This applies as long as the change in constraint remains within the allowable increase or decrease where a linear relationship can be assumed.

    The shadow price only analyzes the change in one variable at a time. In order to do two, you must plug the new constraint value for one of the variables and solve using solver. Using the new sensitivity report, analyze the effect that changing the second variable would have with the change being made in the first constraint.

    Looking at Example 1 above, we will now walk through the steps on how to create a sensitivity report.

    After clicking "solve" in excel, a solver results dialogue box appears as seen below.

    ensitivity 1.jpg

    There is a list of three options on the right; answer, sensitivity, and limits. Select the sensitivity option before clicking ok. A new tab will be generated in the worksheet titled "sensitivity 1." A view of the sensitivity report within the tab is seen below. As you can see, two tables are generated. For this example, resource A and product F are non-binding as shown with a shadow price of 0 and an infinite allowable increase. The allowable decrease is the amount the capacity changes until the final value is reached. Past this point the constraint would become a binding constraint. For the constraining variables (resource B and product E), their constraints are binding. Regarding resource B, if its constraint was increased by up to 5000 or decreased by up to 15000, this would have a linear effect on profit within this range. For each unit increase or decrease, the profit will change by 12 cents per unit, respectively. The same is true if our capacity for product E changes with it's allowable values and shadow price on the table.

    ensitivity 2.jpg

    If the constraint on B increased by 5,000 lbs our new profit would be $8,600/day (8,000+.12*5,000). Instead, if our facility could increase production of E by 30,000 lb/day the resulting profit would be $12,950/day (8,000+.165*30,000).

    2.7 Solving Linear Optimization Problems Using The Primal Simplex Algorithm

    Written by: Tejas Kapadia and Dan Hassing

    [Note: needs specific reference, and also solution to the preceding problem by this method would be good -- R.Z.]

    Instead of solving linear optimization problems using graphical or computer methods, we can also solve these problems using a process called the Primal Simplex Algorithm. The Primal Simplex Algorithm starts at a Basic Feasible Solution (BFS), which is a solution that lies on a vertex of the subspace contained by the constraints of the problem. In the Graph in Example 1, this subspace refers to the shaded region of the plot. Essentially, after determining an initial BFS, the Primal Simplex Algorithm moves through the boundaries from vertex to vertex until an optimal point is determined.

    The basic procedure is the following:

    1. Find a unit basis.
    2. Set-up the problem in standard form using a canonical tableau.
    3. Check optimality criterion.
    1. If criterion passes, then stop, solution has been found.
    1. Select an entering variable among the eligible variables.
    2. Perform pivot step.
    3. Go back to 1.

    For simplicity, we will make the following assumptions:

    1. The optimum lies on a vertex and is not unbounded on an extreme half-line.
    2. The constraints are equations and not also inequalities.
    1. In the case that the constraints are inequalities, slack variables will need to be introduced. Although the process is not very different in this case, we will ignore this to make the algorithm slightly less confusing.
    1. Decision variables are required to be nonnegative.
    2. The problem is a minimization problem. To turn a maximization problem into a minimization problem, multiply the objective function by -1 and follow the process to solve a minimization problem.

    We will begin with the following example:

    Objective Function: Minimize \quad z=-x_5-8x_6

    Subject to the constraints:

    quad x_1 - x_5 + x_6 = 2

    quad x_2+x_5+x_6=1

    quad x_3+2x_5+x_6=5

    quad x_4+x_6=0

    quad x_i \ge 0

    First we begin by finding a unit basis:

    A shortcut method to finding this unit basis is putting numbers in for each variable so that every constraint equation is satisfied.

    In this case, setting quad x_4 = 0, quad x_5 = 0, and quad x_6 = 0will satisfy the final equation and also set the values for quad x_1, quad x_2, and quad x_3to 2, 1, and 5, respectively. Remember, these decision variables must be nonnegative.

    Set up the canonical tableau in the following form:


    As you can see, the first four rows correspond to the constraints, while the final row corresponds to the objective function. The “b” column corresponds to the right hand side (RHS) of the constraints. As you can see, the “-z” column is on the left hand side (LHS) of the equation, rather than the RHS.

    First, we should perform pivot steps so that the tableau corresponds to the unit basis we found earlier. By performing pivot steps on quad x_1, quad x_2, quad x_3, and quad x_4, we will reach the feasible point where (quad x_1, quad x_2, quad x_3, quad x_4, quad x_5, and quad x_6) = quad (2, 1, 5, 0, 0, 0) . Because quad x_4, quad x_5, and quad x_6all equal zero, the pivot step on quad x_4can actually be done on quad x_5or quad x_6, but in this example, we used quad x_4. These pivot steps can be performed on any row as long as they are all different rows. In this example, we performed pivot steps on quad (x_1, 1) , quad (x_2, 2) , quad (x_3, 3) , quad (x_4, 4) using the Pivot and Gauss-Jordan Tool at To use this tool, place the cursor on the cell that you wish to pivot on, and press “pivot”.

    After four pivot steps, the tableau will look like this:


    As you can see, this is identical to the initial tableau, as quad x_1, quad x_2, quad x_3, and quad x_4were set up such that an initial feasible point was already chosen.

    The optimality criterion states that if the vector in the bottom left of the tableau is all positive, then an optimal solution exists in the “b” column vector, with the value at the bottom of the “b” column vector as the negative of the value of the objective function at that optimal solution. If this is not true, then a pivot step must be performed. In this example, clearly, a pivot step must be performed.

    Next, we need to choose an entering variable. We want to choose an entering variable that has a negative element in the bottom row, meaning that the objective value could be improved if that variable was nonzero in the solution. So, we will choose quad x_5in this example. Now, we must calculate ratios of each RHS coefficient divided by the coefficient of the entering variable in that row. In this case, the vector corresponding to this calculation would equal . We cannot pivot on a zero element, so we cannot pivot on the fourth row. We want to keep the RHS positive, so we cannot pivot on the first row. We must choose the minimum nonnegative ratio to remain at a feasible solution, so we choose the second row in the quad x_5column, which has a ratio of 1/1.

    After the pivot step:


    As we can see, quad x_6has a negative coefficient in the bottom row, indicating the same step must be repeated on that column. We calculate ratios for that column, and get: . Consequently, we choose to pivot on the fourth row because it corresponds to the minimum nonnegative ratio of 0.

    After another pivot step:


    Because the bottom row is all positive, we are now at an optimal solution. To understand this final tableau, we look at each column for variables that only have one “1” in the column. If the column has only one “1”, the RHS value in that row is the value of that variable. In this case, quad x_1=3, quad x_3=3, and quad x_5=1. Any variable that does not have just a single “1” in the column is equal to zero. So, the optimal solution is (quad x_1, quad x_2, quad x_3, quad x_4, quad x_5, and quad x_6) = quad (3, 0, 3, 0, 1, 0) , and the optimal value is quad z = -1 (z was on the LHS in the tableau).

    Now, we have successfully solved a linear optimization problem using the Primal Simplex Algorithm. Verification of the solution can be easily performed in Microsoft Excel.


    1. D. E. Seborg, T. F. Edgar, D. A. Mellichamp: Process Dynamics and Control, 2nd Edition, John Wiley & Sons.
    2. Rao, Singiresu S. Engineering Optimization - Theory and Practice, 3rd Edition, 129-135, John Wiley & Sons.