導航:首頁 > 源碼編譯 > 多目標蜂群演算法

多目標蜂群演算法

發布時間:2022-04-21 14:38:01

⑴ 李昕的發表論文情況

近年來主要發表論文9篇,其中EI收錄四篇。
[1] 李昕,張春良,李建. 機械故障診斷技術的發展及其在核機械中的應用. 裝備製造技術. 2009(10).
[2]LI Xin, ZHANG Chun-liang, Li, Li-Jun, HU Zhi. Research on Machine Vision in Forestry Pluck System. Advanced Materials Research Vols. 139-141 (2010) pp 2199-2202. EI收錄:20110113546145
[3]李昕,李立君,易春峰.基於目標保護的林業機器人視覺系統的研究[J]. 中南林業科技大學學報(自然科學版), 2011,31(7): 174-178.
[4]李昕,李立君.一種偏好多目標蜂群演算法及其在油茶果圖像識別中的應用[J]. 計算機應用研究,2012,29(12): 4779-4781.
[5]李立君,李昕,高自成,李慶春,易春峰. 基於偏好免疫網路的油茶果採摘機器人圖像識別演算法[J]. 農業機械學報2012,43(11): 209-213.
[6]李昕,李立君,李慶春,易春峰,高自成. 基於偏好人工免疫網路多特徵融合的油茶果圖像識別[J]. 農業工程學報,2012,28(14):133-137.EI收錄:20123515381925
[7]李昕,李立君,高自成,李慶春,易春峰. 基於核聚類的近鄰人工免疫網路演算法研究[J]. 計算機應用研究,2012,29(7):2464-2466.
[8] 李昕,李立君,高自成,易春峰,李慶春.改進類圓隨機Hough變換及其在油茶果實遮擋識別中的應用[J]. 2013,29(1): 164-170.
[9]左二兵,李立君,高自成,李昕,劉銀輝. 油茶果採摘機採摘臂工作空間模擬分析[J].中南林業科技大學學報(自然科學版), 2012,32(7): 174-178.

⑵ 學習多目標優化需要掌握哪些python知識

多目標優化

目標優化問題一般地就是指通過一定的優化演算法獲得目標函數的最優化解。當優化的目標函數為一個時稱之為單目標優化(Single-
objective Optimization Problem,
SOP)。當優化的目標函數有兩個或兩個以上時稱為多目標優化(Multi-objective Optimization Problem,
MOP)。不同於單目標優化的解為有限解,多目標優化的解通常是一組均衡解。

多目標優化演算法歸結起來有傳統優化演算法和智能優化演算法兩大類。
1. 傳統優化演算法包括加權法、約束法和線性規劃法等,實質上就是將多目標函數轉化為單目標函數,通過採用單目標優化的方法達到對多目標函數的求解。
2. 智能優化演算法包括進化演算法(Evolutionary Algorithm, 簡稱EA)、粒子群演算法(Particle Swarm Optimization, PSO)等。

Pareto最優解:

若x*∈C*,且在C中不存在比x更優越的解x,則稱x*是多目標最優化模型式的Pareto最優解,又稱為有效解。
一般來說,多目標優化問題並不存在一個最優解,所有可能的解都稱為非劣解,也稱為Pareto解。傳統優化技術一般每次能得到Pareo解集中的一個,而
用智能演算法來求解,可以得到更多的Pareto解,這些解構成了一個最優解集,稱為Pareto最優解。它是由那些任一個目標函數值的提高都必須以犧牲其
他目標函數值為代價的解組成的集合,稱為Pareto最優域,簡稱Pareto集。

Pareto有效(最優)解非劣解集是指由這樣一些解組成的集合:與集合之外的任何解相比它們至少有一個目標函數比集合之外的解好。

求解多目標優化問題最有名的就是NSGA-II了,是多目標遺傳演算法,但其對解的選擇過程可以用在其他優化演算法上,例如粒子群,蜂群等等。這里簡單介紹一下NSGA-II的選擇演算法。主要包含三個部分:
1. 快速非支配排序
要先講一下支配的概念,對於解X1和X2,如果X1對應的所有目標函數都不比X2大(最小問題),且存在一個目標值比X2小,則X2被X1支配。
快速非支配排序是一個循環分級過程:首先找出群體中的非支配解集,記為第一非支配層,irank=1(irank是個體i的非支配值),將其從群體中除去,繼續尋找群體中的非支配解集,然後irank=2。
2. 個體擁擠距離
為了使計算結果在目標空間比較均勻的分布,維持種群多樣性,對每個個體計算擁擠距離,選擇擁擠距離大的個體,擁擠距離的定義為:
L[i]d=L[i]d+(L[i+1]m−L[i−1]m)/(fmaxm−fminm)
L[i+1]m是第i+1個個體的第m目標函數值,fmaxm 和 fminm是集合中第m個目標函數的最大和最小值。
3. 精英策略選擇
精英策略就是保留父代中的優良個體直接進入子代,防止獲得的Pareto最優解丟失。將第t次產生的子代種群和父代種群合並,然後對合並後的新種群進行非支配排序,然後按照非支配順序添加到規模為N的種群中作為新的父代。

⑶ 人工蜂群演算法里太多比喻了,能不能就演算法本身的步驟來講講

直接給你java代碼吧,看的簡單易懂
import java.lang.Math;

