Course 1: Modeling Linear Programming

**Author: OptimizationCity Group**

**What is Operations Research?**

Operations research is a scientific approach to the decisions that are made during the operation of organized systems. In other words, operations research is used in issues related to the guidance and coordination of operations and various activities. Operations research is used in a variety of fields such as economics, trade, industry, government, health, and so on. Operations research examines issues with a systematic approach and tries to resolve the conflict of resources between different parts of an organization in such a way that the best result or the optimal answer is created for the whole organization.

Operations research includes various sections, of which mathematical linear programming is one of the most important. In linear programming, a mathematical model is used to explain the problem. The word linear means that all mathematical relations of this model must necessarily be linear. The birth of linear programming dates back to 1947, when George Dantzig invented the simplex method for solving general linear programming problems for the optimal programming computation project. The invention was so influential in management science that it led George Dantzig to the Nobel Prize but never won it.

**Formulating the problem in the form of linear programming**

We continue this section by formulating a small example of linear programming. This example is simple enough that it can be studied graphically.

**Example:** A door and window manufacturing company has three plants. plant 1 produces aluminum frames and metal parts. In plant 2, wooden frames are produced; and in plant 3, the glass is cut and mounted on the frames. The manager of these workshops is looking to produce two new products. He/she has asked the operations research center to increase the production of each product according to the capacity of the plants. Product 1 is a door with an aluminum frame and product 2 is glass windows with a wooden frame. Due to the fact that both products require plant 3 for welding, the capacity of this plant will lead the competition between these two products. The table below shows all data you need.

x_{1} and x_{2 }represent the number of products 1 and 2 per hours, respectively, and z represents the profit from sales per hour. In the operations research literature, x_{1} and x_{2 }are called decision variables and z is called an objective function.

To produce each unit of product 1, 1 unit of plant 1 is used, which has only 4 units of capacity for the new product per hour of plant 1. This constraint is displayed algebraically x_{1}≤4. Similarly for plant 2, a limit 2x_{2}≤12 is required for Product 2. plant 3 capacity is used by both products, which limits 3x_{1} +2x_{2}≤18. Because products cannot be negative, the decision variables are non-negative, and its mathematical representation is x_{1}≥0, x_{2}≥0. The mathematical representation of the linear programming model is summarized as follows.

Because this linear programming model consists of only two variables x_{1} and x_{2}, a graphic method can be used to solve the linear program. This method requires drawing a shape with axes x_{1} and x_{2}. Each constraint covers a part of the two-dimensional axis, which creates a feasible region from sharing these constraints. We are looking for the point that creates the maximum value of the objective function, z. To draw the feasible region, we add the constraints one by one as follows.

**Note:** To add the constraint 3x_{1}+2x_{2}<=18 to the feasible region, it is enough to draw the equation 3x_{1}+2x_{2}=18 first. Given that the point of the origin (x_{1}=0,x_{2}=0) holds in the constraint, the space below the line of equation shows the 3x_{1}+2x_{2}<=18. The only remaining step is to find the point that maximizes the value in the area.

Suppose that Z=10. If this value is within the feasible region, this value can be increased. Otherwise it must be decreased to be in the feasible region. By increasing the value by 10 to 20, the line would be still in the feasible region. In this way, by increasing the constant value(C) of the line C=3x_{1}+5x_{2}, a set of particular parallel lines is drawn, and finally the line that has the greatest distance with the origin is selected. As shown in the figure below, point (2,6) crosses the line 3x_{1}+5x_{2}=36 and this point (x_{1}=2,x_{2}=6) generates the most revenue for the workshop. Therefore, by producing 2 units of product 1 and 6 units of product 2, the most revenue (36) per minute is generated.

**Mathematical representation of linear model**

In this section, the problem of door and window manufacturing company can be generalized. In this problem, there are 3 plants or resources with limited capacity that two products should use three resources according to their needs.

In the general form, suppose that we want to assign *m* sources to *n* competing products. Assume that *x _{j}* is the amount of product

*j*and

*Z*are the measure of efficiency want to be maximize. Also assume that

*c*is the change of

_{j}*Z*is due to each unit of increase

*x*

_{j}*, b*is the amount of source

_{i}*i*, and a

_{ij}is the amount of source i consumed by the product j. A summary of the information is given in the table below.

According to the table above, the general form resource allocation problem can be expressed in mathematical form as follows.

The above standard model is called the ** linear programming problem**.

**Terms of linear programming model**

For simplicity in expressing problems in linear programming, common words are defined as follows.

**Objective function**: Refers to the function c_{1}x_{1}+c_{2}x_{2}+…+c_{n}x_{n} that is intended to find the maximum.

**Functional constraint**: refers to a function that indicates the total consumption of each resource for all products.

**Non-negativity constraint**: Refers to x_{j}>=0

**Constraint****:** Refers to the set of functional constraints and Non-negativity.

**Decision variable**: Refers to the variable x_{j} that indicate the amount of each product.

**Parameter**: Refers to data a_{ij},b_{i},c_{j }

**Note**: The standard model may differ from linear programming models in reality. Other forms of linear programming problem that can be converted to standard form are as follows:

- Instead of maximizing (Max), minimizing (Min) may be considered.
- Some functional constraints may be greater than equal(>= ):

- Some functional constraints may be equal:

Some variables may be only negative; or either negative or positive (unrestricted in sign).

**Term of linear program solution**

**Solution**: Refers to any set of values assigned to decision variables (x_{1},x_{2},…,x_{n}). For example, in the previous example, points (2,3) and (5,5) are the answers of the linear programming model, and it does not matter if they are inside or outside the feasible region.

**Feasible solution:** Refers to the solution that applies to all constraints (functional and non-negative). For example, in the figure above, point (2,3) is a feasible solution and solution (5,5) is an infeasible solution.

**Optimal solution**: A feasible solution for which the value of the objective function is the most desirable. The following figure shows the optimal solution to the previous example.

There are **four** possibilities for the optimal solution:

**1- Unique optimal solution:** In this case, the optimal solution is only one point of feasible region (similar to the figure above).

**2- Multiple (alternative) optimal solution:** Often the linear programming problem has a single solution. But this is not necessarily the case. In the previous example, if the profitability of product 2 decreases from 5 to 2 units, then the line of the objective function will be parallel to the line , and therefore all points on the line between points (2,6) and (4,3) are the optimal solution.

**3-Unbound solution:** This solution occurs when the constraints can not prevent the infinite increase of the objective function (*Z*) in the desired direction. In the previous example, if both constraints 2x_{2}<=12 and 3x_{1}+2x_{2}<=18 are omitted, the possible space becomes as follows where the value of the objective function can be increased infinitely.

**4- Infeasible solution:** In this case, the problem has no feasible solution or the feasible region is empty. In the previous example, if the constraint 2x_{2}<=12 changes to 2x_{2}>=12 and the constraint x_{1}<=4 changes to x_{1}>=4, the feasible region is empty and the problem has no solution..

**5- Degeneracy**

In a two-variable problem, if there is a corner point of the intersection of more than two constraints, it is a degeneracy problem (this problem can be used for n-variable problems). To clarify the issue, consider the following example:

**Example:** Consider this problem:

Its graphical representation is as follows.

In this problem, it can be seen that at point A, three corner points have coincided. The points are:

1) The point resulting from the intersection of the constraints corresponding to the first constraint with the x_{2} axis

2) The point resulting from the intersection of the constriants corresponding to the second constraint with the x_{2 }axis

3) The point resulting from the intersection of the constraints corresponding to both constraints

Later, it is said that in the simplex method, each iteration actually represents the characteristics of a corner point, and since several corner points coincide in degeneracy, we may encounter a situation where in successive iterations on these points.

**Classification of linear programming**

In the previous parts, special cases of linear programming problems were stated. In a general classification, the types of possible situations for the optimal solution of linear programming are as follows.

The types of possible cases that can occur in the feasible region of a bivariate linear programming model are shown in the figure below.

**Classification of constraints in linear programming**

According to the effect of the constraint on the formation of the feasible region and how the optimal solution is found on them, the constraints can be classified into two groups.

**Effective constraints**

There are constraints that are effective in forming the feasbile area, and adding any new effective limitation to the model causes a decrease in the justified area, and removing the effective restriction causes an increase in the justified area.

**Redundant constraints**

There are restrictions that do not affect the creation of the feasbile area, and their presence or absence does not change the feasbile area.

**Example:** Consider this problem.

The graphical representation of this problem is as follows.

Note that only the first constraint and the non-negativity constraints are involved in forming the feasbile region. The second and third constraints have no role in creating the feasible region and determining the optimal solution. These two restrictions are redunfant constriants.

**Example**: An area consists of three farms with two limitations, land and water, that limit the possibilities of planting these farms. Information on the water alocation and usable land of the three farms is given in the table below.

The crops suited for this region include sugar beets, cotton, and sorghum. These crops differ primarily in their expected net return (profit) per acre and their consumption of water. In addition, the maximum acreage that can be devoted to each of these crops is set.

To ensure equity between the three farms, it has been agreed that every famer will plant the same proportion of its available land. For example, if farm 1 plants 200 of its available 400 acres, then farm 2 must plant 300 of its 600 acres, while farm 3 plants 150 acres of its 300 acres. However, any combination of the crops may be grown at any of the farm.

The job is to plan how many acres to devote to each crop at the farms while satisfying the given restrictions. The objective is to maximize the total net return as a whole.

**Solution: **We are going to formalate this problem as a linear programming model. The quantities to be decided are the number of acres to devote to each of the three crops at each of the three farms, which are the decision variables as follows.

For example, in the above table, means the area of farm 1 in acre to devote the suger beets. Since the objective function *Z* is the total net return, the resulting linear programming model for this problem is:

Max Z=400(x_{1}+x_{2}+x_{3})+300(x_{4}+x_{5}+x_{6})+100(x_{7}+x_{8}+x_{9})

Subject to the following constraints:

**1) Usable land for each farm(acre):**

Farm 1: x_{1}+x_{4}+x_{7}<=400

Farm 2:x_{2}+x_{5}+x_{8}<=600

Farm 3:x_{3}+x_{6}+x_{9}<=300

**2) Water allocation for each farm:**

Farm 1: 3x_{1}+2x_{4}+x_{7}<=600

Farm 2: 3x_{2}+2x_{5}+x_{8}<=800

Farm 3: 3x_{3}+2x_{6}+x_{9}<=375

**3) Total acreage for each crop:**

Crop 1:x_{1}+x_{2}+x_{3}<=600

Crop 2:x_{4}+x_{5}+x_{6}<=500

Crop 3:x_{7}+x_{8}+x_{9}<=325

**4) Equal proportion of land planted:**

Equality of cultivated land to usable land for farms 1 and 2:

(x_{1}+x_{4}+x_{7})÷400=(x_{2}+x_{5}+x_{8})÷600

Equality of cultivated land to usable land for farms 1 and 3:

(x_{1}+x_{4}+x_{7})÷400=(x_{3}+x_{6}+x_{9})÷300

Equality of cultivated land to usable land for farms 2 and 3:

(x_{2}+x_{5}+x_{8})÷600=(x_{3}+x_{6}+x_{9})÷300

The above equations are not yet in an appropriate form for a linear programming model because some of the variables are on the right-hand side. Hence, their final form is:

3(x_{1}+x_{4}+x_{7})-2(x_{2}+x_{5}+x_{8})=0

4(x_{3}+x_{6}+x_{9})-3(x_{1}+x_{4}+x_{7})=0

(x_{2}+x_{5}+x_{8})-2(x_{3}+x_{6}+x_{9})=0

**5) Non-negativity of decision variables is as follows.**

x_{j}>=0 for all j=1,…,9

The optimal solution to the above linear programming model is as follows:

**Example**: The financial manager of a company is responsible for investing 10 million dollar in stock market. She can also use 1 million dollar loan with a 5.5% interest rate before tax. The type, their quality rating, expiration time and rate of return are listed in the below table.

There are the following limitations on investment:

- The total investment in type of government and cooperation should be at least $ 4 million
- The average quality scale should not exceed 1.4(note that the smaller number means the higher quality).
- The average duration of validity should not exceed 5 years.

