www.gusucode.com > globaloptim 案例源码程序 matlab代码 > globaloptim/DisconnectedParetoFrontExample.m

    %% Disconnected Pareto Front
% This example shows how to compute and plot the Pareto front for the
% two-objective Schaffer's second function. This function has a disconected
% Pareto front.
%%
% Copy this code to a function file on your MATLAB(R) path.
%
% <include>schaffer2.m</include> 
%
%%
% Plot the two objectives.
x = -1:0.1:8;
y = schaffer2(x);
plot(x,y(:,1),'r',x,y(:,2),'b');
xlabel x
ylabel 'schaffer2(x)'
legend('Objective 1','Objective 2')
%%
% The two objective functions compete for |x| in the range |[1,3|] and
% |[4,5]|. But the Pareto-optimal front consists of only two disconnected
% regions, corresponding to the |x| in the ranges |[1,2]| and |[4,5]|. This
% is because the region |[2,3]| is inferior to |[4,5]|. In that range,
% objective |1| has the same values, but objective |2| is smaller.
%%
% Set bounds to keep population members in the range $-5\le x\le 10$.
lb = -5;
ub = 10;
%%
% Set options to view the Pareto front as |gamultiobj| runs.
options = optimoptions('gamultiobj','PlotFcn',@gaplotpareto);
%%
% Call |gamultiobj|.
rng default % For reproducibility
[x,fval,exitflag,output] = gamultiobj(@schaffer2,1,[],[],[],[],lb,ub,options);