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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
% STK_OPTIONS_SET sets the value of one or all STK options
%
% CALL: stk_options_set ('default')
%
% resets STK's default options.
%
% CALL: stk_options_set (OPTS)
%
% sets all options at once using the option structure OPTS. Such a
% structure can be obtained from stk_options_get.
%
% CALL: stk_options_set (BLOCKNAME, OPTS)
%
% sets all the options from a block BLOCKNAME, using the option
% structure OPTS. Such a structure can be obtained from
% stk_options_get as well.
%
% CALL: stk_options_set (BLOCKNAME, OPTNAME, OPTVAL)
%
% sets options BLACKNAME.OPTNAME to the value OPTVAL.
%
% CALL: OPTS = stk_options_set (...)
%
% returns the modified option structure, containing all STK's options.
%
% See also: stk_options_get
% Copyright Notice
%
% Copyright (C) 201 CentraleSupelec
% Copyright (C) 2015-2017 CentraleSupelec
% Copyright (C) 2014 SUPELEC & A. Ravisankar
% Copyright (C) 2013 SUPELEC
%
% Authors: Julien Bect <julien.bect@centralesupelec.fr>
% Ashwin Ravisankar <ashwinr1993@gmail.com>
% Copying Permission Statement
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (http://sourceforge.net/projects/kriging)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.
function opts = stk_options_set (varargin)
persistent options
if isempty (options)
options = init_options ();
mlock;
end
switch nargin
case 0 % nothing to do, just return the output
case 1 % reset
if (ischar (varargin{1})) && strcmp (varargin{1}, 'default')
options = init_options ();
elseif isstruct (varargin{1})
options = varargin{1};
else
stk_error ('Syntax error', 'SyntaxError');
end
case 2
switch varargin{1}
case 'stk_sf_matern'
% TODO: Remove this warning in STK 3.x
warning (sprintf([ ...
'stk_sf_matern and the corresponding options have been ' ...
'deprecated.\n\nPlease use stk_rbf_matern instead.\n']));
options.stk_rbf_matern = varargin{2};
otherwise
options.(varargin{1}) = varargin{2};
end
case 3
switch varargin{1}
case 'stk_param_estim'
if strcmp (varargin{2}, 'optim_display_level')
% TODO: Remove this warning in STK 3.x
warning (sprintf ([ ...
'Options stk_param_estim.optim_display_level has ' ...
'been removed.\n\nDisplay options for optimization ' ...
'algorithms can be set through the properties of ' ...
'the algorithm objects instead.\n']));
else
options.stk_param_estim.(varargin{2}) = varargin{3};
end
case 'stk_sf_matern'
% TODO: Remove this warning in STK 3.x
warning (sprintf([ ...
'stk_sf_matern and the corresponding options have been ' ...
'deprecated.\n\nPlease use stk_rbf_matern instead.\n']));
options.stk_rbf_matern.(varargin{2}) = varargin{3};
otherwise
options.(varargin{1}).(varargin{2}) = varargin{3};
end
otherwise
stk_error ('Incorrect number of input arguments.', 'SyntaxError');
end
if nargout > 0
opts = options;
end
end % function
%#ok<*CTCH,*SPWRN>
function opts = init_options ()
opts = struct ();
opts.stk_rbf_matern.min_size_for_parallelization = 1e5;
opts.stk_rbf_matern.min_block_size = 1e3;
opts.stk_dataframe.disp_format = 'basic'; % 'basic' or 'verbose'
opts.stk_dataframe.disp_spstr = ' ';
opts.stk_dataframe.openvar_warndlg = true;
opts.stk_param_getdefaultbounds.tolvar = 5.0;
opts.stk_param_getdefaultbounds.tolscale = 5.0;
opts.stk_param_getdefaultbounds.nu_min_dimfun = @(d) 0.5;
opts.stk_param_getdefaultbounds.nu_max_dimfun = @(d) min (50.0, 10 * d);
opts.stk_figure.properties = {'InvertHardcopy', 'off', 'Color', [1 1 1]};
opts.stk_xlabel.properties = {'FontSize', 10, 'Color', [0.2 0 1]};
opts.stk_ylabel.properties = opts.stk_xlabel.properties;
opts.stk_zlabel.properties = opts.stk_xlabel.properties;
opts.stk_title.properties = {'FontSize', 10, 'FontWeight', 'bold'};
opts.stk_axes.properties = {'FontSize', 8};
% Select optimizer for stk_param_estim
if exist ('OCTAVE_VERSION', 'builtin') == 5
% In Octave we use sqp (which is always available) in both cases
opts.stk_param_estim.minimize_box = stk_optim_octavesqp ();
opts.stk_param_estim.minimize_unc = stk_optim_octavesqp ();
else
A_fminsearch = stk_optim_fminsearch ();
try
% See if the Mathworks' Optimization toolbox is installed
opts.stk_param_estim.minimize_box = stk_optim_fmincon ();
opts.stk_param_estim.minimize_unc = A_fminsearch; % FIXME: use fminunc !
check_both (opts.stk_param_estim);
catch
try
% See sqp can be used with MOSEK's quadprog
% (or any other compatible replacement for quadprog)
A = stk_optim_octavesqp (struct ('qp_solver', 'quadprog'));
opts.stk_param_estim.minimize_box = A;
opts.stk_param_estim.minimize_unc = A;
check_both (opts.stk_param_estim);
catch
opts.stk_param_estim.minimize_box = A_fminsearch;
opts.stk_param_estim.minimize_unc = A_fminsearch;
end
end
end
end % function
function check_both (opts)
assert (stk_optim_testmin_box (opts.minimize_box));
assert (stk_optim_testmin_unc (opts.minimize_unc));
end % function
|