Linear Algebra, Optimization

Linear algebra is used to solve optimization problems. For example, linear algebra can be used to find the shortest path between two points, or to allocate resources efficiently.

ORB, Operations Research Bit
Operations Research Bit
7 min readSep 2, 2023

--

Photo by Sam Moghadam Khamseh on Unsplash

Linear algebra is a branch of mathematics that deals with vectors, matrices, and linear transformations. It is a fundamental tool in many fields, including operations research, computer science, and engineering.

  • Computer Science: Linear algebra is used in computer science to develop algorithms. For example, linear algebra can be used to sort data, or to find the eigenvalues of a matrix.
  • Engineering: Linear algebra is used in engineering to design systems. For example, linear algebra can be used to design bridges, or to optimize the performance of a machine.

What is linear algebra? Linear algebra is the study of linear equations and systems of linear equations. A linear equation is an equation of the form Ax = b, where A is a matrix, x is a vector, and b is a scalar. A system of linear equations is a set of linear equations that are all solved for the same unknowns.

Photo by Wim van 't Einde on Unsplash

Why is linear algebra important? Linear algebra is important because it is a fundamental tool in many fields. It is used in operations research to solve optimization problems, in computer science to develop algorithms, and in engineering to design systems. Linear algebra can be used to:

  • Solve optimization problems
  • Develop algorithms
  • Design systems

Some of the most important concepts in linear algebra include:

  • Vectors: A vector is a list of numbers. Vectors can be added and multiplied by scalars.
  • Matrices: A matrix is a rectangular array of numbers. Matrices can be added, subtracted, multiplied, and inverted.
  • Linear Transformations: A linear transformation is a function that takes a vector and maps it to another vector. Linear transformations can be represented by matrices.
Photo by Sigmund on Unsplash

Linear algebra is a powerful tool that can be used to solve problems in a variety of fields. By understanding the concepts of linear algebra, you can become a more effective problem-solver.

Applications of Linear Algebra. Linear algebra has many applications in operations research. For example, linear algebra can be used to:

  • Solving Optimization Problems: Linear algebra can be used to solve optimization problems. For example, linear algebra can be used to find the shortest path between two points, or to allocate resources efficiently.
  • Developing Algorithms: Linear algebra can be used to develop algorithms. For example, linear algebra can be used to sort data, or to find the eigenvalues of a matrix.
  • Designing Systems: Linear algebra can be used to design systems. For example, linear algebra can be used to design bridges, or to optimize the performance of a machine.
Photo by Sean Thomas on Unsplash

Structures and Operations

Vectors, which are lists of numbers. Matrices, which are rectangular arrays of numbers. Finally, linear transformations, which are functions that take vectors and map them to other vectors.

Vectors. A vector is a list of numbers. Vectors can be added and multiplied by scalars. They can be used to represent points, lines, and other geometric objects. By understanding the concepts of vectors, you can become a more effective problem-solver.

  • Vector addition: The sum of two vectors is the vector that is obtained by adding the corresponding components of each vector.
  • Scalar multiplication: The product of a vector and a scalar is the vector that is obtained by multiplying each component of the vector by the scalar.

Linear Algebra operations:

  • Addition: The sum of two vectors is a vector that has the same magnitude and direction as the sum of the vectors’ components.
  • Subtraction: The difference of two vectors is a vector that has the same magnitude and direction as the difference of the vectors’ components.
  • Scalar multiplication: The scalar multiplication of a vector by a scalar is a vector that has the same direction as the original vector but has a magnitude that is multiplied by the scalar.
  • Matrix multiplication: The product of two matrices is a matrix that has the same dimensions as the product of the matrices’ dimensions.

Matrices. A matrix is a rectangular array of numbers. Matrices can be added, subtracted, multiplied, and inverted. Some of the most common types include:

  • Square matrices: A square matrix is a matrix that has the same number of rows and columns.
  • Diagonal matrices: A diagonal matrix is a square matrix that has all zeros except for the diagonal elements.
  • Identity matrices: An identity matrix is a square matrix that has all ones on the diagonal and zeros elsewhere.
  • Triangular matrices: A triangular matrix is a matrix that has all zeros below (or above) the diagonal.

Matrices are a powerful tool that can be used to represent and manipulate data. By understanding the concepts of matrices, you can become a more effective problem-solver.

  • Matrix addition: The sum of two matrices is the matrix that is obtained by adding the corresponding components of each matrix.
  • Matrix subtraction: The difference of two matrices is the matrix that is obtained by subtracting the corresponding components of each matrix.
  • Matrix multiplication: The product of two matrices is the matrix that is obtained by multiplying the corresponding components of each matrix.
  • Matrix inversion: The inverse of a matrix is the matrix that, when multiplied by the original matrix, gives the identity matrix.

Linear Transformations. Linear transformations are a powerful tool that can be used to represent and manipulate geometric objects. A linear transformation is a function that takes a vector and maps it to another vector. Linear transformations can be represented by matrices.

Photo by Hassaan Here on Unsplash

Linear Programming Problems

LP problems are used in a wide variety of applications, including production planning, transportation scheduling, and financial portfolio management.

Problems can be solved using a variety of methods, including the graphical method, the simplex method, and the interior point method. The simplex method is a common way to solve LP problems, and it is implemented in many software packages.

Problem. A company produces two products, A and B. Each product requires a certain amount of time and money to produce. The company has a limited amount of time and money available, so it needs to determine how many units of each product to produce in order to maximize its profits.

  • Decision variables: The decision variables in this problem are the number of units of product A and the number of units of product B that the company should produce.
  • Objective function: The objective function in this problem is to maximize the company’s profits. The profits for each unit of product A are $10 and the profits for each unit of product B are $15. So, the objective function is:
maximize 10x + 15y

Constraints. The company has a limited amount of time and money available, so there are two constraints in this problem. The first constraint is that the total time spent producing product A and product B cannot exceed 100 hours. The second constraint is that the total money spent producing product A and product B cannot exceed $5000.

x + 2y <= 100
10x + 5y <= 5000

Solution. The optimal solution to this problem is to produce 25 units of product A and 50 units of product B. This solution maximizes the company’s profits, which is equal to $1250.

Example 2: We have two machines, A and B, that can be used to produce widgets. Machine A can produce 10 widgets per hour, and machine B can produce 15 widgets per hour. We have a total of 120 hours of machine time available. We want to maximize the number of widgets that we produce, subject to the constraints that we have a limited amount of machine time and that we cannot produce more widgets than the demand.

from scipy.optimize import linprog

# c Set the objective function
objective = [-10, -15]

# A Set the constraints
constraints = [[1, 1]]
b = [220]

# b x,y Set the starting point
bounds = [(0, 100), (0, 150)]

# Solve the problem
solution = linprog(objective, constraints,b, bounds=bounds)

# Print the solution
print('Optimal number of widgets:', round(solution.fun*-1, ndigits=2),
'\nx machine a:', int(solution.x[0]),
'\ny machine b:', int(solution.x[1])
x0 machine a: 70 
x1 machine b: 150

Topics in Operations Research

Photo by Simone Hutsch on Unsplash

--

--

ORB, Operations Research Bit
Operations Research Bit

Business problems, solved. Even the edge cases. Editor of ORB, ORG and Sustainable Cities. Authors, expand your reach: https://bit.ly/write-for-orb