示例#1
0
文件: AppCore.cs 项目: minskowl/MY
        /// <summary>
        /// Loads the project.
        /// </summary>
        /// <param name="project">The project.</param>
        private void LoadProject(GenerateProject project)
        {
            CloseProject();

            switch (project.ProjectType)
            {
            case ProjectType.Assembly:
                _assemblyManager.LoadProject(project);
                _activeManager = _assemblyManager;
                break;

            case ProjectType.PD:
                _pdManager.LoadProject(project);
                _activeManager = _pdManager;
                break;

            case ProjectType.Schema:
                _schemaManager.LoadProject(project);
                _activeManager = _schemaManager;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        public IList <IGenome> Produce(
            int totalRequired,
            IGenerationManager generationManager)
        {
            var totalSession = new GenomeProductionSession(totalRequired);

            foreach (var producer in Producers)
            {
                ExecuteProducer(generationManager, totalSession, producer);
            }

            while (totalSession.CurrentlyProduced.Count < totalRequired)
            {
                var currentCount = totalSession.CurrentlyProduced.Count;
                ExecuteProducer(generationManager, totalSession, Producers.Last());

                if (currentCount == totalSession.CurrentlyProduced.Count)
                {
                    throw new Exception("The last producer MUST yield at least " +
                                        "one genome");
                }
            }

            Trace.Assert(totalSession.CurrentlyProduced.Count == totalRequired);

            return(totalSession.CurrentlyProduced);
        }
 public GeneticManagerClassic(
     IGenerationManager generationManager,
     IInitialGenerationCreator initialGenerationCreator,
     GenomeForge genomeForge,
     int populationGenomesCount
     )
     : base(generationManager)
 {
     this.GenomeForge = genomeForge;
     this.InitialGenerationCreator = initialGenerationCreator;
     this.PopulationGenomeCount    = populationGenomesCount;
 }
示例#4
0
        protected void ExecuteProducer(
            IGenerationManager generationManager,
            GenomeProductionSession totalSession,
            IGenomeProducer producer)
        {
            var requiredNb = GetProducerNbOfGenomesToMake(
                totalSession.requiredNb,
                totalSession.requiredNb - totalSession.CurrentlyProduced.Count,
                producer);

            var thisSession = new GenomeProductionSession(requiredNb);

            producer.Produce(
                generationManager.GetGenomes().ToArray(),
                thisSession,
                totalSession
                );

            totalSession.Merge(thisSession);
        }
示例#5
0
 public GeneticManagerBase(IGenerationManager generationManager)
 {
     this.GenerationManager = generationManager;
 }