This repository has been archived by the owner on Dec 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_simplex.m
executable file
·64 lines (56 loc) · 1.88 KB
/
create_simplex.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
function [X] = create_simplex(strategy, x0)
% -- [X] = create_simplex(strategy, x0)
%
% Create initial simplex using selected strategy. There are multiple
% methods identified by `strategy` parameter:
%
% '0': Default Matlab strategy using L. Pfeffer suggestion (see [1]).
%
% '1': Regular simplex as constructed by Jacoby, Kowalik and Pizzo (see
% pages 80-81 of [2]).
%
% '2': Right-angled simplex generated by adding scaled unit vector along
% all dimensions.
%
% References:
% [1] Fan, E. Global optimization of Lennard-Jones atomic clusters. MASTER
% OF SCIENCE. McMaster University, COMPUTING & SOFTWARE, Hamilton,
% Ontario, 2002.
% [2] Jacoby, S. L., Kowalik, J. S., & Pizzo, J. T. (1972). Iterative
% methods for nonlinear optimization problems.
% Use column vector in computations
x0 = x0(:);
N = length(x0);
switch strategy
% Pfeffer method
case 0
usual_delta = 0.05;
zero_term_delta = 0.0075;
X(:,1) = x0;
for i=1:N
x = x0;
if x(i) ~= 0
x(i) = (1 + usual_delta)*x0(i);
else
x(i) = zero_term_delta;
end
X(:,i+1) = x;
end
% Regular simplex
case 1
s = max(1, norm(x0, Inf));
alpha = ([1, 1] * (sqrt(N+1) - 1) + [N, 0]) * s / (N * sqrt(2));
X = [x0, zeros(N)];
X(:,2:end) = repmat(x0 + alpha(2), 1, N);
for i=2:N+1
X(i-1,i) = x0(i-1) + alpha(1);
end
% Right-angled simplex
case 2
s = max(1, norm(x0, Inf));
X = repmat(x0, 1, N+1);
X(:,2:end) = X(:,2:end) + s*eye(N);
otherwise
error('Unknown simplex creation strategy.');
end
end