0

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);

    }
}
4

1 回答 1

0

我还没有真正理解你的问题到底是什么。但回顾一下:

  1. a主宰是可悲的b,当且仅当a.SoftConstraints<=b.SoftConstraints || a.hardConstraints<=b.hardConstraints成立。
  2. ab当且仅当a.SoftConstraints==b.SoftConstraints || a.hardConstraints==b.hardConstraints保持在同一个主宰战线上是可悲的
  3. 在其他情况下b占主导地位a

基于此,您可以定义一个Comparator来创建未排序集的有序列表。然后,您可以遍历该排序列表。您的内部循环只是对外部循环已经进行到的子列表的迭代(或取决于外部循环已经进行的排序顺序)。您必须采取行动,而不是针对该内部循环的每次迭代。

于 2013-01-13T13:39:21.677 回答