Problem with ga optimization of 2 variables with IntCon
Afficher commentaires plus anciens
I am attempting to optimize airfoils in certain conditions, where my input variables are the digits of NACA airfoils. I am using a genetic algorithm (I am aware that this type of optimization is not great for my purpose, however it is the only optimization that allows the variables to be strictly integers which is required for my optimization).
This works perfectly using 1 variable, and I have tested using 2+ variables with simple fitness functions (x(1) + x(2)), however using 2 variables with my final problem will not run the optimization. I will copy the fitness function and main script file.
%fitness function
function [LiftC] = gaCL(x)
CL = mpxfoil(strcat(num2str(x(1)),'4',num2str(x(2))), 91202,
0.0195498580029, 3);
LiftC = -CL;
end
~
%main script
lb = [1,11];
ub = [7,20];
opts = optimoptions('ga','PlotFcn',@gaplotbestf);
IntCon = 1;
[x,fval] = ga(@gaCL,2,[],[],[],[],...
lb,ub,[],IntCon,opts);
The fitness function as well as the other function this is based off of (mpxfoil) I have tested and both work. It seems that this fails when I add in more than one variable. The plot never shows up and MATLAB is continually busy until canceled. Is it possible that with 2 variables this optimization takes 20+ minutes for even the plot to show up when only 1 variable takes under 2 minutes to completely finish?
Here is the error message I get after manually stopping the optimization (the runperl and mpxfoil error just mean that the inputs that mpxfoil was given caused it to fail).
%errors
Operation terminated by user during runperl (line 41)
In mpxfoil (line 127)
runperl('xfw.pl', airfoil, isnaca, Re, Ma, alfa_start, alfa_end, alfa_step, maxit, input_file, timeout);
In gaCL (line 27)
[alfa, CL, CD, CDp, CM, Top_Xtr, Bot_Xtr] = mpxfoil(strcat(num2str(x(1)),'4',num2str(x(2))), 91202, 0.0195498580029, 3);
In createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
In fcnvectorizer (line 13)
y(i,:) = feval(fun,(pop(i,:)));
In gaminlppenaltyfcn
In gapenalty
In makeState (line 64)
Score = FitnessFcn(state.Population(initScoreProvided+1:end,:));
In galincon (line 17)
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
In gapenalty
In gaminlp
In ga (line 366)
[x,fval,exitFlag,output,population,scores] = gaminlp(FitnessFcn,nvars, ...
In main (line 38)
[x,fval] = ga(@gaCL,2,[],[],[],[],...
In run (line 86)
evalin('caller', [script ';']);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Problem-Based Optimization Setup dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!