public override GeneString crossover(GeneString otherSource, bool keepLength) { Gene[] newGenes = getCrossoverGenes(otherSource, keepLength); ByteGeneString newString = new ByteGeneString(newGenes); return newString; }
public GeneString[] generatePopulation(GeneratorParameters parameters) { ByteGeneStringGeneratorParameters bgsParameters = (ByteGeneStringGeneratorParameters)parameters.parameters; int minimalPopulationSize = parameters.initial.Length; if (parameters.populationSize > minimalPopulationSize) minimalPopulationSize = parameters.populationSize; ByteGeneString[] genes = new ByteGeneString[minimalPopulationSize]; for (int n = 0; n < parameters.initial.Length; n++) { if (!(parameters.initial[n] is ByteGeneString)) throw new WrongGeneTypeException("ByteGeneStringGenerator only accepts ByteGeneStrings"); genes[n] = (ByteGeneString)parameters.initial[n]; } for (int n = parameters.initial.Length; n < genes.Length; n++) { genes[n] = new ByteGeneString(parameters.numGenes, bgsParameters.geneSize, true); } return genes; }
public override GeneString copy() { ByteGeneString genestring = new ByteGeneString(genes); return genestring; }