fitness function for Genetic Algorithms with two variables

hi there. actually i already get my fitness function which are
function F=badz(x,y) F=114357834500*x + 114357834500*y; end
but unfortunately when i run this it will appear with
----------------------------- Optimization running. Error running optimization. Not enough input arguments.
someone please help me as i need used genetic algorithm for this optimization. can this problem solved with genetic algorithm act the initial of the fitness function is below
but after i calculate with N=7000 i get the fitness function as below
F=114357834500*x + 114357834500*y
where x is the first teta different for bo and y is the second teta for to.
hopefully someone can help me. thank you!

 Accepted Answer

Mohamad - the error message is telling you that not enough input arguments are being supplied to your fitness function, which is a function of two variables. If you read the documentation for ga you will see that the fitness function must be defined to accept one input only which is a vector/array of the variables being optimized. If your x and y are the two variables being optimized by the genetic algorithm, then you need to change your fitness function to something like the following
function F=badz(x)
F=114357834500*x(1) + 114357834500*x(2);
end
Try making the above change and see if it resolves your error.

1 Comment

thank you for your answer. it is functioning well when i run it.

Sign in to comment.

More Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!