genetic algorithm run time and result analysis

Hello
i am using Genetic algorithm. my problem has
nvars=30,
population size = 400
size of initial population matrix = 50x30
max. generation = 200
the following is a plot of best fitness value optained at each generation. the dark dots are ''best value across a generation '' the lighter dots are ''mean value across a generation''
question 1 is; it takes very long time to reach this figure, more than 10 hours, is that normal for my code that has around 300 lines?
question 2: whould any one comment on the shape of output result, this is scattered but on the same area. may be the search space does not mutate enogh? i used the default options for mutation and crossover.
question 3: what options could be useful to reduce running time but get an accurate result, i can reduce the max generations and population size, but i want to lmite the run time to 15 min.

댓글 수: 15

is that normal for my code that has around 300 lines?
Did you implement genetic algorithm yourself, in about 300 lines of code? Or are you using ga() ?
i use this function
[x,fval,exitflag,output,population,scores] =ga(@FittingFunction,nvars,[],[],[],[],lb,ub,@NonLinearConstraints,[],options);
What kinds of operations do you do in those 300 lines?
Are the nonlinear constraints only inequalities or are there equalities as well? You can end up having to test a lot of differerent values to find matches for nonlinear equalities.
One possibility is that ga is chasing a moving target, and the fitness function is changing arbitrarily, perhaps due to a random number generator call. A static fitness function — where only the parameters are changing — should converge.
thank you Strider
would you please explaine more about a moving target?
in addition, i want to ask about the last numer '0'
i got when i interrupt the run. as i got this massage
Read of fitting fn successeful
127 1005600 1.55399e+11 1211 0
Optimization terminated: Stopped in inner iterations.
thank you Walter Roberson
i have only nonlinear equality constraints
What kinds of operations do you do in those 300 lines?
i have to make a sequance of calculations to define dependent variables that participate on the fitting function. in addition, some lines calculate the initial population matrix. and other lines read and load input data from excel file
How large is the fitting function and what kinds of operations are you doing in it?
Are you loading a file inside the fitting function?
Nourhan Elsayed — I have no idea how to interpret that vector.
I do not recognize that final message about inner iterations. Which MATLAB version are you using?
Nonlinear equality constraints effectively require the equivalent of an fsolve to try find a position that meets the constraints. That can be tricky since the constraints are permitted to be discontinuous. Also sometimes the constraints involve considerable computation.
Nourhan Elsayed
Nourhan Elsayed 2020년 9월 30일
편집: Nourhan Elsayed 2020년 9월 30일
ok,
my project has 4 files
file 1: it loads input data from excel file and creat initial population matrix based on input data. it contains lower and upper bounds, some independent variables that are defined as Global and most of them are vectors. (i run this file before i run the ga file , i used to do this step befor i run the ga to overcome the error of undefined variable).
file 2 : Fitting Function: this file containes 4 sections doing next tasks:
%%Task 1: Decision variables : define vector X [x1, x2, x3, ..... x30] of 30 Decision variables for the optimization process
%% Task 2: range of suitable Engines
the code access ''excel file'' to look up for data within a defined range and store them on a matrix,
each element of this matrix is compare to value of x1 and choose the closest then the code acces the excel file again and extract data coressponding to this value.
this step repated for x2 and x3
%% Task 3 : calculate dependent variables (V1, V2, PTO, PTI)
V1 = a* Ld^2 + b * Ld + c * ones(1,9)
V2 = u* LF^2 + d * LF + cw* ones(2,9)
given that
Ld = [x(2:12)]
LF = [x(13 :21); x(22:30)]
% PTO and PTI
PTI = P_Prop_left - x1 * Ld;
PTI (PTIt<0)= 0
PTO= x1* Ld - P_Prop_left;
PTO(PTOt<0) = 0 ;
%% Task 4 objective function:
TFC = (( x1 * (Ld.* V1)+ x1 * (Ld .* V1)) * T') + ((x2* (LF .* V2) * T')
Note that operations are matrix operations.
file 3: NonLinearConstraints:
c = [];
ceq = x1 * Ld+ 0.5 * x2* LF - P_Prop_left - 0.5 * P_EL
file 4: it contains only the ga function and optimization options.
i provided here only a sample and conclusion for the code operations for more clarification.
when i interrupt the run. as i got this massage
Read of fitting fn successeful
127 1005600 1.55399e+11 1211 0
Optimization terminated: Stopped in inner iterations.
i want to ask about the meaning of last naumber of this massage. i suppose that the algorithm can not satisfy the constraint.
i hope you can help
thank you a lot
later.
Walter Roberson
Walter Roberson 2020년 9월 30일
편집: Walter Roberson 2020년 10월 4일
Are you reading a file inside your objective function (task 2)? That is expensive to process. https://www.mathworks.com/help/matlab/math/parameterizing-functions.html
yes Walter, it sounds you are right. parametrizing function could be one solution .
i suggest also to use bilevel concept. x1, x2, x3 are the upper level variables which pass their values to lower level optimization process. in that case, lower level optimization problem has a fixed x1, x2, x3 and that will reduce search space significantly.
thank you a lot
Thank you Walter Roberson for your guidence
i used function handle on my task and i re-formated the whole problrm.
i devided it into two optimization problems, or two layers, one inside the other.
the outer layer i used ga algorithm and the inner layer i used fmincon algorithm. that gave me the figure below.
would you please check that. the process terminated because it reached maximum no of generations. i am asking , on the light of this output, do my problem is going on the right way. i know this information is not enough to judge. but i was watching the code during running and i noticed that my variables are changing , but unfortunatlty, i coudn't get out information about each generation
You might want to add an additional PlotFcn to plot the generation information. Or since you are only running 50 generations, change the 'Display' option to 'iter'

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

질문:

2020년 9월 30일

댓글:

2020년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by