Assuming that the stock manageris going to maximize returns after tax (at the rate of 50% and miniucipility is tax-exempt). which type of investment should she buy? Is borrowing up to $ 1 million recommended (interest rate for taking load after tax is 2.75%)?

**Solution: **The amount of investment in each type and the amount of the loan are the decision variables expressed as follows.

x_{A}: The amount of investment in type A in millions of dollars

x_{B}: The amount of investment in type B in millions of dollars

x_{C}: The amount of investment in type C in millions of dollars

x_{D}: The amount of investment in type D in millions of dollars

x_{E}: The amount of investment in type E in millions of dollars

Y: Loan amount with interest rate of 5.5% before tax in millions of dollars

Total income after tax (assuming 50% tax and miniucipility type being tax-exempt) is as follows:

Z=0.043x_{A}+0.027x_{B}+0.025x_{C}+0.022x_{D}+0.045x_{E}-0.0275Y

The constsraints are as follows:

- The manager can only invest $10 million to which the loan amount Y is added:

x_{A}+x_{B}+x_{C}+x_{D}+x_{E}<=10+Y

- The manager should invest at least $4 million in the purchase of cooperation(x
_{B}) and government(x_{C},x_{D}):

x_{B}+x_{C}+x_{D}>=4

- The quality to the total investment should not exceed 1.4. Note that the smaller value means the higher quality:

(2x_{A}+2x_{B}+x_{C}+x_{D}+5x_{E})÷(x_{A}+x_{B}+x_{C}+x_{D}+x_{E})<=1.4

- Multiplying the denominator (x
_{A}+x_{B}+x_{C}+x_{D}+x_{E}) on both sides results in the following:

0.6x_{A}+0.6x_{B}-0.4x_{C}-0.4x_{D}+3.6x_{E}<=0

- The average duration of validity should not exceed 5 years, which is expressed as follows:

(9x_{A}+15x_{B}+4x_{C}+3x_{D}+2x_{E})÷(x_{A}+x_{B}+x_{C}+x_{D}+x_{E})<=5

- Multiplying the denominator on both sides gives the following:

4x_{A}+10x_{B}-x_{C}-2x_{D}-3x_{E}<=0

- The maximum loan is $1 million, which is included in the model as a following limitation:

Y<=1

- Non-negativity of decision variables are as follows:

x_{A},x_{B},x_{C},x_{D},x_{E},Y>=0

The optimal solution to the above linear programming model is as follows:

**Example:** A Company has discontinued the production of a certain unprofitable product line, which creating the excess capacity on machines. The management is considering devoting this excess capacity to products; products 1, 2, and 3. The available capacity on the machines is summarized in the following table:

The number of machine-hour required for each unit of the products is:

The sales department indicates that the sales potential for products 1 and 2 exceeds the maximum production rate and the sales potential for product 3 is 20 units per week. The unit profit would be $50, $20, and $25, respectively, on products 1, 2, and 3. The objective is to determine how much of each product should produce to maximize profit. Formulate a linear programming model for this problem.

**Solution:**

Let be the number of units of product i produced for i=1,2,3. The linear programming model of this problem is as follows.

Constraint 1 is the same as milling machine capacity, constraint 2 is the same as lather machine capacity, constraint 3 is the same as grinder machine capacity, and constraint 4 is demand constriant.

The optimal solution to the above linear programming model is as follows:

**Example: **Consider the following problem, where the value of c_{1} has not yet been certain.

Use graphical analysis to determine the optimal solution(s) for (x_{1}, x_{2}) for the various possible values of c_{1.}

**Solution:**

**Example:** The Company produces precision medical equipment at two factories. Three medical customers have placed orders for products. The table below shows what the cost would be for shipping each unit from each factory to each of these customers. Also shown are the number of units that will be produced at each factory and the number of units ordered by each customer.

A decision now needs to be made about the shipping plan for how many units to ship from each factory to each customer.

**Solution:**

Let x_{ij }be the number of units shipped from factory i (1 and 2) to customer j (1,2 ,and 3).

Objective function: minimizing the shipping cost:

