First, the way to obtain the code

Get the code 1: by subscribing to the paid column of purple Pole Shenguang blog, you can get this code with payment voucher, private letter bloggers.

Access code 2: Open CSDN membership through the homepage of CSDN blog, and the code can be obtained by payment voucher and private letter bloggers.

Multi-objective solution based on matlab adaptive wind drive algorithm to solve multi-objective optimization problem

Note: For CSDN membership, only one code can be obtained free of charge (valid within three days from the date of opening); Subscribe to the paid column of purple Pole Shenguang blog, you can get 2 copies of the code for free (valid for three days from the subscription date);

Two, some source code

function MO_AWDO_v01(a)
%-------------------------------------------------------------------------



tic; clear; close all; clc;  
format long g;
%--------------------------------------------------------------

ArchiveParetoFronts = [];

% User defined parameters:
param.popsize = 100;	% population size.
param.npar = 10;         % Dimension of the problem.
param.maxit = 100;		% Maximum number of iterations.
maximumV = 0.5;             % maximum allowed speed.
%--------------------------------------------------------------

% AWDO will select the coefficient values; alpha, RT, g, c, and Vmax:
rec.arx = rand(5,param.popsize);   %consistent with the CMAES indexing
%---------------------------------------------------------------

% Initialize WDO population, position and velocity:
% Randomize population position in the range of [- 1.1]:
pos = 2*(rand(param.popsize,param.npar)0.5);
% Randomize velocity in the range of [-Vmax, Vmax]:
vel = maximumV * 2 * (rand(param.popsize,param.npar)0.5);  
%---------------------------------------------------------------

% Evaluate initial population via multi-objective function:
for K=1:param.popsize,
%     [f1,f2] = kursawe(pos(K,:));
%     [f1,f2] = kita(pos(K,:));
%     [f1,f2] = schaffer(pos(K,:));
%     [f1,f2] = ZDT1(pos(K,:));
    [f1,f2] = ZDT4(pos(K,:));
    pres(K,:) = [f1,f2];
end
%----------------------------------------------------------------
% 
% Call non-dominated sorting to identify the Pareto-front that each particle belongs:
posF=[pos, pres];
f = non_domination_sort_mod(posF, 2,param.npar);  % f = [pos, f1, f2, rank]

% extract the rank index, i.e. which Pareto-front the particle belongs:
rank_ind = f(:,param.npar+3);

% Select the Pareto-front == 1 particles as Global Best Position:
globalposPOP = f( (f(:,param.npar+3) = =1),1:param.npar);
% Archieve the rank 1 particles:
ArchiveParetoFronts = [ArchiveParetoFronts; f( (f(:,param.npar+3) = =1),1:(param.npar+2))]; %----------------------------------------------------------------- % Start iterations : iter =1;   % iteration counter
for ij = 2:param.maxit,
        ij
    	% Update the velocity:
    	for i=1:param.popsize
		% choose random dimensions:
		a = randperm(param.npar);        			
		% choose velocity based on random dimension:
    		velot(i,:) = vel(i,a);
            % randomly select a globalpos from the 1st Pareto-front members
            [aa, bb] = size(globalposPOP);
            globalpos = globalposPOP(round(((aa- 1) * rand(1.1)) + 1), :); vel(i,:) = (1-rec.arx(1,i))*vel(i,:)-(rec.arx(2,i)*pos(i,:))+ ...
				    abs(1- 1/rank_ind(i))*((globalpos-pos(i,:)).*rec.arx(3,i))+ ...
				    (rec.arx(4,i)*velot(i,:)/rank_ind(i));   
        end
    
        % maxV is optimized by CMAES. Limit it maximumV defined by user
        maxV = rec.arx(5, :); maxV = min(maxV, repmat(maximumV, size(rec.arx(5, :).1),  size(rec.arx(5, :).2))); maxV = max(maxV, repmat(-maximumV, size(rec.arx(5, :).1),  size(rec.arx(5, :).2))); % Check velocity limits: vel = min(vel, repmat(maxV'.1,param.npar));
        vel = max(vel, -repmat(maxV'.1,param.npar));
        % Update air parcel positions:
    	pos = pos + vel;
        pos = min(pos, 1.0);
        pos = max(pos, 1.0); 
		% Evaluate population: (Pressure)
		for K=1:param.popsize,
%             [f1,f2] = kursawe(pos(K,:));
%             [f1,f2] = kita(pos(K,:));
%             [f1,f2] = schaffer(pos(K,:));
%             [f1,f2] = ZDT1(pos(K,:));
            [f1,f2] = ZDT4(pos(K,:));
            pres(K,:) = [f1,f2];
        end

        % Call non-dominated sorting to identify the Pareto-front that each particle belongs:
        posF=[pos, pres];
        f = non_domination_sort_mod(posF, 2,param.npar);  % f = [pos, f1, f2, rank]

        % extract the rank index, i.e. which Pareto-front the particle belongs:
        rank_ind = f(:,param.npar+3);

        % Select the Pareto-front == 1 particles and add them to the archieve along previous Pareto-fronts:
        ArchiveParetoFronts = [ArchiveParetoFronts; f( (f(:,param.npar+3) = =1),1:(param.npar+2))]; % Run the non-dominated sort among the Archieve members: f = non_domination_sort_mod(ArchiveParetoFronts,2,param.npar);        
        % Replace the archieve with only the rank=1 members:
        ArchiveParetoFronts = f( (f(:,param.npar+3) = =1),1:(param.npar+2)); % Use rank=1 members as global position:
        globalposPOP = f( (f(:,param.npar+3) = =1),1:param.npar);  
       
        %--------------------------------
        % call CMAES 
        [rec] = purecmaes_wdo(ij,rec,param.popsize,pres(:, mod(ij,2) +1));
        %%% PRES has two values, pass one of the pres values at each iter
        %%% alternating between two.
    	%----------------------------------------------------

end
    
        %%% PLOT RESULTS:
        % Call non-dominant sorting:
        f = non_domination_sort_mod(ArchiveParetoFronts, 2,param.npar);

        % Plot the MO-results -- debugging purposes
        pres2plot = f( (f(:,param.npar+3) = =1) , param.npar+1 : param.npar+2);
        plot(pres2plot(:,1), pres2plot(:,2),'ko')
        xlabel('F1'); ylabel('F2')
        grid on
%         save('Results.mat'.'pres2plot')
        
        hold on
        % load the known-Pareto-front data for plotting:
        z = load('paretoZDT4.dat');
        [a,b]=sort(z(:,2));
        z = z(b,:);
        plot(z(:,1),z(:,2),'-k') end % end-of-WDO. %---------------------------------------------------------------------- % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --Copy the code

3. Operation results

Matlab version and references

1 matlab version 2014A

Intelligent Optimization Algorithm and its MATLAB Examples (2nd edition), baoyang, Yu Jizhou, Yang Shan, Publishing House of Electronics Industry