Trailing-Edge
-
PDP-10 Archives
-
decuslib10-01
-
43,50110/hook.eng
There are 2 other files named hook.eng in the archive. Click here to see a list.
100' NAME--HOOK
110'
120' DESCRIPTION--DOES A HOOKE-JEEVES PATTERN SEARCH.
130'
140' SOURCE--DESCRIBED IN SECTION 7-08 OF WILDE AND BEIGHTLER,
150' "FOUNDATIONS OF OPTIMIZATION",PP.307-310.
160'
170' INSTRUCTIONS--PRESENTLY THE PROGRAM IN LIMITED TO FOUR INDEPENDENT
180' VARIABLES, X1,X2,X3,X4.
190' THE DATA REQUIRED AND THE APPROPRIATE LINE NUMBERS ARE AS FOLLOWS:
200' 370 LET X1=?
210' 380 LET X2=?
220' 390 LET X3=?
230' 400 LET X4=?
240' 410 LET D1=?
250' 420 LET D2=?
260' 430 LET D3=?
270' 440 LET D4=?
280' 1570 LET F=? (FUNCTION OF X1,X2,X3,X4)
290'
300'
310' * * * * * * * MAIN PROGRAM * * * * * * * * * * *
320'
330 LET P1=0
340 LET P2=0
350 LET P3=0
360 LET P4=0
370 LET X1=-1.2' X1,X2,X3,X4 ARE THE INTIAL BASE POINTS
380 LET X2= 1
390 LET X3=1
400 LET X4=2
410 LET D1=.1 ' D1,D2,D3,D4 ARE THE INITIAL STEP SIZES
420 LET D2=.1
430 LET D4=.1
440 LET D3=.1
450 DIM P(300,4)
460 LET P(0,1)=X1
470 LET P(0,2)=X2
480 LET P(0,3)=X3
490 LET P(0,4)=X4
500 GO SUB 1570
510 LET F0=F
520 '***************************************************************
530 FOR I= 1 TO 290
540 GO SUB 1570
550 IF F>F0 THEN 580
560 LET F0=F
570 GO TO 620
580 LET P1=X1
590 LET P2=X2
600 LET P3=X3
610 LET P4=X4
620 LET X0 = X1
630 LET X1=X1+D1
640 GO SUB 1570
650 IF F>F0 THEN 680
660 LET F0 = F
670 GO TO 750
680 LET X1=X0
690 LET X1=X1-D1
700 GO SUB 1570
710 IF F> F0 THEN 740
720 LET F0= F
730 GO TO 750
740 LET X1 = X0
750 LET X0=X2
760 LET X2= X2+D2
770 GO SUB 1570
780 IF F> F0 THEN 810
790 LET F0 = F
800 GO TO 880
810 LET X2= X0
820 LET X2= X2-D2
830 GO SUB 1570
840 IF F>F0 THEN 870
850 LET F0=F
860 GO TO 880
870 LET X2= X0
880 LET X0= X3
890 LET X3= X3+D3
900 GO SUB 1570
910 IF F>F0 THEN 940
920 LET F=F0
930 GO TO 1010
940 LET X3=X0
950 LET X3= X3-D3
960 GO SUB 1570
970 IF F>F0 THEN 1000
980 LET F0= F
990 GO TO 1010
1000 LET X3= X0
1010 LET X0= X4
1020 LET X4= X4+D4
1030 GO SUB 1570
1040 IF F> F0 THEN 1070
1050 LET F0=F
1060 GO TO 1270
1070 LET X4= X0
1080 LET X4= X4-D4
1090 GO SUB 1570
1100 IF F>F0 THEN 1130
1110 LET F0=F
1120 GO TO 1270
1130 LET X4=X0
1140 ' ************END OF ABOVE DESCRIBED ROUTINE***************
1150 ' THE FOLLOWING TWO TESTS DETERMINE IF THE NEW BASE POINT OR
1160 ' ANY OF ITS SURROUNDING PERTURBATIONS ARE BETTER THAN THE LAST
1170 ' BASE POINT. IF NOT THEN A NEW BASE POINT MUST BE CALCU-
1180 ' LATED USING A SMALLER STEP SIZE.
1190 IF P1<>X1 THEN 1270
1200 IF P2<>X2 THEN 1270
1210 IF P3<> X3 THEN 1270
1220 IF P4<> X4 THEN 1270
1230 LET X1= P(I-1,1)
1240 LET X2= P(I-1,2)
1250 LET X3= P(I-1,3)
1260 LET X4= P(I-1,4)
1270 LET P(I,1)=X1
1280 LET P(I,2)=X2
1290 LET P(I,3)=X3
1300 LET P(I,4)=X4
1310 ' THE FOLLOWING FOUR STATEMENTS CALCULATE AND ASSIGN
1320 ' VALUES TO THE NEW BASE POINT.
1330 FOR J= 1 TO 4
1340 LET P(I+1,J)=2*P(I,J)-P(I-1,J)
1350 NEXT J
1360 LET X1= P(I+1,1)
1370 LET X2= P(I+1,2)
1380 LET X3=P(I+1,3)
1390 LET X4= P(I+1,4)
1400 IF D1<.0001 THEN 1510
1410 ' THE NEXT FOUR STATMENTS REDUCE THE STEP SIZE IF THE PRECEEDING
1420 ' SEARCH DID NOT FIND A NEW MINIMUM.
1430 FOR J= 1 TO 4
1440 IF P(I+1,J)<>P(I,J) THEN 1500
1450 NEXT J
1460 LET D1=D1/2
1470 LET D2=D2/2
1480 LET D4= D4/2
1490 LET D3= D3/2
1500 NEXT I
1510 PRINT "MINIMUM OF FUNCTION IS"F0
1520 PRINT "COORDINATES ARE"X1;X2;X3;X4
1530 PRINT " FINAL STEP SIZES ARE"D1;D2;D3;D4
1540 PRINT
1550 PRINT"IT";I
1560 GO TO 1590
1570 LET F= (X1+10*X2)^2+5*(X3-X4)^2+(X2-2*X3)^4+10*(X1-X4)^4
1580 RETURN
1590 END