├── Fitness.m ├── Main_IIR.m ├── Matching.m ├── MonteCarlo.m ├── README.md ├── WS_VLPSO.m ├── run_for_outputs_of_MC.m └── run_for_outputs_of_WSVLPSO.m /Fitness.m: -------------------------------------------------------------------------------- 1 | function [Error] = Fitness(R, Hfilt, Wfilt, N, Ord, Logcoef, alpha, beta, gamma, Cst2) 2 | T1 = 0; 3 | T2 = 0; 4 | Cst = R(1) + 1; 5 | Hfsiz = size(Hfilt, 1); 6 | Rsiz1 = size(R, 1); 7 | Hfilt_N = zeros(Hfsiz, 1); 8 | q_N = zeros(Hfsiz, 1); 9 | F = zeros(Hfsiz, 1); 10 | Error = zeros(Rsiz1, 1); 11 | 12 | Rsiz2 = size(R,2) - Cst2; 13 | Bipo = zeros(Rsiz1, Rsiz2/2); 14 | Aipo = zeros(Rsiz1, Rsiz2/2 + Cst2); 15 | 16 | Aipo(:,1) = 1; 17 | for i = 1:Rsiz1 18 | for j = 1:Rsiz2/2 19 | Bipo(i,j) = R(i,j + 1); 20 | % Aipo(i,1 + j) = R(i,(Rsiz2/2) + j + 1); %### For O < 5 21 | if (j < Cst) %### For O >= 5 22 | Aipo(i,1 + j) = R(i,(Rsiz2/2) + j + 1); %### For O >= 5 23 | end %### For O >= 5 24 | end 25 | 26 | [q,Q] = freqz(Bipo(i,:),Aipo(i,:),Hfsiz); 27 | 28 | 29 | Hfilt_N = Hfilt .* N; % output with input white noise 30 | q_N = q .* N; % output with input white noise 31 | for j = 1:Hfsiz 32 | F(j,1) = (abs(Hfilt_N(j) - q_N(j)))^ 2; 33 | end 34 | P_f = roots(Aipo); 35 | T1 = sum(abs(P_f(find(abs(P_f) >= 1)))); 36 | T2 = sum(abs(P_f)); 37 | Error(i,1) = (alpha*((1/Hfsiz)*sum(F))) + (beta*((R(1)/(Ord-1)) * (T1/T2))); 38 | Hfilt_N = 0; 39 | q_N = 0; 40 | end 41 | end 42 | 43 | -------------------------------------------------------------------------------- /Main_IIR.m: -------------------------------------------------------------------------------- 1 | function [O h w] = Main_IIR() 2 | 3 | O = 5; 4 | b = [0.1084 0.5419 1.0837 1.0837 0.5419 0.1084]; %for case4 5 | a = [1 0.9853 0.9738 0.3864 0.1112 0.0113]; %for case4 6 | 7 | [h,w]=freqz(b,a,200); 8 | 9 | end 10 | 11 | -------------------------------------------------------------------------------- /Matching.m: -------------------------------------------------------------------------------- 1 | function [Bipo Aipo Z_f P_f] = Matching(R, Cst2) 2 | 3 | Rsiz = size(R,2) - Cst2; 4 | Cst = R(1) + 1; 5 | 6 | Bipo = zeros(1, Rsiz/2); 7 | Aipo = zeros(1, Rsiz/2 + Cst2); 8 | Aipo(1,1) = 1; 9 | for i = 1:Rsiz/2 10 | % for i = 1:5 11 | Bipo(1,i) = R(i + 1); 12 | % Aipo(1,i + 1) = R((Rsiz/2) + i + 1); %### For O < 5 13 | if (i < Cst) %### For O >= 5 14 | Aipo(1,i + 1) = R((Rsiz/2) + i + 1); %### For O >= 5 15 | end %### For O >= 5 16 | end 17 | Z_f = roots(Bipo); 18 | P_f = roots(Aipo); 19 | 20 | end 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /MonteCarlo.m: -------------------------------------------------------------------------------- 1 | clc; 2 | clear all; 3 | close all 4 | tic 5 | 6 | %% IIR Filter Fitness 7 | 8 | [O Hfilt Wfilt] = Main_IIR(); 9 | 10 | Logcoef = 1; 11 | alpha = 0.6; % 0.4 1 0.5 0.5 12 | beta = 0.4; % 0.6 0 0.0 0.1 13 | gamma = 0.0; % 0.0 1 0.5 0.4 14 | Cst1 = 2; % number 1 for O<5 and 2 for >= for PSO function 15 | Cst2 = 0; % number 1 for O<5,0 for >= for Fitness/IIRSOA function 16 | nvar = (2 * (O - 1)) + Cst1; 17 | pnvar = 0; 18 | maxit = 1000000; 19 | 20 | xmin(1) = 1; 21 | xmax(1) = (O - 1); 22 | xmin(2:nvar) = repmat(-2, 1, nvar - 1); 23 | xmax(2:nvar) = repmat(+2, 1, nvar - 1); 24 | Xpos = zeros(maxit,nvar); 25 | Xfit = zeros(maxit,1); 26 | N = rand(size(Hfilt,1),1); 27 | % gbest = zeros(1,nvar); 28 | gbest = 0; 29 | gbestfit = inf; 30 | meanfit = zeros(maxit,1); 31 | minfit = zeros(maxit,1); 32 | 33 | %% Main loop 34 | 35 | for it = 1:maxit 36 | Xpos(it,:) = xmin + (xmax - xmin) .* rand(1,nvar); 37 | Xpos(it,1) = round(Xpos(it,1)); 38 | pnvar = (2 * Xpos(it,1)) + Cst1; 39 | if pnvar < nvar 40 | Xpos(it,pnvar+1:nvar) = 0; 41 | end 42 | 43 | %--------------------------------------------------------------------- 44 | Xfit(it) = Fitness(Xpos(it,1:pnvar),Hfilt,Wfilt,N,O,Logcoef,alpha,beta,gamma,Cst2); 45 | %--------------------------------------------------------------------- 46 | 47 | if Xfit(it) < gbestfit 48 | gbest = Xpos(it,1:pnvar); 49 | gbestfit = Xfit(it); 50 | end 51 | meanfit(it) = sum(Xfit)/it; 52 | minfit(it) = min(Xfit(1:it)); 53 | D = it/maxit; 54 | if ( D == 1/5) | ( D == 2/5) | ( D == 3/5) | ( D == 4/5) 55 | it 56 | end 57 | end 58 | 59 | time = toc 60 | gbest 61 | gbestfit 62 | Minimum_Fitness = minfit(it) 63 | Mean_Fitness = meanfit(it) 64 | [Bsoa Asoa Z_f P_f] = Matching(gbest,Cst2) 65 | 66 | % xx = [1,100,200,300,400,500]; 67 | % pdf(Xfit([1,100,200,300,400,500]),xx) 68 | 69 | figure(1); 70 | plot(1:maxit,meanfit,'r--','LineWidth',2) 71 | ylim([-1 inf]); 72 | % xlim([-1 inf]); 73 | legend('MeanFitness') 74 | xlabel('Iterations') 75 | ylabel('Value') 76 | title('Monte Carlo'); 77 | grid on 78 | 79 | figure(2); 80 | plot(1:maxit,minfit,'b--','LineWidth',2); 81 | axis([0 inf -.01 inf]) 82 | grid on 83 | legend('MinFitness') 84 | xlabel('Iterations') 85 | ylabel('Value') 86 | title('Monte Carlo'); 87 | 88 | figure(3); 89 | zplane(Z_f,P_f); %%% Displays the poles and zeros of discrete-time systems. 90 | legend('Zero','Pole'); 91 | xlabel('Real Part'); 92 | ylabel('Imaginary Part'); 93 | title('MonteCarlo: Pole-Zero Plot'); 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Design-and-modeling-of-adaptive-IIR-filtering-systems-using-a-weighted-sum-variable-length-PSO 2 | 3 | In this repository, all the data of the article called "Design and modeling of adaptive IIR filtering systems using a weighted sum - variable length particle swarm optimization" has been attached. 4 | 5 | Data including specifications, access links, all source code of implementations and simulations are provided along with all extracted results. 6 | 7 | Note: Given the volume of implementations and outputs, the source codes are reported based on Example 4 of the article, which can be easily extended to other examples. 8 | If used, the article link should be cited below. 9 | 10 | A. Mohammadi, S. H. Zahiri, S. M. Razavi, and P. N. Suganthan, “Design and modeling of adaptive IIR filtering systems using a weighted sum-variable length particle swarm optimization,” Appl. Soft Comput., vol. 109, p. 107529, 2021. DOI: https://doi.org/10.1016/j.asoc.2021.107529 11 | 12 | Some information of this research is as follows: 13 | 14 | Highlights: 15 | 16 | • Simultaneous modeling the dynamic order IIR system and its corresponding coefficients. 17 | 18 | • A novel and dynamic version of variable-length PSO as an effective adaptive algorithm. 19 | 20 | • Providing and applying an intelligent and effective weighted sum objective function. 21 | 22 | • The proposed WS-VLPSO used to design optimal IIR filters and solving coverage problems. 23 | 24 | • A new criterion called OMI to verify the intelligent minimization of filter orders. 25 | 26 | Abstract: 27 | 28 | The use of optimization algorithms for designing Infinite Impulse Response (IIR) filters has been considered in many studies. The concern in this area is the multimodal error surface of such filters and their fitting with filter coefficients. The order of the modeled system has a direct effect on the number of coefficients, complexities of the error surface, and the filter’s stability. This paper proposes an efficient approach based on a variable length particle swarm optimization algorithm with a weighted sum fitness function (WS-VLPSO). The proposed WS-VLPSO is utilized as an effective adaptive algorithm for designing optimal IIR filters. The approach is based on the inclusion of the order as a discrete variable in the particle vector, which is done with the goal of intelligent minimizing of order and thereby reducing the design complexity of IIR filters. To ensure the optimality of the systems, the objective function is considered as a weighted sum. Also, a new criterion called Optimum Modeling Indicator (OMI) is introduced, a measure to determine the percentage reduction of order and the success rate of the proposed approach. The proposed algorithm is also applied for solving the sensor coverage problem as another real-world variable length engineering optimization application. Evaluation of simulation results, with Monte-Carlo simulation, indicates the acceptable improvement of identified structures and the significant performance of the proposed approaches. Note that the source codes of the paper will be publicly available at https://github.com/ali-ece. 29 | 30 | 31 | -------------------------------------------------------------------------------- /WS_VLPSO.m: -------------------------------------------------------------------------------- 1 | % for Rep=1:100 2 | clc; 3 | clear all; 4 | close all 5 | tic 6 | %% IIR Filter Fitness 7 | 8 | [O Hfilt Wfilt] = Main_IIR(); 9 | 10 | Logcoef = 1; 11 | alpha = 0.6; 12 | beta = 0.4; 13 | gamma = 0.0; 14 | Cst1 = 2; % number 1 for O<5 and 2 for upper for PSO function 15 | Cst2 = 0; % number 1 for O<5,0 for upper for Fitness/IIRSOA function 16 | nvar = (2 * (O - 1)) + Cst1; 17 | npop = 50; 18 | w = 1; 19 | 20 | maxit = 200; 21 | wdamp = 0.99; 22 | c1 = 2; 23 | c2 = 2; 24 | xmin(1) = 1; 25 | xmax(1) = (O - 1); 26 | xmin(2:nvar) = repmat(-2, 1, nvar - 1); 27 | xmax(2:nvar) = repmat(+2, 1, nvar - 1); 28 | dx = xmax - xmin; 29 | vmax = 0.1 * dx; 30 | empty_particle.position = []; 31 | empty_particle.velocity = []; 32 | empty_particle.cost = []; 33 | empty_particle.pbest = []; 34 | empty_particle.pbestcost = []; 35 | empty_particle.nvar = []; 36 | empty_particle.pnvar = []; 37 | 38 | particle = repmat(empty_particle,npop,1); 39 | N = rand(size(Hfilt,1),1); 40 | gbest = zeros(maxit,nvar); 41 | gbestcost = zeros(maxit,1); 42 | gnvar = zeros(maxit,1); 43 | meanfit = zeros(maxit,1); 44 | Temp1particle = zeros(1,nvar); % The initial nvar is the maximom value of the first dimension 45 | Temp1velocity = zeros(1,nvar); 46 | Temp2particle = zeros(1,nvar); 47 | Temp2velocity = zeros(1,nvar); 48 | for it = 1:maxit 49 | if it == 1 50 | gbestcost(1) = inf; 51 | for i = 1:npop 52 | 53 | particle(i).position = xmin + (xmax - xmin) .* rand(1,nvar); 54 | particle(i).position(1) = round(particle(i).position(1)); 55 | particle(i).nvar = (2 * (particle(i).position(1)))+Cst1; 56 | if particle(i).nvar ~= nvar 57 | dif1 = particle(i).nvar - nvar; 58 | if dif1 < 0 59 | particle(i).position = particle(i).position(1:particle(i).nvar); 60 | else %dif1 > 0 61 | 62 | particle(i).position(nvar+1:nvar+dif1) = xmin(2:1+dif1)... 63 | + (xmax(2:1+dif1) - xmin(2:1+dif1)) .* rand(1,dif1); 64 | end 65 | dif1 = 0; 66 | end 67 | 68 | particle(i).velocity = zeros(1,particle(i).nvar); 69 | 70 | %%%%%%%%********************************* 71 | particle(i).cost = Fitness(particle(i).position,Hfilt,Wfilt,N,O,Logcoef,alpha,beta,gamma,Cst2); 72 | %%%%%%%% 73 | particle(i).pnvar = particle(i).nvar; 74 | particle(i).pbest = particle(i).position;%like line 81(gbest(it,1:gnvar)),nvar can be replace to term of line 75. 75 | particle(i).pbestcost = particle(i).cost; 76 | 77 | if particle(i).pbestcost < gbestcost(it) 78 | gnvar(it) = particle(i).nvar; 79 | gbest(it,1:gnvar(it)) = particle(i).pbest; 80 | gbest(it,gnvar(it)+1:end) = 0; 81 | gbestcost(it) = particle(i).pbestcost; 82 | end 83 | end 84 | else 85 | gbest(it,:) = gbest(it - 1,:); 86 | gbestcost(it) = gbestcost(it - 1); 87 | gnvar(it) = gnvar(it - 1); 88 | 89 | for i = 1:npop 90 | 91 | dif3 = particle(i).pnvar - particle(i).nvar; 92 | Temp1particle = particle(i).position; 93 | Temp1velocity = particle(i).velocity; 94 | 95 | 96 | if dif3 ~= 0 97 | if dif3 < 0 98 | Temp1particle = Temp1particle(1:particle(i).pnvar); 99 | Temp1velocity = Temp1velocity(1:particle(i).pnvar); 100 | else %dif3 > 0 101 | Temp1particle(particle(i).nvar+1:particle(i).nvar+dif3)... 102 | = xmin(2:1+dif3) + (xmax(2:1+dif3) - xmin(2:1+dif3)) .* rand(1,dif3); 103 | Temp1velocity(particle(i).nvar+1:particle(i).nvar+dif3)... 104 | = min(max(rand(1,dif3),-vmax(2:1+dif3)),vmax(2:1+dif3)); 105 | end 106 | end 107 | 108 | 109 | dif4 = gnvar(it) - particle(i).nvar; 110 | Temp2particle = particle(i).position; 111 | Temp2velocity = particle(i).velocity; 112 | 113 | if dif4 ~= 0 114 | if dif4 < 0 115 | Temp2particle = Temp2particle(1:gnvar(it)); 116 | Temp2velocity = Temp2velocity(1:gnvar(it)); 117 | else %dif4 > 0 118 | Temp2particle(particle(i).nvar+1:particle(i).nvar+dif4)... 119 | = xmin(2:1+dif4) + (xmax(2:1+dif4) - xmin(2:1+dif4)) .* rand(1,dif4); 120 | Temp2velocity(particle(i).nvar+1:particle(i).nvar+dif4)... 121 | = min(max(rand(1,dif4),-vmax(2:1+dif4)),vmax(2:1+dif4)); 122 | 123 | end 124 | end 125 | Temp3pbest = particle(i).pbest - Temp1particle; 126 | Temp4gbest = gbest(it,1:gnvar(it)) - Temp2particle; 127 | 128 | dif5 = particle(i).pnvar - gnvar(it); 129 | 130 | if dif5 ~= 0 131 | if dif5 < 0 132 | particle(i).position(particle(i).nvar+1:particle(i).nvar+abs(dif4))... 133 | = xmin(2:1+abs(dif4)) + (xmax(2:1+abs(dif4))... 134 | - xmin(2:1+abs(dif4))) .* rand(1,abs(dif4)); 135 | particle(i).position = particle(i).position(1:gnvar(it)); 136 | particle(i).nvar = gnvar(it); 137 | particle(i).velocity = Temp2velocity; 138 | Temp3pbest(particle(i).pnvar + 1:gnvar(it)) = ... 139 | min(max(rand(1,abs(dif5)),-vmax(2:1+abs(dif5))),vmax(2:1+abs(dif5))); 140 | else %dif5 > 0 141 | particle(i).position(particle(i).nvar+1:particle(i).nvar+abs(dif3))... 142 | = xmin(2:1+abs(dif3)) + (xmax(2:1+abs(dif3))... 143 | - xmin(2:1+abs(dif3))) .* rand(1,abs(dif3)); 144 | particle(i).position = particle(i).position(1:particle(i).pnvar); 145 | particle(i).nvar = particle(i).pnvar; 146 | particle(i).velocity = Temp1velocity; 147 | Temp4gbest(gnvar(it) + 1:particle(i).pnvar) = ... 148 | min(max(rand(1,dif5),-vmax(2:1+dif5)),vmax(2:1+dif5)); 149 | end 150 | else 151 | particle(i).position = particle(i).position(1:gnvar(it)); 152 | particle(i).nvar = gnvar(it); 153 | particle(i).velocity = Temp2velocity; 154 | end 155 | 156 | 157 | particle(i).velocity = w * particle(i).velocity... 158 | + c1 * rand * Temp3pbest + c2 * rand * Temp4gbest; 159 | 160 | particle(i).velocity = min(max(particle(i).velocity,... 161 | -vmax(1:particle(i).nvar)),vmax(1:particle(i).nvar)); 162 | 163 | particle(i).position = particle(i).position + particle(i).velocity; 164 | 165 | particle(i).position = min(max(particle(i).position,... 166 | xmin(1:particle(i).nvar)),xmax(1:particle(i).nvar)); 167 | 168 | particle(i).position(1) = round(particle(i).position(1)); 169 | Temp5nvar = particle(i).nvar; 170 | particle(i).nvar = (2 * (particle(i).position(1)))+Cst1; 171 | 172 | if particle(i).nvar ~= Temp5nvar 173 | dif2 = particle(i).nvar - Temp5nvar; 174 | if dif2 < 0 175 | 176 | particle(i).position = particle(i).position(1:particle(i).nvar); 177 | particle(i).velocity = particle(i).velocity(1:particle(i).nvar); 178 | else %dif2 > 0 179 | particle(i).position(Temp5nvar+1:Temp5nvar+dif2)... 180 | = xmin(2:1+dif2) + (xmax(2:1+dif2) - xmin(2:1+dif2)) .* rand(1,dif2); 181 | particle(i).velocity(Temp5nvar+1:Temp5nvar+dif2)... 182 | = min(max(rand(1,dif2),-vmax(2:1+dif2)),vmax(2:1+dif2)); 183 | end 184 | Temp5nvar = 0; 185 | dif2 = 0; 186 | end 187 | 188 | %%%************************ 189 | particle(i).cost = Fitness(particle(i).position,Hfilt,Wfilt,N,O,Logcoef,alpha,beta,gamma,Cst2); 190 | %%% 191 | if particle(i).cost < particle(i).pbestcost 192 | particle(i).pnvar = particle(i).nvar; 193 | particle(i).pbest = particle(i).position; 194 | particle(i).pbestcost = particle(i).cost; 195 | 196 | if particle(i).pbestcost < gbestcost(it) 197 | gnvar(it) = particle(i).nvar; 198 | gbest(it,1:gnvar(it)) = particle(i).pbest; 199 | gbest(it,gnvar(it)+1:end) = 0; 200 | gbestcost(it) = particle(i).pbestcost; 201 | end 202 | end 203 | end 204 | end 205 | 206 | disp(['Iter= ' num2str(it) ' // Best Cost = ' num2str(gbestcost(it))]); 207 | 208 | for k = 1:npop 209 | meanfit(it) = meanfit(it) + particle(k).cost; 210 | end 211 | meanfit(it) = meanfit(it) / npop; 212 | 213 | w = w * wdamp; 214 | end 215 | 216 | disp([ ' Best Solution = ' num2str(gbest(it,1:gnvar(it)))]) 217 | disp([ ' Best Fitness = ' num2str(gbestcost(it))]) 218 | 219 | % disp([ ' Time = ' num2str(toc)]) 220 | time=toc 221 | % e = particle().pbest; 222 | [Bsoa Asoa Z_f P_f] = Matching(gbest(it,1:gnvar(it)),Cst2) 223 | 224 | figure(1); 225 | plot(gbestcost,'r','LineWidth',2); 226 | % hold on 227 | % plot(meanfit,'.b','LineWidth',2); 228 | legend('Bests') 229 | xlabel('Iteration') 230 | ylabel('Fitness') 231 | title('WSPSO'); 232 | 233 | figure(2); 234 | zplane(Z_f,P_f); %%% Displays the poles and zeros of discrete-time systems. 235 | legend('Zero','Pole'); 236 | xlabel('Real Part'); 237 | ylabel('Imaginary Part'); 238 | title('Pole-Zero Plot'); 239 | 240 | % bmain = [0.1084 0.5419 1.0837 1.0837 0.5419 0.1084]; %for case5 241 | % amain = [1 0.9853 0.9738 0.3864 0.1112 0.0113]; 242 | 243 | % figure(1); 244 | % impz(bmain,amain); 245 | % hold on 246 | % impz(Bsoa,Asoa); 247 | % legend('Real Plant','WS-VLPSO'); 248 | % xlabel('Time (sec)'); 249 | % ylabel('Amplitude'); 250 | % title('Impulse Response'); 251 | % hold off 252 | 253 | % figure(2); 254 | % stepz(bmain,amain); 255 | % hold on 256 | % stepz(Bsoa,Asoa); 257 | % legend('Real Plant','WS-VLPSO'); 258 | % xlabel('Time (sec)'); 259 | % ylabel('Amplitude'); 260 | % title('Step Response'); 261 | % hold off 262 | 263 | % figure(3); 264 | % H = tf([bmain],[amain],1,'variable','z^-1'); 265 | % % bode(H,{10^-4,10^1}) 266 | % bode(H) 267 | % hold on 268 | % H = tf([Bsoa],[Asoa],1,'variable','z^-1'); 269 | % bode(H) 270 | % legend('Real Plant','WS-VLPSO'); 271 | % hold off 272 | -------------------------------------------------------------------------------- /run_for_outputs_of_MC.m: -------------------------------------------------------------------------------- 1 | 2 | bmain = [0.1084 0.5419 1.0837 1.0837 0.5419 0.1084]; %for case5 3 | amain = [1 0.9853 0.9738 0.3864 0.1112 0.0113]; 4 | 5 | figure(1); 6 | plot(1:maxit,meanfit,'r--','LineWidth',2) 7 | ylim([-1 inf]); 8 | % xlim([-1 inf]); 9 | legend('MeanFitness') 10 | xlabel('Iterations') 11 | ylabel('Value') 12 | title('Monte-Carlo'); 13 | grid on 14 | 15 | figure(2); 16 | plot(1:maxit,minfit,'b--','LineWidth',2); 17 | axis([0 inf -.01 inf]) 18 | grid on 19 | legend('MinFitness') 20 | xlabel('Iterations') 21 | ylabel('Value') 22 | title('Monte-Carlo'); 23 | 24 | figure(3); 25 | zplane(Z_f,P_f); %%% Displays the poles and zeros of discrete-time systems. 26 | legend('Zero','Pole'); 27 | xlabel('Real Part'); 28 | ylabel('Imaginary Part'); 29 | title('Monte-Carlo: Pole-Zero Plot'); 30 | 31 | figure(4); 32 | impz(bmain,amain); 33 | hold on 34 | impz(Bsoa,Asoa); 35 | legend('Real Plant','Monte-Carlo'); 36 | xlabel('Time (sec)'); 37 | ylabel('Amplitude'); 38 | title('Impulse Response'); 39 | hold off 40 | 41 | figure(5); 42 | stepz(bmain,amain); 43 | hold on 44 | stepz(Bsoa,Asoa); 45 | legend('Real Plant','Monte-Carlo'); 46 | xlabel('Time (sec)'); 47 | ylabel('Amplitude'); 48 | title('Step Response'); 49 | hold off 50 | 51 | figure(6); 52 | H = tf([bmain],[amain],1,'variable','z^-1'); 53 | % bode(H,{10^-4,10^1}) 54 | bode(H) 55 | hold on 56 | H = tf([Bsoa],[Asoa],1,'variable','z^-1'); 57 | bode(H) 58 | legend('Real Plant','Monte-Carlo'); 59 | hold off 60 | -------------------------------------------------------------------------------- /run_for_outputs_of_WSVLPSO.m: -------------------------------------------------------------------------------- 1 | 2 | bmain = [0.1084 0.5419 1.0837 1.0837 0.5419 0.1084]; %for case5 3 | amain = [1 0.9853 0.9738 0.3864 0.1112 0.0113]; 4 | 5 | figure(1); 6 | impz(bmain,amain); 7 | hold on 8 | impz(Bsoa,Asoa); 9 | legend('Real Plant','WS-VLPSO'); 10 | xlabel('Time (sec)'); 11 | ylabel('Amplitude'); 12 | title('Impulse Response'); 13 | hold off 14 | 15 | figure(2); 16 | stepz(bmain,amain); 17 | hold on 18 | stepz(Bsoa,Asoa); 19 | legend('Real Plant','WS-VLPSO'); 20 | xlabel('Time (sec)'); 21 | ylabel('Amplitude'); 22 | title('Step Response'); 23 | hold off 24 | 25 | figure(3); 26 | H = tf([bmain],[amain],1,'variable','z^-1'); 27 | % bode(H,{10^-4,10^1}) 28 | bode(H) 29 | hold on 30 | H = tf([Bsoa],[Asoa],1,'variable','z^-1'); 31 | bode(H) 32 | legend('Real Plant','WS-VLPSO'); 33 | hold off --------------------------------------------------------------------------------