While implementing genetic algorithm for finding the global minimum for a variable 'y' (which depends upon both x and z), I want to optimise only x and not z. I want to input z from the main code and pass it to my fitness function. Can this be done?

 Respuesta aceptada

Alan Weiss
MATLAB mathematical toolbox documentation

2 comentarios

Thank you. I will be declaring them as global variables now. So the changes I make to these extra parameters inside the fitness function for my genetic algorithm will be reflected in the main function, right?
I am sorry that you didn't comprehend the documentation. It says not to use global variables. It says that you would be much better served by a line such as
myFitness = @(x) (z^2)*x(1) + 4*x(2) + z*x(2)^5;
or by using nested functions.
Alan Weiss
MATLAB mathematical toolbox documentation

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 22 de Nov. de 2016

Comentada:

el 23 de Nov. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by