How to Get the Dual Problem of a Linear Programming Problem

Primal Problem

Max:2x1+x2+6x3x4s.t.{x1+2x2+x3x4<=10x1+2x3+x4>=5x2+x3+2x4=20x1>=0,x2<=0,x3<=0Max:2x_1+x_2+6x_3-x_4\\ s.t.\begin{cases} x_1+2x_2+x_3-x_4<=10\\ x_1+2x_3+x_4>=5\\ x_2+x_3+2x_4=20\\ x_1>=0,x_2<=0,x_3<=0 \end{cases}

The general vector form of the primal problem can be expressed as:

Max:z=CXs.t.{AX<=BX>=0Max:z=CX\\ s.t.\begin{cases}AX<=B\\ X>=0 \end{cases}

We can represent the coefficients of the original problem as matrices:

A=[121110210112]A=\begin{bmatrix}1&2&1&-1\\1&0&2&1\\0&1&1&2\end{bmatrix}    ~~~~B=[10520]B=\begin{bmatrix}10\\5\\20\end{bmatrix}    ~~~~C=[2161]C=\begin{bmatrix}2&1&6&-1\end{bmatrix}


Dual Problem

The general vector form of the dual problem can be expressed as:

Min:zd=BTYs.t.{ATY>=CTY>=0Min:z_d=B^TY\\ s.t.\begin{cases}A^TY>=C^T\\ Y>=0 \end{cases}

Then, we can get the matrices of coefficients of the dual problem:

AT=[110201121112]A^T=\begin{bmatrix}1&1&0\\2&0&1\\1&2&1\\-1&1&2\end{bmatrix}    ~~~~CT=[2161]C^T=\begin{bmatrix}2\\1\\6\\-1\end{bmatrix}    ~~~~BT=[10520]B^T=\begin{bmatrix}10&5&20\end{bmatrix}

Step 1: Get the basic framework

Ignoring the symbol of the constraints for a moment (Replace with ??), we can get the basic framework of the dual problem:

Min:10y1+5y2+20y3s.t.{1y1+1y2+0y3(?)22y1+0y2+1y3(?)11y1+2y2+1y3(?)61y1+1y2+2y3(?)1Min:\textcolor{Purple}{10}y_1+\textcolor{Purple} {5}y_2+\textcolor{Purple}{20}y_3\\ s.t.\begin{cases} \textcolor{blue}{1}y_1+\textcolor{blue}{1}y_2+\textcolor{blue}{0}y_3\quad\textcolor{red}{(?)}\quad\textcolor{OrangeRed}{2}\\ \textcolor{blue}{2}y_1+\textcolor{blue}{0}y_2+\textcolor{blue}{1}y_3\quad\textcolor{red}{(?)}\quad\textcolor{OrangeRed}{1}\\ \textcolor{blue}{1}y_1+\textcolor{blue}{2}y_2+\textcolor{blue}{1}y_3\quad\textcolor{red}{(?)}\quad\textcolor{OrangeRed}{6}\\ \textcolor{blue}{-1}y_1+\textcolor{blue}{1}y_2+\textcolor{blue}{2}y_3\quad\textcolor{red}{(?)}\quad\textcolor{OrangeRed}{-1}\\ \end{cases}

Note:

  • One constraint of the primal problem corresponds to a dual variable.

  • The dual variable is multiplied by the right side (BB) of the primal problem to obtain the objective function of the dual problem.

  • The coefficients of the objective function of the primal problem (CC) is on the right side of the constraints of the dual problem.

Step 2: Determines the symbol of constraints

Primal problemDual problem
MaxMin
Variables>=>=Contraints
<=<=
unconstrained=
  • If the primal problem is a maximization problem, the ii th constraint sign of the dual problem is the same as the sign of the ii th variable of the primal problem.
Primal problemDual problem
MinMax
Variables>=<=Contraints
<=>=
unconstrained=
  • If the primal problem is a minimization problem, the ii th constraint sign of the dual problem is the opposite of the sign of the ii th variable of the primal problem.

  • If a variable is unconstrained, its corresponding constraint to the dual problem is given an equal sign.

The primal problem in this example is a maximization problem, so we can get:

Primalproblem:Dualproblemx1>=0:1y1+1y2+0y3>=2x2<=0:2y1+0y2+1y3<=1x3<=0:1y1+2y2+1y3<=6x4(unconstrained):1y1+1y2+2y3=1Primal\quad problem:\quad Dual\quad problem\\ x_1>=0:\quad\textcolor{blue}{1}y_1+\textcolor{blue}{1}y_2+\textcolor{blue}{0}y_3\quad\textcolor{red}{>=}\quad\textcolor{Orange}{2}\\ x_2<=0:\quad\textcolor{blue}{2}y_1+\textcolor{blue}{0}y_2+\textcolor{blue}{1}y_3\quad\textcolor{red}{<=}\quad\textcolor{Orange}{1}\\ x_3<=0:\quad\textcolor{blue}{1}y_1+\textcolor{blue}{2}y_2+\textcolor{blue}{1}y_3\quad\textcolor{red}{<=}\quad\textcolor{Orange}{6}\\ x_4(unconstrained):\quad\textcolor{blue}{-1}y_1+\textcolor{blue}{1}y_2+\textcolor{blue}{2}y_3\quad\textcolor{red}{=}\quad\textcolor{Orange}{-1}\\

Step 3: Determine the symbol of decision variables

Primal problemDual problem
MaxMin
Contraints>=<=Variables
<=>=
=unconstrained
  • If the primal problem is a maximization problem, the variable sign of the dual problem is the opposite of the sign of the constraint of the primal problem.
Primal problemDual problem
MinMax
Contraints>=>=Variables
<=<=
=unconstrained
  • If the primal problem is a minimization problem, the variable sign of the dual problem is the same as that of the constraint in the primal problem.

The primal problem in this example is a maximization problem, so we can get:

Primalproblem:Dualproblemx1+2x2+x3x4<=10:y1>=0x1+2x3+x4>=5:y2<=0x2+x3+2x4=20:y3(unconstrained)Primal\quad problem:\quad Dual\quad problem\\ x_1+2x_2+x_3-x_4<=10:\quad \textcolor{red}{y_1>=0}\\ x_1+2x_3+x_4>=5:\quad \textcolor{red}{y_2<=0}\\ x_2+x_3+2x_4=20:\quad \textcolor{red}{y_3(unconstrained)}\\

Therefore, the final dual problem is as follows:

Min:10y1+5y2+2y3s.t.{y1+y2>=22y1+y3<=1y1+2y2+y3<=6y1+y2+2y3=1y1>=0,y2<=0,y3(unconstrained)Min:10y_1+5y_2+2y_3\\ s.t.\begin{cases} y_1+y_2>=2\\ 2y_1+y_3<=1\\ y_1+2y_2+y_3<=6\\ -y_1+y_2+2y_3=-1\\ y_1>=0,y_2<=0,y_3(unconstrained) \end{cases}