關於蟻群演算法應用的英文翻譯

  • 作者:由 匿名使用者 發表于 舞蹈
  • 2021-09-13

關於蟻群演算法應用的英文翻譯 匿名使用者 1級 2008-04-29 回答

找不到翻譯,給你一個演算法吧!

該程式試圖對具有31個城市的VRP進行求解,已知的最優解為784。1,我用該程式只能最佳化到810左右,應該是陷入區域性最優,但我不知問題出在什麼地方。請用過蟻群演算法的高手指教。

蟻群演算法的matlab原始碼,同時請指出為何不能最佳化到已知的最好解

%

%

% the procedure of ant colony algorithm for VRP

%

% % % % % % % % % % %

%initialize the parameters of ant colony algorithms

load data。txt;

d=data(:,2:3);

g=data(:,4);

m=31; % 螞蟻數

alpha=1;

belta=4;% 決定tao和miu重要性的引數

lmda=0;

rou=0。9; %衰減係數

q0=0。95;

% 機率

tao0=1/(31*841。04);%初始資訊素

Q=1;% 螞蟻迴圈一週所釋放的資訊素

defined_phrm=15。0; % initial pheromone level value

QV=100; % 車輛容量

vehicle_best=round(sum(g)/QV)+1; %所完成任務所需的最少車數

V=40;

% 計算兩點的距離

for i=1:32;

for j=1:32;

dist(i,j)=sqrt((d(i,1)-d(j,1))^2+(d(i,2)-d(j,2))^2);

end;

end;

%給tao miu賦初值

for i=1:32;

for j=1:32;

if i~=j;

%s(i,j)=dist(i,1)+dist(1,j)-dist(i,j);

tao(i,j)=defined_phrm;

miu(i,j)=1/dist(i,j);

end;

end;

end;

for k=1:32;

for k=1:32;

deltao(i,j)=0;

end;

end;

best_cost=10000;

for n_gen=1:50;

print_head(n_gen);

for i=1:m;

%best_solution=[];

print_head2(i);

sumload=0;

cur_pos(i)=1;

rn=randperm(32);

n=1;

nn=1;

part_sol(nn)=1;

%cost(n_gen,i)=0。0;

n_sol=0; % 由螞蟻產生的路徑數量

M_vehicle=500;

t=0; %最佳路徑陣列的元素數為0

while sumload<=QV;

for k=1:length(rn);

if sumload+g(rn(k))<=QV;

gama(cur_pos(i),rn(k))=(sumload+g(rn(k)))/QV;

A(n)=rn(k);

n=n+1;

end;

end;

fid=fopen(‘out_customer。txt’,‘a+’);

fprintf(fid,‘%s %i\t’,‘the current position is:’,cur_pos(i));

fprintf(fid,‘\n%s’,‘the possible customer set is:’)

fprintf(fid,‘\t%i\n’,A);

fprintf(fid,‘————————————————\n’);

fclose(fid);

p=compute_prob(A,cur_pos(i),tao,miu,alpha,belta,gama,lmda,i);

maxp=1e-8;

na=length(A);

for j=1:na;

if p(j)>maxp

maxp=p(j);

index_max=j;

end;

end;

old_pos=cur_pos(i);

if rand(1)

評論

0

0

載入更多

Top