Beispiel #1
0
        public static FormInputData Run(FormInputData inputData, SettingsOpt settings,
                                        OptimizeWindowViewModel viewModel, CancellationToken token)
        {
            var optController    = GetOptimizationController(inputData, settings);
            var geneticAlgorithm = SetGeneticAlgorithmSettings(settings, optController);

            geneticAlgorithm.GenerationRan += delegate
            {
                OutputGenerationResults(viewModel, geneticAlgorithm, inputData);
                if (token.IsCancellationRequested)
                {
                    geneticAlgorithm.Stop();
                    LogLine(viewModel, "Optimization stopped by user!");
                }
            };

            var optimizedInputData = RunOptimization(inputData, viewModel, geneticAlgorithm);

            return(optimizedInputData);
        }
Beispiel #2
0
        private static GeneticAlgorithm SetGeneticAlgorithmSettings(SettingsOpt settings, ControllerGlassOpt optController)
        {
            var selection      = optController.CreateSelection();
            var crossover      = optController.CreateCrossover();
            var mutation       = optController.CreateMutation();
            var fitness        = optController.CreateFitness();
            var adamChromosome = optController.CreateChromosome();
            var population     = new Population(settings.MinPopulationSize, settings.MaxPopulationSize,
                                                adamChromosome);

            population.GenerationStrategy = new TrackingGenerationStrategy();

            var geneticAlgorithm = new GeneticAlgorithm(population, fitness, selection, crossover, mutation);

            optController.ConfigGA(geneticAlgorithm);

            geneticAlgorithm.Termination          = optController.CreateTermination();
            geneticAlgorithm.MutationProbability  = ConstantsOpt.MutationRate;
            geneticAlgorithm.CrossoverProbability = ConstantsOpt.CrossoverRate;

            return(geneticAlgorithm);
        }
 public ControllerGlassOpt(FormInputData input, SettingsOpt settings)
 {
     this.inputData = input;
     this.settings  = settings;
 }
Beispiel #4
0
        private static ControllerGlassOpt GetOptimizationController(FormInputData inputData, SettingsOpt settings)
        {
            var optController = new ControllerGlassOpt(inputData, settings);

            optController.Initialize();
            return(optController);
        }
Beispiel #5
0
        private static IChromosome ModifyChomosomeAccordingToSettings(ChromosomeGlass chromosome, SettingsOpt settings)
        {
            //
            if (settings.IsSymmetricLaminateUsed)
            {
                chromosome.ReplaceGene(ConstantsOpt.ExtThk1GeneNo, chromosome.GetGene(ConstantsOpt.ExtThk2GeneNo));
                chromosome.ReplaceGene(ConstantsOpt.IntThk1GeneNo, chromosome.GetGene(ConstantsOpt.IntThk2GeneNo));
                chromosome.ReplaceGene(ConstantsOpt.MiddleThk1GeneNo, chromosome.GetGene(ConstantsOpt.MiddleThk2GeneNo));
            }

            // Set monolith
            if (settings.ExternalLaminateOrMonolithic == GlassPaneTypeConsideredInOptimization.Monolithic)
            {
                chromosome.ReplaceGene(ConstantsOpt.ExtMonolithGeneNo, new Gene(GlassPaneType.Monolithic));
            }

            if (settings.InternalLaminateOrMonolithic == GlassPaneTypeConsideredInOptimization.Monolithic)
            {
                chromosome.ReplaceGene(ConstantsOpt.IntMonolithGeneNo, new Gene(GlassPaneType.Monolithic));
            }

            if (settings.MiddleLaminateOrMonolithic == GlassPaneTypeConsideredInOptimization.Monolithic)
            {
                chromosome.ReplaceGene(ConstantsOpt.MiddleMonolithGeneNo, new Gene(GlassPaneType.Monolithic));
            }

            // Set laminate
            if (settings.ExternalLaminateOrMonolithic == GlassPaneTypeConsideredInOptimization.Laminated)
            {
                chromosome.ReplaceGene(ConstantsOpt.ExtMonolithGeneNo, new Gene(GlassPaneType.Laminated));
            }

            if (settings.InternalLaminateOrMonolithic == GlassPaneTypeConsideredInOptimization.Laminated)
            {
                chromosome.ReplaceGene(ConstantsOpt.IntMonolithGeneNo, new Gene(GlassPaneType.Laminated));
            }

            if (settings.MiddleLaminateOrMonolithic == GlassPaneTypeConsideredInOptimization.Laminated)
            {
                chromosome.ReplaceGene(ConstantsOpt.MiddleMonolithGeneNo, new Gene(GlassPaneType.Laminated));
            }

            return(chromosome);
        }
Beispiel #6
0
 public FitnessGlassUnit(FormInputData input, SettingsOpt settings)
 {
     this.inputData = input;
     this.settings  = settings;
 }