ga custom functions parameters

Hi everyone,
I am trying to optimize a race track, represented by a class, with the ga function. Since I use a class and not some numbers to optimize, I need to write all the needed functions myself (mutation, crossover, etc). I have a really hard time figuring out what exactly the input parameters of the functions are and what they are supposed to return.
As an example: I first thought the fitness function gets one individual and returns the fitness value, but apparently it gets a 1x1 cell array with one individual. Or the crossover function: the 'parents' parameter is a vector with two integers. I assume those are the indices of the parents in the 'thisPopulation' parameter, but honestly I have no clue.
Can someone help me understand what happens here? Even just a short description of what goes in/out would help. Unfortunately the official documentation is not very helpful in terms of variable types. The functions I need are the CreationFcn, FitnessFcn, MutationFcn and CrossoverFcn. Here is my code at the moment.
Thanks for your efforts, the help is appreciated.

回答(1 个)

Alan Weiss
Alan Weiss 2017-8-28

0 个投票

I am sorry that you are having trouble. Perhaps this example will help.
Alan Weiss
MATLAB mathematical toolbox documentation

1 个评论

Thanks for the reply, unfortunately I already read this page and it doesn't help much. All the function parameters are explained, but only in a semantic way ( "PARENTS: Parents chosen by the selection function"), I'd also need the syntactic description: "PARENTS: 2x1 cell array of class x".

请先登录,再进行评论。

类别

Community Treasure Hunt

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

Start Hunting!

Translated by