Exemplo n.º 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;
 }
Exemplo n.º 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);
    }
Exemplo n.º 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;
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }