Linear Programming

Linear programming is a process that is used to determine the best outcome of a linear function. It is the best method to perform linear optimization by making a few simple assumptions. The linear function is known as the objective function. Real-world relationships can be extremely complicated. However, linear programming can be used to depict such relationships, thus, making it easier to analyze them.

Linear programming is used in many industries such as energy, telecommunication, transportation, and manufacturing. This article sheds light on the various aspects of linear programming such as the definition, formula, methods to solve problems using this technique, and associated linear programming examples.

What is Linear Programming?

Linear programming, also abbreviated as LP, is a simple method that is used to depict complicated real-world relationships by using a linear function . The elements in the mathematical model so obtained have a linear relationship with each other. Linear programming is used to perform linear optimization so as to achieve the best outcome.

Linear Programming Definition

Linear programming can be defined as a technique that is used for optimizing a linear function in order to reach the best outcome. This linear function or objective function consists of linear equality and inequality constraints. We obtain the best outcome by minimizing or maximizing the objective function .

Linear Programming Examples

Suppose a postman has to deliver 6 letters in a day from the post office (located at A) to different houses (U, V, W, Y, Z). The distance between the houses is indicated on the lines as given in the image. If the postman wants to find the shortest route that will enable him to deliver the letters as well as save on fuel then it becomes a linear programming problem. Thus, LP will be used to get the optimal solution which will be the shortest route in this example.

Example of Linear Programming

Linear Programming Formula

A linear programming problem will consist of decision variables , an objective function, constraints, and non-negative restrictions. The decision variables, x, and y, decide the output of the LP problem and represent the final solution. The objective function, Z, is the linear function that needs to be optimized (maximized or minimized) to get the solution. The constraints are the restrictions that are imposed on the decision variables to limit their value. The decision variables must always have a non-negative value which is given by the non-negative restrictions. The general formula of a linear programming problem is given below:

How to Solve Linear Programming Problems?

The most important part of solving linear programming problem is to first formulate the problem using the given data. The steps to solve linear programming problems are given below:

Let us study about these methods in detail in the following sections.

Linear Programming Methods

There are two main methods available for solving linear programming problem. These are the simplex method and the graphical method. Given below are the steps to solve a linear programming problem using both methods.

Linear Programming by Simplex Method

The simplex method in lpp can be applied to problems with two or more decision variables. Suppose the objective function Z = 40\(x_{1}\) + 30\(x_{2}\) needs to be maximized and the constraints are given as follows:

\(x_{1}\) + \(x_{2}\) ≤ 12

2\(x_{1}\) + \(x_{2}\) ≤ 16

\(x_{1}\) ≥ 0, \(x_{2}\) ≥ 0

Step 1: Add another variable, known as the slack variable, to convert the inequalities into equations. Also, rewrite the objective function as an equation .

- 40\(x_{1}\) - 30\(x_{2}\) + Z = 0

\(x_{1}\) + \(x_{2}\) + \(y_{1}\) =12

2\(x_{1}\) + \(x_{2}\) + \(y_{2}\) =16

\(y_{1}\) and \(y_{2}\) are the slack variables.

Step 2: Construct the initial simplex matrix as follows:

\(\begin{bmatrix} x_{1} & x_{2} &y_{1} & y_{2} & Z & \\ 1&1 &1 &0 &0 &12 \\ 2& 1 & 0& 1 & 0 & 16 \\ -40&-30&0&0&1&0 \end{bmatrix}\)

Step 3: Identify the column with the highest negative entry. This is called the pivot column. As -40 is the highest negative entry, thus, column 1 will be the pivot column.

Step 4: Divide the entries in the rightmost column by the entries in the pivot column. We exclude the entries in the bottom-most row.

12 / 1 = 12

The row containing the smallest quotient is identified to get the pivot row. As 8 is the smaller quotient as compared to 12 thus, row 2 becomes the pivot row. The intersection of the pivot row and the pivot column gives the pivot element.

Thus, pivot element = 2.

Step 5: With the help of the pivot element perform pivoting, using matrix properties , to make all other entries in the pivot column 0.

