資源簡(jiǎn)介
生物地理學(xué)優(yōu)化算法由 Dan Simon 提出,資源是這篇文章的源碼
代碼片段和文件信息
function?[MinCost?Hamming]?=?BBO(ProblemFunction?DisplayFlag?ProbFlag?RandSeed)
%?[最佳解決方案,hamming距離]?=?[函數(shù)句柄,是否顯示打印,是否使用概率更新遷出率,隨機(jī)數(shù)種子]
%?函數(shù)句柄?只是?在?初始化中用到
%?ProblemFunction?=?[InitFunction?CostFunction?FeasibleFunction]
%?Biogeography-based?optimization?(BBO)?software?for?minimizing?a?general?function
%?INPUTS:?ProblemFunction?is?the?handle?of?the?function?that?returns
%?????????the?handles?of?the?initialization?cost?and?feasibility?functions.
%?????????????????????????????????????????是返回初始化、成本和可行性函數(shù)句柄的函數(shù)的句柄
%?????????DisplayFlag?=?true?or?false?whether?or?not?to?display?and?plot
%?????????results.????????????????????????是否顯示和打印結(jié)果
%?????????ProbFlag?=?true?or?false?whether?or?not?to?use?probabilities?to
%?????????update?emigration?rates.????????是否使用概率更新遷出率
%?????????RandSeed?=?random?number?seed???隨機(jī)數(shù)種子
%?OUTPUTS:?MinCost?=?array?of?best?solution?one?element?for?each?generation
%????????????????????最佳解決方案數(shù)組,每代一個(gè)元素
%??????????Hamming?=?final?Hamming?distance?between?solutions?????解之間的最終Hamming距離
%?CAVEAT:?The?“ClearDups“?function?that?is?called?below?replaces?duplicates?with?randomly-generated
%?????????individuals?but?it?does?not?then?recalculate?the?cost?of?the?replaced?individuals.?
%?警告:下面調(diào)用的“cleardups”函數(shù)用隨機(jī)生成的個(gè)體替換重復(fù)的個(gè)體,但是它不會(huì)重新計(jì)算被替換個(gè)體的成本。
%?exit有兩種形式:
%?(1)?b?=?exist(?a?)????????????????若?a?存在,則?b?=?1;?否則?b?=?0;
%?(2)?b?=?exist(?‘name‘?‘kind‘)????kind?表示?name?的類(lèi)型,可以取的值為:builtin(內(nèi)建類(lèi)型),class(類(lèi)),
%???????????????????????????????????dir(文件夾),file(文件或文件夾),var(變量)??
if?~exist(‘DisplayFlag‘?‘var‘)
????DisplayFlag?=?true;
end
if?~exist(‘ProbFlag‘?‘var‘)
????ProbFlag?=?false;
end
if?~exist(‘RandSeed‘?‘var‘)
????RandSeed?=?round(sum(100*clock));???%?clock??讀取的是系統(tǒng)時(shí)間
end
[OPTIONS?MinCost?AvgCost?InitFunction?CostFunction?FeasibleFunction?...
????MaxParValue?MinParValue?Population]?=?Init(DisplayFlag?ProblemFunction?RandSeed);???%?初始化這是一個(gè)函數(shù)
%?ProblemFunction?=?[InitFunction?CostFunction?FeasibleFunction]
%?InitFunction?函數(shù)?得到的?OPTIONS
%?MinCost?AvgCost??MinCost是最小損失值,對(duì)應(yīng)的是?最佳適宜度;?AvgCost表示的是平均損失值,也就是?適宜度的平均水平
%?InitFunction?CostFunction?FeasibleFunction??來(lái)自于函數(shù)的句柄??好像是自己定義的好像是??????
%?MaxParValue?MinParValue?是?InitFunction(OPTIONS)?得到的值
%?Population?相當(dāng)于是一個(gè)?棲息地,經(jīng)過(guò)了?去重復(fù)、計(jì)算損失值、排序之后得到的結(jié)果
Population?=?CostFunction(OPTIONS?Population);??%?在初始化的時(shí)候??執(zhí)行過(guò)了一次
%?棲息地修改概率
OPTIONS.pmodify?=?1;?%?habitat?modification?probability
%?初始突變概率
OPTIONS.pmutate?=?0.005;?%?initial?mutation?probability
%?精英參數(shù):從一代人到下一代人,要保留多少最佳棲息地
Keep?=?2;?%?elitism?parameter:?how?many?of?the?best?habitats?to?keep?from?one?generation?to?the?next
%?每代的遷入概率下限
lambdaLower?=?0.0;?%?lower?bound?for?immigration?probabilty?per?gene
%?每代的遷入概率上限
lambdaUpper?=?1;?%?upper?bound?for?immigration?probabilty?per?gene
%?用于概率數(shù)值積分的步長(zhǎng)
dt?=?1;?%?step?size?used?for?numerical?integration?of?probabilities
%?每個(gè)棲息地?最大遷入率
I?=?1;?%?max?immigration?rate?for?each?island
%?每個(gè)棲息地?最大遷出率
E?=?1;?%?max?emigration?rate?for?each?isl
評(píng)論
共有 條評(píng)論