How to evaluate a simulation with saved_state by PSO program

조회 수: 1 (최근 30일)
tuan manh
tuan manh 2017년 9월 14일
편집: tuan manh 2017년 9월 14일
Good afternoon, I have a trouble of simulating a model of power system. Because my model takes a long time(30sec of simulation, 25 mins real time) to stable, so i need to save the stable state and run it for next time. I am using PSO program to execute simulink, but i can not load the saved_state for my model from PSO program. I've tried to use sim command but still can't load the saved_state. My PSO shown below. Please tell me how to solve my problem. Thank you. tic;
%%PSO Parameters
N = 2; % Number of Swarm size/Population Size
M = 2; % Number of Moves/Interations
Var = 10; % Number of Var
c1 = 1.5; % Self confedence, range: 1.5 to 2
if true
% code
end
c2 = 2; % Swarm confidence, range: 2 to 2.5
w = 0.92; % Inertial factor, range: 0.4 to 1.4
A=1;B=1;C=1;D=1;E=1;F=1;G=1;H=1;I=1;J=1;K=1;L=1;
x=[A B C D E F G H I J K L];
%p=fitness_Frequency(x(1,:));
sim('No_peak_KinMen_simulation1',[0 60]);
error=abs(simout.signals.values);
if error < (60-57.5)
x=[A B C D E F G H I J K L];
else
for i=1:N
for j=1:V
x(i,j)=rand;
v(i,j)=rand;
end
end
for i=1:N
p(i)=fitness_Fuzzy_pid(x(i,:));
y(i,:)=x(i,:);
end
pg = x(N,:);
for i=1:(N-1)
if fitness_Fuzzy_pid(x(i,:))<fitness_Fuzzy_pid(pg)
pg=x(i,:);
end
end
for t=1:M
for i=1:N
v(i,:)=w*v(i,:)+c1*rand*(y(i,:)-x(i,:))+c2*rand*(pg-x(i,:));
x(i,:)=x(i,:)+v(i,:);
if (~isempty(find(x(i,:)<=0, 1)) || ~isempty(find(x(i,:)>=10, 1)))
p(i)=1e06;
end
if fitness_Fuzzy_pid(x(i,:))<p(i)
p(i)=fitness_Fuzzy_pid(x(i,:));
y(i,:)=x(i,:);
end
if p(i)<fitness_Fuzzy_pid(pg)
pg=y(i,:);
end
end
Pbest(t)=fitness_Fuzzy_pid(pg);
end
end
plot(Pbest)
toc;
xm = pg'
fv = fitness_Fuzzy_pid(pg)
%FitnessFunction
function F = fitness_Fuzzy_pid(x)
A=x(1);
B=x(2);
C=x(3);
D=x(4);
E=x(5);
F=x(6);
G=x(7);
H=x(8);
I=x(9);
J=x(10);
K=x(11);
L=x(12);
simopt = simset('solver','ode45','DstWorkspace','current','SrcWorkspace','current');
sim('No_peak_KinMen_simulation1',[0 60],simopt);
F = sum(abs(simout.signals.values));
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Particle Swarm에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by