I'm working at implementing the NSGA ii algorithm into my Final Year Project. Part of the algorithm is sorting all possible solutions into fronts, i.e dominated solutions and undominated solutions
I'm having problems getting the dominated set.
At the minute I'm using a nested for loop, taking the first element from the unsorted list, checking it against every item in the list. If the element is undominated it means either its soft or hard constraints is less than the element being checked against, or both less than. My idea was to say if this isnt true break out of the nested loop and go to the first loop. If it makes it through the whole list without being dominated it will be checked to see if it has been checked against everything, if it has then it is undominated. I hope this makes sense!
Just looking for any bit of help to get it going, thanks :-)
Basically put all I want to do is check the conditions and do something if the conditions ate met within the nested loop for
public void sortIntoFronts(ArrayList<Chromosome> c )
{
ArrayList<Chromosome> UnsortedSet = new ArrayList<Chromosome>();
ArrayList<Chromosome> UndominatedSet = new ArrayList<Chromosome>();
ArrayList<Chromosome> DominatedSet = new ArrayList<Chromosome>();
UnsortedSet = c;
Chromosome a = new Chromosome();
Chromosome b = new Chromosome();
for (int x = 0; x<=UnsortedSet.size()-1; x++)
{
a=UnsortedSet.get(x);
for(int y = 0; y<=UnsortedSet.size()-1;)
{
b=UnsortedSet.get(y);
if(a.SoftConstraints<=b.SoftConstraints || a.hardConstraints<=b.hardConstraints)
{
y++;
} else
{
break;
}
if(y==UnsortedSet.size()-1)
{
UndominatedSet.add(a);
}
}
}
}
Basically put all I want to do is check the conditions and do something if the conditions ate met within the nested loop for, using this code could some1 help me
for (int x = 0; x<=UnsortedSet.size()-1; x++)
{
a=UnsortedSet.get(x);
for(int y = 0; y<=UnsortedSet.size()-1;y++)
{
b=UnsortedSet.get(y);
}
}