## ECJ-INTEREST-L@LISTSERV.GMU.EDU

#### View:

 Message: [ First | Previous | Next | Last ] By Topic: [ First | Previous | Next | Last ] By Author: [ First | Previous | Next | Last ] Font: Proportional Font

Subject:

Re: Mutation changes

From:

Sean Luke <[log in to unmask]>

Reply-To:

ECJ Evolutionary Computation Toolkit <[log in to unmask]>

Date:

Tue, 21 Dec 2004 11:40:45 -0500

Content-Type:

text/plain

Parts/Attachments:

 text/plain (50 lines)
 ```On Dec 21, 2004, at 6:43 AM, thomas kurz wrote: > i am new in applying ECJ and try to adapt tutorial 2 (integer problem) > to our needs. i want to change the mutation rate and maybe also other > parameters during the running optimization. could anybody give me a > hint? Thomas, there are an awful lot of ways to modify ECJ's parameters at runtime: I will just give an example, so let us know if this is in the direction you were hoping for. Let's just directly modify tutorial2 as the example. In tutorial2 we use a parameter in the species called species.mutationProbability (line 76 of OurMutatorPipeline.java). Let's say you wanted to adjust that from 0 to 1 across 100 generations.   One easy way to do this is to create a new Breeder. import ec.*; import ec.vector.*; import ec.simple.*; public class MyBreeder extends SimpleBreeder         {         public Population breedPopulation(final EvolutionState state)                 throws CloneNotSupportedException                 {                 // the generation flag is incremented AFTER breeding,                 // so we can go ahead and do this first. We presume // it's just one population using a VectorSpecies                 // subclass of some kind.                 float prob = state.generation / 100.0f;                 if (prob > 1.0f) prob = 1.0f; ((VectorSpecies)(state.population.subpops[0].species)).mutationProbabili ty                         = prob;                 // now continuing with our regular program                 return super.breedPopulation(state);                 }         } Now you just have to hook MyBreeder in. Add this to your parameters, overriding the old one: breed = MyBreeder Sean ```

Advanced Options

#### Options

 Log In Get Password Search Archives Subscribe or Unsubscribe