MATLAB: Genetic Algorithm – Relation between Population and Fitness Function

genetic algorithmGlobal Optimization Toolboxoptimization algorithms

When using a Custom Population Function and specifically Custom Binary Population. How does the population relate to the Fitness Function?
I have both coded out but and have somewhat knowledge but lack the critical understanding of how they work together. Should my fitness function have a input variable which takes in the population and computes the fitness of the individuals?
I have not found and detailed reading material on this relation. Are there any such reading materials available on these relations or could anyone explain them please.
Thanks.

Best Answer

As described in the documentation, the creation function creates a population, and the fitness function evaluates how good each member of the population is. There is a specific syntax for the creation function, and there is a syntax for the fitness function. There is more information about fitness functions here.
For the creation function, the syntax is
function population = creationfcn(nvars,fitnessfcn,options)
GA passes the arguments nvars, fitnessfcn, and options to your creation function. What you do with those arguments is up to you. You will certainly need the nvars argument so that your population has the right number of elements, but you can use the other two arguments or ignore them as you see fit.
I hope this helps.
Alan Weiss MATLAB mathematical toolbox documentation