Linear Programing
Linear Programing
Linear programming (LP), also called linear optimization, is a way to find the best outcome
(like maximum profit or minimum cost) in a problem where certain rules or limits (called
constraints) must be followed. These rules can be in the form of equalities or inequalities.
Linear programming helps solve problems by figuring out the most efficient solution within
a given set of conditions.
In simpler terms, linear programming is a method used to get the best result for a problem
while meeting certain requirements, all expressed through simple, straight-line
relationships. The goal is to find the best possible answer.
When talking about equality of real numbers, there's just one type of relation called
"equality," but there are five different types of inequalities.
If the objective function or constraints are not linear, the problem would no longer be
considered a linear programming problem but could fall under a different category, such as
nonlinear programming.
Decision Variables
Constraints
Data
Objective Functions
Linear Programming Problems (LPP) involve finding the best possible outcome (either
maximum or minimum value) for a given linear function, known as the objective function.
This function includes multiple variables that must meet certain conditions, represented by
linear inequalities called constraints. LPPs are used to find optimal solutions in various
situations, such as manufacturing, diet planning, transportation, and resource allocation
problems.
Linear programming problems can be solved using various methods, including the graphical
method, the simplex method, and tools like R or OpenSolver. Two of the most widely used
techniques are the simplex method and the graphical method, which are often discussed in
detail.
Question: A doctor wishes to mix two types of foods in such a way that the vitamin contents of the
mixture contain at least 8 units of vitamin A and 10 units of vitamin C. Food ‘I’ contains 2 units/kg of
vitamin A and 1 unit/kg of vitamin C. Food ‘II’ contains 1 unit/kg of vitamin A and 2 units/kg of
vitamin C. It costs Rs 50 per kg to purchase Food ‘I’ and Rs 70 per kg to purchase Food ‘II’. Formulate
this problem as a linear programming problem to minimize the cost of such a mixture
Let:
The goal is to minimize the cost of the food mixture. The cost is given by Rs 50 per kg for
Food I and Rs 70 per kg for Food II. Therefore, the objective function to minimize is:
Vitamin A constraint:
Food I provides 2 units of vitamin A per kg, and Food II provides 1 unit per kg. The
mixture must contain at least 8 units of vitamin A:
2𝑋1 + 𝑋2 ≥ 8
Vitamin C constraint:
Food I provides 1 unit of vitamin C per kg, and Food II provides 2 units per kg. The mixture
must contain at least 10 units of vitamin C:
𝑋1 + 2𝑋2 ≥ 10
1. Vitamin A constraint:
2𝑋1 + 𝑋2 = 8
𝑋1 = 0, 𝑋2 = 8
𝑋2 = 0, 𝑋1 = 4
2. Vitamin C constraint:
𝑋1 + 2𝑋2 = 10
To plot the above line:
𝑋1 = 0, 𝑋2 = 5
𝑋2 = 0, 𝑋1 = 10
2 4 10
Coordinates in feasible region are (0, 8), (2, 4) and (10, 0) and there cost is 560, 380 and
400. The optimal solution is (2, 4) with minimum cost of 380.
Problem 2:
A company produces two products: Product A and Product B. The company wants to maximize
its profit. Each unit of Product A gives a profit of $30, and each unit of Product B gives a profit
of $20.
However, the production is limited by the availability of two resources: Resource 1 and
Resource 2.
The company wants to determine how many units of Product A and Product B to produce to
maximize profit.
Problem:
A factory produces two types of products: Tables and Chairs. To make each table, 4 hours of
carpentry work and 2 hours of painting work are required. Each chair requires 3 hours of carpentry
work and 1 hour of painting work. The factory has a maximum of 24 hours available for carpentry
and 8 hours for painting each day. The profit from each table is $40, and from each chair, it's $25.
Problem:
A person wants to choose a mix of two foods, Food A and Food B, to meet their daily protein and
fat requirements while minimizing cost. Each unit of Food A contains 5 grams of protein and 4
grams of fat, and each unit of Food B contains 3 grams of protein and 6 grams of fat. The person
needs at least 15 grams of protein and 12 grams of fat daily. The cost of Food A is $3 per unit, and
the cost of Food B is $2 per unit.
1. Decision variable
2. Objective function
3. Constraint
4. Standard form (Slack variable)
5. Initial Simplex Table
6. Entering variable (highest negative coefficient in Obj function)
7. Ratio
8. Leaving variable
9. Pivot operation (to make pivot element =1 and others =0)
10. Next Entering variable (highest negative coefficient in Obj
function)
11. Apply Pivot operation (to make pivot element =1 and others =0)
12. Optimal Solution
Problem 1:
A doctor wishes to mix two types of foods in such a way that the vitamin contents of the mixture
contain at least 8 units of vitamin A and 10 units of vitamin C. Food ‘I’ contains 2 units/kg of vitamin
A and 1 unit/kg of vitamin C. Food ‘II’ contains 1 unit/kg of vitamin A and 2 units/kg of vitamin C. It
costs Rs 50 per kg to purchase Food ‘I’ and Rs 70 per kg to purchase Food ‘II’. Formulate this problem
as a linear programming problem to minimize the cost of such a mixture.
1. Decision variable
𝑥1 = 𝐹𝑜𝑜𝑑 1 𝑎𝑛𝑑 𝑥2 = 𝐹𝑜𝑜𝑑 2
2. Objective function
𝑍 = 50𝑥1 + 70𝑥2
3. Constraint
2𝑥1 + 𝑥2 ≥ 8
𝑥1 + 2𝑥2 ≥ 10
2𝑥1 + 𝑥2 − 𝑠1 = 8
𝑥1 + 2𝑥2 − 𝑠2 = 10
Basic 𝒙𝟏 𝒙𝟐 𝒔𝟏 𝒔𝟐 RHS
𝒔𝟏 2 1 -1 0 8
𝒔𝟐 1 2 0 -1 10
Z -50 -70 0 0 0
6. Entering Variable
We look at the objective row (bottom row) to find highest negative coefficients.
Basic 𝒙𝟏 𝒙𝟐 𝒔𝟏 𝒔𝟐 RHS
𝒔𝟏 2 1 -1 0 8
𝒔𝟐 1 2 0 -1 10
Z -50 -70 0 0 0
7. Ratio
The smallest ratio is 5, so 𝒔𝟐 is the leaving variable and 2 is the pivot element.
9. Pivot Operation
Divide R2 by 2
R1: R1-R2
R3: R3+R2*70
Basic 𝒙𝟏 𝒙𝟐 𝒔𝟏 𝒔𝟐 RHS
𝒔𝟏 1.5 0 -1 0.5 3
𝒙𝟐 0.5 1 0 -0.5 5
Z -15 0 0 -35 350
Divide R1 by 1.5
R2: R2-(R1*0.5)
R3: R3+ (R1*15)
Basic 𝒙𝟏 𝒙𝟐 𝒔𝟏 𝒔𝟐 RHS
𝒔𝟏 1 0 -0.66 0.33 2
𝒙𝟐 0 1 0.33 -0.66 4
Z 0 0 -10 -30 380
Optimal Solution
𝒙𝟏 = 𝟐, 𝒙𝟐 = 𝟒 𝒂𝒏𝒅 𝑻𝑪 = 𝟑𝟖𝟎