1 10 REM PERT
  2 20 REM REVISED FEB 1975
  3 30 PRINT TAB(25);"PERT ANALYSIS PROGRAM"
  4 40 PRINT
  5 50 PRINT
  6 60 READ T
  7 70 REM
  8 80 IF T <> 4E36 THEN 1600
  9 90 PRINT
 10 100 PRINT "ENTER DATA STARTING IN LINE 3000."
 11 110 PRINT
 12 120 PRINT "FOR PROGRAM DESCRIPTION AND INSTRUCTIONS TYPE:"
 13 130 PRINT
 14 140 PRINT "LIST 170 1590"
 15 150 STOP
 16 160 REM
 17 170 REM
 18 180 REM                 PROGRAM DOCUMENTATION
 19 190 REM
 20 200 REM         THIS PROGRAM ANALYZES A PERT NETWORK.  THE ANALYSIS
 21 210 REM     IS ADOPTED FROM THE PROGRAM AS SET FORTH IN MC MILLAN
 22 220 REM     AND GONZALES (PAGES 189 TO 211).
 23 230 REM
 24 240 REM         FOLLOWING THE CONVENTION AS DELINEATED IN M &G,
 25 250 REM     A CIRCLE CORRESPONDS TO A 'COMPLETION EVENT' AND
 26 260 REM     AN ARROW CORRESPONDS TO AN 'ACTIVITY'.  IN THE
 27 270 REM     NETWORK ANALYSIS TWO PARAMETERS ARE ASSOCIATED
 28 280 REM     WITH EACH TIME CONSUMING ACTIVITY: A MEAN AND A
 29 290 REM     VARIANCE.
 30 300 REM
 31 310 REM         FOR EACH EVENT IN  YOUR NETWORK, THE PROGRAM
 32 320 REM     WILL DETERMINE THE FOLLOWING VARIABLES FOR YOU:
 33 330 REM
 34 340 REM       1)  TE = THE EARLIEST EXPECTED TIME OF OCCURRENCE
 35 350 REM                OF COMPLETION EVENT X.
 36 360 REM
 37 370 REM       2)  V = THE VARIANCE ASSOCIATED WITH THE TE OF THE
 38 380 REM                EVENT.
 39 390 REM
 40 400 REM       3)  TL = THE LATEST EXPECTED TIME WHICH A COM-
 41 410 REM                PLETION EVENT CAN BE ALLOWED TO OCCUR
 42 420 REM                WITHOUT DISTURBING THE TE OF THE FINAL
 43 430 REM                EVENT OF THE NETWORK.
 44 440 REM
 45 450 REM       4)  SLACK = TE-TL
 46 460 REM
 47 470 REM        THE ABOVE MENTIONED VARIABLE TE MUST NOT BE CONFUSED
 48 480 REM     WITH T(E).  THE VALUE T(E) IS THE EXPECTED ANOUNT OF
 49 490 REM     TIME REQUIRED FOR THE COMPLETION OF A SINGLE ACTIVITY,
 50 500 REM     INDEPENDENT OF WHAT HAS OCCURRED BEFORE IT.  THE DATA
 51 510 REM     FOR T(E) OF EACH EVENT WILL BE ENTERED BY YOU AS
 52 520 REM     DESCRIBED BELOW.  THE SAME NOMENCLATURE IS USED WITH
 53 530 REM     V AND V(E).
 54 540 REM
 55 550 REM         IN THIS PROGRAM NO EVENT CAN HAVE MORE THAN TWO
 56 560 REM     IMMEDIATE PREDECESSOR EVENTS OR MORE THAN TWO
 57 570 REM     IMMEDIATE SUCCESSOR EVENTS.  TO USE THIS PROGRAM WITH
 58 580 REM     MORE COMPLEX NETWORKS CONTAINING MORE THAN TWO
 59 590 REM     IMMEDIATE PREDECESSOR OR SUCCESSOR EVENTS, ENTER
 60 600 REM     A NUMBERED 'DUMMY' EVENT THAT HAS A T(E) =0 AND
 61 610 REM     A V(E) =0.
 62 620 REM
 63 630 REM         FOR EXAMPLE, IF EVENTS 1, 2 AND 3 PRECEED EVENT 5
 64 640 REM     THEN ENTER A 'DUMMY' EVENT 4, OF ZERO (0) TIME FOR
 65 650 REM     COMPLETION AND ZERO (0) VARIANCE, SUCH THAT EVENTS
 66 660 REM     1 AND 2, OR 1 AND 3, OR 2 AND 3 PRECEED EVENT 4.
 67 670 REM     THEN EVENT 5 WILL HAVE ONLY TWO PRECEEDING EVENTS AS
 68 680 REM     ALLOWED BY THE PROGRAM. (IE, EVENT 5 WILL BE PRECEEDED
 69 690 REM     BY 1 AND 4, OR 2 AND 4, OR 3 AND 4)  --SEE PAGE 197
 70 700 REM     OF M & G.
 71 710 REM
 72 720 REM         BEGINNING IN LINE 3000 ENTER THE DATA.  FIRST ENTER
 73 730 REM     T, THE TOTAL NUMBER OF EVENTS IN THE NETWORK INCLUDING
 74 740 REM     DUMMY EVENTS IN LINE 3000.
 75 750 REM
 76 760 REM         THEN BEGINNING WITH THE FINAL EVENT AS NUMBER ONE,
 77 770 REM     ( 1 ), ENTER IN LINE 3001 THE FOLLOWING 8 PIECES OF
 78 780 REM     INFORMATION ABOUT THE EVENT IN THE ORDER INDICATED,
 79 790 REM     ALL ON LINE 3001.  REPEAT THIS SEQUENCE, ENTERING THE
 80 800 REM     8 PIECES OF DATA FOR EACH OF THE REMAINING EVENTS ON A
 81 810 REM     SINGLE LINE.  INCREMENT LINE NUMBERS BY 1 AFTER LINE
 82 820 REM     3001.
 83 830 REM
 84 840 REM     1) THE NUMBER OF THE EVENT'S FIRST IMMEDIATE
 85 850 REM        PREDECESSOR EVENT.
 86 860 REM
 87 870 REM     2) THE T(E) ASSOCIATED WITH THE ACTIVITY BOUNDED
 88 880 REM        BY THIS COMPLETION EVENT AND ITS FIRST
 89 890 REM        IMMEDIATE PREDECESSOR EVENT.
 90 900 REM
 91 910 REM     3) THE VARIANCE V(E) ASSOCIATED WITH THE ACTIVITY
 92 920 REM        BOUNDED BY THIS COMPLETION EVENT AND ITS FIRST
 93 930 REM        IMMEDIATE PREDECESSOR EVENT.
 94 940 REM
 95 950 REM     4) THE NUMBER OF THE EVENT'S SECOND IMMDEIATE
 96 960 REM        PREDECESSOR EVENT. IF NONE, ENTER ZERO.
 97 970 REM
 98 980 REM     5) THE T(E) ASSOCIATED WITH THE ACTIVITY BOUNDED BY
 99 990 REM        THIS COMPLETION EVENT AND ITS SECOND IMMEDIATE
100 1000 REM        PREDECESSOR EVENT.  IF NONE, ENTER ZERO.
101 1010 REM
102 1020 REM     6) THE VARIANCE V(E) ASSOCIATED WITH THE ACTIVITY
103 1030 REM        BOUNDED BY THIS COMPLETION EVENT AND ITS SECOND
104 1040 REM        IMMEDIATE PREDECESSOR EVENT. IF UNKNOWN, ENTER ZERO.
105 1050 REM
106 1060 REM     7) THE TE OF THE EVENT, WHERE KNOWN.
107 1070 REM        IF UNKNOWN, ENTER ZERO.
108 1080 REM
109 1090 REM     8) THE VARIANCE V ASSOCIATED WITH THE EVENT, WHERE
110 1100 REM        KNOWN.  IF UNKNOWN, ENTER ZERO.
111 1110 REM
112 1120 REM        THE LAST EVENT (ACTUALLY ENTERED FIRST, AS ABOVE)
113 1130 REM     MUST BE LABELED ONE.  THE OTHER EVENTS NEED NOT HAVE
114 1140 REM   ANY ORDER.  REMEMBER, WHEN ENTERING THE DATA THAT YOU
115 1150 REM     ENTER T (LINE 3000), THE 8 PIECES OF DATA FOR EVENT
116 1160 REM     1 (LINE 3001), THEN 8 FOR EVENT 2 (LINE 3002), THEN
117 1170 REM     8 FOR EVENT 3 (LINE 3003), ETC., IN STRICT
118 1180 REM     SEQUENTIAL EVENT NUMBER ORDER, REGARDLESS OF THE
119 1190 REM     PHYSICAL LAYOUT ORDER OF THE NETWORK EVENTS.
120 1200 REM
121 1210 REM     T(E) IS DEFINED AS;  T(E) = ( A + 4*M + B )/6, WHERE
122 1220 REM
123 1230 REM     A = MOST OPTIMISTIC TIME FOR COMPLETION OF THE ACTIVITY
124 1240 REM     B = MOST PESSEMISTIC TIME FOR COMPLETION OF THE
125 1250 REM         ACTIVITY
126 1260 REM     C = MOST LIKELY TIME FOR COMPLETION OF THE ACTIVITY
127 1270 REM
128 1280 REM     VARIANCE = V(E) = ((B-A)/6)^2, WHERE A AND B ARE
129 1290 REM     DEFINED AS ABOVE.
130 1300 REM
131 1310 REM
132 1320 REM          AT LEAST ONE EVENT IN THE NETWORK MUST HAVE ITS
133 1330 REM     EARLIEST COMPLETION TIME SPECIFIED ( I.E. AT LEAST
134 1340 REM     ONE EVENT'S TE MUST BE KNOWN.
135 1350 REM
136 1360 REM         IF HOWEVER, NO EVENT HAS A SPECIFIED TE, LET THE
137 1370 REM     THE TE OF THE INITIAL EVENT IN THE NETWORK BE
138 1380 REM     SPECIFIED AS ONE, ( 1 ).  THUS, THE INITIAL EVENT IN
139 1390 REM     THE NETWORK WOULD HAVE IN ITS SEVENTH DATA LOCATION
140 1400 REM     A ONE, INSTEAD OF A ZERO.  (IE, ASSUME EVENT NUMBER
141 1410 REM     9 IS THIS FIRST EVENT IN THE NETWORK AND STARTS AT
142 1420 REM     TIME ZERO, ITS DATA FORM WOULD LOOK LIKE
143 1430 REM     XXXX DATA ------0-, HOWEVER, FOR THE PROGRAM TO
144 1440 REM     OPERATE THE EVENT WOULD HAVE TO BE ASSIGNED AN
145 1450 REM     ARBITRARY TE, SAY 1, ITS CORRECT DATA STATEMENT
146 1460 REM     WOULD TAKE THE FORM,  XXXX DATA ------1-.
147 1470 REM
148 1480 REM
149 1490 REM          DON'T FORGET TO ENTER 'T', THE NUMBER OF EVENTS
150 1500 REM     IN THE NETWORK.  EACH EVENT IN THE NETWORK MUST HAVE
151 1510 REM     8 PIECES OF DATA ENTERED FOR IT.
152 1520 REM
153 1530 REM          IF THERE ARE MORE THAN TEN EVENTS IN THE NETWORK
154 1540 REM     ENTER A DIM STATEMENT IN LINE  1600 SUCH THAT E(T,13),
155 1550 REM     P(T) AND S(T) ARE DIMENSIONED, WHERE T=NUMBER OF EVENTS.
156 1560 REM     FOR EXAMPLE, IF YOUR NETWORK HAS 18 EVENTS, THE
157 1570 REM     DIM STATEMENT WOULD BE DIM E(18,13),P(18),S(18).
158 1580 REM     AFTER THE DATA HAS BEEN ENTERED, TYPE: RUN
159 1590 REM
160 1600 DIM E(10,13),P(10),S(10)
161 1610 REM T READ ALREADY AT FRONT OF PROGRAM
162 1620 FOR N= 1 TO T
163 1630 FOR I= 1 TO 8
164 1640 READ E(N,I)
165 1650 NEXT I
166 1660 FOR I= 9 TO 13
167 1670 LET E(N,I) = 0
168 1680 NEXT I
169 1690 NEXT N
170 1700 REM FIND TE
171 1710 FOR I= 1 TO T
172 1720 LET P(I) = 0
173 1730 NEXT I
174 1740 LET I = 1
175 1750 LET P(1)  = 1
176 1760 LET N = 1
177 1770 LET N = E(N,1)
178 1780 LET I = I + 1
179 1790 IF I>T THEN 2820
180 1800 LET P(I) = N
181 1810 IF E(N,7) = 0 THEN 1770
182 1820 LET I = I - 1
183 1830 IF I = 0 THEN 2200
184 1840 LET N = P(I)
185 1850 IF S(N) = 2 THEN 2040
186 1860 IF E(N,4) <> 0 THEN 1900
187 1870 LET E(N,7) = E(N,2) + E(P(I+1),7)
188 1880 LET E(N,8) =  E(N,3) + E(P(I+1),8)
189 1890 GO TO 1820
190 1900 LET A = E(P(I+1),7) + E(N,2)
191 1910 LET F = E(P(I+1),8) + E(N,3)
192 1920 LET N = E(N,4)
193 1930 LET I = I + 1
194 1940 LET P(I) = N
195 1950 IF E(N,7) <> 0 THEN 1980
196 1960 LET S(P(I-1)) = 2
197 1970 GO TO 1770
198 1980 LET I = I - 1
199 1990 IF I = 0 THEN 2100
200 2000 LET N=P(I)
201 2010 LET B = E(P(I+1),7) + E(N,5)
202 2020 LET G = E(P(I+1),8) + E(N,6)
203 2030 GO TO 2120
204 2040 LET B = E(P(I+1),7) + E(N,5)
205 2050 LET G = E(P(I+1),8) + E(N,6)
206 2060 LET N = E(N,1)
207 2070 LET C = E(N,7)
208 2080 LET H = E(N,8)
209 2090 LET N = P(I)
210 2100 LET A = C + E(N,2)
211 2110 LET F = H + E(N,3)
212 2120 IF A > B THEN 2160
213 2130 LET E(N,7) = B
214 2140 LET E(N,8) = G
215 2150 GO TO 1820
216 2160 LET E(N,7) = A
217 2170 LET E(N,8) = F
218 2180 GO TO 1820
219 2190 REM  FIND SUCCESSOR EVENTS AND RECORD TE'S
220 2200 FOR I = 1 TO T
221 2210 LET N = E(I,1)
222 2220 IF N = 0 THEN 2290
223 2230 IF E(N,9) <> 0 THEN 2270
224 2240 LET E(N,9) = I
225 2250 LET E(N,10) = E(I,2)
226 2260 GO TO 2290
227 2270 LET E(N,11) = I
228 2280 LET E(N,12) = E(I,2)
229 2290 LET N = E(I,4)
230 2300 IF N = 0 THEN 2370
231 2310 IF E(N,9) <> 0 THEN 2350
232 2320 LET E(N,9) = I
233 2330 LET E(N,10) = E(I,5)
234 2340 GO TO 2370
235 2350 LET E(N,11) = I
236 2360 LET E(N,12) = E(I,5)
237 2370 NEXT I
238 2380 REM  FIND TL
239 2390 LET E(1,13) = E(1,7)
240 2400 FOR K= 1 TO T
241 2410 IF E(K,13) = 0 THEN 2440
242 2420 NEXT K
243 2430 GOTO 2740
244 2440 LET N = K
245 2450 LET I = 1
246 2460 LET P(1) = N
247 2470 IF E(N,13) <> 0 THEN 2610
248 2480 LET A = E(N,9)
249 2490 IF E(A,13) = 0 THEN 2650
250 2500 LET B = E(N,11)
251 2510 IF B = 0 THEN 2600
252 2520 IF E(B,13) = 0 THEN 2690
253 2530 LET T1 = E(A,13) - E(N,10)
254 2540 LET T2 = E(B,13) - E(N,12)
255 2550 IF T1 < T2 THEN 2580
256 2560 LET E(N,13) = T2
257 2570 GO TO 2610
258 2580 LET E(N,13) = E(A,13) - E(N,10)
259 2590 IF I = 1 THEN 2400
260 2600 LET E(N,13) = E(A,13) - E(N,10)
261 2610 IF I = 1 THEN 2400
262 2620 LET I = I - 1
263 2630 LET N = P(I)
264 2640 GO TO 2470
265 2650 LET N = A
266 2660 LET I = I + 1
267 2670 LET P(I) = N
268 2680 GO TO 2470
269 2690 LET N = B
270 2700 LET I = I + 1
271 2710 LET P(I) = N
272 2720 GO TO 2470
273 2730 REM PRINT RESULTS
274 2740 PRINT "EVENT NUMBER";TAB(22);"TE";TAB(38);"V";TAB(54);"TL";
275 2750 PRINT TAB(62);"TOTAL SLACK"
276 2760 PRINT "----- ------";TAB(22);"--";TAB(38);"-";TAB(54);"--";
277 2770 PRINT TAB(62);"----- -----"
278 2780 PRINT
279 2790 FOR N = T TO 1 STEP -1
280 2800 PRINT USING " -####            -####.#        -####.#         -####.#      -####.#",N,E(N,7),E(N,8),E(N,13),E(N,13)-E(N,7)
281 2810 NEXT N
282 2815 STOP
283 2820 PRINT "DATA NOT CONSISTENT--OR NO TE SPECIFIED"
284 2830 STOP
285 3000 DATA 4E36
286 9999 END