gamultiobj() is running really slow with a nested loop objective function
古いコメントを表示
I am using gamultiobj() to optimize a nonlinear problem with 5 integer decision variables and one linear contraint. My objective functions are not represented by a closed-form mathematical relationship, but rather by a nested for-loop.
The objective functions evaluations go something like this:
function [obj]= fit_fun(X)
A=linspace(0,20,50);
B=linspace(0,0.05,50);
for i=1:50
for j=1:50
syms a b c
f1=f(a,b,c)==0; %Nonlinear function with trig functions of angles a and b
f2=f(a,b,c)==0; %Nonlinear function with trig functions of angles a and b
f3=f(a,b,c)==0; %Nonlinear function with trig functions of angles a and b
[a, b, c]=vpasolve([f1 f2 f3], [a b c], [0 pi/2; 0 pi/2; 0 inf]);
%Simple calculations involving X, a, b, and c
% .
% .
if statement to check previous calculations for nonlinear constraints
obj_fun_1=[obj_fun_1, A(i)];
obj_fun_2= [obj_fun_2, (simple calculation)];
else
obj_fun_1=1000 %Penalize the solution with large value
obj_fun_2=1000 %Penalize the solution with large value
break %Only to save time since I'm only intrested in maximum values reached before contraint violation
end
end
end
obj(1)=-max(obj_fun_1); %Maximize max(obj_fun_1)
obj(2)=-max(obj_fun_2); %Maximize max(obj_fun_2)
The current setup with a population of 10 and 30 maximum stall generations produces very good results, but takes really long time (14 hrs and counting). Are there any other methods or tips through which I can make my code run more efficiently?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!