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 ビュー (過去 30 日間)
% 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 件のコメント
Sam Chak
Sam Chak 2023 年 8 月 4 日
編集済み: Sam Chak 2023 年 8 月 4 日
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.

サインインしてコメントする。

回答 (1 件)

Alan Weiss
Alan Weiss 2023 年 8 月 3 日
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

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by