Using the elementary operations divide row 2 by 2 (\(R_{2}\) / 2)

\(\begin{bmatrix} x_{1} & x_{2} &y_{1} & y_{2} & Z & \\ 1&1 &1 &0 &0 &12 \\ 1& 1/2 & 0& 1/2 & 0 & 8 \\ -40&-30&0&0&1&0 \end{bmatrix}\)

Now apply \(R_{1}\) = \(R_{1}\) - \(R_{2}\)

\(\begin{bmatrix} x_{1} & x_{2} &y_{1} & y_{2} & Z & \\ 0&1/2 &1 &-1/2 &0 &4 \\ 1& 1/2 & 0& 1/2 & 0 & 8 \\ -40&-30&0&0&1&0 \end{bmatrix}\)

Finally \(R_{3}\) = \(R_{3}\) + 40\(R_{2}\) to get the required matrix.

\(\begin{bmatrix} x_{1} & x_{2} &y_{1} & y_{2} & Z & \\ 0&1/2 &1 &-1/2 &0 &4 \\ 1& 1/2 & 0& 1/2 & 0 & 8 \\ 0&-10&0&20&1&320 \end{bmatrix}\)

Step 6: Check if the bottom-most row has negative entries. If no, then the optimal solution has been determined. If yes, then go back to step 3 and repeat the process. -10 is a negative entry in the matrix thus, the process needs to be repeated. We get the following matrix.

\(\begin{bmatrix} x_{1} & x_{2} &y_{1} & y_{2} & Z & \\ 0&1 &2 &-1 &0 &8 \\ 1& 0 & -1& 1 & 0 & 4 \\ 0&0&20&10&1&400 \end{bmatrix}\)

Writing the bottom row in the form of an equation we get Z = 400 - 20\(y_{1}\) - 10\(y_{2}\). Thus, 400 is the highest value that Z can achieve when both \(y_{1}\) and \(y_{2}\) are 0.

Also, when \(x_{1}\) = 4 and \(x_{2}\) = 8 then value of Z = 400

Thus, \(x_{1}\) = 4 and \(x_{2}\) = 8 are the optimal points and the solution to our linear programming problem.

Linear Programming by Graphical Method

If there are two decision variables in a linear programming problem then the graphical method can be used to solve such a problem easily.

Suppose we have to maximize Z = 2x + 5y.

The constraints are x + 4y ≤ 24, 3x + y ≤ 21 and x + y ≤ 9

where, x ≥ 0 and y ≥ 0.

To solve this problem using the graphical method the steps are as follows.

Step 1: Write all inequality constraints in the form of equations.

x + 4y = 24

3x + y = 21

Step 2: Plot these lines on a graph by identifying test points.

x + 4y = 24 is a line passing through (0, 6) and (24, 0). [By substituting x = 0 the point (0, 6) is obtained. Similarly, when y = 0 the point (24, 0) is determined.]

3x + y = 21 passes through (0, 21) and (7, 0).

x + y = 9 passes through (9, 0) and (0, 9).

Step 3: Identify the feasible region. The feasible region can be defined as the area that is bounded by a set of coordinates that can satisfy some particular system of inequalities.

Any point that lies on or below the line x + 4y = 24 will satisfy the constraint x + 4y ≤ 24.

Similarly, a point that lies on or below 3x + y = 21 satisfies 3x + y ≤ 21.

Also, a point lying on or below the line x + y = 9 satisfies x + y ≤ 9.

The feasible region is represented by OABCD as it satisfies all the above-mentioned three restrictions.

Step 4: Determine the coordinates of the corner points. The corner points are the vertices of the feasible region.

B = (6, 3). B is the intersection of the two lines 3x + y = 21 and x + y = 9. Thus, by substituting y = 9 - x in 3x + y = 21 we can determine the point of intersection.

C = (4, 5) formed by the intersection of x + 4y = 24 and x + y = 9

Linear Programming by Graphical Method

Step 5: Substitute each corner point in the objective function. The point that gives the greatest (maximizing) or smallest (minimizing) value of the objective function will be the optimal point.

