예제 #1
0
        private void Setup()
        {
            _building.ShortGenotype = _geneticsConfiguration.ShortGenotype;
            _building.ApplySimpleEvacuationIfShortGenotype();

            MapBuilder mapBuilder = new MapBuilder(_building.ToDataModel());
            Simulator sim = new Simulator();

            sim.MaximumTicks = _building.GetFloorCount() * 2;
            sim.SetupSimulator(mapBuilder.BuildBuildingMap(), mapBuilder.BuildPeopleMap());
            EvaCalcEvaluator evaluator = new EvaCalcEvaluator(sim, new Building(_building));

            BinaryChromosome.CrossoverOperator = _geneticsConfiguration.CrossoverOperator;
            BinaryChromosome.MutationOperator = _geneticsConfiguration.MutationOperator;
            BinaryChromosome.Transformer = _geneticsConfiguration.Transformer;
            BinaryChromosome.Repairer = new AdvancedRepairer(new Building(_building));
            BinaryChromosome.Evaluator = evaluator;

            GeneticAlgorithm = new GeneticAlgorithm(new BinaryChromosomeFactory(_building.GetFloorCount() * 2), _geneticsConfiguration.InitialPopulationSize);
            if (_geneticsConfiguration.MaxIterationsWithoutImprovement > 0)
                GeneticAlgorithm.EnableBestChromosomeBasedStopCondition(_geneticsConfiguration.MaxIterationsWithoutImprovement);
            GeneticAlgorithm.Selector = _geneticsConfiguration.Selector;
            GeneticAlgorithm.MaxIterations = _geneticsConfiguration.MaxIterations;
            GeneticAlgorithm.CrossoverProbability = _geneticsConfiguration.CrossoverProbability;
            GeneticAlgorithm.ReportStatus += CollectAlgorithmStatus;
        }