导航:首页 > 源码编译 > 多目标蜂群算法

多目标蜂群算法

发布时间: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年提出的一种新颖的基于群智能的全局优化算法,其直观背景来源于蜂群的采蜜行为,蜜蜂根据各自的分工进行不同的活动,并实现蜂群信息的共享和交流,从而找到问题的最优解。人工蜂群算法属于群智能算法的一种。

    阅读全文

    与多目标蜂群算法相关的资料

    热点内容
    python二次开发cad 浏览:302
    程序员直播机器人舞团 浏览:769
    devc指针编译问题 浏览:1000
    支持dsd硬解压声卡 浏览:771
    怎么查看u盘加密区 浏览:184
    台电加密是什么格式 浏览:157
    php论坛版块在哪个文件夹 浏览:442
    暗黑的服务器为什么维护 浏览:624
    android内存溢出的原因 浏览:18
    标志307的压缩比是多少 浏览:636
    服务器启动为什么叫三声 浏览:997
    追风筝的人英文pdf 浏览:940
    解压小熊手机壳 浏览:347
    成都市区建成面积算法 浏览:662
    智能家居单片机 浏览:98
    买男装用什么app好 浏览:856
    文件夹合并了怎么拆开 浏览:262
    波段副图源码无未来函数 浏览:91
    livecn服务器地址 浏览:259
    程序员这个工作真的很吃香吗 浏览:848