- 积分
- 5
- 注册时间
- 2006-4-4
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2009-5-5 16:31:21
|
显示全部楼层
来自 陕西西安
无论遗传算法,还是一般的优化解法,都是单个解。
多目标的时候,需要一组非劣解,需要进行相应的程序来求解
下面是matlab的一个简单的遗传算法对两个目标优化求解过程,
怎么得到pareto解应该很清楚
GA Multiobjective
This example optimizes two objectives defined by Schaffer'ssecond function: a vector-valued function of two components and oneinput argument. The Pareto front is disconnected. Define this functionin an M-file:
function y = schaffer2(x) % y has two columns
% Initialize y for two objectives and for all x
y = zeros(length(x),2);
% Evaluate first objective.
% This objective is piecewise continuous.
for i = 1:length(x)
if x(i) <= 1
y(i,1) = -x(i);
elseif x(i) <=3
y(i,1) = x(i) -2;
elseif x(i) <=4
y(i,1) = 4 - x(i);
else
y(i,1) = x(i) - 4;
end
end
% Evaluate second objective
y(:,2) = (x -5).^2;First, plot the two objectives:
x = -1:0.1:8;
y = schaffer2(x);
plot(x,y(:,1),'.r'); hold on
plot(x,y(:,2),'.b');The two component functions compete in the range [1, 3] and[4, 5]. But the Pareto-optimal front consists of only two disconnectedregions: [1, 2] and [4, 5]. This is because the region [2, 3] is inferiorto [1, 2].
Next, impose a bound constraint on x,
-5<x<10,setting
lb = -5;
ub = 10;The best way to view the results of the genetic algorithm isto visualize the Pareto front directly using the @gaplotpareto option. To optimize Schaffer's function, a larger population sizethan the default (15) is needed, because of the disconnected front.This example uses 60. Set the optimization options as:
options = gaoptimset('PopulationSize',60,'PlotFcns',...
@gaplotpareto);
Now call gamultiobj, specifying one independentvariable and only the bound constraints:
[x,f,exitflag] = gamultiobj(@schaffer2,1,[],[],[],[],...
lb,ub,options);
Optimization terminated: average change in the spread of
Pareto solutions less than options.TolFun.
exitflag
exitflag = 1The vectors x, f(:,1),and f(:,2) respectively contain the Pareto setand both objectives evaluated on the Pareto set. |
评分
-
1
查看全部评分
-
|