33 is the maximum value of Z and it occurs at C. Thus, the solution is x = 4 and y = 5.

Applications of Linear Programming

Linear programming is used in several real-world applications. It is used as the basis for creating mathematical models to denote real-world relationships. Some applications of LP are listed below:

Related Articles:

Important Notes on Linear Programming

Linear programming Example

As the minimum value of Z is 127, thus, B (3, 28) gives the optimal solution. Answer: The minimum value of Z is 127 and the optimal solution is (3, 28)

Linear Programming Problem

go to slide go to slide go to slide

assignment problem linear programming examples

Book a Free Trial Class

Practice Questions on Linear Programming

go to slide go to slide

FAQs on Linear Programming

What is meant by linear programming.

Linear programming is a technique that is used to identify the optimal solution of a function wherein the elements have a linear relationship.

What is Linear Programming Formula?

The general formula for a linear programming problem is given as follows:

What is the Objective Function in Linear Programming Problems?

The objective function is the linear function that needs to be maximized or minimized and is subject to certain constraints. It is of the form Z = ax + by.

How to Formulate a Linear Programming Model?

The steps to formulate a linear programming model are given as follows:

How to Find Optimal Solution in Linear Programming?

We can find the optimal solution in a linear programming problem by using either the simplex method or the graphical method. The simplex method in lpp can be applied to problems with two or more variables while the graphical method can be applied to problems containing 2 variables only.

How to Find Feasible Region in Linear Programming?

To find the feasible region in a linear programming problem the steps are as follows:

What are Linear Programming Uses?

Linear programming is widely used in many industries such as delivery services, transportation industries, manufacturing companies, and financial institutions. The linear program is solved through linear optimization method, and it is used to determine the best outcome in a given scenerio.

upGrad blog

Linear Programming Problems, Solutions & Applications [With Example]

' src=

Rohit Sharma is the Program Director for the UpGrad-IIIT Bangalore, PG Diploma Data Analytics Program.

Data science has many applications, one of the most prominent among them is optimization. We all tend to focus on optimizing stuff. Optimization focuses on getting the most desired results with the limited resources you have.

There are all sorts of optimization problems available, some are small, some are highly complicated. While going through them, you’ll find a specific category called linear programming problems. In this article, we’ve discussed what they are and how you can work on them. 

Suppose you’re a fruit seller who can either buy oranges or apples or a certain combination of them both. However you only have a budget of INR 5,000 and you can only store 30 bags of them. Now, you have to buy them in the way that yields you the highest profit.

Now one bag of oranges costs you INR 500 while a bag of apples costs you INR 750. You can make INR 100 from the sale of one bag of oranges and INR 200 from the sale of one bag of apples. 

This problem has various possibilities. You might choose to only buy oranges but then, you’d only have 10 bags in your storage and your profit would be INR 1000. Similarly, you might choose to only buy apples and make INR 1500 as profit. You can also buy a combination of the two. 

Such problems are called linear programming problems and we’ll discuss them in detail. Let’s get started:

Table of Contents

What is Linear Programming?

Linear programming is a method of depicting complex relationships by using linear functions. Our aim with linear programming is to find the most suitable solutions for those functions. The real relationship between two points can be highly complex, but we can use linear programming to depict them with simplicity. Linear programming finds applications in many industries. 

Check out our data science online courses to upskill yourself

Basics of Linear Programming

Here are some fundamental terms of linear programming:

The limitations (or restrictions) of your decision variables are called constraints. Most of the time constraints are the limitations you have on your resources for solving a problem. 

Decision Variable

These variables define your output. Your result depends on these variables, that’s why we call them ‘decision variables’. 

Non-negativity Restriction

The decision variables of a linear programming problem can only have non-negative value. It means the values for your decision variables can be equal to or greater than zero only. 

Objective Function

The objective function is the objective of making your decision. In simple terms it is the final result of your linear programming problem. For example, when you’re finding the maximum profit you can make with a given set of resources, the maximum profit is the objective function.

