488
XLOW[I]:=X(I]+TLOW*D[I];XUP[I]:=X[I]+TUP*D[I];GANTe[I]:=GRAD[I];
END;
XUP[ 1 ]:=X| 1 ]‘,XLOW[ 1J:=X[1 );XUP[4]:=X[4];XLOW[4]:=X[4]; FU:=Fun(XUP);FL:=Fun(XLOW);GRA(XLOW);S:=0.0;
FOR I:=2 TO N DO S:=S+Grad[I]*DELTA*D[I],
TM :=TLOW-(DELT A*S)/(2*(FU-FL-S));
REFINE:=MIN(MAX(TM,TLOW+0.2*DELTA),TUP-0.2*DELTA);
FOR I:=2 TO N DO GRAD[I]:=GANTe(I],
END;
BEGIN {♦*** GOLDSTEIN-ARMIJO **•*}
ALPHA;=1.0; {** sińce D has been normalized to max step size **} DONE:=FALSE;count:=0;ALPHAUP:=INF;ALPHALOW:=0.0;
REPEAT
count:=count+l;C:=0.0;
FOR I:=2 TO N DO begin
XK1[I]:=X[I]+ALPHA*D[I];C:=C+ALPHA*G[I]*D[I];GANT[I]:=G[IJ;
end;
xkl[4]:=x[4];xkl[ 1 ]:=x[ 1 ];FXK 1 :=Fun(XKl );GRA(xkl );Su:=0.0; for i:=2 to n do
begin su:=su+alpha*grad[i]*d[i];grad[i]:=gant[i]; end;
IF FXKl<(FN+EPSILON*C) THEN IF abs(SU) >= abs(beta*C) THEN
BEGIN DONE:=TRUE;GOLDSTEIN_ARMIJO:=ALPHA;END
ELSE
BEGIN
ALPHALOW:=ALPHA;
IF ALPHAUP>=INF THEN ALPHA:=ALPHA*2.0 ELSE ALPHA:=REFINE( ALPHA, ALPHALOW.ALPHAUP);
END
ELSE
BEGIN
ALPHAUP:=ALPHA;
IF ALPHALOW=0.0 THEN ALPHA:=MAX((-ALPHA*C)/(2.0*(FXK1-FN-C)),0.1*ALPHA) ELSE ALPHA:=REFINE(ALPHA,ALPHALOW,ALPHAUP)
END;
if count>=max_it then begin done:=true; goldstein_armijo:=aIpha;end;
UNTIL DONE;
END; {GOLDSTEIN ARMIJO}
PROCEDURĘ UPDATE_H(VAR H:NXN;P,Q:NX1);
VAR I,J:INTEGER;gamma,A,E:EXTENDED;B,D:NXl;C:NXN;
BEGIN
A:=0.0;E:=0.0;
FOR I:=2 TO N DO BEGIN
A:=A+Q[I]*P[I];B[I]:=0.0;D[I]:=0.0;
FOR J:=2 TO N DO BEGIN
B[I]:=B[I]+H[I,J]*Q[J];D[I]:=D[I]+Q[J]*H[J,I];C[1,J]:=P[I]*P[J]
END;
E:=E+Q[I]*B[I]