一起来学演化计算-SBX(Simulated binary crossover)模拟二进制交叉算子和DE(differential evolution)差分进化算子

觉得有用的话,欢迎一起讨论相互学习~Follow Me

参考文献

[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;
}

SBX(Simulated binary crossover)模拟二进制交叉算子和DE(differential evolution)差分进化算子的更多相关文章

  1. 遗传算法,实数编码的交叉操作之SBX(模拟二进制交叉)

    本文主要介绍遗传算法(实数编码)的交叉操作中的SBX,模拟二进制交叉. 首先,给出个人用python2.7实现的代码,具体模块已上传到: https://github.com/guojun007/sb ...

  2. 标准遗传算法(实数编码 python实现)模拟二进制交叉SBX 多项式变异

    代码地址: https://github.com/guojun007/real_sga 本部分是采用实数编码的标准遗传算法,整体流程与上一篇二进制编码的基本一致, 主要区别在于本部分的交叉操作为模拟二 ...

  3. [转]Laplace算子和Laplacian矩阵

    1 Laplace算子的物理意义 Laplace算子的定义为梯度的散度. 在Cartesian坐标系下也可表示为: 或者,它是Hessian矩阵的迹: 以热传导方程为例,因为热流与温度的梯度成正比,那 ...

  4. Laplace算子和Laplacian矩阵

    1 Laplace算子的物理意义 Laplace算子的定义为梯度的散度. 在Cartesian坐标系下也可表示为: 或者,它是Hessian矩阵的迹: 以热传导方程为例,因为热流与温度的梯度成正比,那 ...

  5. Python 图像处理 OpenCV (13): Scharr 算子和 LOG 算子边缘检测技术

    前文传送门: 「Python 图像处理 OpenCV (1):入门」 「Python 图像处理 OpenCV (2):像素处理与 Numpy 操作以及 Matplotlib 显示图像」 「Python ...

  6. Java流中的map算子和flatMap算子的区别

    map算子和flatMap算子 map和flatMap都是映射(转换),那么他们之间究竟有什么区别呢? 1.我们先简单了解下map算子: @org.junit.Test public void tes ...

  7. Python 图像处理 OpenCV (12): Roberts 算子、 Prewitt 算子、 Sobel 算子和 Laplacian 算子边缘检测技术

    前文传送门: 「Python 图像处理 OpenCV (1):入门」 「Python 图像处理 OpenCV (2):像素处理与 Numpy 操作以及 Matplotlib 显示图像」 「Python ...

  8. [Introduction to programming in Java 笔记] 1.3.7 Converting to binary 十进制到二进制的转换

    public class Binary { public static void main(String[] args) { // Print binary representation of N. ...

  9. Binary Gap(二进制空白)

    中文标题[二进制空白] 英文描述 A binary gap within a positive integer N is any maximal sequence of consecutive zer ...

随机推荐

  1. SVM: 相对于logistic regression而言SVM的 cost function与hypothesis

    很多学习算法的性能都差不多,关键不是使用哪种学习算法,而是你能得到多少数据量和应用这些学习算法的技巧(如选择什么特征向量,如何选择正则化参数等) SVM在解决非线性问题上提供了强大的方法. logis ...

  2. Selenium常用API的使用java语言之20-获取窗口截图

    自动化用例是由程序去执行,因此有时候打印的错误信息并不十分明确.如果在脚本执行出错的时候能对当前窗口截图保存,那么通过图片就可以非常直观地看出出错的原因. WebDriver提供了截图函数getScr ...

  3. sizeof的注意点

    sizeof('a')的值为4.因为此处‘a’是独立存在的一个字符(没有赋值给其它变量),实际上就是一个整型数,占4个字节,即此处‘a’对应的ascii码的十进制为整数97.(貌似解释得有些牵强,但事 ...

  4. mysql跨表删除多条记录

    Mysql可以在一个sql语句中同时删除多表记录,也可以根据多个表之间的关系来删除某一个表中的记录. 假定我们有两张表:Product表和ProductPrice表.前者存在Product的基本信息, ...

  5. Oracle - 合并查询数据项

    select c.channel, c.channel_name , s.show_type, s.show_type_name from T_CHANNEL_INFO c, T_SHOW_INFO ...

  6. Apache Phoenix系列 | 从入门到精通(转载)

    原文地址:https://cloud.tencent.com/developer/article/1498057 来源: 云栖社区 作者: 瑾谦 By 大数据技术与架构 文章简介:Phoenix是一个 ...

  7. Greenplum failed segment的恢复方法--primary与mirror都可修复

    当在使用greenplum过程中有不当的操作时,可能会出现segment节点宕掉的情况(比如在greenplum运行的过程中停掉其中几台segment节点的服务器),通过下面的方法可以恢复segmen ...

  8. saltstack 在window下 发布 service 服务

    saltstack 发布 service 服务 如果是注册的服务发布:   salt -L '172.16.3.39' state.sls service.deploy 目录结构: /home/sal ...

  9. 37、数据源之通用的load和save操作

    一.通用的load和save操作 1.概述 对于Spark SQL的DataFrame来说,无论是从什么数据源创建出来的DataFrame,都有一些共同的load和save操作. load操作主要用于 ...

  10. Mac下打开/usr/local目录

    Mac下/usr/local目录默认是对于Finder是隐藏,如果需要到/usr/local下去,打开Finder,然后使用command+shift+G,在弹出的目录中填写/usr/local就可以 ...