예제 #1
0
 private static void AddCrossoverMethodExperiment(ExperimentSet newSet, ICrossoverMethod crossoverMethod, string title)
 {
     var newExperiment = new Experiment();
     newSet.Experiments.Add(newExperiment);
     newExperiment.CrossoverMethod = crossoverMethod;
     newExperiment.Label = "Crossover Method: " + title;
 }
예제 #2
0
    public void Start()
    {
        //FilePath = "C:\\Users\\JKMT\\Desktop\\OptimizationShooting.txt";

        leftRules  = new List <EvaluationTreeRuleBase>(PopulationSize);
        rightRules = new List <EvaluationTreeRuleBase>(PopulationSize);

        for (int i = 0; i < PopulationSize; i++)
        {
            leftRules.Add(FuzzyShootingUtil.CreateRandomEvaluationTreeRuleBase());
            rightRules.Add(FuzzyShootingUtil.CreateRandomEvaluationTreeRuleBase());
        }

        IsTrialRunning  = false;
        TrialCount      = 0;
        GenerationCount = 1;

        TrialController = Trial.GetComponent <TrialController>();

        OrganismFactory = new EvaluationTreeRuleBaseFactory(FuzzyShootingUtil.InputSets, FuzzyShootingUtil.TorqueSet);
        GeneCopier      = new RuleCopier();

        SelectionMethod = new StochasticUniversalSamplingSelection(0.11f, 0.29f);
        CrossoverMethod = new UniformCrossover();

        GeneticAlgorithm = new GeneticAlgorithm <EvaluationTreeRuleBase, Rule>(SelectionMethod, CrossoverMethod, OrganismFactory, GeneCopier);
    }
예제 #3
0
        private static void AddCrossoverMethodExperiment(ExperimentSet newSet, ICrossoverMethod crossoverMethod, string title)
        {
            var newExperiment = new Experiment();

            newSet.Experiments.Add(newExperiment);
            newExperiment.CrossoverMethod = crossoverMethod;
            newExperiment.Label           = "Crossover Method: " + title;
        }
예제 #4
0
 public Population(IFitnessFunction fitnessFunction, List <IGenome> population)
 {
     //Log.Create("../../Logs/");
     this.selection  = DefaultParameter.selection;
     this.crossover  = DefaultParameter.crossover;
     this.mutation   = DefaultParameter.mutation;
     this.population = population;
 }
예제 #5
0
 public Population(IFitnessFunction fitnessFunction, List<IGenome> population)
 {
     //Log.Create("../../Logs/");
     this.selection = DefaultParameter.selection;
     this.crossover = DefaultParameter.crossover;
     this.mutation = DefaultParameter.mutation;
     this.population = population;
 }
예제 #6
0
        public Population(IFitnessFunction fitnessFunction, int size)
        {
            //            Log.Create("../../Logs/");
            this.selection = DefaultParameter.selection;
            this.crossover = DefaultParameter.crossover;
            this.mutation = DefaultParameter.mutation;
            this.generation = 1;
            this.avarageFitness = 0;
            this.fitnessFunction = fitnessFunction;

            IInitialPopulationMethod initial = DefaultParameter.initialPopulation;
            this.population = initial.Generate(DefaultParameter.genomeSize, fitnessFunction);
        }
예제 #7
0
        public Population(IFitnessFunction fitnessFunction, int size)
        {
//            Log.Create("../../Logs/");
            this.selection       = DefaultParameter.selection;
            this.crossover       = DefaultParameter.crossover;
            this.mutation        = DefaultParameter.mutation;
            this.generation      = 1;
            this.avarageFitness  = 0;
            this.fitnessFunction = fitnessFunction;

            IInitialPopulationMethod initial = DefaultParameter.initialPopulation;

            this.population = initial.Generate(DefaultParameter.genomeSize, fitnessFunction);
        }
예제 #8
0
        /// <summary>
        /// Dos a crossover between this IChromosome and another by applying the specified ICrossoverMethod.
        /// </summary>
        /// <returns>The resulting offspring.</returns>
        /// <param name="crossoverMethod">Crossover method.</param>
        /// <param name="other">Other.</param>
        public IChromosome <T> DoCrossover(ICrossoverMethod crossoverMethod, IChromosome <T> other)
        {
            if (Length != other.Length)
            {
                throw new ArgumentException("Chromosomes must be of same length");
            }

            var childGenes = new T[Length];

            for (var i = 0; i < Length; i++)
            {
                childGenes[i] = crossoverMethod.SelectGene(i, this, other);
            }

            return(new Chromosome <T>(childGenes));
        }