How to use available Matlab P-file in a script.
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yousuf Azimi
el 13 de Sept. de 2020
Comentada: Jonas
el 31 de Ag. de 2022
Hi
I write for my self a simple form of NSGA II to solve an optimization problem with integer constraints. I use the ordinary crossover and mutation to generate new solutions then I use the "round" function to convert the new children into integer form before calling them in the cost function of the problem. But unfortunately, I didn't get good results.
then I think I can call ordinary genetic algorithm special mutation and crossover functions specialized for solving integer constraint optimization problems. I mean to use Laplace crossover and power mutation functions. Unfortunately, these functions are Matlab P-files, so they aren't allowed to see the code inside the files.
As my question is there any way that I can call these three P-file functions, namely; "CreationFcn: @gaminlpcreationuniform" and "CrossoverFcn: @gaminlpcrossoverlaplace" and "MutationFcn: @gaminlpmutationpower" inside my NSGA II code. so that I will create new integer candidate solutions for my optimization problem. I would be so grateful if anyone could help me.
Thanks in advance.
Yousef Azimi
1 comentario
Jonas
el 31 de Ag. de 2022
Hi Yousef,
is there any difference between @gaminlpcrossoverlaplace and @crossoverlaplace? If there is, are all these options better for integer variables and why?
Greetings.
Respuesta aceptada
Walter Roberson
el 13 de Sept. de 2020
As far as MATLAB is concerned, there is no difference in the calling sequence for a .p file and the same function implemented as a .m file. Either way you need to pass in the expected parameters in the expected order.
The expected parameter for those particular kinds of functions are defined in the documentation.
For creation functions, it is described at https://www.mathworks.com/help/gads/genetic-algorithm-options.html#f14223
For mutation functions, it is described at https://www.mathworks.com/help/gads/genetic-algorithm-options.html#f6633
For crossover functions, it is described at https://www.mathworks.com/help/gads/genetic-algorithm-options.html#f7820
The built-in functions such as gaminlpcrossoverlaplace use exactly the same calling sequence as the custom functions: in both cases all that ga() receives in the option is the function handle, and it does not examine the function handle to figure out if it is somehow "special" that should hypothetically be treated differently.
Más respuestas (0)
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!