Evolutionary Algorithm: How to insert a child into an array

11 views (last 30 days)
Hi,
I am really struggling to sort out the following evolutionary algorithm problem. The program deals with two equations F1 and F2.
All objectives in the problem are to be minimised, so:
a dominates b if, for all objectives m, am <= bm, and, for at least one objective, am < bm, where m is either 1 or 2 (for objective function F1 or F2). Dominance is evaluated in terms of the objective values.
So far I have written a program that creates a random array with a set length. I then go on to make that my parent, and to make the child I mutate one of the elements randomly in the parents array. Now the bit i am getting stuck with is determining whether or not the child dominates the parent and if it does i need it to replace it into the array. However if it does not dominate it, and is the same according to the above formula i need to archive it. Any time my archive is beaten by a child, the child replaces the archive and so on...
The following is the code I have written to insert the child into the array if it dominates..needless to say it does not work:
%---------------Child Insertation into Population-------------%
WriteFlag = 0;
DeleteFlag = 0;
DeleteArray = 0;
for i = 1 : PopulationSize
if ChildFitness(F1) < PopulationFitnessArray(i,F1)
if ChildFitness(F2) < PopulationFitnessArray(i,F2)
DeleteArray(length(DeleteArray)+1) = i;
DeleteFlag = 1;
end
WriteFlag = 1;
elseif ChildFitness(F2) < PopulationFitnessArray(i,F2)
WriteFlag = 1;
end
end
if WriteFlag == 1
PopulationArray = [PopulationArray;ChildArray];
PopulationSize = PopulationSize + 1;
PopulationFitnessArray = [PopulationFitnessArray;ChildFitness];
end
if DeleteFlag == 1
DeleteArray(1) = [];
DeleteArray = fliplr(DeleteArray);
for i = 1 : length(DeleteArray)
PopulationArray(DeleteArray(i),:) = [];
PopulationSize = PopulationSize - 1;
PopulationFitnessArray(DeleteArray(i),:) = [];
end
DeleteArray = [];
end
Any advice would be much appreciated on this!

Answers (0)

Categories

Find more on Historical Contests in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!