📄 chrom.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -