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?

6 visualizaciones (últimos 30 días)
% 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 comentario
Sam Chak
Sam Chak el 4 de Ag. de 2023
Editada: Sam Chak el 4 de Ag. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Alan Weiss
Alan Weiss el 3 de Ag. de 2023
The correct function name is optimoptions:
ga_opt = optimoptions('ga','Display', 'off', 'Generations', 25, 'PopulationSize',50,'PlotFcns',@gaplotbestf)
ga_opt =
ga options: Set properties: Display: 'off' MaxGenerations: 25 PlotFcn: @gaplotbestf PopulationSize: 50 Default properties: ConstraintTolerance: 1.0000e-03 CreationFcn: [] CrossoverFcn: [] CrossoverFraction: 0.8000 EliteCount: '0.05*PopulationSize' FitnessLimit: -Inf FitnessScalingFcn: @fitscalingrank FunctionTolerance: 1.0000e-06 HybridFcn: [] InitialPopulationMatrix: [] InitialPopulationRange: [] InitialScoresMatrix: [] MaxStallGenerations: 50 MaxStallTime: Inf MaxTime: Inf MutationFcn: [] NonlinearConstraintAlgorithm: 'auglag' OutputFcn: [] PopulationType: 'doubleVector' SelectionFcn: [] UseParallel: 0 UseVectorized: 0
Alan Weiss
MATLAB mathematical toolbox documentation

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by