亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? validate.m

?? 遺傳退火進化算法 可用于1個約束條件的優(yōu)化
?? M
字號:
function [gl,ff,o]  = validate(gLength,fitness,o)
%VALIDATE validates the contents of the fitness function, genome length and options struct.
%   [gLength,fitness, OUT] = VALIDATE(GenomeLength,FitnessFcn,IN) validates the FitnessFcn, GenomeLength and 
%   the structure IN. OUT is a structure which have all the fields in IN and it gets other 
%   fields like FitnessFcn, GenomeLength, etc.
%
%   This function is private to GA.

%   Copyright 2003-2005 The MathWorks, Inc.
%   $Revision: 1.26.6.5.2.1 $  $Date: 2005/07/17 06:06:36 $

msg = nargchk(3,3,nargin);
if ~isempty(msg)
    error('MATLAB:Validate:numInputs', ...
          'VALIDATE requires one structure of the format created by GAOPTIMSET.');
end

%We need to validate ALL the information, bundle them all
o.FitnessFcn   = fitness;
o.GenomeLength = gLength;
%gaoptimset does not return 2 fields, which need to be validated
options = gaoptimset;
options.FitnessFcn = [];
options.GenomeLength = [];

%Does the options structure contain the right fields?
template = fieldnames(options);
oFields = fieldnames(o);

f = find(0 == ismember(template,oFields));
if(~isempty(f))
    msg = sprintf('The field "%s" is missing from the gaoptimset Structure.\n',template{f});
    error('gads:VALIDATE:missingField',msg);
end

f = find(0 == ismember(oFields,template));
if(~isempty(f))
    msg = sprintf('There is an unexpected field "%s" in the gaoptimset Structure.\n',oFields{f});
    warning('gads:VALIDATE:unexpectedField',msg);
end

% range check each field
validNumberofVariables(o.GenomeLength);
stringSet('PopulationType',o.PopulationType,{'doubleVector','custom','bitString'});

positiveIntegerArray('PopulationSize',o.PopulationSize);
realUnitScalar('CrossoverFraction',o.CrossoverFraction);
nonNegInteger('EliteCount',o.EliteCount);
o = rangeCorrection(o,'PopInitRange');
populationCheck(o);

positiveInteger('MigrationInterval',o.MigrationInterval);
realUnitScalar('MigrationFraction',o.MigrationFraction);
stringSet('MigrationDirection',o.MigrationDirection,{'both','forward'});
stringSet('Display',o.Display,{'off','none','iter','final','diagnose'});
stringSet('Vectorized',o.Vectorized,{'on','off'});

nonNegScalar('TolFun',o.TolFun);
nonNegScalar('TolCon',o.TolCon);
positiveInteger('Generations',o.Generations);
positiveScalar('TimeLimit',o.TimeLimit);
positiveInteger('StallGenLimit',o.StallGenLimit);
positiveScalar('StallTimeLimit',o.StallTimeLimit);
realScalar('FitnessLimit',o.FitnessLimit);

positiveInteger('PlotInterval',o.PlotInterval);
% These functions not only VALIDATE, they seperate ftns from args for
% speed.
o = functionHandleOrCell(o,'FitnessFcn',o.FitnessFcn);
o = functionHandleOrCell(o,'FitnessScalingFcn',o.FitnessScalingFcn);
o = functionHandleOrCell(o,'SelectionFcn',o.SelectionFcn);
o = functionHandleOrCell(o,'CrossoverFcn',o.CrossoverFcn);
o = functionHandleOrCell(o,'MutationFcn',o.MutationFcn);
o = functionHandleOrCell(o,'CreationFcn',o.CreationFcn);

if ~isempty(o.HybridFcn)
    o = functionHandleOrCell(o,'HybridFcn',o.HybridFcn);
end

% protect against Elite Count greater than population Size.
if ( o.EliteCount >= sum(o.PopulationSize) )
    msg = sprintf('Elite count must be less than Population Size.');
    error('gads:VALIDATE:EliteCountGTPop',msg);
end

% this special case takes an array of function cells
o = functionHandleOrCellArray(o,'PlotFcns',o.PlotFcns);
o = functionHandleOrCellArray(o,'OutputFcns',o.OutputFcns);

%Assign all the outputs;
ff = o.FitnessFcn;
gl = o.GenomeLength;
%Remove these fields we added in options
o=rmfield(o,{'FitnessFcn','GenomeLength'});

%-------------------------------------------------------------------
% any positive integer
function positiveInteger(property,value)
valid =  isreal(value) && isscalar(value) && (value > 0) && (value == floor(value));
if(~valid)
   msg = sprintf('The field ''%s'' must contain a positive integer.',property);
   error('gads:VALIDATE:PostiveInteger:notPosInteger',msg);
end
%-------------------------------------------------------------------
% any nonnegative integer
function nonNegInteger(property,value)
valid =  isreal(value) && isscalar(value) && (value >= 0) && (value == floor(value));
if(~valid)
    msg = sprintf('The field ''%s'' must contain a non negative integer.',property);
    error('gads:VALIDATE:NonNegInteger:negativeNum',msg);
end
%-------------------------------------------------------------------
% any scalar >= 0
function nonNegScalar(property,value)
valid =  isreal(value) && isscalar(value) && (value >= 0);
if(~valid)
    msg = sprintf('The field ''%s'' must contain a scalar.',property);
    error('gads:VALIDATE:greaterEqualZeroScalar:lessThanZeroScalar',msg);
end
%-------------------------------------------------------------------
% any positive scalar
function positiveScalar(property,value)
valid =  isreal(value) && isscalar(value) && (value > 0);
if(~valid)
    msg = sprintf('The field ''%s'' must contain a positive scalar.',property);
    error('gads:VALIDATE:PositiveScalar:notPosScalar',msg);
end
%-------------------------------------------------------------------
function positiveIntegerArray(property,value)
allValid = true;
for i = 1:length(value)
    valid =  isreal(value(i)) && (value(i) == floor(value(i)));
    allValid = allValid && valid;
end

if(~valid)
    msg = sprintf('The field ''%s'' must contain a positive integer.',property);
    error('gads:VALIDATE:POSITIVEINTEGERARRAY:notPosIntegerArray',msg);
end
%-------------------------------------------------------------------
% A scalar on the interval [0,1]
function realUnitScalar(property,value)
valid = isreal(value) && isscalar(value) && (value >= 0) && (value <= 1);
if(~valid)
    msg = sprintf('The field ''%s'' must contain a scalar on the interval (0,1)',property);
    error('gads:VALIDATE:REALUNITSCALAR:notScalarOnUnitInterval',msg);
end
%-------------------------------------------------------------------
% A scalar
function realScalar(property,value)
valid = isreal(value) && isscalar(value);
if(~valid)
    msg = sprintf('The field ''%s'' must contain a scalar',property);
    error('gads:VALIDATE:REALSCALAR:notScalar',msg);
end
%-------------------------------------------------------------------
% Number of variables
function validNumberofVariables(GenomeLength)
valid =  isnumeric(GenomeLength) && isscalar(GenomeLength)&& (GenomeLength > 0) ...
         && (GenomeLength == floor(GenomeLength));
if(~valid)
   msg = sprintf('Number of variables (NVARS) must be a positive integer.');
   error('gads:VALIDATE:validNumberofVariables:notValidNvars',msg);
end

%-------------------------------------------------------------------------
% if it's a scalar fcn handle or a cellarray starting with a fcn handle and
% followed by something other than a fcn handle, return parts, else empty
function [handle,args] =  isFcn(x)
  handle = [];
  args = {};
%If x is a cell array with additional arguments, handle them
if iscell(x) && ~isempty(x)
    args = x(2:end);
    handle = x{1};
else
    args = {};
    handle = x;
end
%Only function_handle or inlines are allowed
if  ~(isa(handle,'inline') || isa(handle,'function_handle'))
    handle = [];
end

