-
Notifications
You must be signed in to change notification settings - Fork 1
/
backtr_circ.m
85 lines (74 loc) · 3.62 KB
/
backtr_circ.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
function [alpha] = backtr_circ(alpha_guess, q, r)
%% BACKTRACKING ARMIJO-TYPE
% DESCRIPTION:
% Search method along a coordinate axis in which the search should be conducted
% in both directions of the axis. It should also take into account the fact that
% one direction dk can be assigned such that alpha=0 represents a
% local minimum point of the function g(alpha)=F(xk+alpha*dk), for which
% may not be able to find positive or negative values ??of alpha
% close to 0 for which g(alpha)<g(0). If you do not want to use any
% derivative, numerical "finished" procedures must define can
% discriminate the situation. The model presented is an outline
% Backtracking Armijo-type, based on the condition of acceptability of type "Parabolic".
%
% function [alpha] = backtr(alpha_guess,Xk,dk,F,gamma,delta,rhok)
% INPUT:
% NOTE: (*) indicates necessary input, the other variables are optional
% (*) alpha _guess - current steplength (1*1) [>0];
% (*) Xk - current iterate (N*1);
% (*) dk - search direction (N*1);
% gamma - constant provided by the user (1*1) [>0];
% delta - constant provided by the user (1*1) into the range [0, 1];
% rhok - constant provided by the user (1*1) into the range [0, 1];
% (*) F - function handle of the objective function (RN->R );
% OUTPUT:
% alpha - value of alpha whether the condition holds (1*1);
% REVISION:
% Ennio Condoleo - 21.15 13 Feb 2014
% REFERENCE:
% http://books.google.it/books?id=wXyLzZahvmsC&pg=PA123&lpg=PA123&dq=ottimizzazione+unidimensionale+senza+derivata&source=bl&ots=p5Be0KpbtX&sig=tLnygv0XZwzQYHoyPPfCZ2-e4C4&hl=it&sa=X&ei=CfL7UqfpFcXRhAfujYHIBA&ved=0CDQQ6AEwAQ#v=onepage&q=ottimizzazione%20unidimensionale%20senza%20derivata&f=false
gamma = 1e-4;
delta = 0.5;
rhok = 1e-5;%1e-8;
% positive direction (+)alpha
alpha = alpha_guess;
[f,dk] = costfun_circular(r,q);
[fnew,~] = costfun_circular(r,q+alpha*dk); %compute F(Xk+alpha.*dk)
check = fnew > f-gamma*alpha^2*norm(dk); %test F(Xk+alpha.*dk)>F(Xk)-gamma*alpha^2*(norm(dk))^2
while (check)
if (alpha*norm(dk) < rhok)
alpha = 0; % <-- failure to search for a value of alpha nonzero
else
alpha = alpha*delta; % <-- reduction of the steplength
end
%update
[fnew,~] = costfun_circular(r,q+alpha*dk); %compute F(Xk+alpha.*dk)
check = fnew > f-gamma*alpha^2*norm(dk);
end
alpha1 = alpha;
F1 = fnew-(f-gamma*alpha1^2*(norm(dk))^2);
% negative direction (-)alpha
alpha = alpha_guess;
[f,dk] = costfun_circular(r,q);
[fnew,~] = costfun_circular(r,q+alpha*dk); %compute F(Xk+alpha.*dk)
check = fnew > f-gamma*alpha^2*norm(dk); %test F(Xk+alpha.*dk)>F(Xk)-gamma*alpha^2*(norm(dk))^2
while (check)
if (alpha*norm(dk) < rhok)
alpha = 0; % <-- failure to search for a value of alpha nonzero
else
alpha = alpha*delta; % <-- reduction of the steplength
end
%update
f = fnew;
[fnew,~] = costfun_circular(r,q-alpha*dk); %compute F(Xk+alpha.*dk)
check = fnew > f-gamma*alpha^2*norm(dk);
end
alpha2 = alpha;
F2 = fnew-(f-gamma*alpha2^2*(norm(dk))^2);
% choice of the value of alpha for which it is provided with sufficient reduction
if (F1<F2)
alpha = alpha1;
else
alpha = alpha2;
end
end