Exemplo n.º 1
0
        /// <summary>
        /// Executes the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            String baseFolder = this.CreateBaseDir();
            DocSet docSet     = this.CreateDocSet();
            IEnumerable <Framework> frameworks = this.CreateFrameworks(docSet);
            IList <FrameworkEntity> entities   = frameworks.SelectMany(f => f.GetEntities()).ToList();

            this.statistics = new GenerationStatistics();
            this.license    = this.LoadLicense();
            this.mixedTypes = this.LoadMixedTypes(baseFolder, entities);

            this.typeManager = new TypeManager();
            Func <FrameworkEntity, bool> selector = delegate(FrameworkEntity e) {
                return(e.type == FrameworkEntityType.C || e.type == FrameworkEntityType.P);
            };
            var names = entities.Where(selector).Select(e => e.name);

            this.typeManager.SetClasses(names);

            foreach (var f in frameworks)
            {
                foreach (var e in f.GetEntities())
                {
                    this.Log(Level.Verbose, String.Format("Processing '{0}'...", e.name));

                    String sourcePath      = e.GetPath(baseFolder, DocumentType.Model);
                    String destinationPath = e.GetPath(baseFolder, DocumentType.Generated);

                    if (sourcePath == null || !File.Exists(sourcePath))
                    {
                        continue;
                    }

                    String file = destinationPath + ".cs";
                    if (sourcePath.IsYoungerThan(file))
                    {
                        Generate(baseFolder, entities, f, e, sourcePath, destinationPath);
                    }
                    else
                    {
                        this.Log(Level.Debug, String.Format("Skipping '{0}'...", e.name));
                    }
                }
            }

            this.Log(Level.Info, statistics.ToString());
        }
Exemplo n.º 2
0
 protected void OnAdvanced(GenerationStatistics generation)
 {
     Advanced?.Invoke(this, new WorldArgs(_world, generation));
 }
Exemplo n.º 3
0
        private static void PrintGeneration <T>(GeneticAlgorithm <T> geneticAlgorithm, GenerationStatistics <T> generationStatistics, string programText) where T : struct
        {
            var generation     = geneticAlgorithm.Generation;
            var averageFitness = generationStatistics.AverageFitness;
            var bestFitness    = generationStatistics.BestFitness;

            Console.WriteLine($"Generation {generation,5}: {averageFitness,5} average fitness, {bestFitness,5} best fitness for {programText}");
        }
Exemplo n.º 4
0
 public WorldArgs(World world, GenerationStatistics generation)
 {
     World      = world;
     Generation = generation;
 }