Ejemplo n.º 1
0
        public List <IGenome> EvolveInitialGeneration(List <IGenome> preExistingGenomes)
        {
            var genomes = new List <IGenome>();

            for (i = preExistingGenomes.Count; i < ModelHelper.GetGePrModel().GetPopulationSize(); i++)
            {
                var       failures = 0;
                BpmGenome genome   = null;
                do
                {
                    genome = new BpmGenome
                    {
                        RootGene =
                            ProcessHelper.ProcessGenerator.GenerateRandomValidBpmGenome2(
                                ModelHelper.GetBpmModel().GetMaxDepthRandomGenome(), null)
                    };
                    genome   = genome.ToString().ParseBpmGenome();
                    failures = 0;
                } while (ModelHelper.GetBpmModel().GetOnlyValidSolutionsAtStart() &&
                         !ProcessHelper.Validator.ValidateGenome(genome, ref failures));

                genomes.Add(genome);
            }

            return(genomes);
        }
Ejemplo n.º 2
0
        private IGenome DoMutation(ISelection Selection, List <IGenome> lastGenerationGenomes)
        {
            var     failures          = 0;
            var     mutation          = new BpmnMutation();
            IGenome genomeToMutateOne = new BpmGenome();
            var     mutatedGenome     = new BpmGenome();

            do
            {
                genomeToMutateOne = Selection.SelectGenome(lastGenerationGenomes);
                mutatedGenome     = mutation.Mutate(genomeToMutateOne, 1f) as BpmGenome;
            } while (ModelHelper.GetBpmModel().GetOnlyValidSolutions() &&
                     !ProcessHelper.Validator.ValidateGenome(mutatedGenome, ref failures));

            Debug.WriteLine("Mutation mutated " + genomeToMutateOne + " to " + mutatedGenome);

            return(mutatedGenome);
        }