Formulating Linear Programming Problems

You should know how to formulate a linear programming to apply it in real-life. Suppose you are a manufacturer of toys and you only produce two toys: A and B. Roughly speaking, your toys require two resources X and Y to manufacture. Here are the requirements of your toys:

You have five units of resource X and 12 units of resource Y. Your profit margins on the sale of these toys are:

How many units of each toy would you produce to get the maximum profit?

The Solution

Let’s represent our linear programming problem in an equation:

Z = 6a + 5b

Here, z stands for the total profit, a stands for the total number of toy A units and b stands for total number to B units. Our aim is to maximize the value of Z (the profit). 

Now, your company would want to produce as many units of these toys as possible, but you have limited resources. The limitations on our resources are the constraints of this problem. We only have a total of

Now every unit of toy A and B requires 3 and 2 units of resource Y respectively. And we only have a total of 12 units of resource Y so mathematically, it would look like this:

Remember that the values for the units of toy A can be in integers only. This means we also have the constraints of a->0 and b<-0. 

So, now you have a proper linear programming problem. You can formulate other linear programming problems by following this example. While this example was quite simple, LP problems can become highly complicated. 

Read: Linear Programming Project Ideas & Topics

upGrad’s Exclusive Data Science Webinar for you –

ODE Thought Leadership Presentation

Explore our Popular Data Science Online Courses

Steps of formulating linear programming problems.

To formulate a linear programming problem, follow these steps:

If a problem meets the above criteria, it is a linear programming problem. It’s best practice to keep this criterion in mind when you’re working on identifying the type of the problem. 

Solving Linear Programming Problems with R

If you’re using R, solving linear programming problems becomes much simpler. That’s because R has the lpsolve package which comes with various functions specifically designed for solving such problems. It’s highly probable that you’ll be using R very frequently to solve LP problems as a data scientist. That’s why we’ve shared two distinct examples to help you understand its implementation better:

Let’s start with a basic problem. An organization has two products with selling prices of INR 25 and INR 20 and are called product A and B respectively. Every day, they have 1800 units of resources to produce these products. Product A requires 20 resources units and B requires 12 resources units. The production time for both of these products is four minutes and the organization gets a total of eight working hours every day. The problem is, what should be the production quantity for each of these products to maximize the company’s profits?

We’ll start solving this problem by defining its objective function:

max(Sales) = max( 25 y 1 + 20 y 2 )

Here, 25 and 20 are the prices of product A and B respectively, y1 is the total units of product A produced and y2 is the total units of product B produced. Our decision variables are y1 and y2. 

Top Data Science Skills to Learn to upskill

We’ll now set the constraints for our problem:

Resource constraint:

20 y 1 + 12 y 2 1800

Time constraint:

4 y 1 + 4 y 2 8*60

We aim to find the correct number of products we have to manufacture to get the maximum profit. 

Using R to Solve the Problem:

We’ll use lpsolve to solve this LP problem and start with setting the objective function:

> require(lpSolve)

Loading required package: lpSolve

>  <- c(25, 20)


Then we’ll build a matrix for the constraints:

> const <- matrix(c(20,  12, 4, 4), nrow=2, byrow=TRUE)

     [,1] [,2]

[1,]   20 12

[2,]    4 4

> time_constraints <- (8*60)

> resource_constraints <- 1800

> time_constraints

> resource_constraints

Let’s now create the already-defined equations:

> rhs <- c(resource_constraints, time_constraints)

[1] 1800  480

> direction  <- c(“<=”, “<=”)

> direction

[1] “<=” “<=”

Once all the necessary information is added, we can start finding the optimal answer. The syntax for our package is:

lp( direction, objective, const.mat, const.dir, const.rhs )

> optimum <-  lp(direction=”max”,, const, direction,  rhs)

> optimum

Success: the objective function is 2625

> summary(optimum)

                 Length Class Mode     

direction        1 -none- numeric  

x.count          1 -none- numeric  

objective        2 -none- numeric  

const.count      1 -none- numeric  

constraints      8 -none- numeric  

int.count        1 -none- numeric  

int.vec          1 -none- numeric  

bin.count        1 -none- numeric  

binary.vec       1 -none- numeric  

num.bin.solns    1 -none- numeric  

objval           1 -none- numeric  

solution         2 -none- numeric  

presolve         1 -none- numeric  

compute.sens     1 -none- numeric  

sens.coef.from   1 -none- numeric     1 -none- numeric  

duals            1 -none- numeric  

duals.from       1 -none- numeric         1 -none- numeric  

scale            1 -none- numeric  

use.dense        1 -none- numeric  

dense.col        1 -none- numeric  

dense.val        1 -none- numeric  

dense.const.nrow 1      -none- numeric 

dense.ctr        1 -none- numeric           1 -none- numeric  

tmp              1 -none- character

status           1 -none- numeric

After running the code above, you can get the desired solutions for our problem.

The optimum values for y1 and y2:

Remember that y1 and y2 were the units of product A and product B we had to produce:

> optimum$solution

The optimum sales figure:

The maximum profit we can generate with the obtained values of y1 and y2 is:

> optimum$objval

Also Read:  Linear Algebra For Machine Learning

Read our popular Data Science Articles

Uses of linear programming.

As we mentioned before, linear programming finds applications in many industries. Here are some areas where we use it:

Learn More about Linear Programming and Data Science

Linear programming is one of the most vital concepts of data science. It is also a fundamental topic that you should know about to become a proficient data scientist. As we discussed, there are many applications for this concept and you can find its use cases in your daily life. 

You can learn more about data science and its related concepts, by going to our blog. We have many valuable resources to help you learn more. Here are some for your further reading:

On the other hand, you can get a data science course to learn from industry experts. You’ll get to learn interactively through videos, quizzes, and projects. Taking a course will help you learn the necessary skills to become a professional data scientist. Check out IIIT-B & upGrad’s  PG Diploma in Data Science  which is created for working professionals and offers 10+ case studies & projects, practical hands-on workshops, mentorship with industry experts, 1-on-1 with industry mentors, 400+ hours of learning and job assistance with top firms.

How does linear programming help in optimization?

Optimization is a way of life for many people. Everything utilizes optimization, from how you spend your time to how you solve supply chain issues for your organization. It's a very fascinating and relevant issue in data science. Linear Programming is one of the most effective methods for doing optimization. It aids in the solution of specific extremely complicated optimization problems by making more easy assumptions. As an analyst, you will undoubtedly come across applications and situations that need Linear Programming. Machine Learning takes advantage of optimizations as well. Supervised learning builds on the foundations of Linear Programming. A system is trained to fit a mathematical model of a function using labeled input data to predict values from unknown test data.

How is linear programming useful in data science and machine learning?

Linear programming is a necessary skill for anyone interested in machine learning/data science. Everything in machine learning and deep learning is about optimization. Convex or nonconvex optimization is used in ML algorithms. The key difference between the two categories is that there can only be one optimal solution in convex optimization, which is globally optimal, or you can prove that there is no feasible solution to the problem. In contrast, in nonconvex optimization, there can be multiple locally optimal points. It can take a long time to determine whether the problem has no solution or if the answer is global.

Where is linear programming used?

Professionals can use linear programming in a wide range of disciplines of study. It is often used in mathematics and to a lesser extent in business, economics, and some engineering difficulties. Transportation, energy, telecommunications, and manufacturing are among the industries that employ linear programming methods. It is beneficial in simulating a wide range of problems in planning, routing, scheduling, assignment, and design. Certain specific instances of linear programming, such as network flow issues and multicommodity flow problems, are deemed significant enough to warrant extensive study on specialized methods to solve them. To stabilize YouTube videos, Google employs linear programming.

assignment problem linear programming examples

Prepare for a Career of the Future

Leave a comment, cancel reply.

Your email address will not be published. Required fields are marked *

Our Trending Data Science Courses

Our Popular Data Science Course

Data Science Course

Get Free Consultation

Data science skills to master.

Related Articles

