[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Oct 30 18:06:52 2002 
Subject:RE: Copying Lists 
From:ian 
Volume-ID:1021030.01 


> testbit in a rather peculiar fashion.
> 
>      bool -> testbit( NUMBER, BITNUM ) -> NEW_NUMBER
> 
> Using this, your mutate routine would go from this ...
> 
> >define mutate(chom);
> >lvars pos;
> >     1 + random0( chom_length) -> pos;
> >
> >     if population(chom)(pos) == 1 then
> >         0 -> population(chom)(pos);
> >     else
> >         1 -> population(chom)(pos);
> >     endif;
> >enddefine;
> 
> ... to this ...
> 
> define mutate( chom );
>      lvars pos = random( chom_length );   ;;; random = random0 + 1
>      ;;; toggle the pos'th bit.
>      not( testbit( population( chom ), pos ) ) -> testbit( 
> population( 
> chom ), pos )
> enddefine;

Is that right? It doesn't look like you've updated chom with the new
number...

Shouldn't it be:

define mutate( chom );
     lvars pos = random( chom_length );   ;;; random = random0 + 1
     lvars bitvec = population(chom);
     ;;; toggle the pos'th bit.
     not(testbit(bitvec, pos )) -> testbit(bitvec, pos) ->
population(chom);
enddefine;

[and other judicious use of fast_subscrv to speed things up of course
;-]

Ian
--
www.ianrogers.net