%-------------------------------------------------------------------
% a function Handle or a cell array starting with a function handle.
function options = functionHandleOrCell(options,property,value)
[handle,args] = isFcn(value);

if(~isempty(handle)) && (isa(handle,'inline') || isa(handle,'function_handle'))
    options.(property) = handle;
    options.([property 'Args']) = args;
    return
end

if strcmp(property,'FitnessFcn')
    msg = sprintf('The fitness function must be a function handle.');
else
    msg = sprintf('The field ''%s'' must contain a function handle.',property);
end

error('gads:VALIDATE:FUNCTIONHANDLEORCELL:needHandleOrInline',msg);

%---------------------------------------------------------------------
% the most complex one. A fcn handle, a handle plus args, or an array of
% same.
function options = functionHandleOrCellArray(options,property,value)

% clear out any old value
options.(property) = {};
options.([property 'Args']) = {};

%if a scalar  ~cell  is passed convert to cell (for clarity, not speed)
if ~iscell(value) && isscalar(value)
     value = {value};
 end
% If value is an array of functions, it must be a cell array
for i = 1:length(value)
    candidate = value(i);
    %If any element is also a cell array
    if iscell(candidate)
        if isempty(candidate{1})
            continue;
        end
        %Sometimes the variable 'candidate' might have nested cell array 
        %e.g. {{@outputfcn, p1,p2}} instead of just
        %{@outputfcn,p1,p2}. The following code gets rid of extra braces,
        %which are typically introduced by GUI import/export options.
        temp = candidate{1};
        while iscell(temp) && isscalar(temp)
            candidate = temp(1);
            temp = candidate{1};
        end
        [handle,args] = isFcn(candidate{:});
    else
        [handle,args] = isFcn(candidate);
    end
    if(~isempty(handle)) && isa(handle,'function_handle')
        options.(property){i} = handle;
        options.([property 'Args']){i} = args;
    else
        msg = sprintf('The field ''%s'' must contain a function handle.',property);
        error('gads:VALIDATE:FUNCTIONHANDLEORCELLARRAY:needHandleOrInline',msg);
    end
end
%----------------------------------------------------------------
% one of a set of strings
function stringSet(property,value,set)
for i = 1:length(set)
    if(strcmpi(value,set{i}))
        return;
    end
end

msg = sprintf('The field %s must contain one of these strings: %s %s %s %s %s',property,set{:});
error('gads:VALIDATE:STRINGSET:notCorrectChoice',msg);
%----------------------------------------------------------------
function options = rangeCorrection(options,property)

%Check the size of PopInitRange
Range = options.PopInitRange;
%check only for double data type range
if ~isa(Range,'double')
    return;
end

if size(Range,1) ~=2
    msg = sprintf('The field ''%s'' must have two rows.',property);
    error('gads:VALIDATE:RANGECORRECTION:invalidPopInitRange',msg);  
end
lb = Range(1,:);
lb = lb(:);
lenlb = length(lb);
ub = Range(2,:);
ub = ub(:);
lenub = length(ub);
nvars = options.GenomeLength; %This field was inserted

% Check maximum length
if lenlb > nvars
   warning('gads:VALIDATE:extraRange','Length of lower range is > number of variables; ignoring extra bounds.');
   lb = lb(1:nvars);   
   lenlb = nvars;
elseif lenlb < nvars
   lb = [lb; lb(end)*ones(nvars-lenlb,1)];
   lenlb = nvars;
end

if lenub > nvars
   warning('gads:VALIDATE:extraRange','Length of upper range is > number of variables; ignoring extra bounds.');
   ub = ub(1:nvars);
   lenub = nvars;
elseif lenub < nvars
   ub = [ub; ub(end)*ones(nvars-lenub,1)];
   lenub = nvars;
end
% Check feasibility of bounds
len = min(lenlb,lenub);
if any( lb( (1:len)' ) > ub( (1:len)' ) )
   count = full(sum(lb>ub));
   if count == 1
      msg=sprintf(['\nExiting due to infeasibility:  %i lower range exceeds the' ...
            ' corresponding upper range.\n'],count);
   else
      msg=sprintf(['\nExiting due to infeasibility:  %i lower range exceed the' ...
            ' corresponding upper range.\n'],count);
   end
   error('gads:validate:infesibleRange',msg);
