chrom.m

来自「多目标遗传算法/用法不用多说、要用的赶快下载吧」· M 代码 · 共 49 行

M
49
字号
function c = chrom(varargin)% CHROM - Constructor for the chromosome class% This is the corner stone data type that the genetic tools operate on.% It has four fields that contains all necsessary data.  %     ____________________%    | --------  -------- |%    || NAME   ||FITNESS ||%    | --------  -------- |%    | --------  -------- |%    || CDVS   || DDVS   ||%    | --------  -------- |%    |____________________|%% A chromosome is created by calling the constructor.% c=chrom('name',cdvs,ddvs) or c=chrom % In the first case a chromosome is created with the properties% supplied in the function call.  cdvs and ddvs are the continuous-% and discrete design variables repsectively.  The 'name' is a% string that identifies a chromosome. This to allow multiple% species in a population. Note that the FITNESS is never set. It% is always initialized to an empty matrix.  Calling the% constructor without any arguments creates an "empty" chromosome.% See also CDV,DDV,UI_GEN,UI_CHROM switch nargin case 0  c=struct('name','','cdvs',cdv,'ddvs',ddv,'fitness',[],'id','');  c = class(c,'chrom'); case 1  if isa(varargin{1},'chrom')    c=varargin{1};  else    error('wrong argument')  end case 3  c=struct('name',varargin{1},'cdvs',varargin{2},'ddvs', ...	   varargin{3},'fitness',[],'id','');  c=class(c,'chrom'); otherwise  error('Wrong number of arguments')end

⌨️ 快捷键说明

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