Computer Science/Optimization

13. Simplex method

  • -
728x90
반응형

Algorithmic Idea

  • The optimum is an extreme point (aka vertex)

    → Of course, we have to be sure that it is bounded.

  • Extreme point = a basic feasible solution (BFS)
  • A BFS corresponds to a basis matrix
  • Consider a method that moves to an adjacent vertex
💡
즉, extreme point를 찾고 optimality condition을 check하고 아닌 경우 adjacent vertex로 이동한다는 것. 이때 convex이기 때문에 optimality condition을 만족하면 global minimum임을 보장할 수 있다.
  • Basic variable : 0\ge 0 (00 is possible because of degeneracy)
  • Non-basic variable : =0= 0

Basis matrix update:

  • Entering variable: non-basic → basic
  • Leaving variable: basic → non-basic

Algorithm

mincTx\min c^Tx

subject to\text{subject to}

Ax=bxi0,iAx = b \\ x_i \ge 0,\forall i

Normally, the number of column is larger than the number of row.

W.L.O.G. AL(Rn,Rm)(nm)A\in \mathcal L(\R^n, \R^m) \quad (n \ge m)

  1. Assume that we already know the initial starting point
    💡
    We can get the initial point of this algorithm by Phase-1 which is similar but a slightly different linear programming. This algorithm will be discussed later.
  1. We only consider the columns in the basic.

    W.L.O.G

    A=[BN]x=[xBxN]A = [B| N] \\ x= \begin{bmatrix}x_B \\x_N\end{bmatrix}
  1. Find the solution for
    BxB=bBx_B = b

    or equivalently

    xB=B1bx_B = B^{-1}b

What can we do when given point is not a optimal point?

Revisit our objective function

mincTx=cBTxB+cNTxN\min c^Tx = c_B^Tx_B + c_N^Tx_N

subject to\text{subject to}

Ax=bxi0,iAx = b \\ x_i \ge 0,\forall i

Our given point xB=B1bB1NxNx_B = B^{-1}b - B^{-1}Nx_N

Therefore our objective function is

mincTx=cBTB1b+(cNTcBTB1N)xN\min c^Tx = c_B^TB^{-1}b + (c_N^T - c_B^TB^{-1}N)x_N

we call cNTcBTB1Nc_N^T - c_B^TB^{-1}N to reduced cost and cBTB1bc_B^TB^{-1}b is a current objective function value.

Note that if a non-basic variable increases it s value from zero, it reduced cost indicates the change per unit in the objective function.

💡
Entering variable : variable that have most negative reduced cost. However, we can’t guarantee that it is always optimal since there are other constraints also. Other more sophisticated ways of choosing the entering variable are possible, but they may require additional computations.
💡
추가적으로 BB가 invertible하기 위해서는 적어도 정방행렬이어야 한다. 즉, basic variable의 개수는 주어진 constraint의 개수와 동일하게 잡아야 한다.

Basically, the steps of the simplex algorithm are given below

  1. The optimality test : Computer the reduced cost
    (cNTcBTB1N)(c_N^T - c_B^TB^{-1}N)
    1. If for all coefficient are all non-negative, the current basis is optimal
    1. If not, select a variable that has a negative reduced cost value and make it as a entering variable. For simplicity, let say the entering variable is ii’th component of xNx_N
  1. Select leaving variable : Increase the value of
    xB=B1bB1NixNix_B = B^{-1}b - B^{-1}N_ix_{N_i}

    until there are no violating constraints, where NiN_i is the ii’th column of NN.

  1. Update : Update the basis matrix BB and the vector of basic variables xBx_B
  1. Repeat 1 ~ 3 until current basis is optimal.

Example 1

minx12x2\min -x_1 -2x_2

subject to\text{subject to}

2x1+x2+s1=2x1+x2+s2=3x1+s3=3x1,x2,s1,s2,s30-2x_1 + x_2 + s_1 = 2 \\ -x_1 + x_2 + s_2 = 3 \\ x_1 + s_3 = 3 \\ x_1, x_2, s_1, s_2, s_3 \ge 0

which is equivalent to

mincT[xs]\min c^T\begin{bmatrix}x \\s\end{bmatrix}

subject to\text{subject to}

A[xs]=bA\begin{bmatrix}x\\ s\end{bmatrix} = b

where