end
% check if -inf in ub or inf in lb   
if any(eq(ub, -inf)) 
   error('gads:VALIDATE:infRange','-Inf detected in upper bound: upper bounds must be > -Inf.');
elseif any(eq(lb,inf))
   error('gads:VALIDATE:infRange','+Inf detected in lower bound: lower bounds must be < Inf.');
end

options.PopInitRange = [lb,ub]';
%------------------------------End of rangeCorrection --------------------------

function populationCheck(options)
%Perform some check if Population type is double or bitString
if strcmpi(options.PopulationType,'custom')
    return;
end
if ~isnumeric(gaoptimget(options,'InitialPopulation'))
    error('gads:VALIDATE:invalidPopulation','Invalid value for OPTIONS parameter InitialPopulation.');
end
if ~isnumeric(gaoptimget(options,'InitialScores'))
    error('gads:VALIDATE:invalidScores','Invalid value for OPTIONS parameter InitialScores.');
end
%------------------------------End of populationCheck --------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久不卡影院| 欧美理论片在线| 国产精品家庭影院| 99久久久免费精品国产一区二区| 国产精品无人区| 91亚洲国产成人精品一区二区三| 亚洲女人****多毛耸耸8| 91福利国产精品| 青青草97国产精品免费观看| 精品国产乱码久久久久久蜜臀| 久久99九九99精品| 国产精品久久久久久户外露出| 色又黄又爽网站www久久| 日韩精品一区第一页| 久久久精品人体av艺术| 一本久久综合亚洲鲁鲁五月天| 亚洲18色成人| 欧美激情综合网| 欧美色男人天堂| 国产一区不卡在线| 亚洲综合成人在线视频| 日韩女优视频免费观看| 99久久免费国产| 麻豆高清免费国产一区| 亚洲欧洲av在线| 日韩美女主播在线视频一区二区三区| 成人午夜激情影院| 午夜成人免费电影| 国产精品家庭影院| 精品日韩一区二区三区 | 最新日韩av在线| 欧美日韩国产综合一区二区三区| 久久国产精品99精品国产| 成人免费一区二区三区在线观看 | 久久精品国产成人一区二区三区 | 亚洲免费电影在线| 精品少妇一区二区| 欧美性色黄大片手机版| 国产在线国偷精品产拍免费yy | 天堂蜜桃91精品| 亚洲婷婷综合久久一本伊一区| 91麻豆精品91久久久久同性| 99久精品国产| 国产一区二区福利| 蜜臀久久99精品久久久画质超高清| 亚洲欧洲av在线| 国产性色一区二区| 制服丝袜中文字幕一区| 99精品久久99久久久久| 国产精品一区在线观看乱码| 日韩二区三区四区| 亚洲免费观看高清在线观看| 久久精品在这里| 欧美电视剧在线看免费| 337p亚洲精品色噜噜狠狠| 色婷婷av久久久久久久| 成人国产精品免费观看动漫| 国产精品综合av一区二区国产馆| 亚洲第一二三四区| 亚洲精品国产一区二区三区四区在线| 久久久精品综合| 久久久亚洲精品石原莉奈| 精品免费99久久| 日韩欧美一区在线| 91精品国产欧美一区二区18| 欧美网站大全在线观看| 91久久久免费一区二区| 99久久国产免费看| 99久久777色| 色婷婷激情一区二区三区| 97久久精品人人做人人爽50路| 黄色资源网久久资源365| 久久黄色级2电影| 国产在线精品视频| 国产又粗又猛又爽又黄91精品| 老司机午夜精品99久久| 九一九一国产精品| 精品一区二区综合| 国产在线播放一区三区四| 国模大尺度一区二区三区| 国产在线一区二区| 国产v日产∨综合v精品视频| 成人免费毛片aaaaa**| 成人性生交大片免费看中文网站| 成人性生交大片| 9色porny自拍视频一区二区| av一区二区不卡| 欧洲精品中文字幕| 欧美美女bb生活片| 日韩欧美黄色影院| 久久日韩精品一区二区五区| 国产女人18水真多18精品一级做| 国产精品久久久久久久久晋中 | 成人涩涩免费视频| 99久久亚洲一区二区三区青草| 色偷偷88欧美精品久久久| 欧洲av在线精品| 日韩一区二区三区高清免费看看| 久久久五月婷婷| 亚洲视频图片小说| 日韩成人一级片| 国产91在线看| 欧美在线观看一区| 日韩视频在线你懂得| 国产午夜亚洲精品午夜鲁丝片| 中文字幕亚洲电影| 天天操天天干天天综合网| 精品一区二区在线播放| av一区二区不卡| 欧美一区二区日韩一区二区| 久久综合资源网| 亚洲免费在线电影| 老司机精品视频线观看86| 不卡av电影在线播放| 欧美蜜桃一区二区三区| 久久久久久久综合日本| 一区二区三区日韩欧美精品| 久久国产三级精品| 91福利在线播放| 久久九九影视网| 视频在线观看一区二区三区| 国产99精品国产| 91麻豆精品国产91久久久使用方法 | 欧美一区二区三区婷婷月色| 国产日韩欧美高清在线| 视频一区欧美日韩| a4yy欧美一区二区三区| 精品国产乱码久久久久久1区2区 | 国产一区二区看久久| 欧美亚州韩日在线看免费版国语版| 久久综合成人精品亚洲另类欧美| 夜夜精品视频一区二区| 风间由美性色一区二区三区| 欧美一级免费观看| 亚洲免费在线视频一区 二区| 国产一区高清在线| 91麻豆精品国产91久久久| 亚洲激情图片小说视频| 丁香另类激情小说| 久久久欧美精品sm网站| 蜜桃av一区二区| 欧美日韩成人一区二区| 亚洲视频在线一区二区| 国产aⅴ综合色| 欧美精品一区二区不卡 | 精品一区二区在线观看| 欧美久久一区二区| 一二三区精品福利视频| 91在线观看下载| 国产亚洲1区2区3区| 久久精品国产999大香线蕉| 欧美欧美欧美欧美首页| 一区二区在线观看不卡| 波多野结衣中文字幕一区 | ww亚洲ww在线观看国产| 麻豆成人91精品二区三区| 欧美嫩在线观看| 午夜成人免费视频| 欧美精品1区2区3区| 亚洲国产日韩综合久久精品| 欧美优质美女网站| 亚洲电影第三页| 欧美日韩精品一区二区天天拍小说 | 成人h精品动漫一区二区三区| 国产亚洲欧美日韩在线一区| 国产在线播精品第三| 久久久久久久一区| 成人在线综合网站| 中文字幕亚洲电影| 91豆麻精品91久久久久久| 亚洲国产日韩av| 欧美三日本三级三级在线播放| 亚洲国产综合人成综合网站| 欧美日韩一区二区三区免费看| 午夜伦欧美伦电影理论片| 欧美一区永久视频免费观看| 蜜桃一区二区三区在线观看| 欧美videos中文字幕| 国产酒店精品激情| 亚洲欧美自拍偷拍色图| 色综合久久99| 日韩有码一区二区三区| 久久综合一区二区| 成人精品视频.| 一区二区三区四区视频精品免费| 欧美日韩日日夜夜| 极品美女销魂一区二区三区| 亚洲精品在线三区| 成人三级在线视频| 亚洲一区二区三区影院| 日韩一区二区三区免费看| 国产精品一区不卡| 一区二区三区视频在线看| 欧美一级日韩不卡播放免费| 粉嫩aⅴ一区二区三区四区五区| 亚洲三级在线观看| 日韩欧美在线不卡| 91在线一区二区| 免费成人美女在线观看.| 中文字幕中文乱码欧美一区二区 |