Linear programming
Linear programming is used to minimize or maximize a function subject to constraints when both the objective function and the constraints can be expressed as linear equations or inequalities. More generally, these optimization problems can be expressed as follows:
![](https://static.packt-cdn.com/products/9781783555253/graphics/5253OS_09_52.jpg)
The preceding formula is subject to the following constraints:
![](https://static.packt-cdn.com/products/9781783555253/graphics/5253OS_09_53.jpg)
It is also subject to the non-negativity constraint ,
, …,
. In other words, we are interested in finding the values for the decision variables
, which minimize the objective function L(x) subject to the constraints and non-negative conditions. The opposite of this is also true to maximize a linear program, as follows:
![](https://static.packt-cdn.com/products/9781783555253/graphics/5253OS_09_58.jpg)
The preceding formula is subject to the following constraints:
![](https://static.packt-cdn.com/products/9781783555253/graphics/5253OS_09_59.jpg)
It is also subject to the non-negativity constraint ,
, …,
.
R has a few packages and functions available to help solve linear programming problems. We will go over a few examples to show you how to use these functions to set up and solve linear programs. Let's start by solving...