-
Notifications
You must be signed in to change notification settings - Fork 0
/
f1dim.m
49 lines (40 loc) · 909 Bytes
/
f1dim.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
function varargout = f1dim(varargin)
%F1DIM wrapper d'une fonction ND vers une fonction 1D
%
% output = f1dim(input)
%
% Example
% f1dim
%
% See also
%
%
% ------
% Author: David Legland
% e-mail: [email protected]
% Created: 2010-08-10, using Matlab 7.9.0.529 (R2009b)
% Copyright 2010 INRA - Cepia Software Platform.
% number of iterations
N = 200;
% base search vectors
e1 = [1 0];
e2 = [0 1];
% initial point
x0 = [0 0];
% init result
trace = zeros(N, 2);
trace(1,:) = x0;
% main loop
for i=2:2:N
% find minimim for vector 1
x0 = trace(i-1, :);
tmin = brentLineSearch(@(t)(fun(x0+t*e1)), -10, 0, 10, 1e-5);
% update current point
x0 = x0 + tmin*e1;
trace(i,:) = x0;
% find minimim for vector 2
tmin = brentLineSearch(@(t)(fun(x0+t*e2)), -10, 0, 10, 1e-5);
% update current point
x0 = x0 + tmin*e2;
trace(i+1,:) = x0;
end