cT=[12000]A=[211001101010001]b=[233]c^T = \begin{bmatrix}-1 & -2 & 0 & 0& 0\end{bmatrix} \\ A= \begin{bmatrix}-2 & 1 & 1 & 0 & 0 \\ -1 & 1 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 & 1\end{bmatrix} \\ b = \begin{bmatrix}2 \\ 3\\3\end{bmatrix}

Take

xB=[s1s2s3],xN=[x1x2]B=[100010001]N=[211110]x_B = \begin{bmatrix}s_1 \\ s_2\\s_3\end{bmatrix}, x_N = \begin{bmatrix}x_1\\x_2\end{bmatrix} \\ B = \begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix} \\ N = \begin{bmatrix}-2 & 1 \\ -1 & 1 \\ 1 & 0\end{bmatrix}

Therefore,

xB=B1b=[233]x_B = B^{-1}b = \begin{bmatrix}2 \\ 3\\ 3\end{bmatrix}

and it reduced cost is

cNTcBTB1N=[12][000][211110]=[12]\begin{align}c_N^T - c_B^TB^{-1}N &= \begin{bmatrix}-1 & 2\end{bmatrix} - \begin{bmatrix}0 & 0 & 0\end{bmatrix}\begin{bmatrix}-2 & 1 \\ -1 & 1 \\ 1 & 0\end{bmatrix} \\ &= \begin{bmatrix}-1 & -2\end{bmatrix}\end{align}

Therefore, we take x2x_2 as a entering variable

xB=[233]B1NxN=[233][110]x2x_B = \begin{bmatrix}2 \\ 3\\3\end{bmatrix} - B^{-1}N x_N = \begin{bmatrix}2\\3\\3\end{bmatrix} - \begin{bmatrix}1\\1\\0\end{bmatrix}x_2

Note that the column that related to x2x_2  is (1,1,0)T(1, 1, 0)^T.

💡
s1s_1 is leaving variable since it is firstly violated when we increase the value of x2x_2

Example 2

A=[216102]x=[x1x2x3]b=[41]A = \begin{bmatrix}2 & 1 & 6 \\ 1 & 0 & 2\end{bmatrix} \\ x = \begin{bmatrix}x_1 \\ x_2 \\ x_3\end{bmatrix} \\ b = \begin{bmatrix}4 \\ 1\end{bmatrix}

In addition,

xB=[x1x2]xN=[x3]x_B = \begin{bmatrix}x_1 \\ x_2\end{bmatrix}\\ x_N =\begin{bmatrix}x_3\end{bmatrix}

Let the reduced cost of x3x_3 is negative, therefore we can make x3x_3 as an entering variable. But we have to decide how much we could increase x3x_3 without making any problem with constraints. Ideally it is better to increase the value of x3x_3 but it is impossible because other constraints are also depend on x3x_3.

[2110][x1x2]+[62][x3]=[41]\begin{bmatrix}2 & 1 \\ 1 & 0\end{bmatrix} \begin{bmatrix}x_1\\x_2\end{bmatrix} + \begin{bmatrix}6\\2\end{bmatrix}\begin{bmatrix}x_3\end{bmatrix} = \begin{bmatrix}4\\1\end{bmatrix}
[x1x2]=[2110]1[41][2110]1[62]x3\begin{bmatrix}x_1 \\ x_2\end{bmatrix} = \begin{bmatrix}2 & 1 \\ 1 & 0\end{bmatrix}^{-1}\begin{bmatrix}4 \\ 1\end{bmatrix} - \begin{bmatrix}2 & 1 \\ 1 & 0\end{bmatrix}^{-1}\begin{bmatrix}6 \\ 2\end{bmatrix}x_3
[x1x2]=[12][22]x3\begin{bmatrix}x_1 \\ x_2\end{bmatrix} = \begin{bmatrix}1\\ 2\end{bmatrix} - \begin{bmatrix}2 \\ 2\end{bmatrix}x_3

For example, since x1=12x3x_1 = 1 - 2x_3, if we take x3x_3  greater than 12\frac{1}{2}, x1x_1 goes to negative which makes a problem.

x1=12x3x2=22x3x_1 = 1-2x_3 \\ x_2 = 2 - 2x_3

Therefore, we can increase x3x_3 until 12\frac{1}{2}. In this scenario, x1x_1 have to change to non-basic variable. We call it leaving variable.