Min Z=600x_{11}+800x_{12}+700x_{13}+400x_{21}+900x_{22}+600x_{23}

Output of factory 1:

x_{11}+x_{12}+x_{13}=400

Output of factory 2:

x_{21}+x_{22}+x_{23}=500

Order of customer 1:

x_{11}+x_{21}=300

Order of customer 2:

x_{12}+x_{22}=200

Order of customer 3:

x_{13}+x_{23}=400

As a result, the model as follow:

The above model has the following optimal solution:

(x_{11},x_{12},x_{13},x_{21},x_{22},x_{23})=(0,200,200,300,0,200) and Z*=540000

**Example:** The company desires to blend a new alloy of 40 percent *tin*, 35 percent *zinc*, and 25 percent *lead* from several available alloys having the following properties:

The objective is to determine the proportions of these alloys that should be blended to produce the new alloy at a minimum cost. Formulate the problem as the linear program.

**Solution: **Let x_{i }be the amount of Alloy i used for 1,…,5.

The optimal solution of the above problem is as follow:

(x_{1},x_{2},x_{3},x_{4},x_{5})=(0.0435,0.2826,0.6739,0,0) and Z*=$84.43

**Example:** A cargo airplane has three part for storing cargo: front, center, and back. These parts have capacity limits on both weight and space, as summarized below:

Furthermore, the weight of the cargo in the three parts must be the same proportion of that part’s weight capacity to maintain the balance of the airplane.

The following four cargoes have been offered for shipment on an upcoming flight as space is available:

Any portion of these cargoes can be accepted. The objective is to determine how much (if any) of each cargo should be accepted and how to distribute each among the parts to maximize the total profit for the flight. Formulate a linear programming model for this problem.

**Solution:**

Let be x_{ij} the number of tons of cargo type i=1,2,3,4 stored in part j = F (front), C (center), B (back).

The optimal solution is as follow:

**Example: **Consider the following model:

Use the graphical method to solve this model.

**Solution:**

**Example:** A crude oil company sells two types of gasoline (super and normal). Each type of gasoline has characteristics regarding the maximum allowed evaporation pressure and minimum octane density, which are summarized in the following table:

In this company, two types of gasoline mixer A and B are used for production. The specifications of these gasoline mixers are as follows:

The company’s plan is to sell a combination of two types of gasoline per week that will maximize profit.

**Solution: **

Let x_{1} and y_{1} be the amounts of gasoline in mixer A that are allocated to producing normal and super gasoline, respectively. Also, x_{2} and y_{2} are considered to be the same values of the gasoline of mixer B. Now you can calculate the final profit from the sale of any type of gasoline. For example, in the case of gasoline mixer A, the cost of a barrel is 8 $, and the sale of a barrel of normal gasoline is 9 $, so the final profit from the sale of a barrel of gasoline produced from mixer A is equal to 1 $ (which will be a factor of x_{1}). In a similar way, the final profit can be calculated for x_{2}, y_{2} and y_{1}, which is summarized in the following table:

Objective function is summarized as follows:

Max Z=x_{1}+2y_{1}+2x_{2}+3y_{2}

Production and demand constraints are summarized as follows:

Production constraint of gasoline mixer A(x_{1}+y_{1}<=15000)

Production constraint of gasoline mixer B(x_{2}+y_{2}<=40000)

Demand constraint for super gasoline(y_{1}+y_{2}<=12000)

Demand constraint for normal gasoline(x_{1}+x_{2}<=59000)

If we mix a barrel of A with a barrel of B, according to the evaporation pressure of each, the evaporation pressure of the mixed gasoline is equal to:

And also the resulting octane densit is equal to:

Therefore, the evaporation pressure of normal gasoline is equal to:

Since the maximum evaporation pressure for normal gasoline is 8, we have:

or

Also, to limit the evaporation pressure for super gasoline, we have:

or

We have a similar reason for limiting the minimum octane density in normal gasoline:

or

We have a similar reason for limiting the minimum octane density in super gasoline:

or

Therefore, the resulting model for the above problem is as follows:

The optimal solution of the above model is equal to:

