Print

Print


Nice bug you triggered there.  :-)  It does appear that large long
values for min/max gene will cause a long overflow in reset().
Easily enough stomped, not a serious bug.  While we're doing that,
no, you don't need to have min/max genes -- they're more or less only
used in the reset() and mutate() methods.  What you can do is make a
subclass of LongVectorIndividual which overrides those two methods to
reset and mutate the individual how you like.  Then put whatever you
want in for min-gene and max-gene as dummies.

The default reset marches down the genome and randomizes all genes.
The default mutate marches down the genome and randomizes genes when
a coin flip of mutationProbability comes up true.

Sean

On Dec 8, 2005, at 1:08 PM, Peter Drake wrote:

> (Excuse the newbiness, pointers to FAQs gladly accepted, etc.)
>
> I'm evolving LongVectorIndividuals.  I'd like to use the entire range
> of the long type, because it's secretly a packed binary
> representation of what I'm breeding.
>
> Is there a way to not specify min-gene and max-gene?  I tried leaving
> them out:
>
> pop.subpop.0.species            = ec.vector.IntegerVectorSpecies
> pop.subpop.0.species.ind        = ec.vector.LongVectorIndividual
> # Other setup details omitted
>
> and got this:
>
> Initializing Generation 0
> FATAL ERROR:
> IntegerVectorSpecies must have a default min-gene which is <= the
> default max-gene
> PARAMETER: pop.subpop.0.species.max-gene
>      ALSO: vector.species.max-gene
>
> I also tried including the max and min value for a long:
>
> pop.subpop.0.species.min-gene   = -9223372036854775808
> pop.subpop.0.species.max-gene = 9223372036854775807
>
> Result:
>
> Initializing Generation 0
> Exception in thread "main" java.lang.IllegalArgumentException: n must
> be positive
>        at ec.util.MersenneTwisterFast.nextLong
> (MersenneTwisterFast.java:711)
>        at ec.vector.LongVectorIndividual.reset
> (LongVectorIndividual.java:170)
>        at ec.vector.VectorSpecies.newIndividual(VectorSpecies.java:
> 151)
>        at ec.Subpopulation.populate(Subpopulation.java:202)
>        at ec.Population.populate(Population.java:104)
>        at ec.simple.SimpleInitializer.initialPopulation
> (SimpleInitializer.java:39)
>        at ec.simple.SimpleEvolutionState.startFresh
> (SimpleEvolutionState.java:47)
>        at ec.Evolve.startFresh(Evolve.java:320)
>        at ec.Evolve.main(Evolve.java:468)
>
> This happens, no doubt, because LongVectorIndividual.reset() tries
> something to the effect of (max-gene - min-gene), resulting in an
> overflow.
>
> I was able to work around the problem by subclassing
> LongVectorIndividual, overriding reset() and defaultMutate().
>
> Is there a better way?
>
> Thanks,
>
> Peter Drake
> Assistant Professor of Computer Science
> Lewis & Clark College
> http://www.lclark.edu/~drake/
>