Пример #1
0
        public void BoltzmannSelectionOperator_Ctor()
        {
            double           initialTemp = 10;
            GeneticAlgorithm algorithm   = GetMockAlgorithm(initialTemp);

            FakeBoltzmannSelectionOperator op = new FakeBoltzmannSelectionOperator {
                InitialTemperature = initialTemp
            };

            op.Initialize(algorithm);
            Assert.Equal(initialTemp, op.GetTemp());
        }
Пример #2
0
        public void BoltzmannSelectionOperator_Temperature()
        {
            double initialTemp             = 10;
            MockGeneticAlgorithm algorithm = GetMockAlgorithm(initialTemp);

            FakeBoltzmannSelectionOperator op = (FakeBoltzmannSelectionOperator)algorithm.SelectionOperator;

            op.Initialize(algorithm);

            double currentTemp = initialTemp;

            for (int i = 0; i < 10; i++)
            {
                algorithm.RaiseGenerationCreatedEvent();
                Assert.Equal(op.GetTemp(), currentTemp + 1);
                currentTemp++;
            }
        }