public LGPCrossoverInstruction_OneSegment(LGPSchema lgp) { mMaxProgramLength = lgp.MaxProgramLength; mMinProgramLength = lgp.MinProgramLength; mMaxSegmentLength = lgp.MaxSegmentLength; mInsertionProbability = lgp.InsertionProbabilityInCrossover; }
public LGPCrossoverInstruction_Linear(LGPSchema schema) { mMaxDifferenceOfSegmentLength = schema.MaxDifferenceOfSegmentLength; mMaxProgramLength = schema.MaxProgramLength; mMinProgramLength = schema.MinProgramLength; mMaxSegmentLength = schema.MaxSegmentLength; mMaxDistanceOfCrossoverPoints = schema.MaxDistanceOfCrossoverPoints; }
public void TestSymbolicRegression() { List <LGPFitnessCase> table = mexican_hat(); LGPSchema config = new LGPSchema(); LGPPop pop = new LGPPop(config); pop.OperatorSet.AddOperator(new LGPOperator_Plus()); pop.OperatorSet.AddOperator(new LGPOperator_Minus()); pop.OperatorSet.AddOperator(new LGPOperator_Division()); pop.OperatorSet.AddOperator(new LGPOperator_Multiplication()); pop.OperatorSet.AddOperator(new LGPOperator_Power()); pop.OperatorSet.AddIfltOperator(); config.ConstantRegisters.Add(new KeyValuePair <double, double>(1, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(2, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(3, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(4, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(5, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(6, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(7, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(8, 1)); config.ConstantRegisters.Add(new KeyValuePair <double, double>(9, 1)); config.RegisterCount = 6; pop.CreateFitnessCase += (index) => table[index]; pop.GetFitnessCaseCount += () => table.Count; pop.EvaluateFitnessFromAllCases += (fitness_cases) => { double fitness = 0; for (int i = 0; i < fitness_cases.Count; i++) { MexicanHatFitnessCase fitness_case = (MexicanHatFitnessCase)fitness_cases[i]; double correct_y = fitness_case.Y; double computed_y = fitness_case.ComputedY; fitness += (correct_y - computed_y) * (correct_y - computed_y); } return(fitness); }; pop.BreedInitialPopulation(); while (!pop.IsTerminated) { pop.Evolve(); Console.WriteLine("Mexican Hat Symbolic Regression Generation: {0}", pop.CurrentGeneration); Console.WriteLine("Global Fitness: {0}\tCurrent Fitness: {1}", pop.GlobalBestProgram.Fitness.ToString("0.000"), pop.FindFittestProgramInCurrentGeneration().Fitness.ToString("0.000")); } }
public LGPMutationInstruction_Macro(LGPSchema lgp) { _macroMutateInsertionRate = lgp.MacroMutateInsertionRate; _macroMutateDeletionRate = lgp.MacroMutationDeletionRate; _effectiveMutation = lgp.EffectiveMutation; _macroMutateMaxProgramLength = lgp.MaxProgramLength; _macroMutateMinProgramLength = lgp.MinProgramLength; _macroMutateInsertionRate /= (_macroMutateInsertionRate + _macroMutateDeletionRate); _macroMutateDeletionRate = 1 - _macroMutateInsertionRate; }
public LGPRegInitInstructionFactory(LGPSchema schema) { this.schema = schema; LGPSchema.RegInitType strategy = schema.RegInit; if (strategy == LGPSchema.RegInitType.complete) { mCurrentInstruction = new LgpRegInitInstructionCompleteInputInitReg(schema); } else if (strategy == LGPSchema.RegInitType.standard) { mCurrentInstruction = new LgpRegInitInstructionStandard(schema); } }
public LGPSurvivalInstructionFactory(LGPSchema schema) { _schema = schema; LGPSchema.SurvivalType strategy = schema.Survival; if (strategy == LGPSchema.SurvivalType.complete) { mCurrentInstruction = new LgpSurvivalInstructionCompete(schema); } else { mCurrentInstruction = new LgpSurvivalInstructionProbablistic(schema); } }
protected virtual LGPEnvironment CreateEnvironment(LGPSchema schema) { LGPEnvironment environment = new LGPEnvironment(schema); environment.CreateFitnessCaseTriggered += (index) => { return(CreateFitnessCase(index)); }; environment.GetFitnessCaseCountTriggered += () => { return(GetFitnessCaseCount()); }; return(environment); }
public LGPPopInitInstructionFactory(LGPSchema lgp) { LGPSchema.PopInitType attrname = lgp.PopInit; switch (attrname) { case LGPSchema.PopInitType.variable_length: mCurrentInstruction = new LgpPopInitInstructionVariableLength(lgp); break; case LGPSchema.PopInitType.constant_length: mCurrentInstruction = new LgpPopInitInstructionConstantLength(lgp); break; } }
public LGPRegInitInstruction(LGPSchema schema) { }
public LGPSelectionInstruction(LGPSchema schema) { }
public LGPCrossoverInstruction(LGPSchema schema) { }
protected virtual LGPCrossoverInstructionFactory CreateCrossoverInstructionFactory(LGPSchema schema) { return(new LGPCrossoverInstructionFactory(schema)); }
protected virtual LGPMutationInstructionFactory CreateMutationInstructionFactory(LGPSchema schema) { return(new LGPMutationInstructionFactory(schema)); }
protected virtual LGPRegInitInstructionFactory CreateRegInitInstructionFactory(LGPSchema schema) { return(new LGPRegInitInstructionFactory(schema)); }
public LgpPopInitInstructionVariableLength(LGPSchema schema) { m_iInitialMaxProgLength = schema.MaxProgramLength; m_iInitialMinProgLength = schema.MinProgramLength; }
public LGPMutationInstruction(LGPSchema schema) { }
public LGPEnvironment(LGPSchema config) { Config = config; }
public LgpRegInitInstructionCompleteInputInitReg(LGPSchema schema) { }
public LGPPop(LGPSchema config) { mConfig = config; }
protected virtual LGPSurvivalInstructionFactory CreateSurvivalInstructionFactory(LGPSchema schema) { return(new LGPSurvivalInstructionFactory(schema)); }
public LGPCrossoverInstructionFactory(LGPSchema schema) { this.schema = schema; }
public LgpSurvivalInstructionCompete(LGPSchema schema) { }
public LGPMutationInstructionFactory(LGPSchema lgp) { schema = lgp; mCurrentMacroMutation = new LGPMutationInstruction_Macro(lgp); }
public LGPPopInitInstruction(LGPSchema schema) { }
public LgpSurvivalInstructionProbablistic(LGPSchema schema) { m_reproduction_probability = schema.ReproductionProbability; }
protected virtual LGPSelectionInstructionFactory CreateReproductionSelectionInstructionFactory(LGPSchema schema) { return(new LGPSelectionInstructionFactory(schema)); }
public LgpRegInitInstructionStandard(LGPSchema schema) { mInputCopyCount = schema.RegInitInputCopyCount; mDefaultRegisterValue = schema.RegInitDefaultRegisterValue; }
public LGPSurvivalInstruction(LGPSchema schema) { }
public LgpPopInitInstructionConstantLength(LGPSchema schema) { mConstantProgramLength = schema.PopInitConstantProgramLength; }
public LGPSelectionInstructionFactory(LGPSchema schema) { _schema = schema; mCurrentInstruction = new LgpSelectionInstructionTournament(schema); }