How is genetic algorithm function's ga optimfunctions used? How do I use that? What is the difference between optimset and optimfunction? Why do I receive error in this code?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
% Genetic Algorithm to tune PID parameters
nos_var= 3;
lb = [0 0 0];
ub= [200 200 200];
% GA optionsga_opt = optimoption('ga','Display', 'off', 'Generations', 25, 'PopulationSize',50,'PlotFcns',@gaplotbestf);---- this line has error
obj_fcn= @(k) optimizationofPID(k);
[k,best]= ga((obj_fcn),no_var,[],[],[],[],lb,ub,[],ga_opt);
Output:
Error in GAlgorithmPID (line 9)
ga_opt = optimoption('ga','Display', 'off', 'Generations', 25, 'PopulationSize',50,'PlotFcns',@gaplotbestf);
>> GAlgorithmPID
Unrecognized function or variable 'optimoption'.
Error in GAlgorithmPID (line 9)
ga_opt = optimoption('ga','Display', 'off', 'Generations', 25, 'PopulationSize',50,'PlotFcns',@gaplotbestf);
>>
1 Kommentar
Sam Chak
am 4 Aug. 2023
Bearbeitet: Sam Chak
am 4 Aug. 2023
Two questions:
1. Can you show the math model of the system?
2. How does your cost function in obj_fcn look like? This function usually tells about the desired performance like fast/slow output convergence, and high/low control effort.
The searching range [0 200] for each control gain is also relatively large. Probably most of the iterations lead to instability. Having a model allows you to run some tests and analysis so that the range can be tightened, especially with Ki and Kd. Ideally, the ranges should be set up such that GA searches within the stability regime.
Antworten (1)
Alan Weiss
am 3 Aug. 2023
The correct function name is optimoptions:
ga_opt = optimoptions('ga','Display', 'off', 'Generations', 25, 'PopulationSize',50,'PlotFcns',@gaplotbestf)
Alan Weiss
MATLAB mathematical toolbox documentation
0 Kommentare
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!