コード例 #1
0
        public FractalSelection()
        {
            views = new List <FractalView>();

            foreach (var i in Enumerable.Range(0, POPULATION_SIZE))
            {
                var fractalView = new FractalView();

                fractalView.ViewResolutionWidth  = VIEW_WIDTH;
                fractalView.ViewResolutionHeight = VIEW_HEIGHT;

                views.Add(fractalView);

                Controls.Add(fractalView);
                fractalView.Show();
            }


            this.ga = new MandelbrotCPPNNEATGA(POPULATION_SIZE,
                                               delegate(MandelbrotCPPNNEATGenome genome)
            {
                var pictureBox = views.Where(image => image.Genome == genome).FirstOrDefault();
                return((pictureBox != null) ? pictureBox.Score : 0);
            }, new List <Func <CPPNNEATActivationFunction> >  {
                CPPNActivationFunctionFactories.ComplexLinearActivationFunctionFactory,
                CPPNActivationFunctionFactories.ComplexExponentialActivationFunctionFactory,
                CPPNActivationFunctionFactories.ComplexLogarithmicActivationFunctionFactory,
                CPPNActivationFunctionFactories.ComplexTanHActivationFunctionFactory,
                CPPNActivationFunctionFactories.ComplexEulerActivationFunctionFactory,
                CPPNActivationFunctionFactories.ComplexPolynomialActivationFunctionFactory,
                CPPNActivationFunctionFactories.ComplexGaussianActivationFunctionFactory,
                CPPNActivationFunctionFactories.ComplexSinActivationFunctionFactory,
            },
                                               CPPNActivationFunctionFactories.ComplexLinearActivationFunctionFactory
                                               );

            ga.CompatibilityDistanceThreshold = COMPATIBILITY_DISTANCE_THRESHOLD;
            ga.NoInnovationThreshold          = NO_INNOVATION_THRESHOLD;
            ga.IterationsToClearLinkCache     = ITERATIONS_TO_CLEAR_LINK_CACHE;

            ga.WeightMutationRate = WEIGHT_MUTATION_RATE;
            ga.NewNeuronRate      = NEW_NEURON_RATE;
            ga.NewLinkRate        = NEW_LINK_RATE;

            ga.DisableGeneRate = DISABLE_GENE_RATE;

            ga.SurvivalTreshold       = SURVIVAL_TRESHOLD;
            ga.InterSpeciesMatingRate = INTERSPECIES_MATING_RATE;

            ga.WeightPertubationRate = WEIGHT_PERTUBATION_RATE;
            ga.MaxPerturbation       = MAX_PERTURBATION;
            ga.MaxWeight             = MAX_WEIGHT;

            ga.CrossoverRate = CROSSOVER_RATE;

            ga.ExcessGenesWeight        = EXCESS_GENES_WEIGHT;
            ga.DisjointGenesWeight      = DISJOINT_GENES_WEIGHT;
            ga.MatchingGenesWeight      = MATCHING_GENES_WEIGHT;
            ga.FunctionDifferenceWeight = FUNCTION_DIFFERENCE_WEIGHT;

            ga.MateByAveragingRate = MATE_BY_AVERAGING_RATE;

            ga.ViewPosition = VIEW_POSITION;
            ga.ViewScale    = VIEW_SCALE;

            ga.Initialise();

            LoadGenomesIntoImages();
        }
コード例 #2
0
        public FractalSelection()
        {
            views = new List<FractalView>();

            foreach (var i in Enumerable.Range(0, POPULATION_SIZE))
            {
                var fractalView = new FractalView();

                fractalView.ViewResolutionWidth = VIEW_WIDTH;
                fractalView.ViewResolutionHeight = VIEW_HEIGHT;

                views.Add(fractalView);

                Controls.Add(fractalView);
                fractalView.Show();
            }

            this.ga = new MandelbrotCPPNNEATGA(POPULATION_SIZE,
                        delegate(MandelbrotCPPNNEATGenome genome)
                        {
                            var pictureBox = views.Where(image => image.Genome == genome).FirstOrDefault();
                            return (pictureBox != null) ? pictureBox.Score : 0;
                        }, new List<Func<CPPNNEATActivationFunction>>  {
                                            CPPNActivationFunctionFactories.ComplexLinearActivationFunctionFactory,
                                            CPPNActivationFunctionFactories.ComplexExponentialActivationFunctionFactory,
                                            CPPNActivationFunctionFactories.ComplexLogarithmicActivationFunctionFactory,
                                            CPPNActivationFunctionFactories.ComplexTanHActivationFunctionFactory,
                                            CPPNActivationFunctionFactories.ComplexEulerActivationFunctionFactory,
                                            CPPNActivationFunctionFactories.ComplexPolynomialActivationFunctionFactory,
                                            CPPNActivationFunctionFactories.ComplexGaussianActivationFunctionFactory,
                                            CPPNActivationFunctionFactories.ComplexSinActivationFunctionFactory,
                                    },
                        CPPNActivationFunctionFactories.ComplexLinearActivationFunctionFactory
                   );

            ga.CompatibilityDistanceThreshold = COMPATIBILITY_DISTANCE_THRESHOLD;
            ga.NoInnovationThreshold = NO_INNOVATION_THRESHOLD;
            ga.IterationsToClearLinkCache = ITERATIONS_TO_CLEAR_LINK_CACHE;

            ga.WeightMutationRate = WEIGHT_MUTATION_RATE;
            ga.NewNeuronRate = NEW_NEURON_RATE;
            ga.NewLinkRate = NEW_LINK_RATE;

            ga.DisableGeneRate = DISABLE_GENE_RATE;

            ga.SurvivalTreshold = SURVIVAL_TRESHOLD;
            ga.InterSpeciesMatingRate = INTERSPECIES_MATING_RATE;

            ga.WeightPertubationRate = WEIGHT_PERTUBATION_RATE;
            ga.MaxPerturbation = MAX_PERTURBATION;
            ga.MaxWeight = MAX_WEIGHT;

            ga.CrossoverRate = CROSSOVER_RATE;

            ga.ExcessGenesWeight = EXCESS_GENES_WEIGHT;
            ga.DisjointGenesWeight = DISJOINT_GENES_WEIGHT;
            ga.MatchingGenesWeight = MATCHING_GENES_WEIGHT;
            ga.FunctionDifferenceWeight = FUNCTION_DIFFERENCE_WEIGHT;

            ga.MateByAveragingRate = MATE_BY_AVERAGING_RATE;

            ga.ViewPosition = VIEW_POSITION;
            ga.ViewScale = VIEW_SCALE;

            ga.Initialise();

            LoadGenomesIntoImages();
        }