📄 deagent.java
字号:
/**
* Description: The description of differential evolution agent.
#Supported parameters:
NAME VALUE_type Range DefaultV Description
FACTOR real (0, 1.2] 0.5 DEAgent: scale constant
CR real [0, 1] 0.9 DEAgent: crossover constant
//Other choices for FACTOR and CR: (0.5, 0.1)
*
* @ Author Create/Modi Note
* Xiaofeng Xie May 11, 2004
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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.
*
* Please acknowledge the author(s) if you use this code in any way.
*
* @version 1.0
* @Since MAOS1.0
*
* @References:
* [1] Storn R, Price K. Differential evolution - a simple and efficient
* heuristic for global optimization over continuous spaces. Journal of
* Global Optimization, 1997, 11: 341–359
* @The initial idea
* [2] Zhang W J, Xie X F. DEPSO: hybrid particle swarm with differential
* evolution operator. IEEE Int. Conf. on Systems, Man & Cybernetics,
* Washington D C, USA, 2003: 3816-3821
* @ The experimental-based explanation on the differential vector
*/
package agent;
import knowledge.*;
import Global.*;
import problem.*;
import space.*;
public class DEAgent extends AbstractAgent implements ILibEngine {
public int DVNum = 2; //Number of differential vectors
public double FACTOR = 0.5; //scale constant: (0, 1.2]
public double CR = 0.9; //crossover constant: [0, 1]
//The referred external library
protected Library socialLib;
//the own memory: store the point that generated in last learning cycle
protected SearchPoint pbest_t;
//the best point in the social sharing information
protected SearchPoint gbest_t;
public void setLibrary(Library lib) {
socialLib = lib;
}
public void setProblemEncoder(ProblemEncoder encoder) {
super.setProblemEncoder(encoder);
}
public void setGbest(SearchPoint gbest) {
gbest_t = gbest;
}
public void setPbest(SearchPoint pbest) {
pbest_t = pbest;
}
protected void generatePoint(ILocationEngine tempPoint, int t) {
BasicPoint[] referPoints = getReferPoints();
int DIMENSION = problemEncoder.getDesignSpace().getDimension();
int rj = RandomGenerator.intRangeRandom(0, DIMENSION-1);
for (int k=0; k<DIMENSION; k++) {
if (Math.random()<CR || k == DIMENSION-1) {
double Dabcd = 0;
for(int i=0; i<referPoints.length; i++) {
Dabcd += Math.pow(-1, i%2)*referPoints[i].getLocation()[rj];
}
tempPoint.getLocation()[rj] = gbest_t.getLocation()[rj]+FACTOR*Dabcd;
} else {
tempPoint.getLocation()[rj] = pbest_t.getLocation()[rj];
}
rj = (rj+1)%DIMENSION;
}
}
public void updateInfo() {
Library.replace(specComparator, trailPoint, pbest_t);
}
protected SearchPoint[] getReferPoints() {
SearchPoint[] referPoints = new SearchPoint[DVNum*2];
for(int i=0; i<referPoints.length; i++) {
referPoints[i] = socialLib.getSelectedPoint(RandomGenerator.intRangeRandom(0, socialLib.getPopSize()-1));
}
return referPoints;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -