0% found this document useful (0 votes)
439 views

Modification of Simplex Method and Its Implementation in Visual Basic Simplexfol

The document describes modifications to the simplex method for solving linear programming problems more efficiently. It presents an improved two-phase simplex method that aims to find the first basic feasible solution faster. Key modifications include choosing pivot elements to avoid infeasible solutions, marking but not dropping dependent constraints, and only updating necessary coefficients during pivots. The method is implemented in the Visual Basic programming language. Examples are provided to demonstrate the approach.

Uploaded by

mtx993
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
439 views

Modification of Simplex Method and Its Implementation in Visual Basic Simplexfol

The document describes modifications to the simplex method for solving linear programming problems more efficiently. It presents an improved two-phase simplex method that aims to find the first basic feasible solution faster. Key modifications include choosing pivot elements to avoid infeasible solutions, marking but not dropping dependent constraints, and only updating necessary coefficients during pivots. The method is implemented in the Visual Basic programming language. Examples are provided to demonstrate the approach.

Uploaded by

mtx993
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

MODIFICATION OF SIMPLEX METHOD AND ITS IMPLEMENTATION IN VISUAL BASIC

, Predrag S. Neboj sa V. Stojkovic and Marko D. Petkovic Stanimirovic


Abstract. We investigate the problem of nding the rst basic solution in the simplex algorithm. A modication of two phases simplex method is presented and its implementation in programming language Visual Basic is described. A few Netlib examples are presented. Key words: Linear programming, simplex method, Visual Basic.

1. Introduction Consider the linear program


n

Maximize

f (x) = f (x1 , . . . , xn ) =
i=1 n (1)

ci xi d (i = 1, . . . , p)

subject to Ni | (1.1)
j =1 n

aij xN,j bi aij xN,j bi


j =1 n

Ni | Ji |
j =1

(2)

(i = p + 1, . . . , q )

aij xN,j = bi

(i = q + 1, . . . , m)

xi 0,

(i = 1, . . . , m).

1991 Mathematics Subject Classication. 90C05. Typeset by AMS-TEX

Neboj sa V. Stojkovi c, Predrag S. Stanimirovi c and Marko D. Petkovi c

We can transform constraints (1.1) in the following way. Every inequality of (1) the form Ni we change with the equality
n (1) Ni | j =1

aij xN,j bi = xB,i


(2)

(i = 1, . . . , p),

and every inequality of the form Ni


n

we change with the equality (i = p + 1, . . . , q ).

Ni |
j =1

(2)

aij xN,j bi = xB,i

In a such way we get the linear program Max c1 x1 + + cn xn d (1.2) Ax = b, b = (b1 , . . . , bm ), xi 0, (i = 1, . . . , n + q ), where the matrix A is in Rm(n+q) . We suppose that the system is of full rank ( rank(A) = m). After the substitution n + q m = n, the canonical form of problem (1.2) is written in the following tableau form [1], [6] xN,1 xN,2 a11 a12 a21 a22 ... ... am1 am2 c1 c2 ... ... ... ... ... xN,n 1 a1n = b1 a2n = b2 ... ... amn = bm cn d = xB,1 = xB,2 ... = xB,m =f

(1.3)

...

where xN,1 , . . . , xN,n is the set of nonbasic variables and xB,1 , . . . , xB,m are basic variables. Transformed coecients of the matrix A and the vector c are denoted by aij and cj , respectively, for the sake of simplicity. The paper is organized as follows. In the second section we introduce the modication of two phases simplex method and investigate the problem of nding the rst basic solution in the simplex algorithm. In order to accelerate the process for generating the rst basic feasible solution we investigate two problems: - the problem of the rst choice of basic and nonbasic variables, and - the problem of the replacement of a basic and a nonbasic variable in the general simplex method. In the third section we describe an implementation of the two phases simplex method and its modication in the programming language Visual Basic . Several numerical examples are reported in the last section.

Modication of simplex method and its implementation in visual basic

2. Modication For the sake of completeness we restate one version of the classical two phases maximization algorithms from [3] and [7] with respect to linear problem (1.1), which is presented in the tableau form (1.3). Algorithm 1. Replacing a basis variable xB,p and nonbasis variable xN,j . a1 pj = a1 pl a1 ql a1 ql c1 l c1 j d1 1 , apj bp apl , l = j, b1 , = p = apj apj aqi = , q = p, apj apl aqj = aql , q = p, l = j, apj cj apl , l = j, = cl apj cj = , apj bp cj . =d apj

Algorithm 2. (Simplex method for basic feasible solution). Step S1A. If c1 , . . . , cn 0, then the basic solution is an optimal solution. Step S1B. Choose an arbitrary cj > 0. (We use the maximal cj ). Step S1C. If a1j , . . . , amj 0, stop the algorithm. Maximum is +. Otherwise, go to the next step. Step S1D. Compute min bi | aij > 0 aij = bp apj

1im

and replace nonbasic and basic variables xN,j and xB,p , respectively, applying Algorithm 1. If the condition b1 , . . . , bm 0 is not satised, then we use the following steps to search for the rst basic feasible solution Algorithm 3. Step S2. Select the last bi < 0.

Neboj sa V. Stojkovi c, Predrag S. Stanimirovi c and Marko D. Petkovi c

Step S3. If ai1 , . . . , ain 0 then STOP. Linear program can not be solved. Step S4. Otherwise, nd aij < 0, compute min
k>i

bi aij

bk | akj > 0 akj

bp apj

and replace nonbasic and basic variables xN,j and xB,p , respectively. We use the last aij < 0. In the begining we suppose that the matrix A is of full rank ( rank(A) = m). This is valid if the equalities in Ji are lineary independent. Otherwise, we apply Gauss-Jordan algorithm for the elimination of dependent equalities. After that, we apply the next algorithm to obtain the canonical form (1.3). Algorithm 4. Step 1. If Ji = , perform Algorithm 3. Step 2. Find the rst i such that ith constraint is a equality and choose the last aij = 0 for the pivot element. (If there not exists aij = 0 and bi = 0, the problem is not feasible; if bi = 0, then we can drop ith constraint.) Step 3. Apply Algorithm 1 and drop the j th column. Step 4. Find the next i such that the ith constraint is an equality and perform Step 2. Otherwise, apply Algorithm 3. The problem of the replacement of a basic and a nonbasic variable in the general simplex method is contained in Step S 1D and Step S 4. We observed two drawbacks of Step S 4. 1. If p = i and if there exists index t < i = p such that bp bt < , atj apj bt > 0, atj > 0

in the next iteration xB,t becomes negative: xB,t = b1 t = bt bp atj < 0. apj

2. If p > i, in the next iteration b1 i is negative, but there may exists bt < 0, t < i such that min
k>t

bt , atj > 0 atj

bk | akj < 0, bk > 0 akj

bt . atj

Modication of simplex method and its implementation in visual basic

In this case, it is possible to choose atj for the pivot element and obtain xB,t = b1 t = Also, since bt bk , atj akj each bk > 0 remains convenient for the basic feasible solution: xB,k = b1 k = bk bt akj 0. atj bt 0. atj

For this purpose, we propose a modication of Step S4 . This modication follows from the following lemma. Lemma 2.1. Let the problem (1.1) be feasible and let x be the basic infeasible solution with bi1 , . . . , biq < 0. Denote I = {i1 , . . . , iq }. In the following two cases a) q = m, and b) q < m and there exists r I and s {1, . . . , n} such that (2.1) min
h /I

bh | ahs > 0 ahs

br , ars < 0, ars

1 it is possible to produce the new basic solution x1 = {x1 B,1 , . . . , xB,m } with at most q 1 negative coordinates in only one iterative step of the simplex method, if we choose ars for the pivot element, i.e. replace nonbasic variable xN,s with the basic variable xB,r .

Proof. a) If q = m, choose an arbitrary coecient ams < 0 for the pivot element. Applying the simplex method we get a new solution with at least one coordinate positive. For example, we have
1 x1 B,m = bm =

bm 0. ams

b) Assume now that the conditions q < m and (2.1) are satised. Choose ars for the pivot element. In this case the coordinates of the new basic solution are br 1 x1 ais , i = r, B,i = bi = bi ars br 1 . x1 B,r = br = ars

Neboj sa V. Stojkovi c, Predrag S. Stanimirovi c and Marko D. Petkovi c

For k = r, k / I and aks < 0 it is obvious that x1 B,k = bk For aks > 0 and k / I , using bk br aks ars we conclude immediately
1 x1 B,k = bk = bk

br aks 0. ars

br aks 0 ars

which completes the proof. Remark 2.1. If there is no r such that the condition (2.1) is valid, let r /I and s {1, . . . , n} be such that min
h /I

bh | ahs < 0 ahs

br . ars

For such r and s we use ars for the pivot element. Applying the simplex transformation we get the new solution x1 with nonnegative coordinates
1 x1 B,i = bi = bi

br ais , i / I. ars

As the set of the basic solutions is nite, after nitely many transformations, applying anticycling rules if it is necessary, condition (2.1) will be valid. In accordance with these considerations, we propose the following improvement of Algorithm 3. Algorithm 5. Step 1. If b1 , . . . , bm 0 perform Algorithm 2 . Otherwise, construct the set B = {bi1 , . . . , biq } = {bik | bik < 0, k = 1, . . . , q }. Step 2. Select the rst bis < 0. Step 3. If ais ,1 , . . . , ais ,n 0 then STOP. Linear program is not solvable.

Modication of simplex method and its implementation in visual basic

Otherwise, construct the set Q = {ais ,jp < 0, p = 1, . . . , t}, set p = 1 and continue. Step 4. Compute min bk ak,jp | ak,jp > 0, bk > 0 = bh . ap,jp

