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;
 }
Пример #3
0
        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"));
            }
        }
Пример #4
0
        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;
        }
Пример #5
0
        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);
            }
        }
Пример #7
0
        protected virtual LGPEnvironment CreateEnvironment(LGPSchema schema)
        {
            LGPEnvironment environment = new LGPEnvironment(schema);

            environment.CreateFitnessCaseTriggered += (index) =>
            {
                return(CreateFitnessCase(index));
            };
            environment.GetFitnessCaseCountTriggered += () =>
            {
                return(GetFitnessCaseCount());
            };

            return(environment);
        }
Пример #8
0
        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;
            }
        }
Пример #9
0
 public LGPRegInitInstruction(LGPSchema schema)
 {
 }
Пример #10
0
 public LGPSelectionInstruction(LGPSchema schema)
 {
 }
 public LGPCrossoverInstruction(LGPSchema schema)
 {
 }
Пример #12
0
 protected virtual LGPCrossoverInstructionFactory CreateCrossoverInstructionFactory(LGPSchema schema)
 {
     return(new LGPCrossoverInstructionFactory(schema));
 }
Пример #13
0
 protected virtual LGPMutationInstructionFactory CreateMutationInstructionFactory(LGPSchema schema)
 {
     return(new LGPMutationInstructionFactory(schema));
 }
Пример #14
0
 protected virtual LGPRegInitInstructionFactory CreateRegInitInstructionFactory(LGPSchema schema)
 {
     return(new LGPRegInitInstructionFactory(schema));
 }
Пример #15
0
 public LgpPopInitInstructionVariableLength(LGPSchema schema)
 {
     m_iInitialMaxProgLength = schema.MaxProgramLength;
     m_iInitialMinProgLength = schema.MinProgramLength;
 }
Пример #16
0
 public LGPMutationInstruction(LGPSchema schema)
 {
 }
Пример #17
0
 public LGPEnvironment(LGPSchema config)
 {
     Config = config;
 }
 public LgpRegInitInstructionCompleteInputInitReg(LGPSchema schema)
 {
 }
Пример #19
0
 public LGPPop(LGPSchema config)
 {
     mConfig = config;
 }
Пример #20
0
 protected virtual LGPSurvivalInstructionFactory CreateSurvivalInstructionFactory(LGPSchema schema)
 {
     return(new LGPSurvivalInstructionFactory(schema));
 }
 public LGPCrossoverInstructionFactory(LGPSchema schema)
 {
     this.schema = schema;
 }
Пример #22
0
 public LgpSurvivalInstructionCompete(LGPSchema schema)
 {
 }
Пример #23
0
 public LGPMutationInstructionFactory(LGPSchema lgp)
 {
     schema = lgp;
     mCurrentMacroMutation = new LGPMutationInstruction_Macro(lgp);
 }
 public LGPPopInitInstruction(LGPSchema schema)
 {
 }
Пример #25
0
 public LgpSurvivalInstructionProbablistic(LGPSchema schema)
 {
     m_reproduction_probability = schema.ReproductionProbability;
 }
Пример #26
0
 protected virtual LGPSelectionInstructionFactory CreateReproductionSelectionInstructionFactory(LGPSchema schema)
 {
     return(new LGPSelectionInstructionFactory(schema));
 }
 public LgpRegInitInstructionStandard(LGPSchema schema)
 {
     mInputCopyCount       = schema.RegInitInputCopyCount;
     mDefaultRegisterValue = schema.RegInitDefaultRegisterValue;
 }
 public LGPSurvivalInstruction(LGPSchema schema)
 {
 }
Пример #29
0
 public LgpPopInitInstructionConstantLength(LGPSchema schema)
 {
     mConstantProgramLength = schema.PopInitConstantProgramLength;
 }
Пример #30
0
 public LGPSelectionInstructionFactory(LGPSchema schema)
 {
     _schema             = schema;
     mCurrentInstruction = new LgpSelectionInstructionTournament(schema);
 }