**Example:** A logging company should prepare orders with the following dimensions and deliver them to the applicants.

These orders must be made from standard boards with dimensions of 2” x 4” x 11′ (2” means 2 inches and 11′ means 11 feet). The standard cut to prepare the orders is possible in the following five ways:

This company intends to use the minimum standard board necessary to prepare orders.

**Solution:**

If x_{1}, x_{2}, x_{3}, x_{4}, and x_{5} are the number of standard boards cut according to one of the five possible ways, the objective function will be as follows:

Min C=x_{1}+x_{2}+x_{3}+x_{4}+x_{5}

Considering that in the cutting of the first type, four boards with the dimensions of the order 1 result, and also in the cutting of the third type and the fourth type, two boards with the dimensions of the order 1 respectively, as a result, the number of order 1 is as follows:

4x_{1}+2x_{3}+2x_{4}>=1300

Similarly, the constraints related to the other two types of orders are as follows:

Order 2: 2x_{2}+x_{3}>=1000

Order 3: x_{4}+2x_{5}>=750

By adding the condition of variables being non-negative, the model of the above problem can be summarized as follows:

The optimal solution of the above model is equal to:

**Example:** A manufacturing company has a commitment to deliver 800 refrigerators this year and another 1200 next year to a chain of stores. The production capacity of the company is 1800 refrigerators and the production cost of each unit is estimated at 1000 $ for the current year and 1500 $ for the next year. In addition, every unit produced this year that is not delivered and remains in the warehouse will be charged 200 $.

It is assumed that the manufacturing company does not have any inventory of refrigerators at the beginning of the contract and wants to have no inventory at the end of the second year. This company requests a production plan that minimizes the total cost of fulfilling its contracts.

**Solution:**

We define the decision variables as follows.

t_{1} = production quantity for the current year

t_{2} = quantity produced for next year

Q_{0} = inventory at the beginning of the current year

Q_{1} = Balance at the end of the current year

Q_{2} = Balance at the end of next year

Because Q_{0}=0 and Q_{2}=0, the objective function becomes as follows:

Min C=1000t_{1}+200Q_{1}+1500t_{2}

In forming the constraints of the problem, it should be noted that the total inventory at the beginning of the current year plus the production in this year minus the remaining inventory at the end of the year must be equal to the commitment made this year (800), that is, we have:

Q_{0}+t_{1}-Q_{1}=800

Also, for next year we should have:

Q_{1}+t_{2}-Q_{2}=1200

Considering that Q_{0}=Q_{2}=0, the problem model is as follows:

The optimal solution of the above model is equal to

**Example:** Consider the following problem:

a) Solve the above problem.

b) Convert the objective function to Min and solve it again.

c) Change the objective function to Max Z=x_{1} and solve it again.

d) Change the objective function to Max Z=-x_{1}+2x_{2} and solve it again.

e) Change the objective function to Min Z=x_{1}-2x_{2} and solve it again.

f) Change the second constraint to equal and solve it again.

g) Change the second constraint to be greater or equal and solve it again

**Solution:**

a)

Considering that, in linear programming problems, the optimal solution will be possible in at least one of the corners of the space, so it is enough to list all corner solutions and the corner solution that has the highest value of the objective function (here the model is maximum) to be selected as the optimal solution. In the figure and table below, these points are specified.

b) According to the figure and feasible point of part (a), point A is optimal.

c) By changing the objective function to Max Z=x_{1}, the new objective function will be parallel to constraint x_{1}>=3 and the problem will have a special case of optimal solutions. The corner points C*(3,2) and F*(3,0) are optimal and have value Z*=3.

d) By changing the objective function to Max Z=-x_{1}+2x_{2}, the optimal solution will be E*(0,6) and Z*=12.

e) The objective function of Min Z=x_{1}-2x_{2} is the same as the objective function of part (c) multiplied by -1. So the optimal point does not change, so E*(0,6) and Z*=-12.

f) If the second constraint is converted into equality, the feasible region will be a line segment CD and the optimal point is D*(2,6).

g) When the second constraint is greater or equal, the feasible region changes as follows, the feasible region is CDG and the optimal point is G*(3,6) and Z*=45.