public class beeColony {

/* Control Parameters of ABC algorithm*/
int NP=20; /* The number of colony size (employed bees+onlooker bees)*/
int FoodNumber = NP/2; /*The number of food sources equals the half of the colony size*/
int limit = 100; /*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/
int maxCycle = 2500; /*The number of cycles for foraging {a stopping criteria}*/

/* Problem specific variables*/
int D = 100; /*The number of parameters of the problem to be optimized*/
double lb = -5.12; /*lower bound of the parameters. */
double ub = 5.12; /*upper bound of the parameters. lb and ub can be defined as arrays for the problems of which parameters have different bounds*/

int runtime = 30; /*Algorithm can be run many times in order to see its robustness*/

int dizi1[]=new int[10];
double Foods[][]=new double[FoodNumber][D]; /*Foods is the population of food sources. Each row of Foods matrix is a vector holding D parameters to be optimized. The number of rows of Foods matrix equals to the FoodNumber*/
double f[]=new double[FoodNumber]; /*f is a vector holding objective function values associated with food sources */
double fitness[]=new double[FoodNumber]; /*fitness is a vector holding fitness (quality) values associated with food sources*/
double trial[]=new double[FoodNumber]; /*trial is a vector holding trial numbers through which solutions can not be improved*/
double prob[]=new double[FoodNumber]; /*prob is a vector holding probabilities of food sources (solutions) to be chosen*/
double solution[]=new double[D]; /*New solution (neighbour) proced by v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij}) j is a randomly chosen parameter and k is a randomlu chosen solution different from i*/

double ObjValSol; /*Objective function value of new solution*/
double FitnessSol; /*Fitness value of new solution*/
int neighbour, param2change; /*param2change corrresponds to j, neighbour corresponds to k in equation v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij})*/

double GlobalMin; /*Optimum solution obtained by ABC algorithm*/
double GlobalParams[]=new double[D]; /*Parameters of the optimum solution*/
double GlobalMins[]=new double[runtime];
/*GlobalMins holds the GlobalMin of each run in multiple runs*/
double r; /*a random number in the range [0,1)*/

/*a function pointer returning double and taking a D-dimensional array as argument */
/*If your function takes additional arguments then change function pointer definition and lines calling "...=function(solution);" in the code*/

// typedef double (*FunctionCallback)(double sol[D]);

/*benchmark functions */

// double sphere(double sol[D]);
// double Rosenbrock(double sol[D]);
// double Griewank(double sol[D]);
// double Rastrigin(double sol[D]);

/*Write your own objective function name instead of sphere*/
// FunctionCallback function = &sphere;

/*Fitness function*/
double CalculateFitness(double fun)
{
double result=0;
if(fun>=0)
{
result=1/(fun+1);
}
else
{

result=1+Math.abs(fun);
}
return result;
}

/*The best food source is memorized*/
void MemorizeBestSource()
{
int i,j;

for(i=0;i<FoodNumber;i++)
{
if (f[i]<GlobalMin)
{
GlobalMin=f[i];
for(j=0;j<D;j++)
GlobalParams[j]=Foods[i][j];
}
}
}

/*Variables are initialized in the range [lb,ub]. If each parameter has different range, use arrays lb[j], ub[j] instead of lb and ub */
/* Counters of food sources are also initialized in this function*/

void init(int index)
{
int j;
for (j=0;j<D;j++)
{
r = ( (double)Math.random()*32767 / ((double)32767+(double)(1)) );
Foods[index][j]=r*(ub-lb)+lb;
solution[j]=Foods[index][j];
}
f[index]=calculateFunction(solution);
fitness[index]=CalculateFitness(f[index]);
trial[index]=0;
}

/*All food sources are initialized */
void initial()
{
int i;
for(i=0;i<FoodNumber;i++)
{
init(i);
}
GlobalMin=f[0];
for(i=0;i<D;i++)
GlobalParams[i]=Foods[0][i];

}

void SendEmployedBees()
{
int i,j;
/*Employed Bee Phase*/
for (i=0;i<FoodNumber;i++)
{
/*The parameter to be changed is determined randomly*/
r = ((double) Math.random()*32767 / ((double)(32767)+(double)(1)) );
param2change=(int)(r*D);

/*A randomly chosen solution is used in procing a mutant solution of the solution i*/
r = ( (double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
neighbour=(int)(r*FoodNumber);

/*Randomly selected solution must be different from the solution i*/
// while(neighbour==i)
// {
// r = ( (double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
// neighbour=(int)(r*FoodNumber);
// }
for(j=0;j<D;j++)
solution[j]=Foods[i][j];

/*v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij}) */
r = ( (double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
solution[param2change]=Foods[i][param2change]+(Foods[i][param2change]-Foods[neighbour][param2change])*(r-0.5)*2;

/*if generated parameter value is out of boundaries, it is shifted onto the boundaries*/
if (solution[param2change]<lb)
solution[param2change]=lb;
if (solution[param2change]>ub)
solution[param2change]=ub;
ObjValSol=calculateFunction(solution);
FitnessSol=CalculateFitness(ObjValSol);

/*a greedy selection is applied between the current solution i and its mutant*/
if (FitnessSol>fitness[i])
{

/*If the mutant solution is better than the current solution i, replace the solution with the mutant and reset the trial counter of solution i*/
trial[i]=0;
for(j=0;j<D;j++)
Foods[i][j]=solution[j];
f[i]=ObjValSol;
fitness[i]=FitnessSol;
}
else
{ /*if the solution i can not be improved, increase its trial counter*/
trial[i]=trial[i]+1;
}

}

/*end of employed bee phase*/

}

/* A food source is chosen with the probability which is proportioal to its quality*/
/*Different schemes can be used to calculate the probability values*/
/*For example prob(i)=fitness(i)/sum(fitness)*/
/*or in a way used in the metot below prob(i)=a*fitness(i)/max(fitness)+b*/
/*probability values are calculated by using fitness values and normalized by dividing maximum fitness value*/
void CalculateProbabilities()
{
int i;
double maxfit;
maxfit=fitness[0];
for (i=1;i<FoodNumber;i++)
{
if (fitness[i]>maxfit)
maxfit=fitness[i];
}

for (i=0;i<FoodNumber;i++)
{
prob[i]=(0.9*(fitness[i]/maxfit))+0.1;
}

}

void SendOnlookerBees()
{

int i,j,t;
i=0;
t=0;
/*onlooker Bee Phase*/
while(t<FoodNumber)
{

r = ( (double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
if(r<prob[i]) /*choose a food source depending on its probability to be chosen*/
{
t++;

/*The parameter to be changed is determined randomly*/
r = ((double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
param2change=(int)(r*D);

/*A randomly chosen solution is used in procing a mutant solution of the solution i*/
r = ( (double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
neighbour=(int)(r*FoodNumber);

/*Randomly selected solution must be different from the solution i*/
while(neighbour == i)
{
//System.out.println(Math.random()*32767+" "+32767);
r = ( (double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
neighbour=(int)(r*FoodNumber);
}
for(j=0;j<D;j++)
solution[j]=Foods[i][j];

/*v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij}) */
r = ( (double)Math.random()*32767 / ((double)(32767)+(double)(1)) );
solution[param2change]=Foods[i][param2change]+(Foods[i][param2change]-Foods[neighbour][param2change])*(r-0.5)*2;

/*if generated parameter value is out of boundaries, it is shifted onto the boundaries*/
if (solution[param2change]<lb)
solution[param2change]=lb;
if (solution[param2change]>ub)
solution[param2change]=ub;
ObjValSol=calculateFunction(solution);
FitnessSol=CalculateFitness(ObjValSol);

/*a greedy selection is applied between the current solution i and its mutant*/
if (FitnessSol>fitness[i])
{
/*If the mutant solution is better than the current solution i, replace the solution with the mutant and reset the trial counter of solution i*/
trial[i]=0;
for(j=0;j<D;j++)
Foods[i][j]=solution[j];
f[i]=ObjValSol;
fitness[i]=FitnessSol;
}
else
{ /*if the solution i can not be improved, increase its trial counter*/
trial[i]=trial[i]+1;
}
} /*if */
i++;
if (i==FoodNumber-1)
i=0;
}/*while*/

/*end of onlooker bee phase */
}

/*determine the food sources whose trial counter exceeds the "limit" value. In Basic ABC, only one scout is allowed to occur in each cycle*/
void SendScoutBees()
{
int maxtrialindex,i;
maxtrialindex=0;
for (i=1;i<FoodNumber;i++)
{
if (trial[i]>trial[maxtrialindex])
maxtrialindex=i;
}
if(trial[maxtrialindex]>=limit)
{
init(maxtrialindex);
}
}

double calculateFunction(double sol[])
{
return Rastrigin (sol);
}
double sphere(double sol[])
{
int j;
double top=0;
for(j=0;j<D;j++)
{
top=top+sol[j]*sol[j];
}
return top;
}

double Rosenbrock(double sol[])
{
int j;
double top=0;
for(j=0;j<D-1;j++)
{
top=top+100*Math.pow((sol[j+1]-Math.pow((sol[j]),(double)2)),(double)2)+Math.pow((sol[j]-1),(double)2);
}
return top;
}

double Griewank(double sol[])
{
int j;
double top1,top2,top;
top=0;
top1=0;
top2=1;
for(j=0;j<D;j++)
{
top1=top1+Math.pow((sol[j]),(double)2);
top2=top2*Math.cos((((sol[j])/Math.sqrt((double)(j+1)))*Math.PI)/180);

}
top=(1/(double)4000)*top1-top2+1;
return top;
}

double Rastrigin(double sol[])
{
int j;
double top=0;

for(j=0;j<D;j++)
{
top=top+(Math.pow(sol[j],(double)2)-10*Math.cos(2*Math.PI*sol[j])+10);
}
return top;
}
}

使用方法是:
public class test {
static beeColony bee=new beeColony();

public static void main(String[] args) {
int iter=0;
int run=0;
int j=0;
double mean=0;
//srand(time(NULL));
for(run=0;run<bee.runtime;run++)
{
bee.initial();
bee.MemorizeBestSource();
for (iter=0;iter<bee.maxCycle;iter++)
{
bee.SendEmployedBees();
bee.CalculateProbabilities();
bee.SendOnlookerBees();
bee.MemorizeBestSource();
bee.SendScoutBees();
}
for(j=0;j<bee.D;j++)
{
//System.out.println("GlobalParam[%d]: %f\n",j+1,GlobalParams[j]);
System.out.println("GlobalParam["+(j+1)+"]:"+bee.GlobalParams[j]);
}
//System.out.println("%d. run: %e \n",run+1,GlobalMin);
System.out.println((run+1)+".run:"+bee.GlobalMin);
bee.GlobalMins[run]=bee.GlobalMin;
mean=mean+bee.GlobalMin;
}
mean=mean/bee.runtime;
//System.out.println("Means of %d runs: %e\n",runtime,mean);
System.out.println("Means of "+bee.runtime+"runs: "+mean);

}

}

⑷ 蜂群演算法與人工蜂群演算法有什麼的區別嗎

都是一樣的,為什麼有的會帶上「人工」呢?只是因為這些只能演算法都是「人」仿照動物行為而創造的,所以有時候才會帶上「人工」兩個字。但是指的是一個東西。
例如神經網路,也有人喜歡說是人工神經網路

⑸ 蜂群演算法中蜜蜂種群數與蜜源數是怎樣的一種關系

你得問題不是很清晰,蜜源植物和蜜蜂數量沒有直接關系的。只是和對應的產的蜂蜜數量有一定比例。一朵花上面,蜜蜂平均只會採集一次,最多採集三次,一個地方沒有充分的蜜源植物,那麼在這個地方固定養殖蜜蜂的話肯定是行不通的,最多蜂蜜自給自足。

⑹ 全國數學建模大賽 與 方法的運用

這個還真不好找,除非專門研究國賽獲獎論文的,我推薦一個國賽優秀論壇的下載地址給你,嘗試去下載幾篇看看有沒有適合你的,網路數學中國,第一個就是了

⑺ 有沒有人有多目標人工蜂群演算法的MATLAB代碼。發我一份 不勝感激!!

http://emuch.net/bbs/attachment.php?tid=3808850&aid=11221&pay=yes
裡面有多個文件
其中之一
%/* ABC algorithm coded using MATLAB language */

%/* Artificial Bee Colony (ABC) is one of the most recently defined algorithms by Dervis Karaboga in 2005, motivated by the intelligent behavior of honey bees. */

%/* Referance Papers*/

%/*D. Karaboga, AN IDEA BASED ON HONEY BEE SWARM FOR NUMERICAL OPTIMIZATION,TECHNICAL REPORT-TR06, Erciyes University, Engineering Faculty, Computer Engineering Department 2005.*/

%/*D. Karaboga, B. Basturk, A powerful and Efficient Algorithm for Numerical Function Optimization: Artificial Bee Colony (ABC) Algorithm, Journal of Global Optimization, Volume:39, Issue:3,pp:459-171, November 2007,ISSN:0925-5001 , doi: 10.1007/s10898-007-9149-x */

%/*D. Karaboga, B. Basturk, On The Performance Of Artificial Bee Colony (ABC) Algorithm, Applied Soft Computing,Volume 8, Issue 1, January 2008, Pages 687-697. */

%/*D. Karaboga, B. Akay, A Comparative Study of Artificial Bee Colony Algorithm, Applied Mathematics and Computation, 214, 108-132, 2009. */

%/*Copyright ?2009 Erciyes University, Intelligent Systems Research Group, The Dept. of Computer Engineering*/

%/*Contact:
%Dervis Karaboga ([email protected] )
%Bahriye Basturk Akay ([email protected])
%*/

clear all
close all
clc

%/* Control Parameters of ABC algorithm*/
NP=20; %/* The number of colony size (employed bees+onlooker bees)*/
FoodNumber=NP/2; %/*The number of food sources equals the half of the colony size*/
limit=100; %/*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/
maxCycle=2500; %/*The number of cycles for foraging {a stopping criteria}*/

%/* Problem specific variables*/
objfun='Sphere'; %cost function to be optimized
D=100; %/*The number of parameters of the problem to be optimized*/
ub=ones(1,D)*100; %/*lower bounds of the parameters. */
lb=ones(1,D)*(-100);%/*upper bound of the parameters.*/

runtime=1;%/*Algorithm can be run many times in order to see its robustness*/

%Foods [FoodNumber][D]; /*Foods is the population of food sources. Each row of Foods matrix is a vector holding D parameters to be optimized. The number of rows of Foods matrix equals to the FoodNumber*/
%ObjVal[FoodNumber]; /*f is a vector holding objective function values associated with food sources */
%Fitness[FoodNumber]; /*fitness is a vector holding fitness (quality) values associated with food sources*/
%trial[FoodNumber]; /*trial is a vector holding trial numbers through which solutions can not be improved*/
%prob[FoodNumber]; /*prob is a vector holding probabilities of food sources (solutions) to be chosen*/
%solution [D]; /*New solution (neighbour) proced by v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij}) j is a randomly chosen parameter and k is a randomlu chosen solution different from i*/
%ObjValSol; /*Objective function value of new solution*/
%FitnessSol; /*Fitness value of new solution*/
%neighbour, param2change; /*param2change corrresponds to j, neighbour corresponds to k in equation v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij})*/
%GlobalMin; /*Optimum solution obtained by ABC algorithm*/
%GlobalParams[D]; /*Parameters of the optimum solution*/
%GlobalMins[runtime]; /*GlobalMins holds the GlobalMin of each run in multiple runs*/

GlobalMins=zeros(1,runtime);

for r=1:runtime

% /*All food sources are initialized */
%/*Variables are initialized in the range [lb,ub]. If each parameter has different range, use arrays lb[j], ub[j] instead of lb and ub */

Range = repmat((ub-lb),[FoodNumber 1]);
Lower = repmat(lb, [FoodNumber 1]);
Foods = rand(FoodNumber,D) .* Range + Lower;

ObjVal=feval(objfun,Foods);
Fitness=calculateFitness(ObjVal);

%reset trial counters
trial=zeros(1,FoodNumber);

%/*The best food source is memorized*/
BestInd=find(ObjVal==min(ObjVal));
BestInd=BestInd(end);
GlobalMin=ObjVal(BestInd);
GlobalParams=Foods(BestInd,:);

iter=1;
while ((iter <= maxCycle)),

%%%%%%%%% EMPLOYED BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%
for i=1:(FoodNumber)

%/*The parameter to be changed is determined randomly*/
Param2Change=fix(rand*D)+1;

%/*A randomly chosen solution is used in procing a mutant solution of the solution i*/
neighbour=fix(rand*(FoodNumber))+1;

%/*Randomly selected solution must be different from the solution i*/
while(neighbour==i)
neighbour=fix(rand*(FoodNumber))+1;
end;

sol=Foods(i,:);
% /*v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij}) */
sol(Param2Change)=Foods(i,Param2Change)+(Foods(i,Param2Change)-Foods(neighbour,Param2Change))*(rand-0.5)*2;

% /*if generated parameter value is out of boundaries, it is shifted onto the boundaries*/
ind=find(sol<lb);
sol(ind)=lb(ind);
ind=find(sol>ub);
sol(ind)=ub(ind);

%evaluate new solution
ObjValSol=feval(objfun,sol);
FitnessSol=calculateFitness(ObjValSol);

% /*a greedy selection is applied between the current solution i and its mutant*/
if (FitnessSol>Fitness(i)) %/*If the mutant solution is better than the current solution i, replace the solution with the mutant and reset the trial counter of solution i*/
Foods(i,:)=sol;
Fitness(i)=FitnessSol;
ObjVal(i)=ObjValSol;
trial(i)=0;
else
trial(i)=trial(i)+1; %/*if the solution i can not be improved, increase its trial counter*/
end;

end;

%%%%%%%%%%%%%%%%%%%%%%%% CalculateProbabilities %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%/* A food source is chosen with the probability which is proportioal to its quality*/
%/*Different schemes can be used to calculate the probability values*/
%/*For example prob(i)=fitness(i)/sum(fitness)*/
%/*or in a way used in the metot below prob(i)=a*fitness(i)/max(fitness)+b*/
%/*probability values are calculated by using fitness values and normalized by dividing maximum fitness value*/

prob=(0.9.*Fitness./max(Fitness))+0.1;

%%%%%%%%%%%%%%%%%%%%%%%% ONLOOKER BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

i=1;
t=0;
while(t<FoodNumber)
if(rand<prob(i))
t=t+1;
%/*The parameter to be changed is determined randomly*/
Param2Change=fix(rand*D)+1;

%/*A randomly chosen solution is used in procing a mutant solution of the solution i*/
neighbour=fix(rand*(FoodNumber))+1;

%/*Randomly selected solution must be different from the solution i*/
while(neighbour==i)
neighbour=fix(rand*(FoodNumber))+1;
end;

sol=Foods(i,:);
% /*v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij}) */
sol(Param2Change)=Foods(i,Param2Change)+(Foods(i,Param2Change)-Foods(neighbour,Param2Change))*(rand-0.5)*2;

% /*if generated parameter value is out of boundaries, it is shifted onto the boundaries*/
ind=find(sol<lb);
sol(ind)=lb(ind);
ind=find(sol>ub);
sol(ind)=ub(ind);

%evaluate new solution
ObjValSol=feval(objfun,sol);
FitnessSol=calculateFitness(ObjValSol);

% /*a greedy selection is applied between the current solution i and its mutant*/
if (FitnessSol>Fitness(i)) %/*If the mutant solution is better than the current solution i, replace the solution with the mutant and reset the trial counter of solution i*/
Foods(i,:)=sol;
Fitness(i)=FitnessSol;
ObjVal(i)=ObjValSol;
trial(i)=0;
else
trial(i)=trial(i)+1; %/*if the solution i can not be improved, increase its trial counter*/
end;
end;

i=i+1;
if (i==(FoodNumber)+1)
i=1;
end;
end;

%/*The best food source is memorized*/
ind=find(ObjVal==min(ObjVal));
ind=ind(end);
if (ObjVal(ind)<GlobalMin)
GlobalMin=ObjVal(ind);
GlobalParams=Foods(ind,:);
end;

%%%%%%%%%%%% SCOUT BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%/*determine the food sources whose trial counter exceeds the "limit" value.
%In Basic ABC, only one scout is allowed to occur in each cycle*/

ind=find(trial==max(trial));
ind=ind(end);
if (trial(ind)>limit)
Bas(ind)=0;
sol=(ub-lb).*rand(1,D)+lb;
ObjValSol=feval(objfun,sol);
FitnessSol=calculateFitness(ObjValSol);
Foods(ind,:)=sol;
Fitness(ind)=FitnessSol;
ObjVal(ind)=ObjValSol;
end;

fprintf('Ýter=%d ObjVal=%g\n',iter,GlobalMin);
iter=iter+1;

end % End of ABC

GlobalMins(r)=GlobalMin;
end; %end of runs

save all

⑻ java人工蜂群演算法求解TSP問題

一、人工蜂群演算法的介紹

人工蜂群演算法(Artificial Bee Colony, ABC)是由Karaboga於2005年提出的一種新穎的基於群智能的全局優化演算法,其直觀背景來源於蜂群的采蜜行為,蜜蜂根據各自的分工進行不同的活動,並實現蜂群信息的共享和交流,從而找到問題的最優解。人工蜂群演算法屬於群智能演算法的一種。

二、人工蜂群演算法的原理

1、原理

標準的ABC演算法通過模擬實際蜜蜂的采蜜機制將人工蜂群分為3類: 采蜜蜂、觀察蜂和偵察蜂。整個蜂群的目標是尋找花蜜量最大的蜜源。在標準的ABC演算法中,采蜜蜂利用先前的蜜源信息尋找新的蜜源並與觀察蜂分享蜜源信息;觀察蜂在蜂房中等待並依據采蜜蜂分享的信息尋找新的蜜源;偵查蜂的任務是尋找一個新的有價值的蜜源,它們在蜂房附近隨機地尋找蜜源。

假設問題的解空間是

代碼:

[cpp]view plain

  • #include<iostream>

  • #include<time.h>

  • #include<stdlib.h>

  • #include<cmath>

  • #include<fstream>

  • #include<iomanip>

  • usingnamespacestd;

  • constintNP=40;//種群的規模,采蜜蜂+觀察蜂

  • constintFoodNumber=NP/2;//食物的數量,為采蜜蜂的數量

  • constintlimit=20;//限度,超過這個限度沒有更新采蜜蜂變成偵查蜂

  • constintmaxCycle=10000;//停止條件

  • /*****函數的特定參數*****/

  • constintD=2;//函數的參數個數

  • constdoublelb=-100;//函數的下界

  • constdoubleub=100;//函數的上界

  • doubleresult[maxCycle]={0};

  • /*****種群的定義****/

  • structBeeGroup

  • {

  • doublecode[D];//函數的維數

  • doubletrueFit;//記錄真實的最小值

  • doublefitness;

  • doublerfitness;//相對適應值比例

  • inttrail;//表示實驗的次數,用於與limit作比較

  • }Bee[FoodNumber];

  • BeeGroupNectarSource[FoodNumber];//蜜源,注意:一切的修改都是針對蜜源而言的

  • BeeGroupEmployedBee[FoodNumber];//采蜜蜂

  • BeeGroupOnLooker[FoodNumber];//觀察蜂

  • BeeGroupBestSource;//記錄最好蜜源

  • /*****函數的聲明*****/

  • doublerandom(double,double);//產生區間上的隨機數

  • voidinitilize();//初始化參數

  • doublecalculationTruefit(BeeGroup);//計算真實的函數值

  • doublecalculationFitness(double);//計算適應值

  • voidCalculateProbabilities();//計算輪盤賭的概率

  • voidevalueSource();//評價蜜源

  • voidsendEmployedBees();

  • voidsendOnlookerBees();

  • voidsendScoutBees();

  • voidMemorizeBestSource();

  • /*******主函數*******/

  • intmain()

  • {

  • ofstreamoutput;

  • output.open("dataABC.txt");

  • srand((unsigned)time(NULL));

  • initilize();//初始化

  • MemorizeBestSource();//保存最好的蜜源

  • //主要的循環

  • intgen=0;

  • while(gen<maxCycle)

  • {

  • sendEmployedBees();

  • CalculateProbabilities();

  • sendOnlookerBees();

  • MemorizeBestSource();

  • sendScoutBees();

  • MemorizeBestSource();

  • output<<setprecision(30)<<BestSource.trueFit<<endl;

  • gen++;

  • }

  • output.close();

  • cout<<"運行結束!!"<<endl;

  • return0;

  • }

  • /*****函數的實現****/

  • doublerandom(doublestart,doubleend)//隨機產生區間內的隨機數

  • {

  • returnstart+(end-start)*rand()/(RAND_MAX+1.0);

  • }

  • voidinitilize()//初始化參數

  • {

  • inti,j;

  • for(i=0;i<FoodNumber;i++)

  • {

  • for(j=0;j<D;j++)

  • {

  • NectarSource[i].code[j]=random(lb,ub);

  • EmployedBee[i].code[j]=NectarSource[i].code[j];

  • OnLooker[i].code[j]=NectarSource[i].code[j];

  • BestSource.code[j]=NectarSource[0].code[j];

  • }

  • /****蜜源的初始化*****/

  • NectarSource[i].trueFit=calculationTruefit(NectarSource[i]);

  • NectarSource[i].fitness=calculationFitness(NectarSource[i].trueFit);

  • NectarSource[i].rfitness=0;

  • NectarSource[i].trail=0;

  • /****采蜜蜂的初始化*****/

  • EmployedBee[i].trueFit=NectarSource[i].trueFit;

  • EmployedBee[i].fitness=NectarSource[i].fitness;

  • EmployedBee[i].rfitness=NectarSource[i].rfitness;

  • EmployedBee[i].trail=NectarSource[i].trail;

  • /****觀察蜂的初始化****/

  • OnLooker[i].trueFit=NectarSource[i].trueFit;

  • OnLooker[i].fitness=NectarSource[i].fitness;

  • OnLooker[i].rfitness=NectarSource[i].rfitness;

  • OnLooker[i].trail=NectarSource[i].trail;

  • }

  • /*****最優蜜源的初始化*****/

  • BestSource.trueFit=NectarSource[0].trueFit;

  • BestSource.fitness=NectarSource[0].fitness;

  • BestSource.rfitness=NectarSource[0].rfitness;

  • BestSource.trail=NectarSource[0].trail;

  • }

  • doublecalculationTruefit(BeeGroupbee)//計算真實的函數值

  • {

  • doubletruefit=0;

  • /******測試函數1******/

  • truefit=0.5+(sin(sqrt(bee.code[0]*bee.code[0]+bee.code[1]*bee.code[1]))*sin(sqrt(bee.code[0]*bee.code[0]+bee.code[1]*bee.code[1]))-0.5)

  • /((1+0.001*(bee.code[0]*bee.code[0]+bee.code[1]*bee.code[1]))*(1+0.001*(bee.code[0]*bee.code[0]+bee.code[1]*bee.code[1])));

  • returntruefit;

  • }

  • doublecalculationFitness(doubletruefit)//計算適應值

  • {

  • doublefitnessResult=0;

  • if(truefit>=0)

  • {

  • fitnessResult=1/(truefit+1);

  • }else

  • {

  • fitnessResult=1+abs(truefit);

  • }

  • returnfitnessResult;

  • }

  • voidsendEmployedBees()//修改采蜜蜂的函數

  • {

  • inti,j,k;

  • intparam2change;//需要改變的維數

  • doubleRij;//[-1,1]之間的隨機數

  • for(i=0;i<FoodNumber;i++)

  • {

  • param2change=(int)random(0,D);//隨機選取需要改變的維數

  • /******選取不等於i的k********/

  • while(1)

  • {

  • k=(int)random(0,FoodNumber);

  • if(k!=i)

  • {

  • break;

  • }

  • }

  • for(j=0;j<D;j++)

  • {

  • EmployedBee[i].code[j]=NectarSource[i].code[j];

  • }

  • /*******采蜜蜂去更新信息*******/

  • Rij=random(-1,1);

  • EmployedBee[i].code[param2change]=NectarSource[i].code[param2change]+Rij*(NectarSource[i].code[param2change]-NectarSource[k].code[param2change]);

  • /*******判斷是否越界********/

  • if(EmployedBee[i].code[param2change]>ub)

  • {

  • EmployedBee[i].code[param2change]=ub;

  • }

  • if(EmployedBee[i].code[param2change]<lb)

  • {

  • EmployedBee[i].code[param2change]=lb;

  • }

  • EmployedBee[i].trueFit=calculationTruefit(EmployedBee[i]);

  • EmployedBee[i].fitness=calculationFitness(EmployedBee[i].trueFit);

  • /******貪婪選擇策略*******/

  • if(EmployedBee[i].trueFit<NectarSource[i].trueFit)

  • {

  • for(j=0;j<D;j++)

  • {

  • NectarSource[i].code[j]=EmployedBee[i].code[j];

  • }

  • NectarSource[i].trail=0;

  • NectarSource[i].trueFit=EmployedBee[i].trueFit;

  • NectarSource[i].fitness=EmployedBee[i].fitness;

  • }else

  • {

  • NectarSource[i].trail++;

  • }

  • }

  • }

  • voidCalculateProbabilities()//計算輪盤賭的選擇概率

  • {

  • inti;

  • doublemaxfit;

  • maxfit=NectarSource[0].fitness;

  • for(i=1;i<FoodNumber;i++)

  • {

  • if(NectarSource[i].fitness>maxfit)

  • maxfit=NectarSource[i].fitness;

  • }

  • for(i=0;i<FoodNumber;i++)

  • {

  • NectarSource[i].rfitness=(0.9*(NectarSource[i].fitness/maxfit))+0.1;

  • }

  • }

  • voidsendOnlookerBees()//采蜜蜂與觀察蜂交流信息,觀察蜂更改信息

  • {

  • inti,j,t,k;

  • doubleR_choosed;//被選中的概率

  • intparam2change;//需要被改變的維數

  • doubleRij;//[-1,1]之間的隨機數

  • i=0;

  • t=0;

  • while(t<FoodNumber)

  • {

  • R_choosed=random(0,1);

  • if(R_choosed<NectarSource[i].rfitness)//根據被選擇的概率選擇

  • {

  • t++;

  • param2change=(int)random(0,D);

  • /******選取不等於i的k********/

  • while(1)

  • {

  • k=(int)random(0,FoodNumber);

  • if(k!=i)

  • {

  • break;

  • }

  • }

  • for(j=0;j<D;j++)

  • {

  • OnLooker[i].code[j]=NectarSource[i].code[j];

  • }

  • /****更新******/

  • Rij=random(-1,1);

  • OnLooker[i].code[param2change]=NectarSource[i].code[param2change]+Rij*(NectarSource[i].code[param2change]-NectarSource[k].code[param2change]);

  • /*******判斷是否越界*******/

  • if(OnLooker[i].code[param2change]<lb)

  • {

  • OnLooker[i].code[param2change]=lb;

  • }

  • if(OnLooker[i].code[param2change]>ub)

  • {

  • OnLooker[i].code[param2change]=ub;

  • }

  • OnLooker[i].trueFit=calculationTruefit(OnLooker[i]);

  • OnLooker[i].fitness=calculationFitness(OnLooker[i].trueFit);

  • /****貪婪選擇策略******/

  • if(OnLooker[i].trueFit<NectarSource[i].trueFit)

  • {

  • for(j=0;j<D;j++)

  • {

  • NectarSource[i].code[j]=OnLooker[i].code[j];

  • }

  • NectarSource[i].trail=0;

  • NectarSource[i].trueFit=OnLooker[i].trueFit;

  • NectarSource[i].fitness=OnLooker[i].fitness;

  • }else

  • {

  • NectarSource[i].trail++;

  • }

  • }

  • i++;

  • if(i==FoodNumber)

  • {

  • i=0;

  • }

  • }

  • }

  • ⑼ 人工蜂群演算法的蜜蜂采蜜機理

    蜜蜂是一種群居昆蟲,雖然單個昆蟲的行為極其簡單,但是由單個簡單的個體所組成的群體卻表現出極其復雜的行為。真實的蜜蜂種群能夠在任何環境下,以極高的效率從食物源(花朵)中採集花蜜;同時,它們能適應環境的改變。
    蜂群產生群體智慧的最小搜索模型包含基本的三個組成要素:食物源、被僱傭的蜜蜂(employed foragers)和未被僱傭的蜜蜂(unemployed foragers);兩種最為基本的行為模型:為食物源招募(recruit)蜜蜂和放棄(abandon)某個食物源。
    (1)食物源:食物源的價值由多方面的因素決定,如:它離蜂巢的遠近,包含花蜜的豐富程度和獲得花蜜的難易程度。使用單一的參數,食物源的「收益率」(profitability),來代表以上各個因素。
    (2)被僱用的蜜蜂:也稱引領蜂(Leader),其與所採集的食物源一一對應。引領蜂儲存有某一個食物源的相關信息(相對於蜂巢的距離、方向、食物源的豐富程度等)並且將這些信息以一定的概率與其他蜜蜂分享。
    (3)未被僱用的蜜蜂:其主要任務是尋找和開採食物源。有兩種未被僱用的蜜蜂:偵查蜂(Scouter)和跟隨蜂(Follower)。偵察蜂搜索蜂巢附近的新食物源;跟隨蜂等在蜂巢裡面並通過與引領蜂分享相關信息找到食物源。一般情況下,偵察蜂的平均數目是蜂群的5%-20%。
    在群體智慧的形成過程中,蜜蜂間交換信息是最為重要的一環。舞蹈區是蜂巢中最為重要的信息交換地。蜜蜂的舞蹈叫做搖擺舞。食物源的信息在舞蹈區通過搖擺舞的形式與其他蜜蜂共享,引領蜂通過搖擺舞的持續時間等來表現食物源的收益率,故跟隨蜂可以觀察到大量的舞蹈並依據收益率來選擇到哪個食物源采蜜。收益率與食物源被選擇的可能性成正比。因而,蜜蜂被招募到某一個食物源的概率與食物源的收益率成正比。
    初始時刻,蜜蜂以偵察蜂的身份搜索。其搜索可以由系統提供的先驗知識決定,也可以完全隨機。經過一輪偵查後,若蜜蜂找到食物源,蜜蜂利用它本身的存儲能力記錄位置信息並開始采蜜。此時,蜜蜂將成為「被僱用者」。蜜蜂在食物源采蜜後回到蜂巢卸下蜂蜜然後將有如下選擇:
    (1)放棄食物源而成為非僱傭蜂。
    (2)跳搖擺舞為所對應的食物源招募更多的蜜蜂,然後回到食物源采蜜。
    (3)繼續在同一個食物源采蜜而不進行招募。
    對於非僱傭蜂有如下選擇:
    (1)轉變成為偵察蜂並搜索蜂巢附近的食物源。其搜索可以由先驗知識決定,也可以完全隨機。
    (2)在觀察完搖擺舞後被僱用成為跟隨蜂,開始搜索對應食物源鄰域並采蜜。

    ⑽ 蜂群演算法屬於初級還是高級

    人工蜂群演算法(Artificial Bee Colony, ABC)是由Karaboga於2005年提出的一種新穎的基於群智能的全局優化演算法,其直觀背景來源於蜂群的采蜜行為,蜜蜂根據各自的分工進行不同的活動,並實現蜂群信息的共享和交流,從而找到問題的最優解。人工蜂群演算法屬於群智能演算法的一種。

    閱讀全文

    與多目標蜂群演算法相關的資料

    熱點內容
    成都市區建成面積演算法 瀏覽:658
    智能家居單片機 瀏覽:95
    買男裝用什麼app好 瀏覽:853
    文件夾合並了怎麼拆開 瀏覽:256
    波段副圖源碼無未來函數 瀏覽:86
    livecn伺服器地址 瀏覽:257
    程序員這個工作真的很吃香嗎 瀏覽:844
    程序員和數學分析師待遇 瀏覽:678
    壓縮氣彈簧怎麼拆 瀏覽:321
    華為公有雲伺服器添加虛擬ip 瀏覽:209
    程序員和運營哪個累 瀏覽:24
    抖音安卓信息提示音怎麼設置 瀏覽:454
    光速虛擬機的共享文件夾 瀏覽:248
    程序員培訓機構發的朋友圈真實性 瀏覽:742
    天乾地支簡單演算法 瀏覽:299
    下載個壓縮文件 瀏覽:300
    普通人電腦關機vs程序員關機 瀏覽:628
    米酷建站源碼 瀏覽:115
    氫氣app怎麼搜搭配 瀏覽:619
    pdf綠盟 瀏覽:506