이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
genetic algorithm run time and result analysis
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2020년 9월 30일
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() ?
Nourhan Elsayed
2020년 9월 30일
i use this function
[x,fval,exitflag,output,population,scores] =ga(@FittingFunction,nvars,[],[],[],[],lb,ub,@NonLinearConstraints,[],options);
Walter Roberson
2020년 9월 30일
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.
Star Strider
2020년 9월 30일
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.
Nourhan Elsayed
2020년 9월 30일
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.
Nourhan Elsayed
2020년 9월 30일
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
Walter Roberson
2020년 9월 30일
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?
Walter Roberson
2020년 9월 30일
I do not recognize that final message about inner iterations. Which MATLAB version are you using?
Walter Roberson
2020년 9월 30일
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
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
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
Nourhan Elsayed
2020년 10월 1일
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
Nourhan Elsayed
2020년 10월 4일
that one was helpful https://www.mathworks.com/matlabcentral/answers/602392-genetic-algorithm-run-time-and-result-analysis#comment_1031587
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

Walter Roberson
2020년 10월 4일
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)