📄 routfitness.m
字号:
function [sol,val]=routFitness(sol,options)
% make out the fitness of sol
n=size(sol,2)-1; % not use the fitness value
bk=[8 8]; % cap of trucks
l=8; % num of shops
d=[1 2 1 2 1 4 2 2]; %demand of shops
[b,r]=isFeasible(sol(1:n),bk,l,d); %if the sol realizable
global c %the cost(distance)
%if realizable make out the sum distance on roots
if b
rts=size(r,1);
sum=0;
for k=1:rts
tmp=r(k,find(r(k,:)));
tmp=tmp+1;
tmp=[1 tmp];
n=size(tmp,2);
for x=1:n-1
sum=sum+c(tmp(x),tmp(x+1));
end
sum=sum+c(tmp(n),1);
end
sum;
val=1/sum;
else
mess='no realizable';
val=realmin;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -