1 100 REM HONEYWELL TIME SHARING APPLICATIONS
2 110 PRINT "L I N P R O"
3 120 REM
4 130 REM REVISED APRIL, 1971
5 140 REM
6 150 READ G9
7 160 IF G9=1E38 THEN 1890
8 170 RESET
9 180 LET C=1
10 190 DIM A1931
11 200 PRINT"TYPE '2' FOR OUTPUT OF OF TABLEAUS AND BASIS AT EACH ";
12 210 PRINT"ITERATION,"
13 220 PRINT" '1' FOR THE BASIS ONLY, OR"
14 230 PRINT" '0' FOR JUST THE SOLUTION."
15 240 PRINT"WHICH";
16 250 INPUT P5
17 260 PRINT
18 270 PRINT "WHAT ARE M AND N OF THE DATA MATRIX";
19 280 INPUT M,N
20 290 PRINT
21 300 PRINT "HOW MANY 'LESS THANS','EQUALS','GREATER THANS'";
22 310 INPUT L, E, G
23 320 IF L+E+G = M THEN 350
24 330 PRINT "INPUT DATA NOT CONSISTENT."
25 340 STOP
26 350 LET B = M+N+G+2
27 360 LET W = M
28 370 IF B*W+2<540 THEN 400
29 380 PRINT "PROBLEM TOO LARGE"
30 390 STOP
31 400 IF B>31 THEN 420
32 410 IF W+1<19 THEN 520
33 420 PRINT"CHANGE DIM STATEMENT NO. 50 FOR A";W+2;"BY";B;"MATRIX"
34 430 PRINT
35 440 PRINT"EITHER STATEMENT 260 OR 270 OR BOTH SHOULD BE CHANGED"
36 450 PRINT"AS FOLLOWS:"
37 460 PRINT
38 470 IF B<32 THEN 490
39 480 PRINT " 260 IF B>";B;"THEN 280"
40 490 IF W+1<19 THEN 510
41 500 PRINT " 270 IF W+2<";W+2;"THEN 380"
42 510 STOP
43 520 LET M = M - 1
44 530 LET H = 1
45 540 FOR I = 1 TO W+2
46 550 FOR J = 2 TO B
47 560 LET AIJ = 0
48 570 NEXT J
49 580 NEXT I
50 590 FOR I = 1 TO M+1
51 600 FOR J = 2 TO N+1
52 610 READ AIJ
53 620 NEXT J
54 630 NEXT I
55 640 FOR I = 1 TO M+1
56 650 READ AIB
57 660 NEXT I
58 670 FOR J = 2 TO N+1
59 680 READ AW+1J
60 690 LET AW+1J = -AW+1J
61 700 NEXT J
62 710 FOR K = 2 TO M+2
63 720 LET AK-1N+G+K = 1
64 730 LET AK-11 = K+N+G
65 740 NEXT K
66 750 IF E <> 0 THEN 770
67 760 IF G=0 THEN 920
68 770 FOR K = L+E+2 TO M+2
69 780 LET AK-1K+N-L-E = -1
70 790 NEXT K
71 800 LET W = W + 1
72 810 LET Q = 0
73 820 FOR J = 2 TO N+1 + G
74 830 LET S = 0
75 840 FOR I = M-G-E+2 TO M+1
76 850 LET S = S + AIJ
77 860 NEXT I
78 870 LET AW+1J = -S
79 880 IF AW+1J > Q THEN 910
80 890 LET Q = AW+1J
81 900 LET C = J
82 910 NEXT J
83 920 PRINT
84 930 PRINT " YOUR VARIABLES";H;"THROUGH";N
85 940 IF G = 0 THEN 960
86 950 PRINT " SURPLUS VARIABLES";N+1;"THROUGH";N+G
87 960 IF L = 0 THEN 980
88 970 PRINT " SLACK VARIABLES";N+G+1;"THROUGH";N+G+L
89 980 IF G+E = 0 THEN 1000
90 990 PRINT "ARTIFICIAL VARIABLES";N+G+L+1;"THROUGH";B-2
91 1000 IF P5=0 THEN 1020
92 1010 GOSUB 1770
93 1020 IF G+E=0 THEN 1360
94 1030 IF Q=0 THEN 1430
95 1040 IF P5>0 THEN 1560
96 1050 LET H = H + 1
97 1060 LET Q = 1E38
98 1070 LET R = 0
99 1080 FOR I = 1 TO M+1
100 1090 IF AIC <= 0 THEN 1130
101 1100 IF AIB/AIC > Q THEN 1130
102 1110 LET Q = AIB/AIC
103 1120 LET R = I
104 1130 NEXT I
105 1140 IF R > 0 THEN 1180
106 1150 PRINT "SOLUTION UNBOUNDED"
107 1160 GOSUB 1770
108 1170 STOP
109 1180 LET P = ARC
110 1190 LET AR1=C
111 1200 FOR J = 2 TO B
112 1210 LET ARJ = ARJ/P
113 1220 NEXT J
114 1230 FOR I = 1 TO W+1
115 1240 IF I = R THEN 1310
116 1250 FOR J = 2 TO B
117 1260 IF J = C THEN 1300
118 1270 LET AIJ = AIJ - ARJ*AIC
119 1280 IF ABSAIJ > 1E-8 THEN 1300
120 1290 LET AIJ = 0
121 1300 NEXT J
122 1310 NEXT I
123 1320 FOR I = 1 TO W+1
124 1330 LET AIC = 0
125 1340 NEXT I
126 1350 LET ARC = 1
127 1360 LET Q = 0
128 1370 FOR J = 2 TO N+1+G+L
129 1380 IF AW+1J > Q THEN 1410
130 1390 LET Q = AW+1J
131 1400 LET C = J
132 1410 NEXT J
133 1420 GOTO 1030
134 1430 IF W=M+1 THEN 1460
135 1440 LET W = W-1
136 1450 GOTO 1360
137 1460 PRINT
138 1470 PRINT
139 1480 FOR I = 1 TO M+1
140 1490 IF AI1<N+G+L+2 THEN 1510
141 1500 IF AIB<>0 THEN 1530
142 1510 NEXT I
143 1520 GO TO 1550
144 1530 PRINT"NO FEASIBLE SOLUTION FOUND"
145 1540 GO TO 99999
146 1550 PRINT "ANSWERS:"
147 1560 PRINT
148 1570 IF Q = 0 THEN 1590
149 1580 PRINT " BASIS BEFORE ITERATION";H
150 1590 PRINT " VARIABLE VALUE"
151 1600 FOR I=1 TO M+1
152 1610 IF AI1 = 0 THEN 1630
153 1620 PRINT AI1-1,AIB
154 1630 NEXT I
155 1640 PRINT
156 1650 PRINT "OBJECTIVE FUNCTION VALUE",AW+1B
157 1660 IF Q <> 0 THEN 1050
158 1670 PRINT
159 1680 PRINT
160 1690 PRINT "DUAL VARIABLES:"
161 1700 PRINT " COLUMN VALUE"
162 1710 FOR J=N+2 TO B-G-1
163 1720 PRINT J-1,AW+1J
164 1730 NEXT J
165 1740 IF P5=0 THEN 1760
166 1750 GOSUB 1770
167 1760 GOTO 99999
168 1770 PRINT
169 1780 IF P5=1 THEN 1880
170 1790 PRINT
171 1800 PRINT "TABLEAU AFTER";H-1;"ITERATIONS"
172 1810 FOR I = 1 TO W+1
173 1820 FOR J = 2 TO B
174 1830 PRINT AIJ,
175 1840 NEXT J
176 1850 PRINT
177 1860 PRINT
178 1870 NEXT I
179 1880 RETURN
180 1890 PRINT" INSTRUCTIONS FOR LINPRO"
181 1900 PRINT
182 1910 PRINT"THIS CODE MAXIMIZES THE OBJECTIVE FUNCTION"
183 1920 PRINT"BY THE TWO-PHASE METHOD."
184 1930 PRINT "MAXIMUM SIZE 18X30. LARGE PROBLEMS MAY RESULT IN"
185 1940 PRINT "EXCESSIVE RUNNING TIME AND LARGE ROUNDOFF ERROR."
186 1950 PRINT"ENTER DATA USING LINES 1-99 AND 10000,90000:"
187 1960 PRINT" FIRST - ARRANGE YOUR RESTRICTIONS SO THAT THE"
188 1970 PRINT" 'LESS THAN' INEQUALITIES PRECEDE THE STRICT EQUALITIES,"
189 1980 PRINT" WHICH , IN TURN, PRECEDE THE 'GREATER THAN' INEQUALITIES."
190 1990 PRINT
191 2000 PRINT
192 2010 PRINT"THEN-TYPE IN THE COEFFICIENTS OF THE RESTRICTIONS ROW BY ROW"
193 2020 PRINT" DO NOT INCLUDE COEFFICIENTS FOR SLACK, SURPLUS,"
194 2030 PRINT" OR ARTIFICIAL VARIABLES."
195 2040 PRINT"NEXT - TYPE IN THE ''B'' VECTOR THE CONSTANTS OF THE"
196 2050 PRINT"RESTRICTIONS. THESE VALUES MUST BE NON-NEGATIVE"
197 2060 PRINT
198 2070 PRINT
199 2080 PRINT"FINALLY - TYPE IN THE COEFFICIENTS OF THE COST FUNCTION."
200 2090 PRINT
201 2100 PRINT
202 2110 PRINT"FOR A MINIMIZATION PROBLEM, REVERSE THE SIGNS OF THE"
203 2120 PRINT"COEFFICIENTS OF THE OBJECTIVE FUNCTION."
204 2130 PRINT
205 2140 PRINT
206 2150 PRINT"AT RUN TIME YOU WILL BE ASKED TO:"
207 2160 PRINT" 1 INDICATE THE LEVEL OF DETAIL FOR OUTPUT."
208 2170 PRINT" 2 INPUT THE NUMBER OR RESTRICTIONS AND VARIABLES - "
209 2180 PRINT" M AND N RESPECTIVELY."
210 2190 PRINT" 3 AND TO INPUT THE NUMBER OF LESS THAN INEQUALITIES,"
211 2200 PRINT" STRICT EQUALITIES, AND GREATER THAN INEQUALITIES,"
212 2210 PRINT" RESPECTIVELY."
213 2220 PRINT
214 2230 PRINT"REMEMBER TO ALWAYS SUPPLY ZEROES WHEN THEY ARE APPLICABLE"
215 99998 DATA 1E38
216 99999 END