💡
Note that the simplex algorithm is terminated when all variables in reduced cost vector are non-negative.

Simplex Method in Tableau Form

A couple of More Details

Generating an initial point

In general, the origin is not necessarily a feasible BFS. Therefore, we have to find the initial starting point.

Let say our optimization problem is as follows

mincTx\min c^Tx

subject to\text{subject to}

Ax=bxi0,iAx = b \\ x_i \ge 0,\forall i

We can define different linear programming to get a initial point of the original optimization problem

min1Ty\min 1^Ty

subject to\text{subject to}

Ax+Iy=bx0,y0Ax + Iy = b \\ x\ge 0, y\ge 0

This problem is also a linear programming so that we can apply the simplex method. Moreover, we already know the extreme point of this problem

x=0,y=bx = 0, y = b

It is called Phase-1.

But what if we can’t find the y=0y = 0? In this case, it implies there is no feasible solution in the original optimization problem.

Unbounded problem

The simplex method there is the possibility that the problem will be unbounded.

For example,

xB=B1bB1NixNix_B = B^{-1}b - B^{-1}N_ix_{N_i}

when a any value in B1NiB^{-1}N_i is positive, the basic variable will decrease as the entering variable xNix_{N_i} increases.

However, if there is no positive value in B1NiB^{-1}N_i, we can increase xNix_{N_i} whatever we want. That means the feasible region is unbounded. Therefore, we can detect it by using simplex method when our original optimization problem is unbounded.

Example

Consider this optimization problem

minx12x2\min -x_1 -2x_2

subject to\text{subject to}

x1+x2+x3=22x1+x2+x4=1x1,x2,x3,x40-x_1 + x_2 + x_3 = 2 \\ -2x_1 + x_2 + x_4 = 1 \\ x_1, x_2, x_3, x_4\ge 0

Take

xB=(x1,x2)TxN=(x3,x4)Tx_B = (x_1, x_2)^T \\ x_N = (x_3, x_4)^T

At this iterations, xB=(1,3)Tx_B = (1, 3)^T and the reduced cost for the non-basic variables are (5,3)T(5, -3)^T.

Since it has a negative value 3-3, the current point is not a optimal. Therefore, we take x4x_4 as an entering variable.

Since,

B1N2=[1121][01]=[11]\begin{align}B^{-1}N_2 &= \begin{bmatrix}1 & -1 \\ 2 & -1 \end{bmatrix}\begin{bmatrix}0 \\1 \end{bmatrix} \\ &= \begin{bmatrix}-1 \\ -1\end{bmatrix}\end{align}

That means we can increase x4x_4 without limit, so the objective function can be decreased without limit. Therefore, there is no finite solution to this linear program.

Degeneracy

The version of the simplex method that we have described can fail, cycling endlessly without any improvement in the objective and without finding a solution. This can only happen on degenerate problems, problems where a basic variable is equal to zero in some basis.

Example

This about this example,

minx1x2\min -x_1 -x_2

subejct to\text{subejct to}

x1+s1=2x1+x2+s2=2x1,x2,s1,s20x_1 + s_1 = 2 \\ x_1 + x_2 + s_2 = 2 \\ x_1, x_2, s_1, s_2 \ge 0

It is equivalent to

mincTx\min c^Tx

subejct to\text{subejct to}

Ax=bx0Ax = b \\ x \ge 0

where

cT=[1100]A=[10101101]b=[22]c^T = \begin{bmatrix}-1 & -1 & 0 & 0\end{bmatrix}\\A = \begin{bmatrix}1 & 0 & 1 & 0 \\ 1 & 1 & 0 & 1\end{bmatrix} \\ b = \begin{bmatrix}2 \\ 2\end{bmatrix}

Suppose we take x1,s4x_1, s_4 as a basis. Then

B=[1011]N=[0110]B = \begin{bmatrix}1 & 0 \\ 1 & 1\end{bmatrix} \\ N = \begin{bmatrix}0 & 1 \\ 1 & 0\end{bmatrix}

Calculate the reduced cost

cNTcBTB1N=[10][10][1011][0110]=[11]\begin{align}c_N^T - c_B^{T}B^{-1}N &= \begin{bmatrix}-1 & 0\end{bmatrix} - \begin{bmatrix}-1 & 0\end{bmatrix}\begin{bmatrix}1 & 0 \\ -1 & 1\end{bmatrix}\begin{bmatrix}0 & 1 \\ 1 & 0\end{bmatrix} \\ &= \begin{bmatrix}-1 & 1\end{bmatrix}\end{align}

