Use the left and right arrow keys to navigate the presentation forward and backward respectively. You can also use the arrows at the bottom right of the screen to navigate with a mouse.
FAIR USE ACT DISCLAIMER: This site is for educational purposes only. This website may contain copyrighted material, the use of which has not been specifically authorized by the copyright holders. The material is made available on this website as a way to advance teaching, and copyright-protected materials are used to the extent necessary to make this class function in a distance learning environment. The Fair Use Copyright Disclaimer is under section 107 of the Copyright Act of 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, education and research.
In our previous discussion of optimization, we focused on optimization without constraints.
Constrained optimization also commonly arises in statistical estimation.
In this final discussion of optimization, we will consider how constraints are introduced to our optimization framework.
This will lead us into two classes of constrained optimization problems:
After introducing some general concepts, we will consider several techniques that can be used in the R language to handle such problems.
Courtesy of: J. Nocedal and S. Wright. Numerical optimization. Springer Science & Business Media, 2006.
A representative LP problem can be expressed as finding \( \pmb{x}^\ast \) such that
\[ \begin{align} f(\pmb{x}^\ast) &= \max_{\pmb{x}\in \Omega} \pmb{a}^\top \pmb{x},\quad \text{subject to:}\\ \\ &\mathbf{C}\pmb{x} \leq \pmb{b},\\ &\pmb{x} \geq \pmb{0}, \end{align} \] where \( \pmb{b} \) is a vector of known coefficients and \( \mathbf{C} \) is a known matrix of the coefficients in the constraints.
Because the objective function is linear, it is both convex and concave simultaneously.
Therefore, as long as the constraints are consistent,
we can obtain a global minimum or maximum for such a problem on the feasible region boundary.
Although the linear objective function is a strong constraint on the problem
For example, suppose that a farmer has a piece of farm land, say \( L \) \( \mathrm{km}^2 \), to be planted with either wheat or barley or some combination of the two.
The farmer has a limited amount of fertilizer, \( F \) kg, and pesticide, \( P \) kg.
Every square kilometer of wheat requires \( F_1 \) kilograms of fertilizer and \( P_1 \) kilograms of pesticide.
On the other hand, every square kilometer of barley requires \( F_2 \) kilograms of fertilizer and \( P_2 \) kilograms of pesticide.
Let \( S_1 \) be the selling price of wheat per square kilometer, and \( S_2 \) be the selling price of barley.
If we denote the area of land planted with wheat and barley by \( x_1 \) and \( x_2 \) respectively, then profit can be maximized by choosing optimal values for \( x_1 \) and \( x_2 \).
The example problem can be expressed with the following linear programming problem in the standard form:
\[ \begin{align} \text{Maximize: } S_{1}\cdot x_{1}+S_{2}\cdot x_{2} & &\text{(maximize the revenue)}\\ \text{Subject to:}\\ x_{1}+x_{2}\leq L & & \text{(limit on total area)}\\ F_{1}\cdot x_{1}+F_{2}\cdot x_{2}\leq F & & \text{(limit on fertilizer)}\\ P_{1}\cdot x_{1}+P_{2}\cdot x_{2}\leq P & & \text{(limit on pesticide)}\\ x_{1}\geq 0,x_{2}\geq 0 & & \text{(cannot plant a negative area).} \end{align} \]
Alternatively, in matrix form we have this written equivalently as
\[ \begin{align} \text{Maximize: }\pmb{S}^\top \pmb{x} \\ \text{Subject to:}\\ \begin{pmatrix} 1 & 1\\ F_1 & F_2 \\ P_1 & P_2 \end{pmatrix} \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} \leq \begin{pmatrix}L \\ F \\ P \end{pmatrix} \\ \begin{pmatrix}x_1 \\ x_2 \end{pmatrix} \geq \begin{pmatrix} 0 \\ 0 \end{pmatrix} \end{align} \]
Linear programming problems as above can be solved in R by using the R wrapper for the GNU Linear Programming Kit (GLPK).
This comes in the package Rglpk
below:
require(Rglpk)
As an example, we will show how to solve the following problem,
\[ \begin{align} \text{Maximize: }\begin{pmatrix}2 \\ 4\end{pmatrix}^\top \begin{pmatrix}x_1 \\ x_2\end{pmatrix}\\ \text{Subject to:} & & \begin{pmatrix} 3 \\ 4\end{pmatrix}^\top \begin{pmatrix}x_1 \\ x_2\end{pmatrix} \leq 60 & & \begin{pmatrix}x_1 \\ x_2\end{pmatrix} \geq \pmb{0} \end{align} \]
We will use the Rglpk_solve_LP
with the following arguments:
obj
- a numeric vector representing the objective coefficients.mat
- a matrix of constraint coefficients.dir
- a character vector with the directions of the constraints, "<"
, "<="
, ">"
, ">="
, or "=="
.rhs
- a numeric vector representing the right hand side of the constraints.Rglpk_solve_LP(obj = c(2, 4),
mat = matrix(c(3, 4), nrow = 1),
dir ="<=",
rhs = 60,
max = TRUE)
$optimum
[1] 60
$solution
[1] 0 15
$status
[1] 0
$solution_dual
[1] -1 0
$auxiliary
$auxiliary$primal
[1] 60
$auxiliary$dual
[1] 1
$sensitivity_report
[1] NA