-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectedBacktrackingSearch.m
More file actions
65 lines (51 loc) · 1.78 KB
/
projectedBacktrackingSearch.m
File metadata and controls
65 lines (51 loc) · 1.78 KB
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
function [t] = projectedBacktrackingSearch(f, P, x, d, sigma, verbose)
%PROJECTEDBACKTRACKINGSEARCH Find stepsize t get sufficient decrease for multidimensional objective along line
%% Purpose:
% Find t to satisfy f(x+t*d)< f(x) - sigma/t*norm(x-P(x - t*gradient))^2
%% Input Definition:
% f: function handle of type [value, gradient] = f(x).
% P: box projection handle of type [projectedX] = P(x).
% x: column vector in R^n (domain point)
% d: column vector in R^n (search direction)
% sigma: value in (0,1), marks quality of decrease. Default value:
% 1.0e-4.
% verbose: bool, if set to true, verbose information is displayed
%% Output Definition:
% t: t is set to the biggest 2^m, such that 2^m satisfies the projected sufficient decrease condition
%% Required files:
% <none>
%% Test cases:
% [t]=projectedBacktrackingSearch(@(x)simpleValleyObjective(x,[1;1]), @(x)projectionInBox(x,[-2;1],[2;2],1.0e-6),[1;1], [-1.99;0], 0.5, true);
% should return
% t=0.5;
%% Input verification:
try
xk=P(x);
[value, gradient] = f(xk);
catch
error('evaluation of function handle or projection handle failed!');
end
if (gradient'*d>= 0)
error('descent direction check failed!');
end
if (sigma <= 0 || sigma >= 1)
error('range of sigma is wrong!');
end
if nargin < 6
verbose = false;
end
%% Implementation:
if verbose
disp('Start projectedBacktrackingSearch...');
end
beta = 0.5;
t = 1;
phi=@(t)(f(P(xk+t*d)));
f_x = phi(0);
while (phi(t) > f_x - sigma/t * norm(xk - P(xk - t* gradient))^2 )
t = t * beta;
end
if verbose
disp(sprintf('projectedBacktrackingSearch terminated with t=%d',t));
end
end