PlatMOEA(未完)
使用
1. 不用GUI,用命令行启动的
举例: main(‘-algorithm’, @KnEA, ’-problem’, @DTLZ2, ’-N’, 200, ’-M’, 10);
2. 用GUI启动
找到main文件,启动运行它
public文件夹下的文件
GLOBAL 类(handle类型的类)
内容
one GLOBAL object is maintained to store all the parameter setting and the result data,
including
- the function handles of the executed MOEA
- MOP
- operator
- the population size
- the number of objectives
- the number of decision variables
- the maximum number of fitness evaluations
- the number of evaluated fitness,
- and so on.
变量:
方法:
构造函数 GLOBAL
函数接口
function obj = GLOBAL(varargin)
初始化全局变量,命令行使用方法:
GLOBAL('-algorithm',@NSGAII,'-problem',@DTLZ2,'-N',100,'-M',2,'-D',10)
Start
- 作用: 运行算法并评估它
- obj.Start() 运行算法(只能运行一次)
Initialization
- 作用: 随机生成初始种群
- 函数接口
Population = INDIVIDUAL(obj.problem('init',obj,N));
- 命令行使用方法
P = obj.Initialization()
,使用obj的NP = obj.Initialization(N)
传入population的个数
NotTermination
- 作用: Stop the running if the number of evaluations has exceeded
- 函数接口
function notermination = NotTermination(obj,Population)
Variation
- 作用: 生成子代种群
- 函数接口
function Offspring = Variation(obj,Parent,nOffspring,operator,para)
- 使用方法:
O = obj.Variation(P)
使用默认的operator对种群P操作,TODOO = obj.Variation(P,N)
只返回(最多)前N个子代O = obj.Variation(P,N,Fcn)
使用Fcn operator,只返回前N个子代O = obj.Variation(P,N,Fcn,Para)
TODO
VariationDec
- 作用: 生成子代种群的 decision变量矩阵
- 函数接口
function OffspringDec = VariationDec(obj,varargin)
ParameterSet
- 使用者修改变量
ParameterFile
- 从文件中修改变量
INDIVIDUAL类
使用注意事项
- 四个变量都是以行向量形式返回
- P 是 an array of INDIVIDUAL objects,P 是 INDIVIDUAL类的对象, P 的每一行是一个个体
- 使用 P.decs, P.objs, P.cons ,P.adds可以获得对应的变量矩阵.
变量
- dec
- 个体的决定变量
- obj
- 个体的目标变量
- con
- add
方法
构造函数
- 作用: dec和add由构造函数赋值,con和obj由dec和add计算出
- 函数接口
function obj = INDIVIDUAL(Decs,addValue)
使用:
H = INDIVIDUAL(Dec)
传入矩阵形式的decision 变量,返回an array of individualsH = INDIVIDUAL(Dec,AddProper)
- decs
- 作用: get the matrix of decision variables of the population
- 函数接口
function value = decs(obj)
- objs
- 作用: Get the matrix of objective values of the population
- 函数接口
function value = objs(obj)
- cons
- 作用: Get the matrix of constraint values of the population
- adds
- 作用: Get the matrix of additional property of the population
UniformPoint函数
UniformPoint() is a utility function in the folder Public for generating about Global.N uniformly distributed points with Global.M objectives on the unit hyperplane.
扩展
扩展算法
NSGA2举例
function NSGAII(Global) %用GLOBAL类的对象作为参数
% 初始化种群
Population = Global.Initialization();
% 非支配前沿
FrontNo = NDSort(Population.objs, inf);
% 拥挤密度
CrowdDis = CrowdingDistance(Population.objs, FrontNo);
% 检测适应值函数是否超出取值范围
while Global.NotTermination(Population)
MatingPool = TournamentSelection(2, Global.N, FrontNo, -CrowdDis);
Offspring = Global.Variation(Population(MatingPool));
[Population, FrontNo, CrowdDis] = …
EnvironmentalSelection([Population, Offspring], Global.N);
end
end