필터 지우기
필터 지우기

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 CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by