What is fitness function?

22 views (last 30 days)
priya
priya on 31 May 2012
Commented: Walter Roberson on 30 Mar 2023
What is fitness function?
my prob is multiclass classification what ll be its fitness function

Answers (2)

Thomas
Thomas on 31 May 2012
Fitness function is used in Genetic Algorithm in each iteration of the algorithm to evaluate the quality of all the proposed solutions to your problem in the current population. The fitness function evaluates how good a single solution in a population is, e.g. if you are trying to find for what x-value a function has it's y-minimum with a Genetic algorithm, the fitness function for a unit might simply be the negative y-value (the smaller the value higher the fitness function).

soso
soso on 22 Mar 2023
[F(i),SOC] = fitness(X(i,:),loads,wind_output,solar_output,SOC_init,SOC_min,SOC_max,eta_ch,eta_dis,C_rate,t);
find error please
  1 Comment
Walter Roberson
Walter Roberson on 30 Mar 2023
Mathworks does not provide any function named fitness
Generally speaking, you would pass the handle to a fitness function to one of the minimizers such as fmincon or ga . Those provided minimizers generally expect to be passed a vector of trial values, and they are expected to return a real scalar measure of how "good" that set of trial values is, with lower value being "more fit". The Mathworks minimizers only expect a single output from the fitness function.
If you need to pass a number of constant parameters to the fitness function, then see http://www.mathworks.com/help/matlab/math/parameterizing-functions.html
The mimizers can return a number of different outputs. Most often, the first output of the minimizer is a vector of the model parameters that returned that smallest fitness (and was within the constraint tolerances). Most often, the second output is the fitness value at that set of model parameters.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!