📄 param.m
字号:
function OPTION=param(varargin)
%
% Create SDPA parameters.
% If there is no argument, default parameters are returned.
%
% OPTION=param(field1,value1,field2,value2,....)
%
% <INPUT>
% - field?: string : field name
% - value?: numeric or string :
%
% <OUTPUT>
% - OPTION: structure data: each field is as follows:
% * maxIteration : The maximum number of iterations.
% * epsilonStar : The accuracy of an approximate optimal solution
% for primal and dual SDP.
% * lambdaStar : An initial point.
% * omegaStar : The search region for an optimal solution.
% * lowerBound : Lower bound of the minimum objective value of
% the primal SDP.
% * upperBound : Upper bound of the maximum objective value of
% the dual SDP
% * betaStar : The parameter for controlling the search direction
% if the current point is feasible.
% * betaBar : The parameter for controlling the search direction
% if the current point is infeasible.
% * gammaStar : A reduction factor for the primal and dual step
% lengths.
% * epsilonDash : The relative accuracy of an approximate optimal
% solution between primal and dual SDP.
% * isSymmetric : The flag for the checking the symmetricity of input
% matrices. (0 => no check, 1=> check)
% * print : Destination of file output. the default setting is
% stdout.
% This file is a component of SDPA
% Copyright (C) 2004 SDPA Project
%
% This program 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 2 of the License, or
% (at your option) any later version.
%
% This program 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 this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
%
% SDPA-M: $Revision: 6.2 $
% $Id: param.m,v 6.2 2005/05/28 02:36:40 drophead Exp $
flag=rem(nargin,2);
num=fix(nargin/2);
if flag
error('input argument must be pairs of a field name and a value');
end
% create default OPTION
OPTION.maxIteration = 40;
OPTION.epsilonStar = 1.0E-7;
OPTION.lambdaStar = 1.0E2;
OPTION.omegaStar = 2.0;
OPTION.lowerBound = -1.0E5;
OPTION.upperBound = 1.0E5;
OPTION.betaStar = 0.1;
OPTION.betaBar = 0.2;
OPTION.gammaStar = 0.9;
OPTION.epsilonDash = 1.0E-7;
OPTION.isSymmetric = 0;
OPTION.print = 'display';
for idx=1:num
field=varargin{2*(idx-1)+1};
value=varargin{2*idx};
if ~isstr(field)
if idx==1
error(sprintf('%dst parameter name must be a string.',idx));
elseif idx==2
error(sprintf('%dnd parameter name must be a string.',idx));
elseif idx==3
error(sprintf('%drd parameter name must be a string.',idx));
else
error(sprintf('%dth parameter name must be a string.',idx));
end
end
if strcmp(field,'maxIteration')
if isnumeric(value)
OPTION.maxIteration=double(value);
else
error('maxIteration must be numeric.');
end
elseif strcmp(field,'epsilonStar')
if isnumeric(value)
OPTION.epsilonStar=double(value);
else
error('epsilonStar must be numeric.');
end
elseif strcmp(field,'lambdaStar')
if isnumeric(value)
OPTION.lambdaStar=double(value);
else
error('lambdaStar must be numeric.');
end
elseif strcmp(field,'omegaStar')
if isnumeric(value)
OPTION.omegaStar=double(value);
else
error('omegaStar must be numeric.');
end
elseif strcmp(field,'lowerBound')
if isnumeric(value)
OPTION.lowerBound=double(value);
else
error('lowerBound must be numeric.');
end
elseif strcmp(field,'upperBound')
if isnumeric(value)
OPTION.upperBound=double(value);
else
error('upperBound must be numeric.');
end
elseif strcmp(field,'betaStar')
if isnumeric(value)
OPTION.betaStar=double(value);
else
error('betaStar must be numeric.');
end
elseif strcmp(field,'betaBar')
if isnumeric(value)
OPTION.betaBar=double(value);
else
error('betaBar must be numeric.');
end
elseif strcmp(field,'gammaStar')
if isnumeric(value)
OPTION.gammaStar=double(value);
else
error('gammaStar must be numeric.');
end
elseif strcmp(field,'epsilonDash')
if isnumeric(value)
OPTION.epsilonDash=double(value);
else
error('epsilonDash must be numeric.');
end
elseif strcmp(field,'searchDir')
disp('Parameter *searchDir* is no longer supported.');
disp('HRVW/KSH/M is automatically used.');
elseif strcmp(field,'isSymmetric')
if value==0 | value==1
OPTION.isSymmetric=double(value);
else
error('isSymmetric must be 0 or 1.');
end
elseif strcmp(field,'print')
if isstr(value)
OPTION.print=value;
else
error('print must be string.');
end
else
error(sprintf('%s is unknow parameter.',field));
end
end
% End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -