How to use available Matlab P-file in a script.

14 visualizaciones (últimos 30 días)
Yousuf Azimi
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
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.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
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.
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.
  1 comentario
Yousuf Azimi
Yousuf Azimi el 14 de Sept. de 2020
Dear Walter,
Thank you a lot. I am working on the instruction you said.
Best Wishes.

Iniciar sesión para comentar.

Más respuestas (0)

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!

Translated by