All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ec.app.tutorial2.OurMutatorPipeline Maven / Gradle / Ivy

Go to download

ECJ, A Java-based Evolutionary Computation Research System. ECJ is a research EC system written in Java. It was designed to be highly flexible, with nearly all classes (and all of their settings) dynamically determined at runtime by a user-provided parameter file. All structures in the system are arranged to be easily modifiable. Even so, the system was designed with an eye toward efficiency. ECJ is developed at George Mason University's ECLab Evolutionary Computation Laboratory. The software has nothing to do with its initials' namesake, Evolutionary Computation Journal. ECJ's sister project is MASON, a multi-agent simulation system which dovetails with ECJ nicely.

The newest version!
/*
  Copyright 2006 by Sean Luke
  Licensed under the Academic Free License version 3.0
  See the file "LICENSE" for more information
*/


package ec.app.tutorial2;
import ec.vector.*;
import ec.*;
import ec.util.*;

/*
 * OurMutatorPipeline.java
 */

/**
   OurMutatorPipeline is a BreedingPipeline which negates the sign of genes.
   The individuals must be IntegerVectorIndividuals.  Because we're lazy,
   we'll use the individual's species' mutation-probability parameter to tell
   us whether or not to mutate a given gene.
 
   

Typical Number of Individuals Produced Per produce(...) call
(however many its source produces)

Number of Sources
1 */ public class OurMutatorPipeline extends BreedingPipeline { public static final String P_OURMUTATION = "our-mutation"; // We have to specify a default base, even though we never use it public Parameter defaultBase() { return VectorDefaults.base().push(P_OURMUTATION); } public static final int NUM_SOURCES = 1; // Return 1 -- we only use one source public int numSources() { return NUM_SOURCES; } // We're supposed to create a most _max_ and at least _min_ individuals, // drawn from our source and mutated, and stick them into slots in inds[] // starting with the slot inds[start]. Let's do this by telling our // source to stick those individuals into inds[] and then mutating them // right there. public int produce(final int min, final int max, final int start, final int subpopulation, final Individual[] inds, final EvolutionState state, final int thread) { // grab individuals from our source and stick 'em right into inds. // we'll modify them from there int n = sources[0].produce(min,max,start,subpopulation,inds,state,thread); // should we bother? if (!state.random[thread].nextBoolean(likelihood)) return reproduce(n, start, subpopulation, inds, state, thread, false); // DON'T produce children from source -- we already did // clone the individuals if necessary -- if our source is a BreedingPipeline // they've already been cloned, but if the source is a SelectionMethod, the // individuals are actual individuals from the previous population if (!(sources[0] instanceof BreedingPipeline)) for(int q=start;q





© 2015 - 2024 Weber Informatics LLC | Privacy Policy