Therefore, we take x2x_2 as a intering variable. Now we have to check the leaving variable

xB=B1bB1N1x2=[20][01]x2\begin{align}x_B &= B^{-1}b - B^{-1}N_1x_2 \\ &= \begin{bmatrix}2 \\ 0\end{bmatrix} - \begin{bmatrix}0 \\ 1\end{bmatrix}x_2 \end{align}

Therefore, s4s_4 is a leaving variable and its value set to 00.

In this case, we have to improvement in objective function. Moreover, it can be fluctuate forever even though there is no improvement in objective function.

💡
이러한 일이 근본적으로 벌어지는 이유는 basic variable 중에 해당 값이 0인 것이 존재할 때 발생한다.

Optimality and the Lagrangian Function

We have discussed optimality condition by using the Lagrangian function before. Actually, this approach is more general. Therefore, we can learn this approach even though our optimization problem is linear program.

We can change our objective function as

mincTx\min c^Tx

subject to\text{subject to}

Ax=b(λ)Ix0(π)Ax = b \quad(\lambda) \\ Ix \ge 0 \quad (\pi)

Define

L(x,λ,π)=cTxλT(Axb)πT(Ix0)\mathcal L(x, \lambda, \pi) = c^Tx - \lambda^T(Ax - b) - \pi^T(Ix -0)

Use KKT condition.

  1. Stationary condition
    xL(x,λ,π)=0cλATπ=0\nabla_x\mathcal L(x, \lambda, \pi) = 0 \\ \Rightarrow c - \lambda A^T - \pi = 0
  1. Primal feasibility
    Ax=bIx0Ax^* = b \\ Ix^* \ge 0
  1. Dual feasibility
    π0\pi\ge 0
  1. Complementary slackness
    πTIx=0\pi^TIx = 0

How can we connect a KKT condition and termination condition of simplex method?

Recall that a simplex method can be terminated when all variables in reduced cost vector is non-negative.

cNTcBTB1Nc_N^T - c_B^TB^{-1}N

Take

πN=cNTcBTB1NπB=0\begin{align}\pi_N = c_N^T - c_B^TB^{-1}N \\ \pi_B = 0\end{align}

Then, it satisfy complementary slackness condition and dual feasibility condition.

cπ=λAT[cBTcNT][πBTπNT]=λ[BTNT]c - \pi = \lambda A^{T} \\ \Rightarrow \begin{bmatrix}c_B^T \\ c_N^T\end{bmatrix} - \begin{bmatrix}\pi_B^T \\ \pi_N^T\end{bmatrix}=\lambda\begin{bmatrix}B^T \\ N^T\end{bmatrix}

Since 12 and 13,

[cBTcNT][πBTπNT]=λ[BTNT][cBTcNT][0cN(cBTB1N)T]=λ[BTNT][cBTNT(cBTB1)T]=λ[BTNT]\begin{bmatrix}c_B^T \\ c_N^T\end{bmatrix} - \begin{bmatrix}\pi_B^T \\ \pi_N^T\end{bmatrix}=\lambda\begin{bmatrix}B^T \\ N^T\end{bmatrix} \\ \Rightarrow \begin{bmatrix}c_B^T \\ c_N^T\end{bmatrix} - \begin{bmatrix}0 \\ c_N -(c_B^TB^{-1}N)^T\end{bmatrix}=\lambda\begin{bmatrix}B^T \\ N^T\end{bmatrix} \\ \Rightarrow\begin{bmatrix}c_B^T\\N^T(c_B^TB^{-1})^{T}\end{bmatrix} =\lambda\begin{bmatrix}B^T \\ N^T\end{bmatrix}

Therefore,

λ=(BT)1cBT=(cBTB1)T\begin{align}\lambda &= (B^{T})^{-1}c_B^T \\ &= (c_B^TB^{-1})^T\end{align}

If we take

πN=cNTcBTB1NπB=0λ=(cBTB1)T\begin{align}&\pi_N = c_N^T - c_B^TB^{-1}N \\ &\pi_B = 0 \\ &\lambda = (c_B^TB^{-1})^T\end{align}

KKT condition and a termination condition for simplex method holds simultaneously.

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.