problem with the simplex method

41 Views Asked by At

I wrote a pc program that implements the simples method. In most cases, the program output is correct. But there are cases where an error occurs. For example:

max -x-y

s.t.

x<=230

y<=230

x=1

y=0

The problem is converted to:

max -x-y-Ma1-Ma2

s.t.

x+s1=230

y+s2=230

x+a1=1

y+a2=0

And there the simplex table after initialization:

\begin{bmatrix}-&&&x&y&s1&s2&a1&a2&rhs\\\\s1&&&1&0&1&0&0&0&230\\s2&&&0&1&0&1&0&0&230\\a1&&&1&0&0&0&1&0&1\\a2&&&0&1&0&0&0&1&0\\z&&&1&1&0&0&M&M&0\end{bmatrix}

R5-> R5-MR3-MR4

\begin{bmatrix}-&&&x&y&s1&s2&a1&a2&rhs\\\\s1&&&1&0&1&0&0&0&230\\s2&&&0&1&0&1&0&0&230\\a1&&&1&0&0&0&1&0&1\\a2&&&0&1&0&0&0&1&0\\z&&&1-M&1-M&0&0&0&0&-M\end{bmatrix}

The pivot is [a1,x] = 1.

R1 -> R1-R3

R5->R5- (1-M)R3

\begin{bmatrix}-&&&x&y&s1&s2&a1&a2&rhs\\\\s1&&&0&0&1&0&-1&0&229\\s2&&&0&1&0&1&0&0&230\\x&&&1&0&0&0&1&0&1\\a2&&&0&1&0&0&0&1&0\\z&&&0&1-M&0&0&M-1&0&-1\end{bmatrix}

The pivot is [s2,y] = 1.

R4->R4-R2

R5->R5-(1-M)R2

\begin{bmatrix}-&&&x&y&s1&s2&a1&a2&rhs\\\\s1&&&0&0&1&0&-1&0&229\\y&&&0&1&0&1&0&0&230\\x&&&1&0&0&0&1&0&1\\a2&&&0&0&0&-1&0&1&-230\\z&&&0&0&M-1&0&M-1&0&-1-230(1-M)\end{bmatrix}

That's the final table and y=230. But y need to be zero...

I would be happy if someone could tell me where the problem was.

tnx!