Saturday, August 15, 2009

A Computer Program for Solving Integer Programs

Jsun Yui Wong

The computer program listed below seeks to solve Problem LW5 of Amaral (2006); it is a single-row five-facility layout problem. In order to have integer locations, the facility lengths used in the following computer program have been made twice as long as the given facility lengths.

0 DEFSNG A-Z
3 DEFINT I,J,K
4 DIM X(166),A(166),L(166),K(166),P(166),B(166),S(166)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
111 FOR K=1 TO 5
113 A(K)=FIX(RND*50)
115 NEXT K
126 IMAR=10+FIX(RND*500)
128 FOR I=1 TO IMAR
129 FOR KK=1 TO 5
131 X(KK)=A(KK)
132 NEXT KK
223 IJL=1+FIX(RND*5)
238 X(IJL)=FIX(RND*50)
501 B(1)=ABS(X(1)-X(2))
502 B(2)=ABS(X(1)-X(3))
503 B(3)=ABS(X(1)-X(4))
504 B(4)=ABS(X(1)-X(5))
505 B(5)=ABS(X(2)-X(3))
506 B(6)=ABS(X(2)-X(4))
507 B(7)=ABS(X(2)-X(5))
508 B(8)=ABS(X(3)-X(4))
509 B(9)=ABS(X(3)-X(5))
510 B(10)=ABS(X(4)-X(5))
701 S(1)=B(1)-4
702 S(2)=B(2)-5
703 S(3)=B(3)-7
704 S(4)=B(4)-8
705 S(5)=B(5)-7
706 S(6)=B(6)-9
707 S(7)=B(7)-10
708 S(8)=B(8)-10
709 S(9)=B(9)-11
710 S(10)=B(10)-13
1107 FOR IJUL=1 TO 10
1112 IF S(IJUL)<0 THEN B(IJUL)=333333!
1115 NEXT IJUL
1380 PH=-2*B(1)-1*B(2)-.001*B(3)-1*B(4)
1381 PI=-.001*B(5)-2*B(6)-2*B(7)
1384 PJ=-6*B(8)-3*B(9)-4*B(10)
1589 P=PH+PI+PJ
1599 PR=PH+PI+PJ
1651 IF P<=M THEN 1670
1657 FOR KEW=1 TO 5
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1663 MM=PR
1666 GOTO 128
1670 NEXT I
1890 IF M>-303 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5)
1917 PRINT M,JJJJ
1999 NEXT JJJJ

One notes that the artificial .001 flows of line 1380 and line 1381 replace the original 0 flows.

This BASIC computer program was run with the IBM basica/D interpreter, and the output produced during the first five seconds of running is presented below. (What immediately follows is a manual copy from the computer screen.)

10 6 29 39 18
-302.052 -31995

17 13 48 38 25
-302.056 -31988

12 8 31 41 20
-302.052 -31984

33 37 2 12 25
-302.056 -31958

12 8 31 41 20
-302.052 -31950

7 3 38 28 15
-302.056 -31945

34 38 3 13 26
-302.056 -31912

Interpreted in accordance with line 1912 and line 1917, the output through JJJJ=-31912 was produced during the first five seconds of running on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.

References

Amaral, A. R. S. (2006), "On the exact solution of a facility layout problem," European Journal of Operational Research 173, 508-518.

Heragu, S. S., and Kusiak, A. (1991), "Efficient models for the facility layout problem," European Journal of Operational Research 53, 1-13.

Simmons, D. M. (1969), "One-dimensional space allocation: An ordering algorithm," Operations Research 17, 812-826.