MATLAB Answers

How is 'score' in MATLAB's Genetic Algorithm defined??

27 views (last 30 days)
Aditya Kommajosula
Aditya Kommajosula on 30 Jan 2017
Commented: arij22 on 26 Nov 2020
Hello all!
I have tried browsing online for answers to my question but there seem to be none. I am using MATLAB's Genetic Algorithm (GA) for some problems. I have been using the GA, with linear constraints and no integer constraints for many months now, and the results seem okay. However, I made a recent shift to using integer constraints (with linear constraints), and the results seem spurious. More specifically, I extract data from every generation to monitor progress, and the best score from the 'state' structure for the final generation looked completely different than the 'fval' reported by MATLAB as the GA output (once its done).
Now, I've been through the cited article that MATLAB uses for handling integer constraints and it is my understanding that for feasible solutions, the score should be the same as the fitness value ('fval'), because penalty would be zero. I also had breakpoints in the code and got to the bottom of the function stack, but I do not see the 'score' field to be computed as anything other than the fitness function itself, in which case the final 'score' reported by MATLAB would have to be the same as 'fval' itself.
I'm unsure of whether 'score' is defined differently by MATLAB, but there is no clear documentation on this. I was wondering if anyone could perhaps help me clarify this issue?
Looking forward to your response, thank you!


roshani thapa
roshani thapa on 20 Jul 2017
I am also having the same issue. I have 96 decision variables and all should be integers. After GA opimisation is terminated what i find is fval and score are two different values which i believe should have been the same. Please reply if you had your answer already.
Aditya Kommajosula
Aditya Kommajosula on 3 Oct 2017
I haven't been able to procure an explanation for this behavior. I sincerely hope this is not a bug!

Sign in to comment.

Answers (2)

Matteo Sangiorgio
Matteo Sangiorgio on 3 Oct 2017
" 'score' reported by MATLAB would have to be the same as 'fval' itself."
Score contains the objectives values for the whole final population (stored in the variable population). On the other hand, in fval are stored only the NON-DOMINATED (the ones which represent the Pareto front) points.
X and population are point of the decision space. fval and score are point of the objective space. X and fval refer to non-dominated points. population and score refer to the whole (non-dominated + dominated) set.


Sign in to comment.

Mohan on 2 Oct 2017
please check this link An individual is any point to which you can apply the fitness function. The value of the fitness function for an individual is its score. For example, if the fitness function is
f(x1,x2,x3)=(2x1+1)^2+(3x2+4)^2+(x3−2)^2, the vector (2, -3, 1), whose length is the number of variables in the problem, is an individual. The score of the individual (2, –3, 1) is f(2, –3, 1) = 51.
An individual is sometimes referred to as a genome and the vector entries of an individual as genes.
So, I think score is the value of the fitness function for an individual,this individual could be any points in the generation. but fval is the Final value of the fitness function.


Aditya Kommajosula
Aditya Kommajosula on 3 Oct 2017
Please refer to my post carefully, my question was about integer-constrained problems where the GA optimizes a penalty function. For a feasible genome, the penalty is the same as its score (or fitness-function value like you said), and for infeasible ones, it is the normalized constraint-violation. The issue is that for my feasible solutions, the 'fval' returned by the GA function is not the exact same as the fitness-function evaluated at those points
arij22 on 26 Nov 2020
Hi Aditya!
I know it has been quite a long time since you worked on this, but I seem to have the exact same problem as yours, and could not find any answer anywhere.
Did you manage to understand the difference between fval and the best scores?
Thanks by advance,
All the best,

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by