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

20 Ansichten (letzte 30 Tage)
Dario Miric am 26 Jan. 2022
Kommentiert: Alan Weiss am 27 Jan. 2022
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?
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Geoff Hayes am 26 Jan. 2022
@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 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Alan Weiss am 27 Jan. 2022
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

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Genetic Algorithm in Help Center and File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by