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?

 채택된 답변

Alan Weiss
MATLAB mathematical toolbox documentation

댓글 수: 2

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2016년 11월 22일

댓글:

2016년 11월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by