islegal_chrom.m

来自「多智能体工具包」· M 代码 · 共 26 行

M
26
字号
function Is_Legal=islegal_chrom(Individual)% ISLEGAL_CHROM	Test whether the chromosome is legal.%     Copyright (c) 1997-2000 Jiming Liu and Jianbing Wuglobal Cell_Min_Distance Total_Cell_Num Single_Code_Width;Robot_Config=[];for mm=1:Total_Cell_Num  Current_Cell_Code=Individual((mm-1)*Single_Code_Width+1:mm*...                 Single_Code_Width);  Robot_Config(mm,:)=get_code_config(Current_Cell_Code);endIs_Legal=1;for nn=1:(Total_Cell_Num-1)  for mm=(nn+1):Total_Cell_Num    Robot_Diff=Robot_Config(mm,:)-Robot_Config(nn,:);    TwoRobot_Distance=sqrt(Robot_Diff(1)^2+Robot_Diff(2)^2);    if TwoRobot_Distance<Cell_Min_Distance      Is_Legal=0;      return;    end  endend

⌨️ 快捷键说明

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