1km

Step 5. If bis ais ,jp bh ap,jp

then replace nonbasic and basic variables xN,jp and xB,is , else go to Step 6. Step 6. If p > t replace xN,jp and xB,h and go to Step 2. Otherwise, put p = p + 1 and go to Step 3. In the sequel we propose an improvement of Algorithm 1. Observe that in the real problems the matrix A is very sparse, so the number of coecients needed to transform is not very great. Algorithm 6. (The modication of Algortihm 1.) Step 1. Form the sets V = {apl |apl = 0, l = 1, . . . , n + 1}, K = {aqj |aqj = 0, q = 1, . . . , m + 1}. Step 2. Apply Algorithm 1 only for apl , aqj and aql satisfying apl V and aqj K. The next improvement is in Algorithm 4. Instead dropping columns, we will mark this column. In other words, we introduce logical sequence outc with values outc(i) = true if the ith column is not dropped, and outc(i) = f alse otherwise. Similary, outr is an indicator for rows. Algorithm 7. The improvement of Algorithm 4. Step 1. Set outc(i) = true, i = 1, . . . , n, and outr(j ) = true, i = 1, . . . , m. Step 2. If Ji = , go to Step 7. Step 3. If the ith constraint is the equality, continue. Step 4. Find aij = 0 such that outc(j ) = true. (If there not exists aij = 0 with outc(j ) = true and bi = 0, the problem is not feasible; if bi = 0, then we can drop the ith constraint and set outr(i) = f alse.)

Neboj sa V. Stojkovi c, Predrag S. Stanimirovi c and Marko D. Petkovi c

Step 5. Put aij for a pivot element and perform Algortihm 1. Step 6. Go to Step 2. Step 7. Drop all columns and rows with outc(i) = f alse and outr(j ) = f alse, respectively, set outc(i) = true and outr(j ) = true for all i, j and perform Algortihm 3. 3. Implementation Simplex algorithm (Algorithms 1, 2, 3 and 4), modication (Algorithm 5) and both improvements (Algorithms 6 and 7) are implemented in the code M arP lex written in the programming language Visual Basic [5]. 4. Numerical experience Example 4.1. We tested the code M arP lex on some Netlib test problems. We compare our results with the popular robust code P Cx [2]. From Table 1. we can see that our results are in accordance with the results obtained by P Cx. Let us mentioned that the code P Cx is not based on the simplex method. Instead the simplex algorithm, the interior point primal dual method is implemented in P Cx.
Problem P Cx M arP lex Algorithm5Algorithm2No5No2 Adlittle 2.25494963105 225494.963162 18 100436272Aro -4.64753143102 -464.753142 - 1717Agg 3.59917673107 -35991767.28657662 186 109249 Agg3 1.03121159107 10312115.933596 - - 393393Blend -3.08121498101 -30.812150 - -189189 Lot 2.5264706062101 -25.264706 155 7559634Sc105 -5.2202061212101 -52.202061 - -6363Sc205 -5.22020612101 -52.202061 - -179179 Sc50a -6.4575077059101 64.575077 - -3030Sc50b -7.000000000101 -70 --3232Scagr25 1.47534331107 -14753433.0607691362344801234Scagr7 -2.33138982106 2331389.8243302351125123 Scorpion1.87812482103 1878.12482260 68191142 Sctap1 1.41225000103 1412.25000047154793897 Share2b -4.1573224074102 415.732241 - -8686Stocfor1 -4.1131976219104 -41131.976219 - -4747LitVera 1.999992102 0 -- 33 Table 1.

Note that our result for the ill-conditioned problem LitV era from [4] is correct and that code P Cx is unable to give better precision in that case. In the next two columns we give the number of iterations needed for the rst basis feasible solution. As we can see, Algorithm 5 is faster then Algorithm 2 almost in all casses. In the last two columns the number of all iterations are given. References
[1] B.D. Bounday, Basic linear programming, Edvard Arnold, Baltimore, 1984.

Modication of simplex method and its implementation in visual basic [2] [3] [4]

[5] [6] [7]

J. Czyzyk, S. Mehrotra and S.J. Wright, PCx User Guide, Optimization Thechnology Center, Technical Report 96/01, 1996. J.P. Ignizio, Linear programming in single-multiple-objective systems, Englewood Clis:Prentice Hall, 1982. V. Kova cevi c-Vuj ci c, Ill conditioness and interior point method, Technical Report 901-98, Laboratory of Operations Research, Faculty of Organizational Sciences, November 1998. Microsoft Developer Network, Microsoft Corporation Inc.1998. M. Sakarovitch, Linear programming, Springer-Verlag, New York, 1983. S. Vukadinovi c, S. Cveji c, Matemati cko programiranje, Univerzitet u Pri stini, Pri stina 1996., 1983. (In Serbian)

You might also like