Can't find the problem attached in code for system control optimization for Genetic Algorithm
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
if true
% code
clear all
close all
global Kp Ki Kd Y T
%ObjectiveFunction = @objective_function_ITAE; %ObjectiveFunction = @objective_function_ISE; %ObjectiveFunction = @objective_function_ITSE; %ObjectiveFunction = @objective_function_MSE;
Fitnessfcn = @objective_function_IAE; nvars = 3;
options = gaoptimset;
options = gaoptimset(options,'PopInitRange',[0; 300]) options = gaoptimset(options,'PopulationSize',[20]) options = gaoptimset(options,'EliteCount',[2]) options = gaoptimset(options,'Generations',[100]) options = gaoptimset(options,'InitialPopulation',[18 12.4100 6.3216]) options = gaoptimset(options,'CreationFcn',@gacreationlinearfeasible) options = gaoptimset(options,'SelectionFcn',@selectiontournament) options = gaoptimset(options,'CrossoverFcn',@crossoversinglepoint)
lb =[0.00; 0.00; 0.00]; ub = [200; 100; 300];
[X,FVAL,REASON,OUTPUT,POPULATION,SCORES] = ga(Fitnessfcn,nvars,... [],[],lb,ub,options);
Kp = X(1); Ki = X(2); Kd = X(3);
sim('model2_opt',T) plot(T,Y) end
if true
% code
function IAE = objective_function_IAE(x)
global Kp Ki Kd Y T
Kp = x(1); Ki = x(2); Kd = x(3);
%Integral do Erro Absoluto (IAE) time=0:0.1:20; [T X Y]=sim('dp_pid',time) error = abs(erro)
%IAE (integral of absolute error) IAE=sum(error)
end
Antworten (0)
Diese Frage ist geschlossen.
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!