Quadratic programming
Quadratic programming is an optimization problem where the objective function is quadratic and the constraint functions are linear. We can solve quadratic programs in R using the solve.QP()
function part of the quadprog
package. Quadratic programs are often expressed in the form of the following equation:

The preceding equation is subject to the following constraints:

However, the solve.QP()
function requires that your quadratic program be written in the standard form:

The preceding equation is subject to the following constraint:

In the preceding constraint, T is the mathematical symbol for transpose (matrix A, but with its rows swapped for columns), is a vector of p unknowns, G is a positive definite symmetric
matrix, d is a vector of length p, A is a
matrix, and b is a vector with the length of the number of constraints c. For example, let's solve the following quadratic program:

The preceding equation is subject to the following constraints:

First, we install the...