⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddv.m

📁 一些用matlab编写的经典遗传算法算例。可以用于解决许多优化问题
💻 M
字号:
function d = ddv(varargin)
% DDV - Constructor for the class ddv, a sub class of the gen class.
% The constructor can be called in two ways:
%
% ddv('name',value_1,value_2,etc..) where 'name' is a string identifying
% the variable and value_1, value_2 etc. are the possible values that
% the discrete variable can assume.  
%
% ddv('name',[value_1 value_2 etc..]) here 'name' is as before but
% the possible values are suppplied in a vector.  
% 
% There is no need  for supplpiyng the coding bits since this is
% determined by the possible values that the variable can assume.    
%
% Calling the constructor without any argument creates an "empty" variable.
%
% See also CDV,CHROM,UI_GEN,UI_CHROM
switch nargin
 case 0
  pointer=0;
  d=struct('ddv_val',[]);
  d = class(d,'ddv',gen);
 case 1
  if isa(varargin{1},'ddv')
    d=varargin{1};
  else 
    error('wrong argument')
  end
 case 2
  if ~isa(varargin{1},'char')
    error('You must specify the the id as the first argument')
  else 
    for k=1:length(varargin{2})
      ddv_val(k)=varargin{2}(k);
    end
    d=struct('ddv_val',ddv_val);
    d=class(d,'ddv',gen(varargin{1},nextpow2(ddv_val)));
  end
 otherwise
  if ~isa(varargin{1},'char')
    error('You must specify the the id as the first argument')
  else 
    for k=2:nargin
      ddv_val(k-1)=varargin{k};
    end
    d=struct('ddv_val',ddv_val);
    d=class(d,'ddv',gen(varargin{1},nextpow2(ddv_val)));
  end
end




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -