swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with Map


From: Fabio Mascelloni
Subject: Problems with Map
Date: Wed, 17 Mar 1999 11:56:22 +0100

In the G.A I've implemented ,the  population is represented by a Map collection.The members are ordered according to their fitness;the compare function is defined in this way:

-(int) compare:(id) b
{
    return ( [self getFitness] > [b getFitness] ) ? 1:-1;
}

The G.A. is a do-while cycle (whose termination condition is the number of generations to run) in which:

Step 1) Using a Tournament or RouletteWheel selection ,a selection List is filled.After the desired length of the selection List is reached,
            the population Map is cleaned for the next step,using an index that traverses it from the last position to the first removing each
            member.
Step 2) Random couples of members are picked  from the selection List , subjected to CrossOver and Mutation and reinserted
            into the population Map keyed with their new fitness.Afterthat the selection list is also cleaned for the next step.

The problem is that after the population Map has been cleaned at Step1),it seems to 'forget' to be a Map , so the members are not reinserted in order.This happens only if  reinserted members  have been subjected to Crossover and Mutation (and so their fitness is changed) :if I simply reinsert them in the population Map without changing thair fitness value,they're correctly reinserted in order.
Here's an output example for a population of 6 :

Population before selection : 18.99  18.61  6.69   5.90    3.62    1.89       //descending order.
Selection list                       :  18.61  18.61  5.90  18.99  18.61  18.61
Population after C.O & Mut:  18.99  15.74  15.74  8.31    8.31  15.74    //order is only partially preserved!

Here's th for loop in which I make C.O. and Mutation:

sel_lis_Idx = [selection_list begin:self];

for (i=0 ;i < popSize/2 ;i++)
{
    int offSet1,offSet2;
    offSet1=[uniformUnsRand getUnsignd withMin:0 withMax:popSize-1];
    offSet2=[uniformUnsRand getUnsignd withMin:0 withMax:popSize-1];
 
   //pick the first  member , selMem1 is a local variable of the method in which the loop is inserted
   [sel_list_Idx setOffSet: offSet1];
    selMem1=[selList_Idx get];
 
  //pick the second
   [sel_list_Idx setOffSet:offSet2];
  selMem2=[sel_list_Idx get];

   if ( (float)[uniformDblRand getDoubleWithMin:0.0L withMax:1.0L]<=crossOverProb)
                          [selMem1 crossOver: selMem2];

   [selMem1 mutateWithProb: mutationProb];
   [selMem2 mutateWithProb: mutationProb];

   //After C.O and mutation assign the members their new fitness
  [selMem1  setFitness: [self getFitnessOf: selMem1] ];
  [selMem2 setFitness: [self getFitnessOf: selMem2 ] ];

  //now reinsert them in the population Map.Here's the critical point:members are not reinserted in order.
 [pop_Map at: selMem1  insert:   selMem1];
 [pop_Map at: selMem2  insert : selMem2 ];

}

If  I simply remove C.O and Mutation steps,the members from the selection list are reinserted in the population map in exact order.
Any idea?

Fabio.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]