-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspgSetParms.m
165 lines (153 loc) · 5.7 KB
/
spgSetParms.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
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
function options = spgSetParms(varargin)
%SPGSETPARMS Set options for SPGL1
%
% options = spgSetParms('param1',val1,'param2',val2,...) creates an
% options structure in which the named parameters have the specified
% values. Unspecified parameters are empty and their default
% values are used.
%
% spgSetParms with no input arguments and no output arguments
% displays all parameter names and their possible values.
%
% options = spgSetParms (with no input arguments) creates an options
% structure where all the fields are empty.
%
% spgSetParms.m
% $Id: spgSetParms.m 70 2012-06-28 23:41:39Z saravkin $
% Print out possible values of properties.
if nargin == 0 && nargout == 0
fprintf(' Default parameters for l1Set.m:\n');
fprintf(' fid : [ positive integer | 1 ]\n');
fprintf(' verbosity : [ integer: 1, 2, or 3 | 3 ]\n');
fprintf(' iterations : [ positive integer | 10*m ]\n');
fprintf(' nPrevVals : [ positive integer | 10 ]\n');
fprintf(' bpTol : [ positive scalar | 1e-06 ]\n');
fprintf(' lsTol : [ positive scalar | 1e-06 ]\n');
fprintf(' optTol : [ positive scalar | 1e-04 ]\n');
fprintf(' decTol : [ positive scalar | 1e-04 ]\n');
fprintf(' stepMin : [ positive scalar | 1e-16 ]\n');
fprintf(' stepMax : [ positive scalar | 1e+05 ]\n');
fprintf(' rootMethod : [ 1=linear, 2=quadratic | 2 ]\n');
fprintf('activeSetIt : [ positive integer | Inf ]\n');
fprintf('subspaceMin : [ 0=no, 1=yes | 0 ]\n');
fprintf(' iscomplex : [ 0=no, 1=yes, NaN=auto | NaN ]\n');
fprintf(' maxMatvec : [ positive integer | Inf ]\n');
fprintf(' weights : [ vector | 1 ]\n');
fprintf(' project : [ projection function | @()]\n');
fprintf('primal_norm : [ primal norm eval fun | @()]\n');
fprintf(' dual_norm : [ dual norm eval fun | @()]\n');
fprintf(' Kaczmarz : [ 0=no, 1=proj, 2=rtfind | 0 ]\n');
fprintf(' KaczScale : [ positive scalar | 1 ]\n');
fprintf(' quitPareto : [ 0=no, 1=yes | 0 ]\n');
fprintf(' minPareto : [ positive integer | 3 ]\n');
fprintf(' lineSrchIt : [ positive integer | 1 ]\n');
fprintf(' feasSrchIt : [ positive integer | 10000 ]\n');
fprintf(' ignorePErr : [ 0=no, 1=yes | 0 ]\n');
fprintf(' funPenalty : [ function | funLS]\n');
fprintf(' proxy : [ 0=no, 1=yes | 0 ]\n');
fprintf(' linear : [ 0=no, 1=yes | 0 ]\n');
fprintf(' restore : [ 0=no, 1=yes | 0 ]\n');
fprintf('\n');
return;
end
Names = [
'fid '
'verbosity '
'iterations '
'nPrevVals '
'bpTol '
'lsTol '
'optTol '
'decTol '
'stepMin '
'stepMax '
'rootMethod '
'activeSetIt '
'subspaceMin '
'iscomplex '
'maxMatvec '
'weights '
'Kaczmarz '
'KaczScale '
'quitPareto '
'minPareto '
'lineSrchIt '
'feasSrchIt '
'ignorePErr '
'project '
'primal_norm '
'dual_norm '
'funPenalty '
'proxy '
'linear '
'restore '
];
[m,n] = size(Names);
names = lower(Names);
% Combine all leading options structures o1, o2, ... in l1Set(o1,o2,...).
options = [];
for j = 1:m
eval(['options.' Names(j,:) '= [];']);
end
i = 1;
while i <= nargin
arg = varargin{i};
if ischar(arg), break; end
if ~isempty(arg) % [] is a valid options argument
if ~isa(arg,'struct')
error(sprintf(['Expected argument %d to be a string parameter name ' ...
'or an options structure\ncreated with OPTIMSET.'], i));
end
for j = 1:m
if any(strcmp(fieldnames(arg),deblank(Names(j,:))))
eval(['val = arg.' Names(j,:) ';']);
else
val = [];
end
if ~isempty(val)
eval(['options.' Names(j,:) '= val;']);
end
end
end
i = i + 1;
end
% A finite state machine to parse name-value pairs.
if rem(nargin-i+1,2) ~= 0
error('Arguments must occur in name-value pairs.');
end
expectval = 0; % start expecting a name, not a value
while i <= nargin
arg = varargin{i};
if ~expectval
if ~ischar(arg)
error(sprintf('Expected argument %d to be a string parameter name.', i));
end
lowArg = lower(arg);
j = strmatch(lowArg,names);
if isempty(j) % if no matches
error(sprintf('Unrecognized parameter name ''%s''.', arg));
elseif length(j) > 1 % if more than one match
% Check for any exact matches (in case any names are subsets of others)
k = strmatch(lowArg,names,'exact');
if length(k) == 1
j = k;
else
msg = sprintf('Ambiguous parameter name ''%s'' ', arg);
msg = [msg '(' deblank(Names(j(1),:))];
for k = j(2:length(j))'
msg = [msg ', ' deblank(Names(k,:))];
end
msg = sprintf('%s).', msg);
error(msg);
end
end
expectval = 1; % we expect a value next
else
eval(['options.' Names(j,:) '= arg;']);
expectval = 0;
end
i = i + 1;
end
if expectval
error(sprintf('Expected value for parameter ''%s''.', arg));
end