simulation based GA, runs slow and calculate more than the number of population
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi everyone:
Im using non-linear constrianted GA to optimize my Simulink model but run into a problem.
As you can see in my code, the population is set to 15 (because it will cost my simulink model around 4mins to calculate each solution so i set it to a small number), but based on my timing record i found GA calculate way more than that on each iteration which is really time-consuming. Any sugguestions will be very much appreciated, thanks !
%% Objective function
ObjectiveFunction = @f_eco; % define objective function
NumVar = 9; % number of variables
LB = [90*10^(-6),330*10^(-6),0.025,250,400,4*10^(-3),0.8,7,7]; % lower bound
UB = [110*10^(-6),400*10^(-6),0.04,350,600,7.2*10^(-3),1.2,12,12]; % upper bound
ConstraintFunction = @f_cons; % constraint function
%% GA Options
% population size
options = optimoptions('ga','PopulationSize',15);
% modifying the stopping criteria
options = optimoptions(options,'MaxGenerations',10,'MaxStallGenerations',inf);
% initial populaztion
options = optimoptions(options,'InitialPopulationMatrix',var_ini);
% visualization
options = optimoptions(options,'PlotFcn',{@gaplotbestf},'Display','iter');
% modify the output
options = optimoptions(options,'OutputFcn',@gaoutfun);
% Termination certeria
options = optimoptions(options,'TolFun',1e-6,'TolCon',1e-3);
% Parrell
options = optimoptions(options,'UseParallel',true,'EliteCount',2);
%% SPMD
spmd
mkdir(sprintf('worker%d', labindex));
copyfile('E28.slx',sprintf('worker%d/',labindex));
cd(sprintf('worker%d', labindex));
end
%% Run GA !
tic
[x,fval,exitFlag,Output] = ga(ObjectiveFunction,NumVar,[],[],[],[],LB,UB, ...
ConstraintFunction,options);
toc
댓글 수: 10
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Global Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!