www.gusucode.com > sloptim工具箱matlab源码程序 > sloptim/sloptim/@ResponseOptimizer/@OptimOptions/schema.m

    function schema
% Optimization options for SRO Project.

% Copyright 1986-2012 The MathWorks, Inc.

% Construct class
c = schema.class(findpackage('ResponseOptimizer'), 'OptimOptions');

% Make sure have enumeration types
if (isempty(findtype('SRO_Method')))
   schema.EnumType('SRO_Method',{'fmincon', 'patternsearch', 'fminsearch'});
end
if isempty( findtype('SRO_Algorithm') )
  schema.EnumType('SRO_Algorithm', ...
		  {'active-set', 'interior-point', 'trust-region-reflective'});
end
if (isempty(findtype('SRO_Display')))
   schema.EnumType('SRO_Display',{'off','iter','notify','final'});
end
if (isempty(findtype('SRO_Gradient')))
   schema.EnumType('SRO_Gradient',{'basic','refined'});
end
if isempty( findtype('slcontrol_Parallel'))
   schema.EnumType('slcontrol_Parallel', {'always','never'});
end

% Method
p = schema.prop(c, 'Method', 'SRO_Method');
p.FactoryValue = 'fmincon';

% Algorithm
p = schema.prop(c, 'Algorithm', 'SRO_Algorithm');
p.FactoryValue = 'active-set';

% Display
p = schema.prop(c, 'Display', 'SRO_Display');
p.FactoryValue = 'iter';

% Gradient algorithm
p = schema.prop(c, 'GradientType', 'SRO_Gradient');
p.FactoryValue = 'basic';

%InteriorPoint settings
p = schema.prop(c,'MaximallyFeasible','bool');
p.FactoryValue = true;

% Max iterations
p = schema.prop(c, 'MaxIter', 'double');
p.SetFunction = @localSetMaxIter;
p.FactoryValue = 100;

% Constraint tolerance
p = schema.prop(c, 'TolCon', 'double');
p.FactoryValue = 0.001;
p.SetFunction = {@localSetTol 'TolCon'};

% Objective tolerance
p = schema.prop(c, 'TolFun', 'double');
p.FactoryValue = 0.01;
p.SetFunction = {@localSetTol 'TolFun'};

% Optimal X tolerance
p = schema.prop(c, 'TolX', 'double');
p.FactoryValue = 0.01;
p.SetFunction = {@localSetTol 'TolX'};

% Restarts
p = schema.prop(c,'Restarts', 'double');
p.FactoryValue = 0;
p.SetFunction = @localSetRestart;

% Enable parallel
p = schema.prop(c, 'UseParallel', 'slcontrol_Parallel');
p.FactoryValue = 'never';

% Parallel path dependencies
p = schema.prop(c, 'ParallelPathDependencies', 'string vector');
p.FactoryValue = {};

% Search Method (GADS only)
schema.prop(c,'SearchMethod', 'MATLAB array');

% Version
p = schema.prop(c, 'Version', 'double');
p.FactoryValue = 1;
p.AccessFlags.PublicGet = 'off';
p.AccessFlags.PublicSet = 'off';

%---------------- Local Functions ---------------------

function a = localSetMaxIter(this,a)
if ~isreal(a) || a<1 || a~=round(a)
   ctrlMsgUtils.error('Sloptim:engine:errMaxIter')
end

function a = localSetRestart(this,a)
if ~isreal(a) || a<1 || a~=round(a)
   ctrlMsgUtils.error('Sloptim:engine:errRestarts')
end

function a = localSetTol(this,a,checkWhat)
if ~isreal(a) || a<0 || a>1
   ctrlMsgUtils.error('Sloptim:engine:errTolerances',checkWhat)
end