Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0025/linpro.bas
There are 2 other files named linpro.bas in the archive. Click here to see a list.
99 Q=1E36
101	LET C=1
102	DIM A(18,30)
103	PRINT"TYPE 2 FOR OUTPUT OF TABLEAUS AND BASIS AT EACH ITERATION,"
104	PRINT"1 FOR BASIS ONLY, 0 FOR JUST THE SOLUTION, OR 3 FOR"
105	PRINT"INSTRUCTIONS. WHICH.";
106	INPUT P5
107	IF P5=3THEN60000
108	PRINT
112	PRINT "WHAT ARE M AND N OF THE DATA MATRIX";
116	INPUT M,N
117	Y1=M
120	PRINT
124	PRINT "HOW MANY 'LESS THANS','EQUALS','GREATER THANS'";
128	INPUT L, E, G
132	IF L+E+G = M THEN 144
136	PRINT "INPUT DATA NOT CONSISTENT."
140	STOP
144	LET B = M+N+G+1
148	LET W = M
152	IF B*(W+1)<540 THEN 164
156	PRINT "PROBLEM TOO LARGE"
160	STOP
164	IF B>30 THEN 169
168	IF W+1<18 THEN 180
169	PRINT "CHANGE DIM STATEMENT (NO. 102) FOR A"W+1"BY"B"MATRIX"
170	PRINT
171	PRINT "EITHER STATEMENT 164 OR 168 OR BOTH SHOULD BE CHANGED"
172	PRINT "AS FOLLOWS:"
173	PRINT
174	IF B<31 THEN 176
175	PRINT "     164 IF B>";B;"THEN 169"
176	IF W+1<18 THEN 178
177	PRINT "     168 IF W+1<";W+1;"THEN 180"
178	STOP
180	LET M = M - 1
184	LET H = 1
188	FOR I = 0 TO W+1
192	FOR J = 1 TO B
196	LET A(I,J) = 0
200	NEXT J
204	NEXT I
208	FOR I = 0 TO M
212	FOR J = 1 TO N
216	READ A(I,J)
220	NEXT J
224	NEXT I
228	FOR I = 0 TO M
232	READ A(I,B)
236	NEXT I
240	FOR J = 1 TO N
244	READ A(W,J)
248	LET A(W,J) = -A(W,J)
252	NEXT J
256	FOR K = 1 TO M+1
260	LET A(K-1,N+G+K) = 1
264	LET A(K-1,0) = K+N+G
268	NEXT K
272	IF E <> 0 THEN 280 
276	IF G=0 THEN 340
280	FOR K = L+E+1 TO M+1
284	LET A(K-1,K+N-L-E) = -1
288	NEXT K
292	LET W = W + 1
296	LET Q = 0
300	FOR J = 1 TO N + G
304	LET S = 0
308	FOR I = M-G-E+1 TO M
312	LET S = S + A(I,J)
316	NEXT I
320	LET A(W,J) = -S
324	IF A(W,J) > Q THEN 336
328	LET Q = A(W,J)
332	LET C = J
336	NEXT J
340	PRINT
344	PRINT "      YOUR VARIABLES"H"THROUGH"N
348	IF G = 0 THEN 356
352	PRINT "   SURPLUS VARIABLES"N+1"THROUGH"N+G
356	IF L = 0 THEN 364
360	PRINT "     SLACK VARIABLES"N+G+1"THROUGH"N+G+L
364	IF G+E = 0 THEN 372
368	PRINT "ARTIFICIAL VARIABLES"N+G+L+1"THROUGH"B-1
372	IF P5=0 THEN 380
376	GOSUB 636
380	IF Q=0 THEN 540
384	IF P5>0 THEN 564
388	LET H = H + 1
392	LET Q = 1E36
396	LET R = -1
400	FOR I = 0 TO M
404	IF A(I,C) <= 0 THEN 420
408	IF A(I,B)/A(I,C) > Q THEN 420
412	LET Q = A(I,B)/A(I,C)
416	LET R = I
420	NEXT I
424	IF R >= -.5 THEN 440
428	PRINT "SOLUTION UNBOUNDED"
432	GOSUB 636
436	STOP
440	LET P = A(R,C)
444	LET A(R,0) = C
448	FOR J = 1 TO B
452	LET A(R,J) = A(R,J)/P
456	NEXT J
460	FOR I = 0 TO W
464	IF I = R THEN 492
468	FOR J = 1 TO B
472	IF J = C THEN 488
476	LET A(I,J) = A(I,J) - A(R,J)*A(I,C)
480	IF ABS(A(I,J)) > 1E-8 THEN 488
484	LET A(I,J) = 0
488	NEXT J
492	NEXT I
496	FOR I = 0 TO W
500	LET A(I,C) = 0
504	NEXT I
508	LET A(R,C) = 1
512	LET Q = 0
516	FOR J = 1 TO N+G+L
517	IF ABS(A(W,J)) >= 1E-7 THEN 520
518	LET A(W,J)=0
520	IF A(W,J) > Q THEN 532
524	LET Q = A(W,J)
528	LET C = J
532	NEXT J
536	GOTO 380
540	IF W=M+1 THEN 552
544	LET W = W-1
548	GOTO 512
552	PRINT
556	PRINT
560	PRINT "ANSWERS:"
564	PRINT
568	IF Q = 0 THEN 576
572	PRINT "BASIS BEFORE ITERATION"H
576	PRINT "VARIABLE","VALUE"
580	FOR I = 0 TO M
584	IF A(I,0) = 0 THEN 592
585	IF A(I,0) > N THEN 588
587 C1=A(Y1,B)
588	PRINT A(I,0),A(I,B)
592	NEXT I
596	IF Q <> 0 THEN 388
600	PRINT
602	PRINT "OBJECTIVE FUNCTION = ";ABS(C1)
604	PRINT
608	PRINT "DUAL VARIABLES:"
612	PRINT "COLUMN", "VALUE"
616	FOR J = N+1 TO B-G-1
620	PRINT J, A(W,J)
624	NEXT J
626	IF P5=0 THEN 632
628	GOSUB 636
632	GOTO 70000
636	PRINT
638	IF P5=1 THEN 676
640	PRINT
644	PRINT "TABLEAU AFTER"H-1"ITERATIONS"
648	FOR I = 0 TO W
652	FOR J = 1 TO B
656	PRINT A(I,J),
660	NEXT J
664	PRINT
668	PRINT
672	NEXT I
676	RETURN
20000	READ G9
30000	IF G9=4E30 THEN 60000
40000	RESTORE
50000	GOTO 101
60000	PRINT "LIST THE FILE 'LPINST***' FOR INSTRUCTIONS"
70000	END