LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN no.2l2-22o Digitized by the Internet Archive in 2013 http://archive.org/details/linearprogrammin218baug '£6aJ , lit Report No. 2l8 January 6, 1967 TTUiZ/u A LINEAR PROGRAMMING CODE TO DETERMINE WHETHER A BOOLEAN FUNCTION IS A THRESHOLD FUNCTION by Charles R. Baugh FEB 2 b67 Report No. 2l8 A LINEAR PROGRAMMING CODE TO DETERMINE WHETHER A BOOLEAN FUNCTION IS A THRESHOLD FUNCTION by Charles R. Baugh January 6, 1967 Department of Computer Science University of Illinois Urbana, Illinois 6l801 This work was submitted in partial fulfillment for the degree of Master of Science in Electrical Engineering under the direction of Professor S. Muroga, January 19^7 • Ill ACKNOWLEDGMENT The author wishes to express his appreciation to Professor S. Muroga, Department of Computer Science, who graciously offered many suggestions and comments . His advice was of great benefit to the preparation of this thesis. Thanks are also expressed to Dr. T. Tsuboi without whose close cooperation the programming of the linear programming code would have been considerably more difficult. IV TABLE OF CONTENTS Page INTRODUCTION 1 COMPUTER IMPLEMENTATION 6 PROGRAM DESCRIPTION 10 LIST OF REFERENCES Ik APPENDIX. SUBROUTINE DESCRIPTIONS 15 INTRODUCTION An interesting subclass of Boolean functions are threshold functions. Muroga, Toda, and Takasu devised a test which incorporated linear programming techniques to determine whether a switching function 1* is a threshold function ; and if so, its structure. If we consider only positive self -dual threshold functions of exactly nine variables excluding functions with permuted variables, we can be assured of dis- covering all eight variable threshold functions. The advantage of dealing with these self -dual threshold functions is that as many as 18 eight variable threshold functions can be enumerated from one of these 2 nine variable functions. Thus the problem is to determine all nine variable self-dual 2 threshold functions. Through various reduction techniques the set of all nine variable Boolean functions is reduced to 319>12^ possible self-dual threshold functions. With such a large number of functions to check, it is necessary to have a very fast and efficient linear programming code . A set of inequalities characterize each function and are of the following form: See List of References i ' w ' + a ' w ' + 1,1 1 1,2 2 + a l,9V - 1 a ' w ' + m,l 1 w i' - V w. + a ' w ' > 1 m,9 9 - > > (1) Wg' - w 9 ' > where a . . ' = + 1 for all i and j . ij - With the nine variable functions m ranges from 1 to 23 inclusive. These constraints along with the object function of min(w ' + w ' + . . . + w ' ) 12 y (2) 5 constituted the linear programming problem. However, Gabelman and k Winder reformulated the problem by substituting w. for w.' - w! , 11 l-l for i = 1,„..,8 and w for w '. Using this substitution technique, the problem becomes the following: min(w + 2w + 3w + . . . + 9w Q ) (3) while satisfying * Our programming results yield 23 as maximum m, a' 1 w 1+ (a^' + a 12 ')w 2 + ...+ (a il + a' 2+ ... + a '^ > 1 a ml W l + (a ml' + V'K + -• + (a ml + *i& + ~ ' + ^\ ± ± ' i \* Note that the last nine inequalities of (1) are simply w. > for i = 1,...,9 an( 3- will not be explicitly present in the simplex method. For clarity let a. . = ) a ' with (h) "becoming ij Z_j 1 ^ k=l a il w l + • • • + a 19 w 9 > 1 (5) a n w_. + . „ . + a ^w^ > 1 ml 1 m9 9 — and w. > for i = 1, . . . ,$. Since all of the coefficients of the object function (3) are non-negative and the inequalities of (5) are all in the "greater than or equal" form, the dual of the problem is : max(v n + v,.. + „ . . + v ) (6) 12 m while satisfying a v + . . . + a v < 1 11 1 ml in - a v.. + . . . + a v < 2 12 1 m2 m — (7) a v + . . . + a v < 19 1 m9 m — These inequalities are useful for reducing the number of inequalities in the first m inequalities of (l). In Winder's formulation, this advantage was not fully used. where v. > for i = 1... . . ,m. 1 — ' The linear programming problem in this form has an initial feasible solution which eliminates the need for artificial variables and reduces the amount of computation and as a result reduces the time necessary to arrive at the solution. Also when this dual problem is solved by the simplex method, the solution of the primal problem as well as a solution to the dual problem is obtained. In other words, the values of w.. , . . . ,w_ are located in their respective positions of b - .,_ . . . 1' ' 9 m+1, 10 b _ .. of (8a). m+9, 10 v ' For clarity write the simplex tableau as: i . . . l ... 1 . . . m m+1 . . . m+9 B l B 9 C B1 C B9 b oi b 09 \l • ' • V b 19 ' ' • b m 9 b . . . b _ _ m+1,1 m+9 A m+1, 9 ' m+9, 9 Vio b I,10 b mlO b m+l,10 . . . b m+9,10 (8a) Thus the initial tableau is m+1 m4 9 1 m m+1 l ll 22. -1 a i m 1 m9 O m+9 o (8b) An iteration of the simplex method is performed by trans- forming each tableau entry. The conventional transformation of the tableau entries b . . of (8a) is formulated by using a column of (8a) as a reference column y and an entry of y as a pivot y ; i.e. b is replaced by "° 1 r' b st ^ J^ t for i=0 > • • ■ ,i-l,i+l, . . .,m+9 and j=l,... ,10 (9) and b is replaced by b /y for j=l,...,10. Or rewriting we get b ij = l\?l ' Vi ]/y i for i=0,...,i-l,i+l,...,m +9 and j=l,, . .,10 (10) and b a = b i/ y ^ for o =1 ^--AO. COMPUTER IMPLEMENTATION NICAP, ILLIAC II assembly language, is the language in which the linear program code was written. The features of this machine which are particularly appealing are its word structure and control unit. The word is broken into a kk bit mantissa and a 7 bit exponent which makes ILLIAC II very suitable for numerical problems . The central control unit is divided into an advanced control which handles indexing functions and delayed control which supervises the accumulator. The advantage of the dual control is that one can be executing an advanced control and delayed control instruction simul- taneously. Therefore one can increase the speed of the code by appro- priate intermixing of advanced and delayed control instructions. Also the delayed control execution of multiplication and division is by- passed if the accumulator contains zero. Since the problem often contained zeros, the computation time was reduced. The last feature is the bank of fast memory in which inter- mediate arithmatic results could be stored and retrieved very quickly. The typical advanced control instruction including store and access of fast memory is 1 u second. Typical timing for core access is 1.8 u seconds, for multiplication 6.6 u seconds, and for addition 3.3u seconds. Making use of the fact that the coefficients of the inequali- ties of (7) are all integers, we were able to eliminate time consuming divisions which introduce and propagate round off error. This is done by putting all entries of the tableau over a common denominator y and 7 then keeping the numerators in the tableau and the denominator in a separate location. This procedure necessitated the use of the transformation formulae of (10) rather than (9)- In (10) we can keep the denominator y separate. Thus the denominator at any given iteration of the simplex method is the product of each of the y/s of the previous iterations. However, if no provision is made to scale down the denominator and the tableau entries, accumulator overflow will occur since the represented number will be the ratio of two very large members. From the expressions for the numerator entries of the transformed tableau (lO), one can see that the magnitude is a function of the entries of the column y which contain the pivot. Thus keeping the y entries as small as possible yet still integer will prohibit the b. . entries from growing as rapidly. The following simple pseudo common divisor routine was incorporated to prevent overflow and to keep the increased compu- tation time small. First the value of the smallest, in absolute value, of the m+1 y column entries, y was found. The largest in absolute K. value of y , y^/2, ud^> ^v/^ ^J^ wnich was "both an integer and a common divisor of all y column entries was used as the greatest common divisor of the y column. By this scheme the mantissa of the tableau entries never became larger than the kk bits and the magnitudes never exceeded the capacity during the computation. A consideration of the number of multiplications per iteration needed for the simplex method and the revised simplex method will show which is superior for our class of problems. For the simplex method 8 there are 10(m+9)+9 entries in the tableau with 2 multiplications for each entry. This amounts to 20m + 198 multiplications. For the revised simplex method the number of multiplications is: 10m to calculate the (z-c)'s of the non-basic variables; 90 to calculate the pivot column entries; and 220 to transform the basis for a total of 10m + 310- The following table shows the comparison of the two methods Number of Multiplications for One Iteration for a Problem With m Constraints SIMPLEX REVISED SIMPLEX m 20m + 198 10m + 310 2 238 330 3 258 340 4 278 350 5 298 360 6 318 370 7 338 380 8 358 390 9 378 4oo 10 398 410 11 4i8 420 12 438 430 13 458 440 14 478 450 15 498 460 16 518 470 17 538 480 18 558 490 19 578 500 20 598 510 Thus the revised simplex method is more efficient when m is greater than 11. In our problems m averaged 4.91 which is well below the approximate breakeven point of 11.2. However, since it would be 9 convenient to do some post-linear programming operations on the coefficients, the revised simplex method was chosen so that the co- efficient matrix would remain unchanged. With this code we solved 319, 12k linear programming problems in 11 hours and ~$k minutes with 1,^66, ^Ok iterations using ILLIAC II. Thus the average problem took 2.17 n\ seconds with each iteration consuming kk2 u seconds. This total time includes some pre- and post-linear programming operations which consumed only about 10$> of the time. The linear programming code itself used 280 locations of instructions and 262 locations for data storage. This thesis is a part of the joint research work with Professor S. Muroga and Dr. T. Tsuboi. The problem statement of the joint research work and the results produced from the computer program of this thesis will be published elsewhere. 10 PROGRAM DESCRIPTION PROBLEM: LNPG1 is a linear program which max / ex. i=l while satisfying l l,l l l,n a . . . a m,l m,n ~ x l V . • > • • • • X n b m (11) and x. > for i = 1, ...,n where n < 23 and m < 9- All of the real numbers c's, a's, and b's must be integers. The revised-simplex method as outlined in Linear Programming by George Hadley is the method employed. The procedure requires that [A] contain a unit matrix in the last m columns or that a full set of artificial variables be appended. LATA FORMAT: The coefficients a. . and constants b. and c. must be i;J i i in one area in core memory and in the following form: 'i,i • m,l a b, l,n 1 a b m,n n c n (12) 11 The entries of the matrix in (.12) must be stored by row in sequential core memory locations . At the completion of the linear programming calculations the entries of matrix in (12) will be unchanged. MEMORY DESTROYED: FO, Fl, F2, F3, M3, and accumulator. PROGRAM LENGTH; 280 1Q or 428 g COMMON MEMORY; None ERASABLE MEMORY: 262 1Q or ^06 Q OUTPUT: The program calls an external subroutine 10 which must be supplied by the user . The 10 routine is called after every iteration of both Phase I and Phase II of the revised simplex method. The user must return control back to the program by a JLH M3 with all modifiers except M3 unchanged. The user will be given the following information: M3 i Return jump Uk-i Count of Phase I iterations M5: Count of Phase 1 plus Phase II iterations M8: Number of equalities in (ll) M9« Number of variables in (ll) plus one M10; Location of a of (12) 1,1 Mil: First location of basis (stored by column) M12 : First location of the two additional equalities necessary for the revised simplex method (stored by row) 12 M13: l^th bit (sign bit) is 1 if Phase I is completed, 12th bit is 1 if Phase II is completed, 11th through 1st bit are the same as the user's Mil when LNPG1 was originally called. Ml 5 : Location of denominator of all basis entries. NO SOLUTION: If the linear program discovers that the problem has no finite solution or no feasible solution, then it calls a subroutine called ER0R. This subroutine must be supplied by the user and control need not be returned to LNPG1. If control is returned to LNPG1 by a JLH M3 ; it will return control to the user's routine which originally activated LNPG1. The user is given the same information as he was in subroutine 10 with the addition of Ml: is if no feasible solution and is -1 if no finite solution. All other modifiers are the same as they were when the call to LNPGI was made. ACTIVATION OF LNPG 1 : The modifiers must contain the following information : M8: Number of equalities of (ll) M9: Number of variables plus one of (ll) M10: Location of a of (12) Ulk: Negative if no artificial variables added; Positive if full set of artificial variables added. 13 All other modifiers can contain any information the user desires. The call to LNPG1 is by a CALL LNPG1 statement in NICAP. Ik LIST OF REFERENCES 1. Muroga, Saburoj Toda, Iwao; Takasu, Satoru. "Theory of Majority Decision Elements," Journal of the Franklin Institute , Vol. 271, No. 5, May 1961. 2. Muroga, Sahuro. Lecture Notes for Threshold Logic Course, Depart- ment of Computer Science, University of Illinois, 1966. 3- Gabelman, I. J. "The Functional Behavior of Majority Elements," Ph.D. Dissertation, Electrical Engineering Department, Syracuse University, Syracuse, New York, 1961. k. Winder, R. 0. "Enumeration of Seven -Argument Threshold Functions," IEEE Transactions on Electronic Computers , Vol. EC-14, No. 3> June 1965. 5. Hadley, George. Linear Programming, Addison Wesley, 1962. 15 APPENDIX SUBROUTINE DESCRIPTIONS LNPG1 first initializes itself and then jumps to an internal subroutine called LP which is the main control of the revised-simplex method. Thus LNPG1 initializes the basis and establishes the two additional constraints for Phase I and Phase II of the revised -simplex procedure as outlined in Chapter 7 of Linear Programming by George Hadley . 5 SUBROUTINES: (Constitute LNPGl) INTERNAL LP FASI FASH FASIIA BXA TRANS EXTERNAL (Supplied by user) 10 ER0R DATA: The basis data array includes: (l) the subscripts of the variables which make up the present basis; (2) the inverse of the matrix formed by the columns of (ll) which correspond to the variables constituting the basis; (3) the values of these basic variables; and (k) the control 16 column y which corresponds to the last variable introduced into the basis. The basis is stored by column and has the following format: [B #'s] 01 >11 m+1,1 xi b X y o CD o,m+l o o u «H -P O X l y l ipt o les s qt-w . . bscr riab 3rd m+1, m+1 m+1 y m+l 3 cd a CO > -H (13) Initially (first basis); (a) x q = 0, x ± = - m b . and x. = b . , i l l-l 2,..., m+1; i=l (b) variable numbers correspond to the last m subscripts of the variables in (ll) or to n+1 through n+m if artificial variables are added; and (c) the first m+1 columns of (13) are m+1 where 0' = [0, . . .,0] and I , is a unit matrix of rank m+1, m+1 The coefficients for the additional two rows of (ll) necessary for the revised simplex method are stored sequentially by row in an array A12 as follows: - c - c in m "li 2i a . ni i=l 1=1 1=1 = [A12] (Ik) Both (13) and (lU) are data arrays in erasable memory. There- fore care must be exercised if the user is also using erasable storage. 17 LP: Determines whether a full set of artificial variables are needed and branches to Phase I or Phase II depending upon the necessity of artificial variables. Upon the completion of Phase I it enters Phase II. If, however, a feasible solution does not exist, control is transferred to subroutine ER0R which has been supplied by the user. At the completion of Phase II control is returned to the user's calling routine. If an unbounded solution is encountered control is given to the user's subroutine ER0R once again, Control is transferred to user's subroutine 10 at the end of each iteration of both Phase I and Phase II. FASI, FASH, and FASIIA: This routine with its three entry points FASI, FASH, and FASIIA calculates the variable which is to be introduced into the basis. If a feasible solution does not exist, a flag is set so that LP can detect the condition. If Phase I is completed another flag is set for LP. FASH serves the same purpose as FASI except that it deals with Phase II instead of Phase I. Upon completion of Phase II a flag is set to signal LP. If the solution is unbounded another flag is set for LP. Since FASI and FASH are so similar, the main work of both of these routines is handled by FASIIA. BXA : This short routine conducts the multiplication of a row of the basis of (13) with the column of the modified coefficient matrix A12 A which consists of (ll) and (lk) . However, the product of b. with the first entry of A12 A is not included in the product. The product is 18 [b. n t.« . . . *b. -,] with the second through the last entries of the ll i2 i,m+l J A 12 column of . TRANS: The routine is divided into two parts. After calculating a column vector y by which elementary row operations are conducted on the basis, the section of the pseudo greatest common divisor (described below) is entered. Since one of the main objectives of the program is to maintain numerical accuracy, the y column is divided by a pseudo greatest common divisor. As the values of all the constants are integers a very specialized procedure was devised: Step 1. y = min|y.|, i = 0, ...,m+l 2. Calculate y R , y^/2, y^/3, Y k A, Y^/5 3. Among the constants of step 2 select the largest one which is both an integer and common divisor of all y. ' s J i k. Divide all entries of y by value determined in step 3. The second section of TRANS transforms all but the last two columns of (13) by the formulae: d replaced by [d y - d y ] — for i f I ij Id I II 1 y | (15) and d. . replaced by d„./y„ for i = i ij iy j z where y corresponds to min (x /y ) for y > and r = 0, ...,m+l. Since the d. . 's and y . ' s are all integers, (d. ,y . - y .d„ .) will be integer. If one does not divide "by y , the entries of (13) will contain 19 integers. Thus upon completion of every iteration y is stored separately and the numerators of (15 ) are stored in the basis. The 12k division of all the entries of (13) hy the product y y . . . y is delayed until the end of Phase II. IL