How to Build a Collaborative Data Science Environment?

How to Build a Collaborative Data Science Environment?

' src=

Top 30 Tableau Interview Questions & Answers in 2023

What is Data warehousing? Type, Definition & Examples

What is Data warehousing? Type, Definition & Examples

Start your upskilling journey now, get a free personalised counselling session..

Schedule 1:1 free counselling

Talk to a career expert

Explore Free Courses

Data Science & Machine Learning

Data Science & Machine Learning

Build your foundation in one of the hottest industry of the 21st century


Build essential technical skills to move forward in your career in these evolving times

Career Planning

Career Planning

Get insights from industry leaders and career counselors and learn how to stay ahead in your career


Master industry-relevant skills that are required to become a leader and drive organizational success


Advance your career in the field of marketing with Industry relevant free courses


Kickstart your career in law by building a solid foundation with these relevant free courses.

Register for a demo course, talk to our counselor to find a best course suitable to your career growth.

assignment problem linear programming examples


  1. PPT

    assignment problem linear programming examples

  2. linear programming (Assignment problem) شرح

    assignment problem linear programming examples

  3. PPT

    assignment problem linear programming examples

  4. linear programming

    assignment problem linear programming examples

  5. Assignment Problem, Linear Programming

    assignment problem linear programming examples

  6. What is Linear Programming? (Explained with 7 Detailed Examples!)

    assignment problem linear programming examples


  1. Operations research II Lecture-2 ll Formulation ll Linear programming problems II

  2. Linear Programming Classic Problems 10

  3. B.Sc.Final maths.//Lec.3 Transportation Problem.//Linear Programming Problem

  4. Linear Programming Problem

  5. #1 Formulation of Linear Programming Problem

  6. SLST Mathematics: Linear Programming Problem


  1. Assignment problem

    The assignment problem can be solved by presenting it as a linear program. For convenience we will present the maximization problem. Each edge (i,j), where i is in A and j is in T, has a weight . For each edge we have a variable . The variable is 1 if the edge is contained in the matching and 0 otherwise, so we set the domain constraints:

  2. Section 2.1

    If a linear programming problem represents a company’s profits, then a maximum amount of profit is desired. In most of the examples in this section, both the maximum and minimum will be found. Fundamental Theorem of Linear Programming To solve a linear programming problem, we first need to know the Fundamental Theorem of Linear Programming:

  3. Chapter Four: Linear Programming: Modeling Examples

    Consultant project assignment (minimization) 65. College admissions (maximization) 66. Product flow/scheduling (minimization) PROBLEM SOLUTIONS 1. Since the profit values would change, the shadow prices would no longer be effective. Also, the sensitivity analysis provided in the computer output does not provide ranges for constraint parameter ...

  4. Linear Programming

    The most important part of solving linear programming problem is to first formulate the problem using the given data. The steps to solve linear programming problems are given below: Step 1: Identify the decision variables. Step 2: Formulate the objective function. Check whether the function needs to be minimized or maximized.

  5. Unit 1 Lesson 20 :Solving Assignment problem

    Writing of an assignment problem as a Linear programming problem Example 1. Three men are to to be given 3 jobs and it is assumed that a person is fully capable of doing a job independently. The following table gives an idea of that cost incurred to complete each job by each person: Jobs → Men ↓ J1 J2 J3 Supply M1 M2 M3 Demand 20 15 8 1 28 ...

  6. Examples of Linear-Programming Problems

    For additional formulation examples, browse Section 3.4 of the text. We now briefly discuss how to use the LINDO software. Suppose you wish to solve the product-mix problem. Launch the LINDO package. We will use XR and XE to denote the decision variables. In the current window, enter: MAX 5 XR + 7 XE ST 3 XR + 4 XE < 650 2 XR + 3 XE < 500 END ...

  7. Linear Programming Problems, Solutions & Applications [With

    Let’s represent our linear programming problem in an equation: Z = 6a + 5b Here, z stands for the total profit, a stands for the total number of toy A units and b stands for total number to B units. Our aim is to maximize the value of Z (the profit).