Matlab GA evaluating incorrect fitness values.
Dear All, I am trying to minimize a function using GA but it "sees" wrong fitness values. My GA script looks like the following:
ObjectiveFunction = @FF;
ConstraintFunction = @constraints;
nvars = 5;
LB = [1e9 1e9 0.1 -1 1e9];
UB = [1.3825E+12 6.45E+11 0.272 +1 1.12E+11];
options = optimoptions(‘ga’,’PlotFcn’,{@gaplotbestf, @gaplotscores},’Display’,’Iter’,’FitnessLimit’,0.25,’PopulationSize’,20);
[HOM_MOD,FF_val] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction,options);
the first and last lines of FF are as follows:
function y = FF(moduli_short)
…
E = [3.73E+10 3.62E+10 3.81E+10 3.36E+09 1.83E+10];
y = abs(energies(1)-E(1))/E(1) + abs(energies(2)-E(2))/E(2) + abs(energies(3)-E(3))/E(3) + abs(energies(4)-E(4))/E(4) + abs(energies(5)-E(5))/E(5);
When the first generation is evaluated the plots are displayed but the values don’t make any sense. The fitness values in the plots are on the order of -10^19, while as you can see from FF fitness can’t even be negative. I print fitness values from the FF function just to be sure and they are always somewhere between 5 and 1000, not -10^19. As a result of this abnormality the code never converges (and keeps evaluating the FF function at useless points). Last but not least, the plots don’t progress past 1st generation, and the outputs look like this:
Best Max Stall
Generation Func-count f(x) Constraint Generations
without anything following it.
I tried a simpler code with only 2 inputs and it works fine in this case. Does anyone have any guesses as to why I may be facing this problem?Dear All, I am trying to minimize a function using GA but it "sees" wrong fitness values. My GA script looks like the following:
ObjectiveFunction = @FF;
ConstraintFunction = @constraints;
nvars = 5;
LB = [1e9 1e9 0.1 -1 1e9];
UB = [1.3825E+12 6.45E+11 0.272 +1 1.12E+11];
options = optimoptions(‘ga’,’PlotFcn’,{@gaplotbestf, @gaplotscores},’Display’,’Iter’,’FitnessLimit’,0.25,’PopulationSize’,20);
[HOM_MOD,FF_val] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction,options);
the first and last lines of FF are as follows:
function y = FF(moduli_short)
…
E = [3.73E+10 3.62E+10 3.81E+10 3.36E+09 1.83E+10];
y = abs(energies(1)-E(1))/E(1) + abs(energies(2)-E(2))/E(2) + abs(energies(3)-E(3))/E(3) + abs(energies(4)-E(4))/E(4) + abs(energies(5)-E(5))/E(5);
When the first generation is evaluated the plots are displayed but the values don’t make any sense. The fitness values in the plots are on the order of -10^19, while as you can see from FF fitness can’t even be negative. I print fitness values from the FF function just to be sure and they are always somewhere between 5 and 1000, not -10^19. As a result of this abnormality the code never converges (and keeps evaluating the FF function at useless points). Last but not least, the plots don’t progress past 1st generation, and the outputs look like this:
Best Max Stall
Generation Func-count f(x) Constraint Generations
without anything following it.
I tried a simpler code with only 2 inputs and it works fine in this case. Does anyone have any guesses as to why I may be facing this problem? Dear All, I am trying to minimize a function using GA but it "sees" wrong fitness values. My GA script looks like the following:
ObjectiveFunction = @FF;
ConstraintFunction = @constraints;
nvars = 5;
LB = [1e9 1e9 0.1 -1 1e9];
UB = [1.3825E+12 6.45E+11 0.272 +1 1.12E+11];
options = optimoptions(‘ga’,’PlotFcn’,{@gaplotbestf, @gaplotscores},’Display’,’Iter’,’FitnessLimit’,0.25,’PopulationSize’,20);
[HOM_MOD,FF_val] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction,options);
the first and last lines of FF are as follows:
function y = FF(moduli_short)
…
E = [3.73E+10 3.62E+10 3.81E+10 3.36E+09 1.83E+10];
y = abs(energies(1)-E(1))/E(1) + abs(energies(2)-E(2))/E(2) + abs(energies(3)-E(3))/E(3) + abs(energies(4)-E(4))/E(4) + abs(energies(5)-E(5))/E(5);
When the first generation is evaluated the plots are displayed but the values don’t make any sense. The fitness values in the plots are on the order of -10^19, while as you can see from FF fitness can’t even be negative. I print fitness values from the FF function just to be sure and they are always somewhere between 5 and 1000, not -10^19. As a result of this abnormality the code never converges (and keeps evaluating the FF function at useless points). Last but not least, the plots don’t progress past 1st generation, and the outputs look like this:
Best Max Stall
Generation Func-count f(x) Constraint Generations
without anything following it.
I tried a simpler code with only 2 inputs and it works fine in this case. Does anyone have any guesses as to why I may be facing this problem? genetic algorithm, plot MATLAB Answers — New Questions