一起来学演化计算-SBX模拟二进制交叉算子和DE差分进化算子
时间:2022-07-23
本文章向大家介绍一起来学演化计算-SBX模拟二进制交叉算子和DE差分进化算子,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
参考文献
[1] https://blog.csdn.net/qq_36347331/article/details/96351162
[2] http://www.it1352.com/994287.html
[3] https://www.egr.msu.edu/~kdeb/
SBX
DE
SBX matlab版本实现
function object=crossover(object,p1,p2,cf)
object.rnvec=0.5*((1+cf).*p1.rnvec + (1-cf).*p2.rnvec);
% 截断范围
object.rnvec(object.rnvec>1)=1;
object.rnvec(object.rnvec<0)=0;
end
u = rand(1,D_multitask);
cf = zeros(1,D_multitask);
cf(u<=0.5)=(2*u(u<=0.5)).^(1/(mu+1));
cf(u>0.5)=(2*(1-u(u>0.5))).^(-1/(mu+1));
child(count) = crossover(child(count),population(p1),population(p2),cf);
child(count+1) = crossover(child(count+1),population(p2),population(p1),cf);
SBX java版本实现
/**
* This class allows to apply a SBX crossover operator using two parent
* solutions.
* 关于此代码和Deb论文中代码不一致可以查看http://www.it1352.com/994287.html帖子或者查看Deb官方源码
*/
// SBXCrossover.java
//
// Author:
// Antonio J. Nebro <antonio@lcc.uma.es>
// Juan J. Durillo <durillo@lcc.uma.es>
//
// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.*/
public Solution[] doCrossover(double probability, Solution parent1, Solution parent2) throws JMException {
Solution[] offSpring = new Solution[2];
/**
*使用一个父代个体去生成新个体的原因在于可以将父代的属性传给子代
*具体有:
* public Solution(Solution solution) {
* problemSet_ = solution.problemSet_;
* type_ = solution.type_;
*
* numberOfObjectives_ = solution.getNumberOfObjectives();
* objective_ = new double[numberOfObjectives_];
* for (int i = 0; i < objective_.length; i++) {
* objective_[i] = solution.getObjective(i);
* } // for
* // <-
*
* variable_ = type_.copyVariables(solution.variable_);
* overallConstraintViolation_ = solution.getOverallConstraintViolation();
* numberOfViolatedConstraints_ = solution.getNumberOfViolatedConstraint();
* distanceToSolutionSet_ = solution.getDistanceToSolutionSet();
* crowdingDistance_ = solution.getCrowdingDistance();
* kDistance_ = solution.getKDistance();
* fitness_ = solution.getFitness();
* rank_ = solution.getRank();
* location_ = solution.getLocation();
*
* skillFactor_ = solution.getSkillFactor();* } // Solution
* */
offSpring[0] = new Solution(parent1);
offSpring[1] = new Solution(parent2);
int i;
double rand;
double y1, y2, yL, yu;
double c1, c2;
double alpha, beta, betaq;
double valueX1, valueX2;
XReal x1 = new XReal(parent1);
XReal x2 = new XReal(parent2);
XReal offs1 = new XReal(offSpring[0]);
XReal offs2 = new XReal(offSpring[1]);
int numberOfVariables = x1.getNumberOfDecisionVariables();
if (PseudoRandom.randDouble() <= probability) {
//只有随机生成的数小于自定义的交叉可能性时才进行交叉操作
for (i = 0; i < numberOfVariables; i++) {
valueX1 = x1.getValue(i);
valueX2 = x2.getValue(i);
if (PseudoRandom.randDouble() <= 0.5) {
if (java.lang.Math.abs(valueX1 - valueX2) > EPS) {
if (valueX1 < valueX2) {
y1 = valueX1;
y2 = valueX2;
} else {
y1 = valueX2;
y2 = valueX1;
} // if
yL = x1.getLowerBound(i);
yu = x1.getUpperBound(i);
rand = PseudoRandom.randDouble();
beta = 1.0 + (2.0 * (y1 - yL) / (y2 - y1));
alpha = 2.0 - java.lang.Math.pow(beta, -(distributionIndex_ + 1.0));
if (rand <= (1.0 / alpha)) {
betaq = java.lang.Math.pow((rand * alpha), (1.0 / (distributionIndex_ + 1.0)));
} else {
betaq = java.lang.Math.pow((1.0 / (2.0 - rand * alpha)),
(1.0 / (distributionIndex_ + 1.0)));
} // if
c1 = 0.5 * ((y1 + y2) - betaq * (y2 - y1));
beta = 1.0 + (2.0 * (yu - y2) / (y2 - y1));
alpha = 2.0 - java.lang.Math.pow(beta, -(distributionIndex_ + 1.0));
if (rand <= (1.0 / alpha)) {
betaq = java.lang.Math.pow((rand * alpha), (1.0 / (distributionIndex_ + 1.0)));
} else {
betaq = java.lang.Math.pow((1.0 / (2.0 - rand * alpha)),
(1.0 / (distributionIndex_ + 1.0)));
} // if
c2 = 0.5 * ((y1 + y2) + betaq * (y2 - y1));
if (c1 < yL)
c1 = yL;
if (c2 < yL)
c2 = yL;
if (c1 > yu)
c1 = yu;
if (c2 > yu)
c2 = yu;
if (PseudoRandom.randDouble() <= 0.5) {
offs1.setValue(i, c2);
offs2.setValue(i, c1);
} else {
offs1.setValue(i, c1);
offs2.setValue(i, c2);
} // if
} else {
offs1.setValue(i, valueX1);
offs2.setValue(i, valueX2);
} // if
} else {
offs1.setValue(i, valueX2);
offs2.setValue(i, valueX1);
} // if
} // if
} // if
return offSpring;
}
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 数据库应用技术系列第一讲 创建数据库和表
- 怎样让数据库再快一点?
- 大数据场景下,如何快速将Linux 大文件处理小
- Mysql系列第十六讲 变量详解
- Mysql系列第十七讲 流程控制语句(高手进阶)
- 私藏的5个好用的Pandas函数!
- 漫画:如何在数组中找到和为 “特定值” 的两个数?
- 当你在百度搜索关键字的时候,哪个网站会排在最前面?今天给大家科普一下“网站SEO”
- Mysql系列第十九讲 异常捕获及处理详解
- 【原创】经验分享:一个小小emoji尽然牵扯出来这么多东西?
- jQuery 事件对象,拷贝对象,多库共存
- jQuery 事件注册与事件处理
- v-charts 修改文本颜色
- 使用 jsDelivr 免费加速 GitHub Pages 博客的静态资源(二)
- 竞赛比完,代码、模型怎么处理?Kaggle大神:别删,这都是宝藏