How to Add Fitness Limit as Stopping Criterion in Genetic Algorithm?

7 次查看(过去 30 天)
I added fitness limit into field 'options' in genetic algorithm code and defined its value to be 0.5.
clc
clear all
global x1e x2e x3e x1r x2r x3r alfa12 alfa13 alfa23
%LLE podatci - ekstrakcija aromata smjesom TTEG i vode - 6 komponenata (heptan) na 60°C
%eksperimentalni podatci - ekstrakt
x1e = [0.0140 0.0175 0.0163 0.0188 0.0181 0.0227 0.0228 0.0214 0.0191 0.0208];
x2e = [0.0729 0.0696 0.106 0.1041 0.1107 0.0931 0.0732 0.0739 0.113 0.069];
x3e = 1 - x1e - x2e;
%eksperimentalni podatci - rafinat
x1r = [0.689 0.6289 0.485 0.4727 0.4332 0.6831 0.6967 0.6553 0.4507 0.6139];
x2r = [0.275 0.2855 0.4418 0.3501 0.4056 0.313 0.2716 0.271 0.4436 0.253];
x3r = 1 - x1r - x2r;
%Optimizacija NRTL parametara - Metoda Sorensena i Arlta
%1. stupanj optimizacije - opis fazne ravnoteze - geneticki algoritam
%parametri neslucajnosti
alfa12 = 0.3;
alfa13 = 0.3;
alfa23 = 0.2;
rng default
%definiranje strukture problema
OF_A = @OF_2_6H_60C;
problem.fitnessfcn = OF_A;
problem.nvars = 6;
problem.options = optimoptions('ga','FitnessLimit',0.5);
[x,fval] = ga(problem)
However, after running code I get following result:
Optimization terminated: average change in the fitness value less than options.FunctionTolerance.
x =
6.1833 5.3657 2.3855 0.6108 2.6711 2.4970
fval =
0.9834
Matlab used function tolerance (default setting) as stopping criterion and not fitness limit even though I added FitnessLimit in field options. Why is this?

采纳的回答

Geoff Hayes
Geoff Hayes 2022-1-26
@Dario Miric - from Stopping Conditions for GA, it mentions that for all of the different stopping conditions, the algorithm stops as soon as any one of these conditions is met. In your case, it seems that the FunctionTolerance condition is being met before the FitnessLimit. For the function tolerance, it also mentions that the algorithm runs until the average relative change in the fitness function value over MaxStallGenerations is less than Function tolerance. You could try increasing the MaxStallGenerations but this won't gurantee that the FitnessLimit will be used to stop the algorithm.
  2 个评论
Dario Miric
Dario Miric 2022-1-27
编辑:Dario Miric 2022-1-27
Okay, thanks. However, it really has no sense that it works this way since:
1) There are many criteria in GA
2) Adding criterion you want is meaningless since algorithm will nevertheless stop on first one which is satisfied
3) GA is used to find function minimum and it has no sense that algorithm stops as soon as possible since method is numerical and we want to get as close to minimum as possible
Matlab should change this.
Problem is I don't know how many stall generations were used to find minimum since I didn't specify this nor is that written in results. Can I make function tolerance smaller and see if it gets to better result?
Alan Weiss
Alan Weiss 2022-1-27
I would like to point out that you set a fitness limit of 0.5, and the final reported value of the fitness function was 0.98, which is well above the fitness limit. That is why ga did not stop. If you would set a fitness limit above the value 1, ga would stop based on hitting that limit.
Alan Weiss
MATLAB mathematical toolbox documentation

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by