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

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 commentaire

Jonas
Jonas le 31 Août 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.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 13 Sep 2020

0 votes

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 commentaire

Dear Walter,
Thank you a lot. I am working on the instruction you said.
Best Wishes.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by