Invalid solver specified. Provide a solver name or handle (such as 'fmincon' or @fminunc). Type DOC OPTIMOPTIONS for a list of solvers. Error in Part2 (line 12) options = opt
112 views (last 30 days)
Show older comments
clear
close all
Maximum_Gen = 30;
Population_Size = 60;
actual = 0.6;
options = optimoptions(['ga','PopulationSize', Population_Size ...
'MaxGenerations',Maximum_Gen, ...
'CrossoverFraction', actual ,'PlotFcn','gaplotbestf']);
%v for 1st Airfoil
v=[0.54,0.19,0.18,0.35,0.45,0.1,0.10,0.55,0.70,0.35,0.07];
%v for 2nd Airfoil
%v=[0.5,0.23,0.18,0.44,0.45,0.15,0.10,0.55,0.8,0.35,0.07];
%v for third Airfoil
%v=[0.27,0.30,0.18,0.29,0.08,0.01,0.10,0.65,0.78,0.45,0.07];
lob = max(0, v - 0.1);
upb = max(1, v + 0.1);
global jj
jj = 0;
[parameter, fval] = ga(@(b) OptGA(b),11, [],[],[],[],lob,upb,@Constr, options);
disp(['Minimizer value:' num2str(param)])
disp(['Final CL value:' num2str(1/fval)])
t= linspace(0,1,200);
curve1 = airfoil_pmodel(v);
curve2= airfoil_pmodel(param);
cop1 = fnval(curve1,t);
cop2 = fnval(curve2,t);
copf1= cop1(1,:);
copg1= cop1(2,:);
copf2= cop2(1,:);
copg2= cop2(2,:);
f1= copf1';
g1= copg1';
f2= copf2';
g2= copg2';
[k1, A1] = boundary(f1,g1);
[k2, A2] = boundary(f2,g2);
fprintf("A1 = %f \n A2 = %f \n |A1-A2| = %f", A1, A2, abs(A1-A2));
func [OF] = OptGA(b)
global jj
jj= jj + 1;
%jj
%a
curve = airfoil_pmodel(b);
t = linspace(0, 1, 200);
Emx = fnval(crv, t);
Emx = Emx';
x = fopen('C:\Users\User\Documents\project\Emx300.dat','w');
for loop_ii = 1:length(Emx)
for loop_jj = 1:2
fprintf(x, "%10.12f ",Emx(loop_ii,loop_jj));
end
fprintf(x,"\n");
end
fclose(x);
system("C:\Users\User\Documents\project\xfoil.exe< xfoil_mycommand.txt");
CL = importdata("C:\Users\User\Documents\project\datum.dat");
CL = CL(end,2);
if CL==0 || CL<-4 || CL>4
OF = 1000;
else
OF = 1/CL;
end
0 Comments
Accepted Answer
Torsten
on 24 Mar 2022
Remove the square brackets when specifying optimoptions.
8 Comments
Torsten
on 25 Mar 2022
I can't tell without your code.
But maybe
options = optimoptions('ga','PopulationSize', Population_Size, ...
'MaxGenerations',Maximum_Gen, ...
'CrossoverFraction', actual ,'PlotFcn',@gaplotbestf);
instead of your call
options = optimoptions('ga','PopulationSize', Population_Size, ...
'MaxGenerations',Maximum_Gen, ...
'CrossoverFraction', actual ,'PlotFcn','gaplotbestf');
Note the difference in specifying the plot function "gaplotbestf".
By the way: How did you set up this plot function ("gaplotbestf") ?
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!