人工蜂群算法里太多比喻了,能不能就算法本身的步骤来讲讲?
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/09 10:11:29
人工蜂群算法里太多比喻了,能不能就算法本身的步骤来讲讲?
哪位熟悉人工蜂群算法的么?硕士论文中要用,只是介绍的论文和文章中都是原始意义,就是太多比喻,雇佣蜂侦查蜂回巢跳舞什么的.能不能就计算机算法本身,如怎样编码,初始种群生成,从这个角度来讲讲这个算法的步骤?
哪位熟悉人工蜂群算法的么?硕士论文中要用,只是介绍的论文和文章中都是原始意义,就是太多比喻,雇佣蜂侦查蜂回巢跳舞什么的.能不能就计算机算法本身,如怎样编码,初始种群生成,从这个角度来讲讲这个算法的步骤?
直接给你JAVA代码吧,看的简单易懂
import java.lang.Math;
public class beeColony {
\x05/* Control Parameters of ABC algorithm*/
\x05int NP=20; /* The number of colony size (employed bees+onlooker bees)*/
\x05int FoodNumber = NP/2; /*The number of food sources equals the half of the colony size*/
\x05int limit = 100; /*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/
\x05int maxCycle = 2500; /*The number of cycles for foraging {a stopping criteria}*/
\x05/* Problem specific variables*/
\x05int D = 100; /*The number of parameters of the problem to be optimized*/
\x05double lb = -5.12; /*lower bound of the parameters.*/
\x05double 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*/
\x05int runtime = 30; /*Algorithm can be run many times in order to see its robustness*/
\x05int dizi1[]=new int[10];
\x05double 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*/
\x05double f[]=new double[FoodNumber]; /*f is a vector holding objective function values associated with food sources */
\x05double fitness[]=new double[FoodNumber]; /*fitness is a vector holding fitness (quality) values associated with food sources*/
\x05double trial[]=new double[FoodNumber]; /*trial is a vector holding trial numbers through which solutions can not be improved*/
\x05double prob[]=new double[FoodNumber]; /*prob is a vector holding probabilities of food sources (solutions) to be chosen*/
\x05double solution[]=new double[D]; /*New solution (neighbour) produced 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*/
\x05
\x05double ObjValSol; /*Objective function value of new solution*/
\x05double FitnessSol; /*Fitness value of new solution*/
\x05int neighbour,param2change; /*param2change corrresponds to j,neighbour corresponds to k in equation v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij})*/
\x05double GlobalMin; /*Optimum solution obtained by ABC algorithm*/
\x05double GlobalParams[]=new double[D]; /*Parameters of the optimum solution*/
\x05double GlobalMins[]=new double[runtime];
\x05 /*GlobalMins holds the GlobalMin of each run in multiple runs*/
\x05double r; /*a random number in the range [0,1)*/
\x05/*a function pointer returning double and taking a D-dimensional array as argument */
\x05/*If your function takes additional arguments then change function pointer definition and lines calling "...=function(solution);" in the code*/
//\x05typedef double (*FunctionCallback)(double sol[D]);
\x05/*benchmark functions */
//\x05double sphere(double sol[D]);
//\x05double Rosenbrock(double sol[D]);
//\x05double Griewank(double sol[D]);
//\x05double Rastrigin(double sol[D]);
\x05/*Write your own objective function name instead of sphere*/
//\x05FunctionCallback function = &sphere;
\x05/*Fitness function*/
\x05double CalculateFitness(double fun)
\x05 {
\x05\x05 double result=0;
\x05\x05 if(fun>=0)
\x05\x05 {
\x05\x05\x05 result=1/(fun+1);
\x05\x05 }
\x05\x05 else
\x05\x05 {
\x05\x05\x05
\x05\x05\x05 result=1+Math.abs(fun);
\x05\x05 }
\x05\x05 return result;
\x05 }
\x05/*The best food source is memorized*/
\x05void MemorizeBestSource()
\x05{
\x05 int i,j;
\x05
\x05\x05for(i=0;i
import java.lang.Math;
public class beeColony {
\x05/* Control Parameters of ABC algorithm*/
\x05int NP=20; /* The number of colony size (employed bees+onlooker bees)*/
\x05int FoodNumber = NP/2; /*The number of food sources equals the half of the colony size*/
\x05int limit = 100; /*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/
\x05int maxCycle = 2500; /*The number of cycles for foraging {a stopping criteria}*/
\x05/* Problem specific variables*/
\x05int D = 100; /*The number of parameters of the problem to be optimized*/
\x05double lb = -5.12; /*lower bound of the parameters.*/
\x05double 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*/
\x05int runtime = 30; /*Algorithm can be run many times in order to see its robustness*/
\x05int dizi1[]=new int[10];
\x05double 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*/
\x05double f[]=new double[FoodNumber]; /*f is a vector holding objective function values associated with food sources */
\x05double fitness[]=new double[FoodNumber]; /*fitness is a vector holding fitness (quality) values associated with food sources*/
\x05double trial[]=new double[FoodNumber]; /*trial is a vector holding trial numbers through which solutions can not be improved*/
\x05double prob[]=new double[FoodNumber]; /*prob is a vector holding probabilities of food sources (solutions) to be chosen*/
\x05double solution[]=new double[D]; /*New solution (neighbour) produced 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*/
\x05
\x05double ObjValSol; /*Objective function value of new solution*/
\x05double FitnessSol; /*Fitness value of new solution*/
\x05int neighbour,param2change; /*param2change corrresponds to j,neighbour corresponds to k in equation v_{ij}=x_{ij}+\phi_{ij}*(x_{kj}-x_{ij})*/
\x05double GlobalMin; /*Optimum solution obtained by ABC algorithm*/
\x05double GlobalParams[]=new double[D]; /*Parameters of the optimum solution*/
\x05double GlobalMins[]=new double[runtime];
\x05 /*GlobalMins holds the GlobalMin of each run in multiple runs*/
\x05double r; /*a random number in the range [0,1)*/
\x05/*a function pointer returning double and taking a D-dimensional array as argument */
\x05/*If your function takes additional arguments then change function pointer definition and lines calling "...=function(solution);" in the code*/
//\x05typedef double (*FunctionCallback)(double sol[D]);
\x05/*benchmark functions */
//\x05double sphere(double sol[D]);
//\x05double Rosenbrock(double sol[D]);
//\x05double Griewank(double sol[D]);
//\x05double Rastrigin(double sol[D]);
\x05/*Write your own objective function name instead of sphere*/
//\x05FunctionCallback function = &sphere;
\x05/*Fitness function*/
\x05double CalculateFitness(double fun)
\x05 {
\x05\x05 double result=0;
\x05\x05 if(fun>=0)
\x05\x05 {
\x05\x05\x05 result=1/(fun+1);
\x05\x05 }
\x05\x05 else
\x05\x05 {
\x05\x05\x05
\x05\x05\x05 result=1+Math.abs(fun);
\x05\x05 }
\x05\x05 return result;
\x05 }
\x05/*The best food source is memorized*/
\x05void MemorizeBestSource()
\x05{
\x05 int i,j;
\x05
\x05\x05for(i=0;i
DES算法加密的算法步骤是
我想知道像差分进化算法、蚁群算法、蜂群算法、量子进化算法属于进化算法吗?
鸡兔同笼简便算法鸡和兔都抬起一条腿,然后脚的总数除以2,然后这个数减头的总数 就是兔的只数了.……偶不会,谁来讲讲.
tsp是什么啊?用TSP算法来遍历图的时候,遍历形成了一个环,没有遍历到所有节点,如何改进,还是这种算法本身就有缺陷啊,
有些数学难题 要步骤(有简便算法的计算题就用)
matlab遗传算法工具箱里用的是哪种遗传算法
写出1—1000所有奇数的程序框图.框图可以不画,告诉我算法步骤的就可以了,流程
蚁群算法、遗传算法、蜂群算法、粒子群算法和差分进化算法,这五种群智能对比分析
ANN算法是什么(人工神经网络),求简单算法介绍
设计一个算法找出50以内的所有质数,算法步骤用自然语言描述
有谁知道运用英国Sheffield遗传算法工具箱能不能进行混合遗传算法的编程?
启发式算法是最优化算法吗?像遗传算法、粒子群算法这一类的可不可以归结到最优化算法里?