-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSchrittweite622.m
75 lines (60 loc) · 1.37 KB
/
Schrittweite622.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function [ tauJ, xPlus, sPlus, alphaPlus, outcome, fxdMinusfx ] = Schrittweite622( functionObject, x, d, params, outputPropertiesObj )
%Page 111
epsilonTilde = params(1);
m1 = params(2);
m2 = params(3);
funct = @functionObject.getValueAt;
%ToDo: what to do with v?
v = DirectionalDerivative(funct,x,d);
if v >= 0
v = -v;
end
tauLow = 0;
tauHigh = Inf;
tauJ = 1;
j=0;
maxIter = 30;
while j < maxIter
%LS1
xPlus = x + tauJ*d;
fx = funct(x);
fxd = funct(xPlus);
fxdMinusfx = fxd - fx;
sPlus = functionObject.getSubgradientAt(xPlus);
alphaPlus = - fxdMinusfx + dot(sPlus, tauJ*d);
%LS2
if dot(sPlus, d) >= m2*v && alphaPlus <= epsilonTilde
outcome = -1;
break;
end
%LS3
if dot(sPlus, d) >= m2*v && fxdMinusfx <= m1*tauJ*v
outcome = 1;
break;
end
%LS4
if fxdMinusfx >= m1*tauJ*v
tauHigh = tauJ;
tauJ = Interpol(tauLow, tauHigh);
else
tauLow = tauJ;
if tauHigh == Inf
tauJ = Extrapol(tauJ);
else
tauJ = Interpol(tauLow, tauHigh);
end
end
if outputPropertiesObj.showTauJ
fprintf('Tauj: %.3e\n', tauJ);
end
%LS5
j=j+1;
end
% Subprocedures
function res = Interpol(x,y)
res = (x+y)*0.5;
end
function res = Extrapol(x)
res = 2*x;
end
end