資源簡介
蟻群算法工具箱蟻群算法資料:蟻群算法工具箱蟻群算法資料:蟻群算法工具箱蟻群算法資料:蟻群算法工具箱蟻群算法資料:蟻群算法工具蟻群算法工具箱蟻群算法資料:箱蟻群算法資料:蟻群算法工具蟻群算法工具箱蟻群算法資料:箱蟻群算法資料:蟻群算法工具箱蟻群算法資料:蟻群算法工具箱蟻群算法資料:

代碼片段和文件信息
function?[messageresultstimeElapsed]?=?runcontest(drawboard)
%RUNCONTEST?Test?an?entry.
%???[MESSAGERESULTSTIME]?=?RUNCONTEST(DRAWBOARD)?runs?the?M-file
%???solver.m?against?all?the?problems?defined?in?testsuite_sample.mat.??The
%???input?DRAWBOARD?specifies?if?you?want?to?graphically?visualize?the?results.
%???MESSAGE?returns?a?summary?of?the?testing.??RESULTS?measures?how?well?the
%???entry?solved?the?problem?and?TIME?measures?the?time?the?entry?took?to
%???compute?its?answer.
%?Argument?parsing.
if?(nargin?1)
????drawboard?=?0;
end
%?Define?constants.
scentDecay?=?1;
range?=?-2:2;
load?testsuite_sample?testsuite
%?Run?the?submission?for?each?problem?in?the?suite.
score?=?zeros(size(testsuite));
time0?=?cputime;
for?i?=?1:?numel(testsuite)
????main??=?testsuite(i).main;
????food??=?testsuite(i).food;
????scent?=?testsuite(i).scent;
????ants??=?testsuite(i).ants;
????locs??=?testsuite(i).locs;
????if?drawboard?viewsolution(mainscentfoodlocs1);?end
????nAnts?=?sum(ants(:));
????for?timeCtr?=?1:1000
????????for?antCtr?=?1:nAnts
????????????y?=?locs(antCtr1);
????????????x?=?locs(antCtr2);
????????????yv?=?y?+?range;
????????????xv?=?x?+?range;
????????????mainMap??=?main(yvxv);
????????????foodMap??=?food(yvxv);
????????????antMap???=?ants(yvxv);
????????????scentMap?=?scent(yvxv);
????????????%?call?ant?micro-program
????????????clear?global
????????????[dydxmarkcarry]?=?solver(mainMapfoodMapantMapscentMap);
????????????%?figure?out?the?new?ant?position
????????????ny?=?y;
????????????nx?=?x;
????????????if?dy>0
????????????????ny?=?ny+1;
????????????elseif?dy<0
????????????????ny?=?ny-1;
????????????end
????????????if?dx>0
????????????????nx?=?nx+1;
????????????elseif?dx<0
????????????????nx?=?nx-1;
????????????end
????????????
????????????%?validate?move
????????????if?main(nynx)<0
????????????????ny?=?y;
????????????????nx?=?x;
????????????end
????????????%?move?food?when?carry?is?true
????????????if?carry?&?food(yx)
????????????????food(yx)???=?food(yx)??-1;
????????????????food(nynx)?=?food(nynx)+1;
????????????end
????????????%?leave?scent
????????????mark?=?min(max(real(round(mark))0)100);
????????????if?mark
????????????????scent(yx)?=?scent(yx)+mark;
????????????end
????????????%?move?ant
????????????locs(antCtr:)=[ny?nx];
????????????ants(yx)???=?ants(yx)??-1;
????????????ants(nynx)?=?ants(nynx)+1;
????????end?%?next?ant
????????%?time?passes?reduce?scent
????????scent?=?max(0scent?-?scentDecay);
????????if?drawboard
????????????viewsolution(mainscentfoodlocs0)
????????????drawnow
????????end
????end?%?next?time?step
????score(i)?=?grade(mainfood);
end?%?next?problem?in?testsuite
%?report?the?time
timeElapsed?=?cputime-time0;
if?drawboard
????%?time?is?not?accurate?when?drawing?the?board
????timeElapsed?=?NaN;
end
%?Report?results.
results?=?sum(score);
message?=
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????59512??2005-05-10?23:40??testsuite_sample.mat
?????文件????????5091??2005-05-11?00:39??runcontest.m
?????文件?????????750??2005-05-11?00:33??solver.m
?????文件???????68392??2005-05-19?23:10??testsuite_validation.mat
?????文件???????58952??2005-05-10?23:40??testsuite_actual.mat
?????文件????????5296??2005-05-19?23:12??runcontest_actual.m
- 上一篇:鮑德里亞 模擬物與擬像
- 下一篇:QQ自動回復機器人易語言源碼
評論
共有 條評論