-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBundle.m
121 lines (96 loc) · 2.42 KB
/
Bundle.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
function [ xk, Xs, asCounter, nsCounter ] = Bundle( funct, x0, params )
% Bundle Algorithm to solve nonsmooth, convex problem
% params include in this order
%
% Stepsize parameters
% 0 < m1 < m2 < 1
% 0 < m3 < 1
%
% Break conditions
% 0 < epsilonLow
% 0 < eta
%
% Maximal size of bundle
% 3 < bundleMaxSize
%
% Page 128
m1 = params(1);
m2 = params(2);
m3 = params(3);
epsilonLow = params(4);
eta = params(5);
bundleMaxSize = params(6);
maxSteps = params(7);
% assuming f(xStar) is somewhere near zero
epsilonHigh = 2;
Bundle = Subgradient(funct, x0);
Alphas = 0;
k = 1;
xk = x0;
Xs(:,k) = xk;
nsCounter = 0;
asCounter = 0;
epsilonK = epsilonHigh;
%First Iteration
dk = -Bundle; %s1
[tk, ykPlus, skPlus, alphakPlus, outcome, fxdMinusfx] = Schrittweite622(funct, xk, dk, [epsilonK*m3 m1 m2]);
if outcome == 1
xkNext = ykPlus;
epsilonK = ChooseNextEpsilon(epsilonK);
asCounter = asCounter + 1;
else
xkNext = xk;
nsCounter = nsCounter + 1;
end
[Bundle, Alphas] = UpdateBundlePlus(Bundle, Alphas, outcome, fxdMinusfx, tk*dk, skPlus, alphakPlus);
k = k+1;
xk = xkNext;
Xs(:,k) = xk;
while k < maxSteps
%1
epsilonK = ClipTo(epsilonK, epsilonLow, epsilonHigh);
%2
[betaTilde] = SolveQS(epsilonK, Bundle, Alphas);
sTildeK = Bundle * betaTilde;
alphaTildeK = dot(betaTilde, Alphas);
%3
if( norm(sTildeK) <= eta)
if(alphaTildeK <= epsilonLow )
break;
else
epsilonHigh = max(0.1*alphaTildeK, epsilonLow);
continue;
end
end
%4
dk = -sTildeK;
[tk, ykPlus, skPlus, alphakPlus, outcome, fxdMinusfx] = Schrittweite622(funct, xk, dk, [epsilonK*m3 m1 m2]);
if outcome == 1
xkNext = ykPlus;
epsilonK = ChooseNextEpsilon(epsilonK);
asCounter = asCounter + 1;
else
xkNext = xk;
nsCounter = nsCounter + 1;
end
%5
[Bundle, Alphas] = UpdateBundleFull(Bundle, Alphas, outcome, bundleMaxSize, fxdMinusfx, tk*dk, sTildeK, alphaTildeK, skPlus, alphakPlus);
%6
k = k+1;
xk = xkNext;
Xs(:,k) = xk;
end
%subprocedures
function clip = ClipTo(x, low, high)
if x < low;
clip = low;
elseif x>high
clip = high;
else
clip = x;
end
end
function new = ChooseNextEpsilon(old)
new = 0.1*old;
end
end