public override TGPProgram Clone() { GEPProgram program = new GEPProgram(mOperatorSet, mVariableSet, mConstantSet, mPrimitiveSet, mChromosomeBasis, mChromosomeValueUpperBound); program.Copy(this); return(program); }
public override void Copy(TGPProgram rhs) { base.Copy(rhs); GEPProgram rhs_ = (GEPProgram)rhs; mChromosome = new List <int>(); int chromosome_length = rhs_.mChromosome.Count; for (int i = 0; i < chromosome_length; ++i) { mChromosome.Add(rhs_.mChromosome[i]); } }
public GEPProgram CloneWithoutGPTree() { GEPProgram clone = new GEPProgram(mOperatorSet, mVariableSet, mConstantSet, mPrimitiveSet, mChromosomeBasis, mChromosomeValueUpperBound); clone.mChromosome = new List <int>(); int chromosome_length = mChromosome.Count; for (int i = 0; i < chromosome_length; ++i) { clone.mChromosome.Add(mChromosome[i]); } clone.mDepth = mDepth; clone.mLength = mLength; return(clone); }
public void UniformMutate() { for (int tindex = 0; tindex < mTrees.Count; ++tindex) { GEPProgram program = (GEPProgram)mTrees[tindex]; double mutation_rate = mPop.MacroMutationRate; int upper_bound = program.CodonGeneUpperBound; List <int> codon = program.Chromosome; for (int i = 0; i < codon.Count; ++i) { if (DistributionModel.GetUniform() < mutation_rate) { codon[i] = DistributionModel.NextInt(upper_bound); } } } TrashFitness(); }
public void OnePointCrossover(GEPSolution rhs) { for (int tindex = 0; tindex < mTrees.Count; ++tindex) { GEPProgram gp1 = (GEPProgram)mTrees[tindex]; GEPProgram gp2 = (GEPProgram)rhs.mTrees[tindex]; List <int> codon1 = gp1.Chromosome; List <int> codon2 = gp2.Chromosome; int cut_point_index = 1 + DistributionModel.NextInt(codon1.Count - 2); for (int i = cut_point_index; i < codon1.Count; ++i) { int temp = codon1[i]; codon1[i] = codon2[i]; codon2[i] = temp; } } TrashFitness(); rhs.TrashFitness(); }
public override object CreateProgram() { GEPProgram program = new GEPProgram(mOperatorSet, mVariableSet, mConstantSet, mPrimitiveSet, mChromosomeBasis, ChromosomeValueUpperBound); return(program); }