simulation based GA, runs slow and calculate more than the number of population

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 Comments

its only a guess - but you should try what happens if you do not use parallel. i know this sounds crazy but i think it is worth a try.
Hi Stephan, i did try not to use parallel computing and ga just got even slower. I did some research on the forum and followed the suggestion to replace ga with pattern search, same problem occur: based on my time record the objective function and constrained function are being called and calculated endlessly. Now im confused, whats the criteria for the optimization solver to finish one iteration?
maybe someone can help if you provide your objective and your constraints functions.
check this link
I think i found the reason why.
My total func-count is 840 of 5 iterations.
Then another problem occurs: Even though i choose pattern search instead of GA, still Augmented Lagrangian Pattern Search is adopted and a subproblem will be generated. Which optimization solver should i choose in order to save time?
Jason Xu comments to Stephan:
Thanks, it did work ! Not only faster than GA but also perform better in terms of global minimum
@Walter: I do not really understand... Did Jason delete a comment? I did not find anything in the activity feed.
Hi Stephan, do u know how to use surrogate optimization when the problem is mixed-integer? thanks

Sign in to comment.

Answers (0)

Products

Release

R2018b

Asked:

on 11 Jan 2019

Edited:

on 1 May 2019

Community Treasure Hunt

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

Start Hunting!